[Schmitzm-commits] r57 - trunk/src/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 17 17:26:14 CEST 2009


Author: mojays
Date: 2009-04-17 17:26:14 +0200 (Fri, 17 Apr 2009)
New Revision: 57

Modified:
   trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
Log:


Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 15:19:00 UTC (rev 56)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 15:26:14 UTC (rev 57)
@@ -42,95 +42,94 @@
  * 
  */
 public class StyledFeatureCollectionTableModel extends
-		FeatureCollectionTableModel {
+    FeatureCollectionTableModel {
 
-	protected Map<Integer, AttributeMetaData> visibleAMD = null;
+  protected Map<Integer, AttributeMetaData> visibleAMD = null;
 
-	public StyledFeatureCollectionTableModel(
-			StyledFeatureCollectionInterface map) {
-		super();
-		setFeatureCollection(map);
-	}
+  public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map) {
+    this(map,Filter.INCLUDE);
+  }
 
-	public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) {
-		super();
-		setFeatureCollection(map);
-	}
+  public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map, Filter filter) {
+    super();
+    setFeatureCollection(map, filter);
+  }
 
-	protected void setFeatureSource(FeatureSource fs,
-			Map<Integer, AttributeMetaData> amd) throws Exception {
-		FeatureCollection fc = null;
-		this.visibleAMD = null;
-		if (fs != null) {
-			Query query = new DefaultQuery();
-			if (amd != null) {
-				// determine the names of the visible Attributes
-				this.visibleAMD = StyledMapUtil.getVisibleAttributeMetaData(
-						amd, true);
-				Vector<String> visibleAttrNames = new Vector<String>();
+  public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) {
+    this(map,Filter.INCLUDE);
+  }
 
-				// Add the column with the geometry (usually "the_geom")
-				visibleAttrNames.add(fs.getSchema().getDefaultGeometry()
-						.getLocalName());
+  public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map, Filter filter) {
+    super();
+    setFeatureCollection(map, filter);
+  }
 
-				for (int attrIdx : visibleAMD.keySet())
-					visibleAttrNames.add(fs.getSchema().getAttributeType(
-							attrIdx).getLocalName());
+  protected void setFeatureSource(FeatureSource fs, Map<Integer, AttributeMetaData> amd, Filter filter) throws Exception {
+    this.visibleAMD = null;
+    if ( filter == null )
+      filter = Filter.INCLUDE;
+    
+    FeatureCollection fc = null;
+    if (fs != null) {
+      Query query = new DefaultQuery();
+      if (amd != null) {
+        // determine the names of the visible Attributes
+        this.visibleAMD = StyledMapUtil.getVisibleAttributeMetaData(amd, true);
+        Vector<String> visibleAttrNames = new Vector<String>();
+        // Add the column with the geometry (usually "the_geom")
+        visibleAttrNames.add(fs.getSchema().getDefaultGeometry().getLocalName());
+        for (int attrIdx : visibleAMD.keySet())
+          visibleAttrNames.add(fs.getSchema().getAttributeType(attrIdx).getLocalName());
 
-				// create a query for the visible attributes
-				String[] properties = visibleAttrNames.toArray(new String[0]);
+        // create a query for the visible attributes
+        String[] properties = visibleAttrNames.toArray(new String[0]);
+        query = new DefaultQuery(fs.getSchema().getTypeName(), filter, properties);
+      }
+      fc = fs.getFeatures(query);
+    }
+    setFeatureCollection(fc);
+  }
 
-				query = new DefaultQuery(fs.getSchema().getTypeName(),
-						Filter.INCLUDE, properties);
-			}
-			fc = fs.getFeatures(query);
-		}
-		setFeatureCollection(fc);
-	}
+  public void setFeatureCollection(StyledFeatureCollectionInterface map, Filter filter) {
+    try {
+      if (map == null)
+        setFeatureSource(null, null, null);
+      else {
+        FeatureCollection fc = map.getGeoObject();
+        String fcName = fc.getFeatureType().getTypeName();
+        FeatureSource fs = new MemoryDataStore(fc).getFeatureSource(fcName);
+        setFeatureSource(fs, map.getAttributeMetaDataMap(), filter);
+      }
+    } catch (Exception err) {
+      throw new RuntimeException(err);
+    }
+  }
 
-	public void setFeatureCollection(StyledFeatureCollectionInterface map) {
-		try {
-			if (map == null)
-				setFeatureSource(null, null);
-			else {
-				FeatureCollection fc = map.getGeoObject();
-				String fcName = fc.getFeatureType().getTypeName();
-				FeatureSource fs = new MemoryDataStore(fc)
-						.getFeatureSource(fcName);
-				setFeatureSource(fs, map.getAttributeMetaDataMap());
-			}
-		} catch (Exception err) {
-			throw new RuntimeException(err);
-		}
-	}
+  public void setFeatureCollection(StyledFeatureSourceInterface map, Filter filter) {
+    try {
+      if (map == null)
+        setFeatureSource(null, null, null);
+      else
+        setFeatureSource(map.getGeoObject(), map.getAttributeMetaDataMap(), filter);
+    } catch (Exception err) {
+      throw new RuntimeException(err);
+    }
+  }
 
-	public void setFeatureCollection(StyledFeatureSourceInterface map) {
-		try {
-			if (map == null)
-				setFeatureSource(null, null);
-			else
-				setFeatureSource(map.getGeoObject(), map
-						.getAttributeMetaDataMap());
-		} catch (Exception err) {
-			throw new RuntimeException(err);
-		}
-	}
-
-	@Override
-	public void reorganize() {
-		super.reorganize();
-		// translate the column names
-		if (visibleAMD != null) {
-			Iterator<Integer> keys = visibleAMD.keySet().iterator();
-			for (int i = 0; i < colNames.length && keys.hasNext(); i++) {
-				Translation title = visibleAMD.get(keys.next()).getTitle();
-				if (!I8NUtil.isEmpty(title)) {
-					System.out.println("set colname " + i + " to "
-							+ title.toString());
-					colNames[i] = title.toString();
-				}
-			}
-		}
-		fireTableStructureChanged();
-	}
+  @Override
+  public void reorganize() {
+    super.reorganize();
+    // translate the column names
+    if (visibleAMD != null) {
+      Iterator<Integer> keys = visibleAMD.keySet().iterator();
+      for (int i = 0; i < colNames.length && keys.hasNext(); i++) {
+        Translation title = visibleAMD.get(keys.next()).getTitle();
+        if (!I8NUtil.isEmpty(title)) {
+          System.out.println("set colname " + i + " to " + title.toString());
+          colNames[i] = title.toString();
+        }
+      }
+    }
+    fireTableStructureChanged();
+  }
 }



More information about the Schmitzm-commits mailing list