[Schmitzm-commits] r221 - in trunk/src: schmitzm/jfree/chart schmitzm/jfree/feature/style skrueger/geotools skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jul 14 16:40:53 CEST 2009
Author: alfonx
Date: 2009-07-14 16:40:52 +0200 (Tue, 14 Jul 2009)
New Revision: 221
Added:
trunk/src/skrueger/geotools/StyledFeatureInterface.java
Modified:
trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java
trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
trunk/src/skrueger/geotools/StyledFS.java
trunk/src/skrueger/geotools/StyledFeatureCollection.java
trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java
trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java
trunk/src/skrueger/swing/TranslationEditJPanel.java
Log:
* Neues Interface StyledFeatures<T> eingef?\195?\188ht. Es hat getFeatureCollection und getFeatureSource und ?\195?\188berwindet somit den Dualismus zwischen FeatureSource und FeatureCollection.
Ein paar mehr Infos: http://wald.intevation.org/tracker/index.php?func=detail&aid=1061&group_id=37&atid=295
* Noch ein bisschen Feinschliff in den StyleCharts
Modified: trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -150,8 +150,8 @@
addMouseListener(selectionTracker);
setWindowSelectionMode( WindowSelectionMode.ZOOM_IN );
- XYPlot p = (XYPlot)getChart().getPlot();
- XYLineAndShapeRenderer r = (XYLineAndShapeRenderer)p.getRenderer();
+// XYPlot p = (XYPlot)getChart().getPlot();
+// XYLineAndShapeRenderer r = (XYLineAndShapeRenderer)p.getRenderer();
//
// XYItemRenderer r2 = new XYLineAndShapeRenderer(r.getBaseLinesVisible(), r.getBaseShapesVisible()) {
Modified: trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -16,6 +16,7 @@
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.Dataset;
+import schmitzm.jfree.JFreeChartUtil;
import schmitzm.jfree.chart.style.BasicChartStyle;
/**
@@ -79,10 +80,11 @@
* @see ChartStyle#RANGE_AXIS
* @see ChartStyle#RANGE_AXIS2
*/
+ @Override
public void setAttributeName(int idx, String attrName) {
dummyFeatureChartStyle.setAttributeName(idx,attrName);
}
-
+
/**
* Creates an appropriate {@link Dataset} for the attributes defined
* by this style (according to the attributes types in the given
@@ -91,7 +93,8 @@
*/
@Override
public JFreeChart applyToFeatureCollection(FeatureCollection fc) {
- Dataset dataset = null; // TODO: Create dataset from FeatureCollection by utility method
+// Dataset dataset = null; // TODO: Create dataset from FeatureCollection by utility method
+ Dataset dataset = JFreeChartUtil.createXYDataset(fc, getTitleStyle().getLabel(), getAttributeName(DOMAIN_AXIS), getAttributeName(RANGE_AXIS));
return applyToDataset(dataset);
}
Modified: trunk/src/skrueger/geotools/StyledFS.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFS.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/geotools/StyledFS.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -15,9 +15,11 @@
import org.apache.log4j.Logger;
import org.geotools.data.FeatureSource;
import org.geotools.feature.AttributeType;
+import org.geotools.feature.FeatureCollection;
import org.geotools.styling.Style;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import schmitzm.geotools.feature.FeatureOperationTreeFilter;
import schmitzm.geotools.styling.StylingUtil;
import skrueger.AttributeMetaData;
import skrueger.i8n.Translation;
@@ -227,4 +229,32 @@
this.sldFile = sldFile;
}
+ /**
+ * Returns the features of the {@link FeatureSource}.
+ *
+ * @see {@link StyledFeatureInterface}
+ */
+ @Override
+ public FeatureCollection getFeatureCollection() {
+ FeatureCollection features;
+ try {
+ features = getGeoObject().getFeatures();
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Error getting the features of the FeatureSource");
+ }
+ return features;
+ }
+
+ /**
+ * Same as {@link #getGeoObject()} method, but complies to the
+ * {@link StyledFeatureInterface}
+ *
+ * @see {@link StyledFeatureInterface}
+ */
+ @Override
+ public FeatureSource getFeatureSource() {
+ return getGeoObject();
+ }
+
}
Modified: trunk/src/skrueger/geotools/StyledFeatureCollection.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollection.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/geotools/StyledFeatureCollection.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -1,11 +1,14 @@
package skrueger.geotools;
+import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
+import org.geotools.data.FeatureSource;
+import org.geotools.data.collection.CollectionDataStore;
import org.geotools.feature.AttributeType;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureType;
@@ -15,245 +18,343 @@
import skrueger.AttributeMetaData;
import skrueger.i8n.Translation;
-
/**
- * This class provides a simple implementation of {@link StyledMapInterface}
- * for {@link FeatureCollection}. The uncache functionality is not supported,
+ * This class provides a simple implementation of {@link StyledMapInterface} for
+ * {@link FeatureCollection}. The uncache functionality is not supported,
* because this class bases on an existing {@link FeatureCollection} object in
* memory.
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ *
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ * (University of Bonn/Germany)
* @version 1.0
*/
-public class StyledFeatureCollection extends AbstractStyledMap<FeatureCollection> implements StyledFeatureCollectionInterface {
+public class StyledFeatureCollection extends
+ AbstractStyledMap<FeatureCollection> implements
+ StyledFeatureCollectionInterface {
- /** Holds the meta data for displaying a legend. */
- protected Map<Integer,AttributeMetaData> attrMetaData = null;
+ /** Holds the meta data for displaying a legend. */
+ protected Map<Integer, AttributeMetaData> attrMetaData = null;
- /**
- * Creates a styled {@link FeatureCollection} with language-specific informations.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a (language-specific) short description
- * @param desc a (language-specific) long description
- * @param keywords (language-specific) keywords for the geo objects
- * @param style a display style (if {@code null}, a default style is created)
- * @param attrMetaData meta data for displaying a legend
- * @param icon an icon for the object (can be {@code null})
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Translation desc, Translation keywords, Style style, Map<Integer,AttributeMetaData> attrMetaData, ImageIcon icon) {
- super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry().getCoordinateSystem(), id, title, desc, keywords, style, icon);
- setAttributeMetaData( attrMetaData );
- }
+ /**
+ * We be filled with a "virtual" {@link FeatureSource} on demand.
+ */
+ private FeatureSource featureSource = null;
- /**
- * Creates a styled {@link FeatureCollection} with language-specific informations.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a (language-specific) short description
- * @param desc a (language-specific) long description
- * @param keywords (language-specific) keywords for the geo objects
- * @param style a display style with attribute meta data information
- * @param icon an icon for the object (can be {@code null})
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Translation desc, Translation keywords, StyledMapStyle<Map<Integer,AttributeMetaData>> style, ImageIcon icon) {
- super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry().getCoordinateSystem(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);
- setAttributeMetaData( style != null ? style.getMetaData() : null );
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with language-specific
+ * informations.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a (language-specific) short description
+ * @param desc
+ * a (language-specific) long description
+ * @param keywords
+ * (language-specific) keywords for the geo objects
+ * @param style
+ * a display style (if {@code null}, a default style is created)
+ * @param attrMetaData
+ * meta data for displaying a legend
+ * @param icon
+ * an icon for the object (can be {@code null})
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ Translation title, Translation desc, Translation keywords,
+ Style style, Map<Integer, AttributeMetaData> attrMetaData,
+ ImageIcon icon) {
+ super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry()
+ .getCoordinateSystem(), id, title, desc, keywords, style, icon);
+ setAttributeMetaData(attrMetaData);
+ }
- /**
- * Creates a styled {@link FeatureCollection} with a language-specific title,
- * no long description, no keywords, default attribute meta data and no icon.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a short description
- * @param style a display style (if {@code null}, a default style is created)
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Style style) {
- this(fc, id, title, null, null, style, null, null);
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with language-specific
+ * informations.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a (language-specific) short description
+ * @param desc
+ * a (language-specific) long description
+ * @param keywords
+ * (language-specific) keywords for the geo objects
+ * @param style
+ * a display style with attribute meta data information
+ * @param icon
+ * an icon for the object (can be {@code null})
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ Translation title, Translation desc, Translation keywords,
+ StyledMapStyle<Map<Integer, AttributeMetaData>> style,
+ ImageIcon icon) {
+ super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry()
+ .getCoordinateSystem(), id, title, desc, keywords,
+ style != null ? style.getGeoObjectStyle() : null, icon);
+ setAttributeMetaData(style != null ? style.getMetaData() : null);
+ }
- /**
- * Creates a styled {@link FeatureCollection} with non-translated informations.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a short description
- * @param desc a long description
- * @param keywords keywords for the geo objects
- * @param style a display style (if {@code null}, a default style is created)
- * @param attrMetaData meta data for displaying a legend
- * @param icon an icon for the object (can be {@code null})
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, String title, String desc, String keywords, Style style, Map<Integer,AttributeMetaData> attrMetaData, ImageIcon icon) {
- this(fc, id, (Translation)null, null, null, style, attrMetaData, icon);
- setTitle(title);
- setDesc(desc);
- setKeywords(keywords);
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with a language-specific
+ * title, no long description, no keywords, default attribute meta data and
+ * no icon.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a short description
+ * @param style
+ * a display style (if {@code null}, a default style is created)
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ Translation title, Style style) {
+ this(fc, id, title, null, null, style, null, null);
+ }
- /**
- * Creates a styled {@link FeatureCollection} with non-translated informations.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a short description
- * @param desc a long description
- * @param keywords keywords for the geo objects
- * @param style a display style with attribute meta data information
- * @param icon an icon for the object (can be {@code null})
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, String title, String desc, String keywords, StyledMapStyle<Map<Integer,AttributeMetaData>> style, ImageIcon icon) {
- this(fc,
- id,
- title,
- desc,
- keywords,
- style != null ? style.getGeoObjectStyle() : null,
- style != null ? style.getMetaData() : null,
- icon
- );
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with non-translated
+ * informations.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a short description
+ * @param desc
+ * a long description
+ * @param keywords
+ * keywords for the geo objects
+ * @param style
+ * a display style (if {@code null}, a default style is created)
+ * @param attrMetaData
+ * meta data for displaying a legend
+ * @param icon
+ * an icon for the object (can be {@code null})
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ String title, String desc, String keywords, Style style,
+ Map<Integer, AttributeMetaData> attrMetaData, ImageIcon icon) {
+ this(fc, id, (Translation) null, null, null, style, attrMetaData, icon);
+ setTitle(title);
+ setDesc(desc);
+ setKeywords(keywords);
+ }
- /**
- * Creates a styled {@link FeatureCollection} with a non-translated title,
- * no long description, no keywords, default attribute meta data and no icon.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a short description
- * @param style a display style (if {@code null}, a default style is created)
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, String title, Style style) {
- this(fc, id, title, null, null, style, null, null);
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with non-translated
+ * informations.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a short description
+ * @param desc
+ * a long description
+ * @param keywords
+ * keywords for the geo objects
+ * @param style
+ * a display style with attribute meta data information
+ * @param icon
+ * an icon for the object (can be {@code null})
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ String title, String desc, String keywords,
+ StyledMapStyle<Map<Integer, AttributeMetaData>> style,
+ ImageIcon icon) {
+ this(fc, id, title, desc, keywords, style != null ? style
+ .getGeoObjectStyle() : null, style != null ? style
+ .getMetaData() : null, icon);
+ }
- /**
- * Creates a styled {@link FeatureCollection} with a non-translated title,
- * no long description, no keywords, default attribute meta data and no icon.
- * @param fc the {@link FeatureCollection}
- * @param id a unique ID for the object
- * @param title a short description
- * @param style a display style (if {@code null}, a default style is created)
- * @exception IllegalArgumentException if {@code null} is given as ID or geo object
- * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
- */
- public StyledFeatureCollection(FeatureCollection fc, String id, String title, StyledMapStyle<Map<Integer,AttributeMetaData>> style) {
- this(
- fc,
- id,
- title,
- null,
- null,
- style != null ? style.getGeoObjectStyle() : null,
- style != null ? style.getMetaData() : null,
- null
- );
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with a non-translated title,
+ * no long description, no keywords, default attribute meta data and no
+ * icon.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a short description
+ * @param style
+ * a display style (if {@code null}, a default style is created)
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ String title, Style style) {
+ this(fc, id, title, null, null, style, null, null);
+ }
- /**
- * Creates a default style for the {@link FeatureCollection}.
- * @see FeatureUtil#createDefaultStyle(FeatureCollection)
- */
- protected Style createDefaultStyle() {
- return FeatureUtil.createDefaultStyle( geoObject );
- }
+ /**
+ * Creates a styled {@link FeatureCollection} with a non-translated title,
+ * no long description, no keywords, default attribute meta data and no
+ * icon.
+ *
+ * @param fc
+ * the {@link FeatureCollection}
+ * @param id
+ * a unique ID for the object
+ * @param title
+ * a short description
+ * @param style
+ * a display style (if {@code null}, a default style is created)
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
+ */
+ public StyledFeatureCollection(FeatureCollection fc, String id,
+ String title, StyledMapStyle<Map<Integer, AttributeMetaData>> style) {
+ this(fc, id, title, null, null, style != null ? style
+ .getGeoObjectStyle() : null, style != null ? style
+ .getMetaData() : null, null);
+ }
- /**
- * Returns the meta data needed for displaying a legend.
- */
- public Map<Integer,AttributeMetaData> getAttributeMetaDataMap() {
- return attrMetaData;
- }
+ /**
+ * Creates a default style for the {@link FeatureCollection}.
+ *
+ * @see FeatureUtil#createDefaultStyle(FeatureCollection)
+ */
+ protected Style createDefaultStyle() {
+ return FeatureUtil.createDefaultStyle(geoObject);
+ }
- /**
- * Sets the meta data needed for displaying a legend.
- * If {@code legendData} is {@code null} an empty map is set, so
- * {@link #getAttributeMetaDataMap()} never returns {@code null}.
- * @param attrMetaData map of attribute meta data
- */
- public void setAttributeMetaData(Map<Integer,AttributeMetaData> attrMetaData) {
- this.attrMetaData = (attrMetaData != null) ? attrMetaData : createDefaultAttributeMetaDataMap(geoObject);
- }
+ /**
+ * Returns the meta data needed for displaying a legend.
+ */
+ public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() {
+ return attrMetaData;
+ }
- /**
- * Creates non-translated default meta data for a {@link FeatureCollection}
- * with all attributes visible and no unit set.
- * @param fc a {@link FeatureCollection}
- */
- public static Map<Integer,AttributeMetaData> createDefaultAttributeMetaDataMap(FeatureCollection fc) {
- HashMap<Integer,AttributeMetaData> metaDataMap = new HashMap<Integer,AttributeMetaData>();
- FeatureType ftype = fc.getSchema();
- for (int i=0; i<ftype.getAttributeCount(); i++) {
- AttributeType aType = ftype.getAttributeType(i);
- if ( aType != ftype.getDefaultGeometry() )
- metaDataMap.put(
- i,
- new AttributeMetaData(
- i, // Column no.
- true, // visible
- new Translation( aType.getName() ), // Column name
- new Translation(), // description
- "" // Unit
- )
- );
- }
- return metaDataMap;
- }
+ /**
+ * Sets the meta data needed for displaying a legend. If {@code legendData}
+ * is {@code null} an empty map is set, so
+ * {@link #getAttributeMetaDataMap()} never returns {@code null}.
+ *
+ * @param attrMetaData
+ * map of attribute meta data
+ */
+ public void setAttributeMetaData(
+ Map<Integer, AttributeMetaData> attrMetaData) {
+ this.attrMetaData = (attrMetaData != null) ? attrMetaData
+ : createDefaultAttributeMetaDataMap(geoObject);
+ }
- /**
- * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
- * {@link #attrMetaData} to {@code null}.
- */
- public void dispose() {
- this.geoObject = null;
- this.envelope = null;
- this.crs = null;
- this.attrMetaData = null;
- }
+ /**
+ * Creates non-translated default meta data for a {@link FeatureCollection}
+ * with all attributes visible and no unit set.
+ *
+ * @param fc
+ * a {@link FeatureCollection}
+ */
+ public static Map<Integer, AttributeMetaData> createDefaultAttributeMetaDataMap(
+ FeatureCollection fc) {
+ HashMap<Integer, AttributeMetaData> metaDataMap = new HashMap<Integer, AttributeMetaData>();
+ FeatureType ftype = fc.getSchema();
+ for (int i = 0; i < ftype.getAttributeCount(); i++) {
+ AttributeType aType = ftype.getAttributeType(i);
+ if (aType != ftype.getDefaultGeometry())
+ metaDataMap.put(i, new AttributeMetaData(i, // Column no.
+ true, // visible
+ new Translation(aType.getName()), // Column name
+ new Translation(), // description
+ "" // Unit
+ ));
+ }
+ return metaDataMap;
+ }
- /**
- * Tests whether the geo object is disposed.
- */
- public boolean isDisposed() {
- return geoObject == null;
- }
+ /**
+ * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
+ * {@link #attrMetaData} to {@code null}.
+ */
+ public void dispose() {
+ this.geoObject = null;
+ this.envelope = null;
+ this.crs = null;
+ this.attrMetaData = null;
+ }
- /**
- * Does nothing, because the {@link AbstractStyledMap} bases on existing
- * objects (in memory) which can not be uncached and reloaded.
- */
- public void uncache() {
- LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");
- }
+ /**
+ * Tests whether the geo object is disposed.
+ */
+ public boolean isDisposed() {
+ return geoObject == null;
+ }
+ /**
+ * Does nothing, because the {@link AbstractStyledMap} bases on existing
+ * objects (in memory) which can not be uncached and reloaded.
+ */
+ public void uncache() {
- /*
- * (non-Javadoc)
- * @see skrueger.geotools.StyledMapInterface#getInfoURL()
- */
+ /** It will be recreated on the next getFetureSource() **/
+ featureSource = null;
+
+ LOGGER
+ .warn("Uncache onyl uncached any virtual FeatureSource. Object remains in memory.");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see skrueger.geotools.StyledMapInterface#getInfoURL()
+ */
public URL getInfoURL() {
return null;
}
/**
- * If true, this layer will not be shown in the legend. Default = false
+ * Same as {@link #getGeoObject()} method, but complies to the {@link StyledFeatureInterface}
+ * @see {@link StyledFeatureInterface}
*/
+ @Override
+ public FeatureCollection getFeatureCollection() {
+ return getGeoObject();
+ }
+
/**
- *
- * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf
- * verstecken/nicht verstecken gestellt werden können. Das sind
- * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.
- * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer
- * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
- * die Funktion genutzt.
- *
- public boolean isHideInLegend() {
- return false;
+ * Returns a virtual {@link FeatureSource} to access the
+ * {@link FeatureCollection}. Once created, it will be reused until
+ * {@link #uncache()} is called.<br/>
+ * @see {@link StyledFeatureInterface}
+ */
+ @Override
+ public FeatureSource getFeatureSource() {
+ if (featureSource == null) {
+ CollectionDataStore store = new CollectionDataStore(getGeoObject());
+ try {
+ featureSource = store.getFeatureSource(store.getTypeNames()[0]);
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Could not create a FeatureSource from the CollectionDataStore:",
+ e);
+ }
+ }
+ return featureSource;
}
- */
+
}
Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -9,7 +9,7 @@
/**
* {@link StyledMapInterface} which contains a {@link FeatureCollection} as geo object.<br>
*/
-public interface StyledFeatureCollectionInterface extends StyledMapInterface<FeatureCollection> {
+public interface StyledFeatureCollectionInterface extends StyledFeatureInterface<FeatureCollection> {
public abstract Map<Integer,AttributeMetaData> getAttributeMetaDataMap();
Added: trunk/src/skrueger/geotools/StyledFeatureInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureInterface.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/geotools/StyledFeatureInterface.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -0,0 +1,24 @@
+package skrueger.geotools;
+
+import org.geotools.data.FeatureSource;
+import org.opengis.feature.FeatureCollection;
+
+/**
+ * This Interface combines all styled layers that are running on {@link FeatureCollection} or {@link FeatureSource}
+ *
+ * @author Stefan A. Krüger
+ *
+ * @param <T> The base Type returned in the getObject() method.
+ */
+public interface StyledFeatureInterface<T> extends StyledMapInterface<T>{
+
+ /**
+ * @return The features of this layer as a {@link FeatureSource}.
+ */
+ public FeatureSource getFeatureSource();
+
+ /**
+ * @return The features of this layer as a {@link FeatureCollection}.
+ */
+ public abstract org.geotools.feature.FeatureCollection getFeatureCollection();
+}
Property changes on: trunk/src/skrueger/geotools/StyledFeatureInterface.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -9,7 +9,7 @@
/**
* {@link StyledMapInterface} which contains a {@link FeatureSource} as geo object.<br>
*/
-public interface StyledFeatureSourceInterface extends StyledMapInterface<FeatureSource> {
+public interface StyledFeatureSourceInterface extends StyledFeatureInterface<FeatureSource> {
public abstract Map<Integer,AttributeMetaData> getAttributeMetaDataMap();
Modified: trunk/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- trunk/src/skrueger/swing/TranslationEditJPanel.java 2009-07-14 09:41:31 UTC (rev 220)
+++ trunk/src/skrueger/swing/TranslationEditJPanel.java 2009-07-14 14:40:52 UTC (rev 221)
@@ -1,12 +1,21 @@
package skrueger.swing;
import java.awt.BorderLayout;
+import java.awt.Container;
import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.beans.PropertyChangeListener;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
@@ -25,7 +34,7 @@
*
* @author Stefan Alfons Krüger
*/
-public class TranslationEditJPanel extends JPanel {
+public class TranslationEditJPanel extends JPanel {
static final protected Logger LOGGER = Logger
.getLogger(TranslationEditJPanel.class);
@@ -34,6 +43,11 @@
private Translation trans;
/**
+ * Remembers all {@link JTextField} that have been created.
+ */
+ private Set<JTextField> langTextFields = new HashSet<JTextField>();
+
+ /**
* Creates a {@link JPanel} that asks the user for the translation of a
* String in several languages
*/
@@ -84,6 +98,8 @@
langDesc.setLabelFor(langTextField);
translationGrid.add(langDesc);
translationGrid.add(langTextField);
+
+ langTextFields .add(langTextField);
}
// Lay out the panel.
@@ -104,4 +120,31 @@
return trans;
}
+ public void addActionListener(final ActionListener actionListener) {
+ for (final JTextField langTextField : langTextFields){
+ langTextField.addKeyListener( new KeyListener(){
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+ actionListener.actionPerformed(new ActionEvent(TranslationEditJPanel.this, 0, ""));
+ }
+
+ });
+ }
+ }
+
+ public void removeActionListener(ActionListener actionListener) {
+ for (JTextField langTextField : langTextFields){
+ langTextField.removeActionListener(actionListener);
+ }
+ }
+
}
More information about the Schmitzm-commits
mailing list