[Schmitzm-commits] r428 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/feature skrueger/geotools skrueger/geotools/selection

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Oct 4 16:28:08 CEST 2009


Author: alfonx
Date: 2009-10-04 16:28:07 +0200 (Sun, 04 Oct 2009)
New Revision: 428

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/selection/StyledLayerSelectionModel.java
Log:
* Changed the constructor of AttributetableDialog to be more standard
* StyledFeatureCollectionTableModel now uses the Filter from StyledFeaturesInterface
* Created a test case for AttributeTableJDialog

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-10-02 19:38:44 UTC (rev 427)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-10-04 14:28:07 UTC (rev 428)
@@ -1791,7 +1791,7 @@
 	 * @see {@link FeatureUtilities#wrapGridCoverage(GridCoverage2D)} and
 	 *      {@link FeatureUtilities#wrapGridCoverageReader(AbstractGridCoverage2DReader, GeneralParameterValue[])}
 	 * 
-	 * @param layer
+	 * @param styledFeatures
 	 *            ein Layer
 	 * @return {@code null}, falls das Objekt nicht ermittelt werden kann (da
 	 *         ein Fehler aufgetreten ist).
@@ -1824,7 +1824,7 @@
 	 * @see {@link FeatureUtilities#wrapGridCoverage(GridCoverage2D)} and
 	 *      {@link FeatureUtilities#wrapGridCoverageReader(AbstractGridCoverage2DReader, GeneralParameterValue[])}
 	 * 
-	 * @param layer
+	 * @param styledFeatures
 	 *            ein Layer
 	 * @return {@code null}, falls das Objekt nicht ermittelt werden kann (da
 	 *         ein Fehler aufgetreten ist).

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-10-02 19:38:44 UTC (rev 427)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-10-04 14:28:07 UTC (rev 428)
@@ -37,7 +37,6 @@
 import org.geotools.data.DefaultQuery;
 import org.geotools.data.FeatureSource;
 import org.geotools.data.Query;
-import org.geotools.data.memory.MemoryDataStore;
 import org.geotools.feature.FeatureCollection;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
@@ -53,27 +52,24 @@
 
 /**
  * This class extends the the {@link FeatureCollectionTableModel} with the
- * functionalities of the {@link AttributeMetaData} of
- * {@linkplain StyledLayerInterface styled objects}.
+ * functionalities of the {@link AttributeMetaData}.
  * <ul>
  * <li>column names are translated according to
  * {@link AttributeMetaData#getTitle()}</li>
  * <li>columns are hidden according to {@link AttributeMetaData#isVisible()()}</li>
+ * <li>Any filter defined in the {@link StyledFeaturesInterface} will be applied.</li>
  * </ul>
  * 
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
- *         (University of Bonn/Germany)
+ * @author Stefan A. Krüger
  */
 public class StyledFeatureCollectionTableModel extends
 		FeatureCollectionTableModel {
 	final static private Logger LOGGER = Logger
 			.getLogger(StyledFeatureCollectionTableModel.class);
-	/** Holds the data source as styled layer. */
-	protected StyledLayerInterface<?> layer = null;
 	/** Contains only the visible elements of the {@link AttributeMetaData}-Map */
 	protected Map<Integer, AttributeMetaData> visibleAMD = null;
-	/** Holds the data source for the table as {@code FeatureSource}. */
-	protected FeatureSource featureSource = null;
+//	/** Holds the data source for the table as {@code FeatureSource}. */
+//	protected FeatureSource featureSource = null;
 	/** Contains the complete {@link AttributeMetaData}-Map of the styled layer. */
 	protected Map<Integer, AttributeMetaData> origAMD = null;
 	/** Holds the current filter on the table */
@@ -82,58 +78,19 @@
 	protected Envelope bounds;
 
 	
-
 	/**
 	 * Creates a new table model for a styled layer.
 	 * 
-	 * @param layer
+	 * @param styledFeatures
 	 *            the styled layer
-	 */
-	public StyledFeatureCollectionTableModel(
-			StyledFeatureCollectionInterface layer) {
-		this(layer, Filter.INCLUDE);
-	}
-
-	/**
-	 * Creates a new table model for a styled layer.
-	 * 
-	 * @param layer
-	 *            the styled layer
 	 * @param filter
 	 *            filter applied to the table
 	 */
-	public StyledFeatureCollectionTableModel(
-			StyledFeatureCollectionInterface layer, Filter filter) {
-		super();
-		setFeatureCollection(layer, filter);
+	public StyledFeatureCollectionTableModel(StyledFeaturesInterface<?> styledFeatures) {
+		setStyledFeatures(styledFeatures);
 	}
 
-
 	/**
-	 * Creates a new table model for a styled layer.
-	 * 
-	 * @param layer
-	 *            the styled layer
-	 */
-	public StyledFeatureCollectionTableModel(StyledFeaturesInterface layer) {
-		this(layer, Filter.INCLUDE);
-	}
-
-	/**
-	 * Creates a new table model for a styled layer.
-	 * 
-	 * @param layer
-	 *            the styled layer
-	 * @param filter
-	 *            filter applied to the table
-	 */
-	public StyledFeatureCollectionTableModel(StyledFeaturesInterface layer,
-			Filter filter) {
-		super();
-		setFeatureCollection(layer, filter);
-	}
-
-	/**
 	 * Sets a new data source for the table.
 	 * 
 	 * @param fs
@@ -145,15 +102,16 @@
 	protected void setFeatureSource(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
 			Map<Integer, AttributeMetaData> amd, Filter filter)
 			throws Exception {
+		
 		if (filter == null)
 			filter = Filter.INCLUDE;
 
-		this.featureSource = fs;
+//		this.featureSource = fs;
 		this.filter = filter;
 		this.origAMD = amd;
 		this.visibleAMD = null;
 
-		FeatureCollection fc = null;
+		FeatureCollection<SimpleFeatureType, SimpleFeature> fc = null;
 		if (fs != null) {
 
 			bounds = fs.getBounds();
@@ -194,19 +152,6 @@
 						properties);
 			}
 			fc = fs.getFeatures(query);
-
-			// FAILS:!!!, even with query = new
-			// DefaultQuery(fs.getSchema().getTypeName(), filter);
-			// java.lang.UnsupportedOperationException: Unknown feature
-			// attribute: PQM_MOD
-			// at
-			// schmitzm.geotools.feature.FeatureOperationTree.evaluate(FeatureOperationTree.java:93)
-			// bounds = fc.getBounds();
-			// SK, 17.4.2009
-			//      
-			// System.out.println("Filter = "+filter);
-			// System.out.println("Size of FC = "+fc.size());
-			// System.out.println("anz att= "+fc.getNumberOfAttributes());
 		}
 		setFeatureCollection(fc);
 	}
@@ -221,18 +166,12 @@
 	 *            {@link AttributeMetaData}-Map to define the visible attributes
 	 *            and translation
 	 */
-	public void setFeatureCollection(StyledFeaturesInterface layer,
-			Filter filter) {
-		this.layer = layer;
+	public void setStyledFeatures(StyledFeaturesInterface<?> styledFeatures) {
 		try {
-			if (layer == null)
+			if (styledFeatures == null)
 				setFeatureSource(null, null, null);
 			else {
-				FeatureCollection fc = layer.getFeatureCollection();
-				String fcName = fc.getSchema().getName().getLocalPart();
-				FeatureSource fs = new MemoryDataStore(fc)
-						.getFeatureSource(fcName);
-				setFeatureSource(fs, layer.getAttributeMetaDataMap(), filter);
+				setFeatureSource(styledFeatures.getFeatureSource(), styledFeatures.getAttributeMetaDataMap(), styledFeatures.getFilter());
 			}
 		} catch (Exception err) {
 			throw new RuntimeException(err);
@@ -240,53 +179,6 @@
 	}
 
 	/**
-	 * Sets the {@code StyledFeatureCollection} as new data source for the
-	 * table.
-	 * 
-	 * @param fs
-	 *            the feature source
-	 * @param amd
-	 *            {@link AttributeMetaData}-Map to define the visible attributes
-	 *            and translation
-	 */
-	public void setFeatureCollection(StyledFeatureSourceInterface layer,
-			Filter filter) {
-		this.layer = layer;
-		try {
-			if (layer == null)
-				setFeatureSource(null, null, null);
-			else
-				setFeatureSource(layer.getGeoObject(), layer
-						.getAttributeMetaDataMap(), filter);
-		} catch (Exception err) {
-			throw new RuntimeException(err);
-		}
-	}
-
-	/**
-	 * Resets the filter for the table.
-	 * 
-	 * @param filter
-	 *            a filter
-	 */
-	public void setFilter(Filter filter) {
-		try {
-			setFeatureSource(this.featureSource, this.origAMD, filter);
-		} catch (Exception err) {
-			LOGGER.error("Setting the filter of the table model", err);
-			throw new RuntimeException(err);
-		}
-	}
-
-	/**
-	 * @return <code>Filter.INCLUDE</code> or the {@link Filter} applied to the
-	 *         Features
-	 */
-	public Filter getFilter() {
-		return this.filter;
-	}
-
-	/**
 	 * After calling {@code super.reorganize(.)} this method replaced the column
 	 * descriptions with the titles of the {@code AttributeMetaData}.
 	 * 

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/selection/StyledLayerSelectionModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/selection/StyledLayerSelectionModel.java	2009-10-02 19:38:44 UTC (rev 427)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/selection/StyledLayerSelectionModel.java	2009-10-04 14:28:07 UTC (rev 428)
@@ -79,7 +79,7 @@
   protected final HashSet<E> selectionObjects;
 
   /** Holds the styled map whose selection is managed by this class. */
-  protected final StyledLayerInterface<?> styledLayer;
+  private final StyledLayerInterface<?> styledLayer;
 
 
   /** Indicates whether a selection change is a part of multiple
@@ -241,5 +241,9 @@
     this.removeListener(listener);
   }
 
+public StyledLayerInterface<?> getStyledLayer() {
+	return styledLayer;
+}
 
+
 }



More information about the Schmitzm-commits mailing list