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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 17 17:55:33 CEST 2009


Author: mojays
Date: 2009-04-17 17:55:33 +0200 (Fri, 17 Apr 2009)
New Revision: 58

Modified:
   trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
   trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
Log:
StyledFeatureCollectionTableModel stable and documented

Modified: trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java	2009-04-17 15:26:14 UTC (rev 57)
+++ trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java	2009-04-17 15:55:33 UTC (rev 58)
@@ -81,6 +81,18 @@
    * uebernommen werden.
    */
   public void reorganize() {
+    reorganize(true);
+  }
+  
+  /**
+   * Baut die interne Datenbasis (Array) des Tabellen-Modells neu auf.
+   * Muss aufgerufen werden, damit nachtraegliche Aenderungen an der
+   * zugrunde liegenden {@link FeatureCollection} in das Tabellenmodell
+   * uebernommen werden.
+   * @param fireTableStructureChanged bestimmt, ob nach dem Neu-Aufbau
+   *        ein entsprechendes Event initiiert wird
+   */
+  protected void reorganize(boolean fireTableStructureChanged) {
     featureArray = FeatureUtil.featuresToArray(featureTable);
     if ( featureArray == null || featureArray.length == 0 )
       colNames = new String[0];
@@ -103,7 +115,8 @@
         colNames[i]      = ft.getAttributeType(idx).getLocalName();
       }
     }
-    fireTableStructureChanged();
+    if ( fireTableStructureChanged )
+      fireTableStructureChanged();
   }
 
   /**

Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 15:26:14 UTC (rev 57)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-04-17 15:55:33 UTC (rev 58)
@@ -32,42 +32,70 @@
  * 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>
+ *   <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)
- * 
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
  */
-public class StyledFeatureCollectionTableModel extends
-    FeatureCollectionTableModel {
-
+public class StyledFeatureCollectionTableModel extends FeatureCollectionTableModel {
+  /** Holds the data source as styled map. */ 
+  protected StyledMapInterface map = 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 current filter on the table */
+  protected Filter filter = null;
 
+  /**
+   * Creates a new table model for a styled map.
+   * @param map the styled map
+   */
   public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map) {
     this(map,Filter.INCLUDE);
   }
 
+  /**
+   * Creates a new table model for a styled map.
+   * @param map the styled map
+   * @param filter filter applied to the table
+   */
   public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map, Filter filter) {
     super();
     setFeatureCollection(map, filter);
   }
 
+  /**
+   * Creates a new table model for a styled map.
+   * @param map the styled map
+   */
   public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) {
     this(map,Filter.INCLUDE);
   }
 
+  /**
+   * Creates a new table model for a styled map.
+   * @param map the styled map
+   * @param filter filter applied to the table
+   */
   public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map, Filter filter) {
     super();
     setFeatureCollection(map, filter);
   }
 
+  /**
+   * Sets a new data source for the table.
+   * @param fs     the feature source
+   * @param amd    {@link AttributeMetaData}-Map to define the visible attributes
+   *               and translation
+   */
   protected void setFeatureSource(FeatureSource fs, Map<Integer, AttributeMetaData> amd, Filter filter) throws Exception {
-    this.visibleAMD = null;
     if ( filter == null )
       filter = Filter.INCLUDE;
+
+    this.featureSource = fs;
+    this.filter        = filter;
+    this.visibleAMD    = null;
     
     FeatureCollection fc = null;
     if (fs != null) {
@@ -90,7 +118,15 @@
     setFeatureCollection(fc);
   }
 
+  /**
+   * Converts the {@code StyledFeatureCollection} to a {@code FeatureSource}
+   * and sets this as the 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(StyledFeatureCollectionInterface map, Filter filter) {
+    this.map = map;
     try {
       if (map == null)
         setFeatureSource(null, null, null);
@@ -105,7 +141,14 @@
     }
   }
 
+  /**
+   * 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 map, Filter filter) {
+    this.map = map;
     try {
       if (map == null)
         setFeatureSource(null, null, null);
@@ -115,10 +158,28 @@
       throw new RuntimeException(err);
     }
   }
+  
+  /**
+   * Resets the filter for the table. 
+   * @param filter a filter
+   */
+  public void setFilter(Filter filter) {
+    try{
+      setFeatureSource(this.featureSource, this.visibleAMD, filter);
+    } catch (Exception err) {
+      throw new RuntimeException(err);
+    }
+  }
 
+  /**
+   * After calling {@code super.reorganize(.)} this method replaced the
+   * column descriptions with the titles of the {@code AttributeMetaData}.
+   * @param fireTableStructureChanged indicates whether a table event is
+   *        initiated after reorganize
+   */
   @Override
-  public void reorganize() {
-    super.reorganize();
+  protected void reorganize(boolean fireTableStructureChanged) {
+    super.reorganize(false);
     // translate the column names
     if (visibleAMD != null) {
       Iterator<Integer> keys = visibleAMD.keySet().iterator();
@@ -130,6 +191,7 @@
         }
       }
     }
-    fireTableStructureChanged();
+    if ( fireTableStructureChanged )
+      fireTableStructureChanged();
   }
 }



More information about the Schmitzm-commits mailing list