[Schmitzm-commits] r772 - in trunk/src: schmitzm/jfree/feature/style skrueger skrueger/geotools skrueger/i8n

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Mar 21 15:05:28 CET 2010


Author: alfonx
Date: 2010-03-21 15:05:26 +0100 (Sun, 21 Mar 2010)
New Revision: 772

Added:
   trunk/src/skrueger/AttributeMetadataInterface.java
Removed:
   trunk/src/skrueger/AttributeMetadata.java
Modified:
   trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
   trunk/src/skrueger/AbstractAttributeMetadata.java
   trunk/src/skrueger/AttributeMetadataImpl.java
   trunk/src/skrueger/geotools/AttributeMetadataMap.java
   trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
   trunk/src/skrueger/geotools/StyledLayerUtil.java
   trunk/src/skrueger/i8n/Translation.java
Log:
The new Interface AttributeMetadata has been renamed to AttributeMetadataInterface. 


Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -72,7 +72,7 @@
 import schmitzm.jfree.feature.FeatureDatasetMetaData;
 import schmitzm.jfree.feature.FeatureDatasetSelectionModel;
 import schmitzm.lang.LangUtil;
-import skrueger.AttributeMetadata;
+import skrueger.AttributeMetadataInterface;
 import skrueger.geotools.AttributeMetadataMap;
 
 /**
@@ -801,7 +801,7 @@
     for (int idx = 0; idx < featureChartStyle.getAttributeCount(); idx++) {
 
       String attributeName = featureChartStyle.getAttributeName(idx);
-      AttributeMetadata attributeMetadata = attributeMetaDataMap.get(attributeName);
+      AttributeMetadataInterface attributeMetadata = attributeMetaDataMap.get(attributeName);
 
       if (attributeMetadata != null) {
         featureChartStyle.setNoDataValues(idx,
@@ -811,7 +811,7 @@
       // Set NODATA-Values for the weight attributes
       String weightAtt = featureChartStyle.getAttributeAggregationWeightAttributeName(idx);
       if (weightAtt != null) {
-        AttributeMetadata weightAttributeMetadata = attributeMetaDataMap.get(attributeName);
+        AttributeMetadataInterface weightAttributeMetadata = attributeMetaDataMap.get(attributeName);
         if (weightAttributeMetadata != null) {
           featureChartStyle.setWeightAttributeNoDataValues(
                                                            idx,

Modified: trunk/src/skrueger/AbstractAttributeMetadata.java
===================================================================
--- trunk/src/skrueger/AbstractAttributeMetadata.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/AbstractAttributeMetadata.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -8,7 +8,7 @@
 import skrueger.geotools.StyledLayerUtil;
 import skrueger.i8n.Translation;
 
-public abstract class AbstractAttributeMetadata implements AttributeMetadata {
+public abstract class AbstractAttributeMetadata implements AttributeMetadataInterface {
 
 	/** The Name of the attribute. This is the 'primary key' **/
 	protected NameImpl name;
@@ -44,7 +44,17 @@
 	public String getUnit() {
 		return unit;
 	}
+	
+	@Override
+	public void setTitle(final String title) {
+		this.title = new Translation(title);
+	}
 
+	@Override
+	public void setDesc(final String desc) {
+		this.desc = new Translation(desc);
+	}
+	
 	/**
 	 * When listed, the attributes are listed according to their {@link #weight}
 	 * (heavier => further down)

Deleted: trunk/src/skrueger/AttributeMetadata.java
===================================================================
--- trunk/src/skrueger/AttributeMetadata.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/AttributeMetadata.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -1,112 +0,0 @@
-package skrueger;
-
-import java.util.HashSet;
-
-import org.geotools.feature.NameImpl;
-import org.opengis.feature.type.Name;
-
-import skrueger.geotools.Copyable;
-import skrueger.i8n.Translation;
-
-public interface AttributeMetadata extends Copyable<AttributeMetadata>,
-		Comparable<AttributeMetadata> {
-
-	/**
-	 * @return a translatable title for this attribute..
-	 */
-	public Translation getTitle();
-
-	/**
-	 * Set a translatable title for this attribute..
-	 */
-	public void setTitle(Translation title);
-
-	/**
-	 * @return a translatable description for this attribute
-	 */
-	public Translation getDesc();
-
-	/**
-	 * Set a translatable description for this attribute.
-	 */
-	public void setDesc(Translation desc);
-
-	/**
-	 * The local name. E.g. the name of the DBF column as a {@link String}.
-	 */
-	public String getLocalName();
-
-	/**
-	 * A short form for #setName(new NameImpl(localName))
-	 */
-	public void setLocalName(String localName);
-
-	/**
-	 * The fully qualified {@link Name} of the attribute, e.g.
-	 * <code>org.bla.plo:blub</code>. The second part equals the
-	 * {@link #getLocalName()} value. The first may be <code>null</code> or
-	 * represent the layer name.
-	 */
-	public NameImpl getName();
-
-	/**
-	 * set the fully qualified {@link Name} of this attribute.
-	 */
-	public void setName(NameImpl name);
-
-	/**
-	 * A list og objects that represent NODATA-values for this attribute. The
-	 * objects are supporsed to be correctly casted already. That means that the
-	 * NODATA objects listed here have must have the same type as the values of
-	 * this object.
-	 */
-	public HashSet<Object> getNodataValues();
-
-	/**
-	 * Takes any value object and checks it against the NODATA values. If the
-	 * value equals a NODATA value, <code>null</code> is returned. Otherwise the
-	 * same object is returned.
-	 * 
-	 * Note: This method is called often.
-	 */
-	public Object fiterNodata(Object value);
-
-	/**
-	 * @return a non-translatable unit {@link String} for this attribute values.
-	 */
-	public String getUnit();
-
-	/**
-	 * Set a unit {@link String} for this attribute values.
-	 */
-	public void setUnit(String unit);
-
-	/**
-	 * @return A value defining the position of this attribute whenever the
-	 *         attributes are listed to an end-user. The higher the weight, the
-	 *         lower the position. (heavy goes down, light goes up)
-	 */
-	public double getWeight();
-
-	/**
-	 * set a value defining the position of this attribute whenever the
-	 * attributes are listed to an end-user. The higher the weight, the lower
-	 * the position. (heavy goes down, light goes up)
-	 */
-	public void setWeight(double weight);
-
-	/**
-	 * @return <code>false</code> if this attribute should not be selectable or
-	 *         shown to the end-user.
-	 */
-	public boolean isVisible();
-
-	/**
-	 * Set <code>false</code> if this attribute should not be shown to the
-	 * end-user.
-	 */
-	public void setVisible(boolean visible);
-
-	String getNoDataValuesFormatted();
-
-}

Modified: trunk/src/skrueger/AttributeMetadataImpl.java
===================================================================
--- trunk/src/skrueger/AttributeMetadataImpl.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/AttributeMetadataImpl.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -184,7 +184,7 @@
 	 * further down.
 	 */
 	@Override
-	public int compareTo(final AttributeMetadata atm2) {
+	public int compareTo(final AttributeMetadataInterface atm2) {
 		return new Integer(weight).compareTo(new Double(atm2.getWeight())
 				.intValue());
 	}
@@ -193,7 +193,7 @@
 	 * @see Copyable inferface
 	 */
 	@Override
-	public AttributeMetadata copy() {
+	public AttributeMetadataInterface copy() {
 		return copyTo(new AttributeMetadataImpl());
 	}
 
@@ -201,7 +201,7 @@
 	 * @see Copyable inferface
 	 */
 	@Override
-	public AttributeMetadata copyTo(final AttributeMetadata amd) {
+	public AttributeMetadataInterface copyTo(final AttributeMetadataInterface amd) {
 		getTitle().copyTo(amd.getTitle());
 		getDesc().copyTo(amd.getDesc());
 		amd.setUnit(getUnit());

Copied: trunk/src/skrueger/AttributeMetadataInterface.java (from rev 771, trunk/src/skrueger/AttributeMetadata.java)
===================================================================
--- trunk/src/skrueger/AttributeMetadata.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/AttributeMetadataInterface.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -0,0 +1,125 @@
+package skrueger;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.geotools.feature.NameImpl;
+import org.opengis.feature.type.Name;
+
+import skrueger.geotools.Copyable;
+import skrueger.i8n.Translation;
+
+public interface AttributeMetadataInterface extends Copyable<AttributeMetadataInterface>,
+		Comparable<AttributeMetadataInterface> {
+
+	/**
+	 * @return a translatable title for this attribute..
+	 */
+	public Translation getTitle();
+
+	/**
+	 * Set a translatable title for this attribute..
+	 */
+	public void setTitle(Translation title);
+	
+	/**
+	 * Set an untranslated title for this attribute or pass a {@link Translation} encryped as a {@link String}
+	 */
+	public void setTitle(String title);
+
+	/**
+	 * @return a translatable description for this attribute
+	 */
+	public Translation getDesc();
+
+	/**
+	 * Set a translatable description for this attribute.
+	 */
+	public void setDesc(Translation desc);
+
+	/**
+	 * Set an untranslated description for this attribute or pass a {@link Translation} encryped as a {@link String}  
+	 */
+	public void setDesc(String desc);
+
+
+	/**
+	 * The local name. E.g. the name of the DBF column as a {@link String}.
+	 */
+	public String getLocalName();
+
+	/**
+	 * A short form for #setName(new NameImpl(localName))
+	 */
+	public void setLocalName(String localName);
+
+	/**
+	 * The fully qualified {@link Name} of the attribute, e.g.
+	 * <code>org.bla.plo:blub</code>. The second part equals the
+	 * {@link #getLocalName()} value. The first may be <code>null</code> or
+	 * represent the layer name.
+	 */
+	public NameImpl getName();
+
+	/**
+	 * set the fully qualified {@link Name} of this attribute.
+	 */
+	public void setName(NameImpl name);
+
+	/**
+	 * A list og objects that represent NODATA-values for this attribute. The
+	 * objects are supporsed to be correctly casted already. That means that the
+	 * NODATA objects listed here have must have the same type as the values of
+	 * this object.
+	 */
+	public HashSet<Object> getNodataValues();
+
+	/**
+	 * Takes any value object and checks it against the NODATA values. If the
+	 * value equals a NODATA value, <code>null</code> is returned. Otherwise the
+	 * same object is returned.
+	 * 
+	 * Note: This method is called often.
+	 */
+	public Object fiterNodata(Object value);
+
+	/**
+	 * @return a non-translatable unit {@link String} for this attribute values.
+	 */
+	public String getUnit();
+
+	/**
+	 * Set a unit {@link String} for this attribute values.
+	 */
+	public void setUnit(String unit);
+
+	/**
+	 * @return A value defining the position of this attribute whenever the
+	 *         attributes are listed to an end-user. The higher the weight, the
+	 *         lower the position. (heavy goes down, light goes up)
+	 */
+	public double getWeight();
+
+	/**
+	 * set a value defining the position of this attribute whenever the
+	 * attributes are listed to an end-user. The higher the weight, the lower
+	 * the position. (heavy goes down, light goes up)
+	 */
+	public void setWeight(double weight);
+
+	/**
+	 * @return <code>false</code> if this attribute should not be selectable or
+	 *         shown to the end-user.
+	 */
+	public boolean isVisible();
+
+	/**
+	 * Set <code>false</code> if this attribute should not be shown to the
+	 * end-user.
+	 */
+	public void setVisible(boolean visible);
+
+	String getNoDataValuesFormatted();
+
+}

Modified: trunk/src/skrueger/geotools/AttributeMetadataMap.java
===================================================================
--- trunk/src/skrueger/geotools/AttributeMetadataMap.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/geotools/AttributeMetadataMap.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -11,7 +11,7 @@
 import org.opengis.feature.type.Name;
 
 import skrueger.AbstractAttributeMetadata;
-import skrueger.AttributeMetadata;
+import skrueger.AttributeMetadataInterface;
 import skrueger.QualityQuantizable;
 import skrueger.i8n.Translation;
 
@@ -22,7 +22,7 @@
  * The {@link #get(Name)} and {@link #get(String)} methods will never return
  * <code>null</code>, but rather create a default {@link AMD_IMPL} on-the-fly.
  */
-public abstract class AttributeMetadataMap<AMD_IMPL extends AttributeMetadata>
+public abstract class AttributeMetadataMap<AMD_IMPL extends AttributeMetadataInterface>
 		extends TreeMap<NameImpl, AMD_IMPL> implements
 		Copyable<AttributeMetadataMap>, QualityQuantizable {
 
@@ -71,7 +71,7 @@
 	 * {@link Copyable} interface.
 	 */
 	@Override
-	public AttributeMetadataMap<? extends AttributeMetadata> copyTo(AttributeMetadataMap amdMap) {
+	public AttributeMetadataMap<? extends AttributeMetadataInterface> copyTo(AttributeMetadataMap amdMap) {
 
 		amdMap.clear();
 
@@ -84,7 +84,7 @@
 
 	/**
 	 * Returns the {@link AMD_IMPL} for a given {@link NameImpl}. May return
-	 * <code>null</code> or create a default {@link AttributeMetadata} depending
+	 * <code>null</code> or create a default {@link AttributeMetadataInterface} depending
 	 * on whether this method is overwritten. fly.
 	 */
 	public AMD_IMPL get(final NameImpl name) {

Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -45,7 +45,7 @@
 
 import schmitzm.geotools.feature.FeatureUtil;
 import schmitzm.geotools.gui.FeatureCollectionTableModel;
-import skrueger.AttributeMetadata;
+import skrueger.AttributeMetadataInterface;
 import skrueger.AttributeMetadataImpl;
 
 import com.vividsolutions.jts.geom.Envelope;
@@ -68,7 +68,7 @@
 	final static private Logger LOGGER = Logger
 			.getLogger(StyledFeatureCollectionTableModel.class);
 	/** Contains the complete {@link AttributeMetadataImpl}-Map of the styled layer. */
-	protected AttributeMetadataMap<? extends AttributeMetadata> amdMap = null;
+	protected AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap = null;
 	/** Holds the current filter on the table */
 	protected Filter filter = null;
 	/** Holds the Bounds for all features. Only set once during the constructor **/
@@ -80,7 +80,7 @@
 	protected String[] colTooltips = null;
 
 	/** A cache for the #sortedValuesVisibleOnly() **/
-	protected List<? extends AttributeMetadata> amdMapVisibleOnly = null;
+	protected List<? extends AttributeMetadataInterface> amdMapVisibleOnly = null;
 
 	/**
 	 * Creates a new table model for a styled layer.
@@ -116,7 +116,7 @@
 	 */
 	protected void setFeatureSource(
 			FeatureSource<SimpleFeatureType, SimpleFeature> fs,
-			AttributeMetadataMap<? extends AttributeMetadata> amdm, Filter filter) throws Exception {
+			AttributeMetadataMap<? extends AttributeMetadataInterface> amdm, Filter filter) throws Exception {
 
 		if (filter == null)
 			filter = Filter.INCLUDE;
@@ -141,7 +141,7 @@
 						.getLocalName());
 
 				// Add other visible attributes as ordered by weights
-				for (AttributeMetadata a : amdMapVisibleOnly) {
+				for (AttributeMetadataInterface a : amdMapVisibleOnly) {
 					visibleAttrNames.add(a.getLocalName());
 				}
 
@@ -208,7 +208,7 @@
 			SimpleFeatureType schema = featureArray[0].getFeatureType();
 			// Pruefen, welche Attribute angezeigt werden
 			attrTypes.clear();
-			for (AttributeMetadata amd : amdMapVisibleOnly) {
+			for (AttributeMetadataInterface amd : amdMapVisibleOnly) {
 				AttributeDescriptor type = schema.getDescriptor(amd.getName());
 				if (attrFilter == null || attrFilter.accept(type))
 					attrTypes.add(type);
@@ -230,7 +230,7 @@
 				String attName = schema.getAttributeDescriptors().get(idx)
 						.getLocalName();
 				colNames[i] = amdMap.get(attName).getTitle().toString();
-				AttributeMetadata amd = amdMap.get(attName);
+				AttributeMetadataInterface amd = amdMap.get(attName);
 				colTooltips[i] = "<html>" + amd.getDesc().toString() + "<br>"
 						+ amd.getName() + "</html>";
 				colClass[i] = schema.getAttributeDescriptors().get(idx)

Modified: trunk/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- trunk/src/skrueger/geotools/StyledLayerUtil.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/geotools/StyledLayerUtil.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -92,7 +92,7 @@
 import schmitzm.lang.LangUtil;
 import schmitzm.swing.JPanel;
 import schmitzm.swing.SwingUtil;
-import skrueger.AttributeMetadata;
+import skrueger.AttributeMetadataInterface;
 import skrueger.AttributeMetadataImpl;
 import skrueger.RasterLegendData;
 import skrueger.i8n.Translation;
@@ -254,16 +254,16 @@
 	 *            TODO replace with
 	 *            {@link AttributeMetadataMap#sortedValuesVisibleOnly()}
 	 */
-	public static AttributeMetadataMap<? extends AttributeMetadata > getVisibleAttributeMetaData(
-			final AttributeMetadataMap<? extends AttributeMetadata> amdMap,
+	public static AttributeMetadataMap<? extends AttributeMetadataInterface > getVisibleAttributeMetaData(
+			final AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap,
 			final boolean visible) {
 
-		final AttributeMetadataMap<AttributeMetadata> filteredMap = (AttributeMetadataMap<AttributeMetadata>) amdMap.clone();
+		final AttributeMetadataMap<AttributeMetadataInterface> filteredMap = (AttributeMetadataMap<AttributeMetadataInterface>) amdMap.clone();
 		if (filteredMap.size() > 0 ) {
 			filteredMap.clear(); // Just in case the close copies the contents
 		}
 		
-		for (final AttributeMetadata amd : amdMap.values())
+		for (final AttributeMetadataInterface amd : amdMap.values())
 			if (amd.isVisible() == visible)
 				filteredMap.put(amd.getName(), amd);
 
@@ -358,7 +358,7 @@
 	 *            classes. (SK, 3.2.2010)
 	 */
 	public static Element createAttributeMetaDataElement(
-			final AttributeMetadata amd) {
+			final AttributeMetadataInterface amd) {
 		final Element element = new Element(ELEM_NAME_ATTRIBUTE, AMLURI);
 		element.setAttribute("namespace", String.valueOf(amd.getName()
 				.getNamespaceURI()));
@@ -380,9 +380,9 @@
 	 *            map of attribute meta data
 	 */
 	public static Element createAttributeMetaDataMapElement(
-			final AttributeMetadataMap<? extends AttributeMetadata> amdMap) {
+			final AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap) {
 		final Element element = new Element(ELEM_NAME_AMD, AMLURI);
-		for (final AttributeMetadata amd : amdMap.values())
+		for (final AttributeMetadataInterface amd : amdMap.values())
 			element.addContent(createAttributeMetaDataElement(amd));
 		return element;
 	}
@@ -1260,7 +1260,7 @@
 		// 1. Check.. all attributes in the atm should be in the schema as well.
 		// maybe correct some upperCase/loweCase stuff
 
-		for (AttributeMetadata atm : attributeMetaDataMap.values()) {
+		for (AttributeMetadataInterface atm : attributeMetaDataMap.values()) {
 
 			AttributeDescriptor foundDescr = schema
 					.getDescriptor(atm.getName());
@@ -1306,7 +1306,7 @@
 	 * @param schema
 	 */
 	public static void addEmptyStringToAllTextualAttributes(
-			AttributeMetadataMap<? extends AttributeMetadata> attributeMetaDataMap,
+			AttributeMetadataMap<? extends AttributeMetadataInterface> attributeMetaDataMap,
 			SimpleFeatureType schema) {
 
 		for (Name name : attributeMetaDataMap.keySet()) {
@@ -1319,7 +1319,7 @@
 
 	/**
 	 * @return a nicely formatted String containing all NODATA values of any
-	 *         {@link AttributeMetadata} object. Strings are quoted so that any
+	 *         {@link AttributeMetadataInterface} object. Strings are quoted so that any
 	 *         empty {@link String} can be seen.
 	 */
 	public static String formatNoDataValues(Set<Object> nodataValuesList) {

Modified: trunk/src/skrueger/i8n/Translation.java
===================================================================
--- trunk/src/skrueger/i8n/Translation.java	2010-03-21 12:12:06 UTC (rev 771)
+++ trunk/src/skrueger/i8n/Translation.java	2010-03-21 14:05:26 UTC (rev 772)
@@ -33,6 +33,7 @@
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -58,7 +59,10 @@
  */
 
 public class Translation extends HashMap<String, String> implements
-		Copyable<Translation> {
+		Copyable<Translation>, Serializable {
+	
+	private static final long serialVersionUID = -347702744122305245L;
+	
 	public static final String LOCALECHANGE_PROPERTY = "localechange";
 	public static final String NO_TRANSLATION = "NO TRANSLATION";
 	public static final String DEFAULT_KEY = "default";
@@ -77,6 +81,8 @@
 		Locale locale = Locale.getDefault();
 		setActiveLang(locale.getLanguage());
 	}
+	
+	
 
 	private WeakHashSet<ActionListener> actionListeners = new WeakHashSet<ActionListener>(
 			ActionListener.class);



More information about the Schmitzm-commits mailing list