[Schmitzm-commits] r56 - in trunk/src: schmitzm/geotools/gui skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 17 17:19:00 CEST 2009


Author: alfonx
Date: 2009-04-17 17:19:00 +0200 (Fri, 17 Apr 2009)
New Revision: 56

Modified:
   trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
   trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
   trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
Log:


Modified: trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-04-17 14:26:14 UTC (rev 55)
+++ trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-04-17 15:19:00 UTC (rev 56)
@@ -34,6 +34,7 @@
 import org.geotools.feature.FeatureCollections;
 import org.geotools.feature.FeatureIterator;
 import org.geotools.feature.FeatureType;
+import org.geotools.gui.swing.table.FeatureTableModel;
 import org.geotools.map.MapLayer;
 import org.geotools.styling.Style;
 
@@ -110,7 +111,7 @@
    *                    oder nicht ({@code false})
    */
   public FeatureTablePane(FeatureCollection fc, Style style, boolean geomPreview) {
-    this(null,fc,style,geomPreview);
+    this(new FeatureCollectionTableModel(fc),style,geomPreview);
   }
   
   /**
@@ -121,7 +122,7 @@
    * @param geomPreview bestimmt, ob ein Preview-Bereich angezeigt wird ({@code true})
    *                    oder nicht ({@code false})
    */
-  public FeatureTablePane(FeatureCollectionTableModel model, FeatureCollection fc, Style style, boolean geomPreview) {
+  public FeatureTablePane(FeatureCollectionTableModel model, Style style, boolean geomPreview) {
     super();
     this.featureStyle = style;
     this.featuresTableModel = (model != null) ? model : new FeatureCollectionTableModel();
@@ -145,7 +146,7 @@
     } else {
       add(featuresTableScrollPane);
     }
-    setFeatureCollection( fc );
+	setFeatureCollection(model.getFeatureCollection());
   }
 
   /**

Modified: trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-17 14:26:14 UTC (rev 55)
+++ trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-17 15:19:00 UTC (rev 56)
@@ -39,7 +39,7 @@
 
 	public SelectableFeatureTablePane(FeatureCollectionTableModel model,
 			boolean geomPreview) {
-		super(model, null, null, geomPreview);
+		super(model, null, geomPreview);
 		
 		JPanel newPanelArroundTable = new JPanel(  new BorderLayout() );
 		
@@ -54,7 +54,7 @@
 		}
 		
 		newPanelArroundTable.add(getToolBar(), BorderLayout.NORTH);
-		newPanelArroundTable.add(getSearchBar(), BorderLayout.NORTH);
+		newPanelArroundTable.add(getSearchBar(), BorderLayout.SOUTH);
 	}
 	
 
@@ -125,19 +125,19 @@
 		
 		return toolBar;
 	}
+ 
+//
+//	/**
+//	 * Zeigt die aktuell in der Tabelle selektierten Features im Preview-Bereich
+//	 * an.
+//	 */
+//	@Override
+//	protected void performListSelection() {
+//		FeatureCollection subCollection = getSelectedFeatures();
+//		// Wenn keine Auswahl getaetigt ist, alle Features anzeigen
+//		if (subCollection == null || subCollection.isEmpty())
+//			subCollection = getFeatureCollection();
+//		showFeaturesInMap(subCollection);
+//	}
 
-
-	/**
-	 * Zeigt die aktuell in der Tabelle selektierten Features im Preview-Bereich
-	 * an.
-	 */
-	@Override
-	protected void performListSelection() {
-		FeatureCollection subCollection = getSelectedFeatures();
-		// Wenn keine Auswahl getaetigt ist, alle Features anzeigen
-		if (subCollection == null || subCollection.isEmpty())
-			subCollection = getFeatureCollection();
-		showFeaturesInMap(subCollection);
-	}
-
 }

Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 14:26:14 UTC (rev 55)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 15:19:00 UTC (rev 56)
@@ -27,91 +27,110 @@
 import skrueger.i8n.I8NUtil;
 import skrueger.i8n.Translation;
 
-
 /**
  * This class extends the the {@link FeatureCollectionTableModel} with the
- * functionalities of the {@link AttributeMetaData} of {@linkplain StyledMapInterface styled objects}.
+ * functionalities of the {@link AttributeMetaData} of
+ * {@linkplain StyledMapInterface styled objects}.
  * <ul>
- *   <li>column names are translated according to {@link AttributeMetaData#getTitle()}</li>
- *   <li>columns are hidden according to {@link AttributeMetaData#isVisible()()}</li>
- * </ul> 
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
- *
+ * <li>column names are translated according to
+ * {@link AttributeMetaData#getTitle()}</li>
+ * <li>columns are hidden according to {@link AttributeMetaData#isVisible()()}</li>
+ * </ul>
+ * 
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *         (University of Bonn/Germany)
+ * 
  */
-public class StyledFeatureCollectionTableModel extends FeatureCollectionTableModel {
-  
-  protected Map<Integer,AttributeMetaData> visibleAMD = null;
-  
-  public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map) {
-    super();
-    setFeatureCollection(map);
-  }
-  
-  public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) {
-    super();
-    setFeatureCollection(map);
-  }
-  
-  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>();
-        for ( int attrIdx : visibleAMD.keySet() )
-          visibleAttrNames.add( fs.getSchema().getAttributeType(attrIdx).getLocalName() );
-        // create a query for the visible attributes  
-        query = new DefaultQuery(
-                       fs.getSchema().getTypeName(),
-                       Filter.INCLUDE,
-                       visibleAttrNames.toArray(new String[0])
-        );
-      }
-      fc = fs.getFeatures(query);
-    }
-    setFeatureCollection( fc );
-  }
-  
-  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) {
-    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) )
-          colNames[i] = title.toString();
-      }
-    }
-  }
+public class StyledFeatureCollectionTableModel extends
+		FeatureCollectionTableModel {
+
+	protected Map<Integer, AttributeMetaData> visibleAMD = null;
+
+	public StyledFeatureCollectionTableModel(
+			StyledFeatureCollectionInterface map) {
+		super();
+		setFeatureCollection(map);
+	}
+
+	public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) {
+		super();
+		setFeatureCollection(map);
+	}
+
+	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>();
+
+				// 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]);
+
+				query = new DefaultQuery(fs.getSchema().getTypeName(),
+						Filter.INCLUDE, properties);
+			}
+			fc = fs.getFeatures(query);
+		}
+		setFeatureCollection(fc);
+	}
+
+	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) {
+		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();
+	}
 }



More information about the Schmitzm-commits mailing list