[Schmitzm-commits] r90 - in trunk: dist src/schmitzm/geotools/gui
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Apr 26 19:44:02 CEST 2009
Author: mojays
Date: 2009-04-26 19:43:58 +0200 (Sun, 26 Apr 2009)
New Revision: 90
Modified:
trunk/dist/schmitzm-src.zip
trunk/dist/schmitzm.jar
trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
Log:
FeatureCollectionTableModel extended
- findFeature(.)
- getFeature(.)
Modified: trunk/dist/schmitzm-src.zip
===================================================================
(Binary files differ)
Modified: trunk/dist/schmitzm.jar
===================================================================
(Binary files differ)
Modified: trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java 2009-04-23 19:47:11 UTC (rev 89)
+++ trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java 2009-04-26 17:43:58 UTC (rev 90)
@@ -10,6 +10,7 @@
**/
package schmitzm.geotools.gui;
+import java.util.HashMap;
import java.util.Vector;
import org.geotools.data.FeatureSource;
@@ -62,6 +63,9 @@
/** Speichert den Attribut-Index fuer jede Spalte (wichtig, wenn nicht
* alle Spalten angezeigt werden!) */
protected int[] attrIdxForCol = null;
+ /** Speichert die Indexe der Features im TableModel um die Funktion
+ * {@link #findFeature(Feature)} moeglichst effizient zugestalten. */
+ protected HashMap<Feature,Integer> featureIdx = null;
/**
* Erzeugt ein neues (leeres) Tabellen-Modell.
@@ -123,6 +127,12 @@
colClass[i] = ft.getAttributeType(idx).getBinding();
}
}
+
+ // store feature indexes in HashMap to optimize findFeature(.)
+ featureIdx = new HashMap<Feature, Integer>();
+ for (int i=0; i<featureArray.length; i++)
+ featureIdx.put(featureArray[i], i);
+
if ( fireTableStructureChanged )
fireTableStructureChanged();
}
@@ -232,4 +242,24 @@
return featureCol;
}
+ /**
+ * Returns a Feature of the model.
+ * @param row row index
+ */
+ public Feature getFeature(int row) {
+ return featureArray[row];
+ }
+
+ /**
+ * Returns the index of a {@link Feature} in the model.
+ * @param f a feature
+ * @return -1 if the model does not contain the feature
+ */
+ public int findFeature(Feature f) {
+ Integer idx = featureIdx.get(f);
+ if ( idx != null )
+ return idx;
+ return -1;
+ }
+
}
More information about the Schmitzm-commits
mailing list