[Schmitzm-commits] r1196 - in trunk/src: schmitzm/geotools/gui schmitzm/swing skrueger/geotools/selection

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 2 14:24:18 CET 2010


Author: alfonx
Date: 2010-11-02 14:24:17 +0100 (Tue, 02 Nov 2010)
New Revision: 1196

Modified:
   trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
   trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
   trunk/src/schmitzm/swing/SortableJTable.java
   trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java
Log:
Removed the filter function for the attribute table again.. will be reenabled in the next version with more testing.

Modified: trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2010-11-02 10:33:32 UTC (rev 1195)
+++ trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2010-11-02 13:24:17 UTC (rev 1196)
@@ -64,9 +64,9 @@
  * Tabelle die in der Tabelle ausgewaehlten Features grafisch dargestellt.<br>
  * <br>
  * <b>Bemerkung:</b><br>
- * Als {@code TableModel} fuer die SimpleFeature-Tabelle verwendet diese Klasse ein
- * eigenes internes {@link FeatureCollectionTableModel}, welches effizienter arbeitet, als
- * {@link org.geotools.swing.table.FeatureTableModel
+ * Als {@code TableModel} fuer die SimpleFeature-Tabelle verwendet diese Klasse
+ * ein eigenes internes {@link FeatureCollectionTableModel}, welches effizienter
+ * arbeitet, als {@link org.geotools.swing.table.FeatureTableModel
  * org.geotools.swing.table.FeatureTableModel}.
  * 
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
@@ -90,8 +90,7 @@
 	 * Constant for the ToolTip of the preview mappane
 	 */
 	public static final String PREVIEW_MAPPANE_TOOLTIP = FeatureTablePane.class
-			.getName()
-			+ ".PreviewMapPaneToolTip";
+			.getName() + ".PreviewMapPaneToolTip";
 
 	/**
 	 * Splitpane, das die Karten-Vorschau von der Tabelle trennt ({@code null}
@@ -117,7 +116,8 @@
 	 * @param fc
 	 *            angezeigte Features
 	 */
-	public FeatureTablePane(FeatureCollection<SimpleFeatureType,SimpleFeature> fc) {
+	public FeatureTablePane(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
 		this(fc, true);
 	}
 
@@ -141,7 +141,9 @@
 	 *            bestimmt, ob ein Preview-Bereich angezeigt wird ({@code true})
 	 *            oder nicht ({@code false})
 	 */
-	public FeatureTablePane(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, boolean geomPreview) {
+	public FeatureTablePane(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			boolean geomPreview) {
 		this(fc, null, geomPreview);
 	}
 
@@ -156,8 +158,9 @@
 	 *            bestimmt, ob ein Preview-Bereich angezeigt wird ({@code true})
 	 *            oder nicht ({@code false})
 	 */
-	public FeatureTablePane(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, Style style,
-			boolean geomPreview) {
+	public FeatureTablePane(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			Style style, boolean geomPreview) {
 		this(new FeatureCollectionTableModel(fc), style, geomPreview);
 	}
 
@@ -220,10 +223,10 @@
 	protected void initGUI(boolean geomPreview) {
 		setLayout(new BorderLayout());
 		// MapPane fuer Preview der in der Tabelle selektieren Features
-		
+
 		if (geomPreview) {
 			this.mapPane = new SelectableXMapPane();
-			
+
 			// {
 			// // Bei Links-Klick auf das gesamte Layer zoomen
 			// public void mouseClicked(MouseEvent e) {
@@ -241,7 +244,7 @@
 			// }
 			// };
 			mapPane.setToolTipText(GeotoolsGUIUtil.R(PREVIEW_MAPPANE_TOOLTIP));
-//			mapPane.setState(SelectableXMapPane.NONE);
+			// mapPane.setState(SelectableXMapPane.NONE);
 			mapPane.setMinimumSize(new Dimension(100, 100));
 			SwingUtil.setPreferredWidth(mapPane, 200);
 			mapPane.setBorder(BorderFactory.createLoweredBevelBorder());
@@ -254,12 +257,13 @@
 		featuresTable.setModel(featuresTableModel);
 		featuresTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 		featuresTable.setColumnSelectionAllowed(false);
-		featuresTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+		featuresTable
+				.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
 		// Wenn Auswahl in Tabelle sich aendert, Vorschau anpassen
 		featuresTable.getSelectionModel().addListSelectionListener(
 				new ListSelectionListener() {
 					public void valueChanged(ListSelectionEvent e) {
-					  performListSelection();
+						performListSelection();
 					}
 				});
 
@@ -267,9 +271,9 @@
 		// selektierten rot angezeigt. Der rest grau.
 		featuresTableModel.addTableModelListener(new TableModelListener() {
 			public void tableChanged(TableModelEvent e) {
-				
+
 				LOGGER.info("tableChanged");
-				
+
 				// showFeaturesInMap(getSelectedFeatures());
 				if (mapPane != null) {
 					// falls diese TableContextChange durch einen neu
@@ -285,7 +289,7 @@
 		NumberFormat formatter = NumberFormat.getNumberInstance();
 		formatter.setMinimumFractionDigits(3);
 		formatter.setMaximumFractionDigits(3);
-		DoubleRenderer doubleRenderer = new DoubleRenderer(formatter,null);
+		DoubleRenderer doubleRenderer = new DoubleRenderer(formatter, null);
 		featuresTable.setDefaultRenderer(Double.class, doubleRenderer);
 	}
 
@@ -319,7 +323,8 @@
 	 * @param fc
 	 *            anzuzeigende Features
 	 */
-	public void setFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc) {
+	public void setFeatureCollection(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
 		featuresTableModel.setFeatureCollection(fc);
 	}
 
@@ -334,7 +339,7 @@
 	/**
 	 * Liefert die angezeigten Features.
 	 */
-	public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatureCollection() {
+	public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatureCollection() {
 		return featuresTableModel.getFeatureCollection();
 	}
 
@@ -358,7 +363,7 @@
 	/**
 	 * Liefert die in der Tabelle selektierten Features.
 	 */
-	public FeatureCollection<SimpleFeatureType,SimpleFeature> getSelectedFeatures() {
+	public FeatureCollection<SimpleFeatureType, SimpleFeature> getSelectedFeatures() {
 		return featuresTableModel.getFeaturesAsCollection(featuresTable
 				.getSelectedModelRows());
 	}
@@ -372,6 +377,11 @@
 		// // Wenn keine Auswahl getaetigt ist, alle Features anzeigen
 		// if (subCollection == null || subCollection.isEmpty())
 		// subCollection = getFeatureCollection();
+
+		if (getTable().getSelectionModel() != null
+				&& getTable().getSelectionModel().getValueIsAdjusting())
+			return;
+
 		showFeaturesInMap();
 	}
 
@@ -387,7 +397,7 @@
 		if (mapPane == null)
 			return;
 
-		FeatureCollection<SimpleFeatureType,SimpleFeature> selectedFeatures = getSelectedFeatures();
+		FeatureCollection<SimpleFeatureType, SimpleFeature> selectedFeatures = getSelectedFeatures();
 
 		/**
 		 * Das layer mit allen features soll nicht immer neu eingefügt werden.
@@ -395,25 +405,27 @@
 		 */
 		if (mapPane.getMapContext().getLayerCount() == 0) {
 
-			final FeatureCollection<SimpleFeatureType,SimpleFeature> allFeatures = getFeatureCollection();
+			final FeatureCollection<SimpleFeatureType, SimpleFeature> allFeatures = getFeatureCollection();
 
 			/**
 			 * Add ALL features to the JMapPane as the base layer and style them
 			 * in grey
 			 */
 			if (allFeatures != null && mapPane != null) {
-				
-// Let's try not to use a MemoryFeatureCollection				
-//				mapPane.getMapContext().addLayer(
-//						new DefaultMapLayer(FeatureUtil.createMemoryFeatureSource(allFeatures), StylingUtil
-//								.createStyleSimple(allFeatures,
-//										Color.lightGray, Color.darkGray)));
 
+				// Let's try not to use a MemoryFeatureCollection
+				// mapPane.getMapContext().addLayer(
+				// new
+				// DefaultMapLayer(FeatureUtil.createMemoryFeatureSource(allFeatures),
+				// StylingUtil
+				// .createStyleSimple(allFeatures,
+				// Color.lightGray, Color.darkGray)));
+
 				mapPane.getMapContext().addLayer(
-				new DefaultMapLayer(allFeatures, StylingUtil
-						.createStyleSimple(allFeatures,
-								Color.lightGray, Color.darkGray)));
-				
+						new DefaultMapLayer(allFeatures, StylingUtil
+								.createStyleSimple(allFeatures,
+										Color.lightGray, Color.darkGray)));
+
 			}
 		}
 
@@ -422,14 +434,15 @@
 			mapPane.getMapContext().removeLayer(1);
 
 		// Und ggf. neu hinzufügen
-		if (selectedFeatures != null && selectedFeatures.size() > 0  &&
-		    selectedFeatures.getSchema().getGeometryDescriptor() != null) {
+		if (selectedFeatures != null && selectedFeatures.size() > 0
+				&& selectedFeatures.getSchema().getGeometryDescriptor() != null) {
 
 			if (getFeatureStyle() == null) {
 				setFeatureStyle(StylingUtil.createStyleSimple(selectedFeatures,
 						Color.red, Color.white));
 			}
-			mapPane.getMapContext().addLayer(selectedFeatures, getFeatureStyle());
+			mapPane.getMapContext().addLayer(selectedFeatures,
+					getFeatureStyle());
 
 			/**
 			 * TODO Das schmeisst eine blöde exception
@@ -439,7 +452,7 @@
 			 * .evaluate(FeatureOperationTree.java:92) at
 			 * schmitzm.lang.tree.OperationTree.evaluate(OperationTree.java:181)
 			 */
-//			mapPane.zoomTo(getFeatureCollection()); //
+			// mapPane.zoomTo(getFeatureCollection()); //
 		}
 
 		// Vorschaukarte aktualisieren

Modified: trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2010-11-02 10:33:32 UTC (rev 1195)
+++ trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2010-11-02 13:24:17 UTC (rev 1196)
@@ -156,7 +156,7 @@
 		north.add(getToolBar(), BorderLayout.WEST);
 		north.add(getStatusLabel(), BorderLayout.EAST);
 		newPanelArroundTable.add(north, BorderLayout.NORTH);
-		newPanelArroundTable.add(getSearchBar(), BorderLayout.SOUTH);
+		// newPanelArroundTable.add(getSearchBar(), BorderLayout.SOUTH);
 
 		featuresTable.getSelectionModel().addListSelectionListener(
 				new ListSelectionListener() {
@@ -231,6 +231,9 @@
 	/**
 	 * Adding the ability to search all Field. The Key events are collected evry
 	 * 1000ms for fast typers ;-).
+	 * 
+	 * Disabled to be reenabled in next version of schmitzm. Too many
+	 * complications with the map<->table-<chart selection synchronizers.
 	 */
 	private JPanel getSearchBar() {
 		if (sarchPanel == null) {
@@ -336,6 +339,8 @@
 				featuresTable.getSelectionModel().setValueIsAdjusting(true);
 
 				for (int i = 0; i < featuresTable.getModel().getRowCount(); i++) {
+					// for (int i = 0; i <
+					// featuresTable.getRowSorter().getViewRowCount(); i++) {
 					if (featuresTable.getSelectionModel().isSelectedIndex(i)) {
 						featuresTable.getSelectionModel()
 								.removeSelectionInterval(i, i);

Modified: trunk/src/schmitzm/swing/SortableJTable.java
===================================================================
--- trunk/src/schmitzm/swing/SortableJTable.java	2010-11-02 10:33:32 UTC (rev 1195)
+++ trunk/src/schmitzm/swing/SortableJTable.java	2010-11-02 13:24:17 UTC (rev 1196)
@@ -36,6 +36,8 @@
 import javax.swing.table.TableColumnModel;
 import javax.swing.table.TableModel;
 
+import org.apache.log4j.Logger;
+
 /**
  * Extends the {@link JTable} with automatic sort functionality.
  * This class adds the following methods so that manually calling
@@ -54,6 +56,8 @@
  */
 public class SortableJTable extends SelectableJTable {
 
+	final static Logger LOGGER = Logger.getLogger(SortableJTable.class);
+
   /**
    * Creates an empty table.
    */
@@ -140,8 +144,16 @@
    */
   public int[] getSelectedModelRows() {
     int[] rows = super.getSelectedRows();
-    for (int i=0; i<rows.length; i++)
-      rows[i] = convertRowIndexToModel(rows[i]);
+    
+//    String s = "";
+//    for (int i : rows) {
+//    	s += ","+i;
+//    }
+//    LOGGER.debug("Selected row "+s);
+    
+    for (int i=0; i<rows.length; i++) {
+    	rows[i] = convertRowIndexToModel(rows[i]);
+    }
     return rows;
   }
   

Modified: trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java
===================================================================
--- trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java	2010-11-02 10:33:32 UTC (rev 1195)
+++ trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java	2010-11-02 13:24:17 UTC (rev 1196)
@@ -190,6 +190,8 @@
 			layerSelModel.clearSelection();
 		} else{
 			
+//		    LOGGER.debug("Selected "+evt.getFirstIndex()+" bis "+evt.getLastIndex());
+
 			for (int i = evt.getFirstIndex(); i <= evt.getLastIndex(); i++) {
 				int featureIndex = featureTable.convertRowIndexToModel(i);
 				SimpleFeature changedFeature = featureTableModel.getFeature(featureIndex);



More information about the Schmitzm-commits mailing list