[Schmitzm-commits] r111 - in trunk: dist src/schmitzm/geotools/gui src/skrueger src/skrueger/geotools src/skrueger/geotools/resource src/skrueger/geotools/resource/icons src/skrueger/geotools/selection

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 13 01:33:18 CEST 2009


Author: alfonx
Date: 2009-05-13 01:33:14 +0200 (Wed, 13 May 2009)
New Revision: 111

Added:
   trunk/src/skrueger/geotools/AttributeTableJDialog.java
   trunk/src/skrueger/geotools/resource/
   trunk/src/skrueger/geotools/resource/icons/
   trunk/src/skrueger/geotools/resource/icons/info.png
   trunk/src/skrueger/geotools/resource/icons/pan.png
   trunk/src/skrueger/geotools/resource/icons/selection_add.png
   trunk/src/skrueger/geotools/resource/icons/selection_clear.png
   trunk/src/skrueger/geotools/resource/icons/selection_remove.png
   trunk/src/skrueger/geotools/resource/icons/selection_set.png
   trunk/src/skrueger/geotools/resource/icons/zoom_back (Kopie).png
   trunk/src/skrueger/geotools/resource/icons/zoom_back.png
   trunk/src/skrueger/geotools/resource/icons/zoom_forward (Kopie).png
   trunk/src/skrueger/geotools/resource/icons/zoom_forward.png
   trunk/src/skrueger/geotools/resource/icons/zoom_in.png
   trunk/src/skrueger/geotools/resource/icons/zoom_out.png
Removed:
   trunk/src/skrueger/geotools/info.png
   trunk/src/skrueger/geotools/pan.png
   trunk/src/skrueger/geotools/zoom_back.png
   trunk/src/skrueger/geotools/zoom_forward.png
   trunk/src/skrueger/geotools/zoom_in.png
   trunk/src/skrueger/geotools/zoom_out.png
Modified:
   trunk/dist/schmitzm-src.zip
   trunk/dist/schmitzm.jar
   trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
   trunk/src/schmitzm/geotools/gui/JMapPane.java
   trunk/src/skrueger/AttributeMetaDataAttributeTypeFilter.java
   trunk/src/skrueger/geotools/MapPaneToolBar.java
   trunk/src/skrueger/geotools/MapView.java
   trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
   trunk/src/skrueger/geotools/StyledMapUtil.java
   trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
   trunk/src/skrueger/geotools/selection/StyledFeatureLayerSelectionModel.java
   trunk/src/skrueger/geotools/selection/StyledLayerSelectionModel.java
   trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java
Log:
* Fixed some bugs with the SelectionListeners and the JMapPane. To make this work,  StyledFeatureLayerSelectionModel now extends StyledLayerSelectionModel<String>. So the selection is remembered as a Set of Feature-IDs. This change was needed, because Feature.java doesn't overwrite the equals method, and therefore the HashSet didn't function as expected.
* Added new Tools and BUttons to MapPaneToolBar.java to select features
* Changed a lot in MapPaneToolBar.java. It now allows to position Spaces, Actions and Tools via the ID field. (the new feature is to mix them)
* Fixed a bug in AV's ClickInfoPanel that would suddenly pop up an AtlasViewer if started from Geopublisher under special circumstances.
* Moving layers in the legend is using MapContext's move method instead of remove and insert.
* LayerPanel's remember* Maps now all have the MapLayer's ID as a key. 

This commit includes latest schmitzm.jar and av.jar. The av.jar is also commited to the ISDSS, but the ISDSS will still have the old schmitzm.jar. Latest schmitzm.jar in ISDSS should be updated ASAP. I just don't know where to put it.

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-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -64,8 +64,10 @@
    *  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;
+   *  {@link #findFeature(Feature)} moeglichst effizient zugestalten. 
+   *  Der Key ist nicht das Feature, sondern die FeatureID, weil 
+   *  {@link Feature} die equals methode nicht überschreibt.*/
+  protected HashMap<String,Integer> featureIdx = null;
 
   /**
    * Erzeugt ein neues (leeres) Tabellen-Modell.
@@ -129,9 +131,9 @@
     }
 
     // store feature indexes in HashMap to optimize findFeature(.)
-    featureIdx = new HashMap<Feature, Integer>();
+    featureIdx = new HashMap<String, Integer>();
     for (int i=0; i<featureArray.length; i++)
-      featureIdx.put(featureArray[i], i);
+      featureIdx.put(featureArray[i].getID(), i);
     
     if ( fireTableStructureChanged )
       fireTableStructureChanged();
@@ -147,7 +149,7 @@
   public void setFeatureCollection(final FeatureCollection features) {
       featureTable = features;
       reorganize();
-  }
+   }
 
   /**
    * Liefert die FeatureCollection fuer das Tabellen-Modell.
@@ -256,10 +258,20 @@
    * @return -1 if the model does not contain the feature
    */
   public int findFeature(Feature f) {
-   Integer idx = featureIdx.get(f);
+   return findFeature(f.getID());
+  }
+  
+  /**
+   * Returns the index of a {@link Feature} in the model.
+   * @param fid A feature-ID
+   * @return -1 if the model does not contain the feature
+   */
+  public int findFeature(String fId) {
+   Integer idx = featureIdx.get(fId);
    if ( idx != null )
      return idx;
    return -1; 
   }
+  
 
 }

Modified: trunk/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/JMapPane.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/schmitzm/geotools/gui/JMapPane.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -1487,7 +1487,8 @@
 				// Liefert eine FeatureCollection zurück, in welcher nur
 				// Features enthalten sind, welche bei der aktuellen
 				// Anzeigeskala aufgrund des Styles gerendert werden.
-				fc = filterSLDVisibleOnly(fc, layer.getStyle());
+				if (!fc.isEmpty())
+					fc = filterSLDVisibleOnly(fc, layer.getStyle());
 
 				if (!fc.isEmpty()) {
 					result.put(layer, fc);

Modified: trunk/src/skrueger/AttributeMetaDataAttributeTypeFilter.java
===================================================================
--- trunk/src/skrueger/AttributeMetaDataAttributeTypeFilter.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/AttributeMetaDataAttributeTypeFilter.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -1,10 +1,9 @@
 package skrueger;
 
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.geotools.feature.AttributeType;
-import org.geotools.feature.FeatureType;
 
 import schmitzm.geotools.feature.AttributeTypeFilter;
 

Added: trunk/src/skrueger/geotools/AttributeTableJDialog.java
===================================================================
--- trunk/src/skrueger/geotools/AttributeTableJDialog.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/AttributeTableJDialog.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -0,0 +1,187 @@
+//package skrueger.geotools;
+//
+//import java.awt.Component;
+//import java.awt.Window;
+//import java.awt.event.WindowAdapter;
+//import java.awt.event.WindowEvent;
+//import java.beans.PropertyChangeListener;
+//import java.util.HashMap;
+//
+//import javax.swing.JComponent;
+//import javax.swing.JDialog;
+//
+//import org.geotools.map.MapLayer;
+//import org.opengis.filter.Filter;
+//
+//import schmitzm.geotools.feature.AttributeTypeFilter;
+//import schmitzm.geotools.gui.FeatureTablePane;
+//import schmitzm.geotools.gui.JMapPane;
+//import schmitzm.geotools.gui.SelectableFeatureTablePane;
+//import schmitzm.swing.SwingUtil;
+//import skrueger.geotools.selection.StyledFeatureLayerSelectionModel;
+//import skrueger.geotools.selection.StyledLayerSelectionModel;
+//import skrueger.geotools.selection.StyledLayerSelectionModelSynchronizer;
+//import skrueger.geotools.selection.TableSelectionSynchronizer;
+//
+///**
+// * A dialog to show the attribute table of a vector layer. This class implements
+// * a {@link PropertyChangeListener} which is connected to the {@link StyledMapInterface
+// * StyledMapInterface's} {@link StyledLayerSelectionModel} to keep the table selection
+// * synchronized to other component's selection (e.g. Map or chart).
+// */
+//public class AttributeTableJDialog extends JDialog {
+//
+//	/** A cache that manages maximum one instance of this class per layer **/
+//	private static HashMap<String, AttributeTableJDialog> dialogCache = new HashMap<String, AttributeTableJDialog>();
+//
+//	private final StyledFeatureCollectionTableModel model;
+//
+//	private final JMapPane mapPane;
+//
+//	/** Holds the table and preview of the dialog. */
+//	protected FeatureTablePane featureTablePane;
+//
+//	protected final MapLayer mapLayer;
+//
+//	private final StyledMapInterface styledObj;
+//
+//	private AttributeTableJDialog(Window owner, MapLayer mapLayer,
+//			final StyledMapInterface styledObj, LayerPanel layerPanel) {
+//		super(owner);
+//		this.styledObj = styledObj;
+////		setTitle(RES("AttributeTable.dialog.title", styledObj
+////				.getTitle()));
+//
+//		this.mapLayer = mapLayer;
+//
+//		this.mapPane = layerPanel.geoMapPane != null ? layerPanel.geoMapPane
+//				.getMapPane() : null;
+//
+//		Filter filter = mapLayer.getQuery() != null ? mapLayer.getQuery()
+//				.getFilter() : Filter.INCLUDE;
+//
+//		// Falsch:
+//		// FeatureOperationTreeFilter filter = new
+//		// FeatureOperationTreeFilter(dpLayer.getFilterRule());
+//
+//		if (styledObj instanceof StyledFeatureCollectionInterface) {
+//			model = new StyledFeatureCollectionTableModel(
+//					(StyledFeatureCollectionInterface) styledObj, filter);
+//		} else if (styledObj instanceof StyledFeatureSourceInterface) {
+//			model = new StyledFeatureCollectionTableModel(
+//					(StyledFeatureSourceInterface) styledObj, filter);
+//		} else {
+//			throw new IllegalArgumentException("StyledObj must be of StyledFeatureSourceInterface or StyledFeatureCollectionInterface"); 
+//		}
+//
+//		getModel().setAttributeFilter(AttributeTypeFilter.NO_GEOMETRY);
+//
+//		initialize();
+//
+//		StyledLayerSelectionModel<?> anySelectionModel = layerPanel
+//				.getRememberSelection(mapLayer);
+//
+//		if ((anySelectionModel instanceof StyledFeatureLayerSelectionModel)) {
+//			StyledFeatureLayerSelectionModel selectionModel = (StyledFeatureLayerSelectionModel) anySelectionModel;
+//			// create a synchronizer to keep the feature table selection
+//			// synchronized with the other components connected to the
+//			// DpLayerSelectionModel
+//			TableSelectionSynchronizer synchronizer = new TableSelectionSynchronizer(
+//					selectionModel, featureTablePane.getTable());
+//			selectionModel
+//					.addSelectionListener((StyledLayerSelectionModelSynchronizer) synchronizer);
+//			featureTablePane.getTable().getSelectionModel()
+//					.addListSelectionListener(synchronizer);
+//		}
+//
+//	}
+//
+//	private void initialize() {
+//		featureTablePane = new SelectableFeatureTablePane(getModel(), true,
+//				mapPane);
+//
+//		setContentPane(featureTablePane);
+//
+//		SwingUtil.centerFrameOnScreenRandom(this);
+//
+//		pack();
+//	}
+//
+//	public StyledFeatureCollectionTableModel getModel() {
+//		return model;
+//	}
+//
+//	/**
+//	 * Checks if there exists an open instance of the AtlasAttributeTable and
+//	 * disposes it.
+//	 * 
+//	 * @param layerId
+//	 *            A {@link String} id that equals mapLayer.getTitle() and
+//	 *            dpLayer.getId()
+//	 * @return <code>true</code> if a window has been disposed.
+//	 */
+//	public static boolean disposeInstanceFor(String layerId) {
+//		AttributeTableJDialog atlasAttributeTableJDialog = dialogCache
+//				.get(layerId);
+//		if (atlasAttributeTableJDialog != null) {
+//			atlasAttributeTableJDialog.dispose();
+//			dialogCache.remove(layerId);
+//			return true;
+//		}
+//		return false;
+//	}
+//
+//	/**
+//	 * This class manages itself, that there is always only one instance for any {@link StyledMapInterface}
+//	 * 
+//	 * @param dpLayer
+//	 *            The source for the attribute table
+//	 * @param owner
+//	 *            A {@link JComponent} that is the parent GUI Dialogue
+//	 * @param layerPanel
+//	 *            May be <code>null</code>
+//	 * @param mapLayer
+//	 *            If <code>null</code>, then no "ZoomToLayer" button will
+//	 *            appear.
+//	 */
+//	public static AttributeTableJDialog getInstanceFor(Component comp,
+//			MapLayer mapLayer, final StyledMapInterface<?> styledObj,
+//			LayerPanel layerPanel) {
+//
+//		AttributeTableJDialog atlasAttributeTableJDialog = dialogCache
+//				.get(styledObj.getId());
+//
+//		if (atlasAttributeTableJDialog == null) {
+//			Window window = SwingUtil.getParentWindow(comp);
+//			atlasAttributeTableJDialog = new AttributeTableJDialog(window,
+//					mapLayer, styledObj, layerPanel);
+//
+//			atlasAttributeTableJDialog.addWindowListener(new WindowAdapter() {
+//				@Override
+//				public void windowClosing(WindowEvent e) {
+//					super.windowClosing(e);
+//					dialogCache.remove(styledObj.getId());
+//				}
+//			});
+//
+//			dialogCache.put(styledObj.getId(), atlasAttributeTableJDialog);
+//		}
+//		// Changing the filter is propagated via an Event in AtlaslayerPaneGroup
+//		// else {
+//		// Filter filter = (mapLayer != null && mapLayer.getQuery() != null) ?
+//		// mapLayer
+//		// .getQuery().getFilter()
+//		// : Filter.INCLUDE;
+//		// // Check if the filter has changed...
+//		// if (!filter.equals(atlasAttributeTableJDialog.getModel()
+//		// .getFilter())) {
+//		//
+//		// atlasAttributeTableJDialog.getModel().setFilter(filter);
+//		// }
+//		// }
+//
+//		return atlasAttributeTableJDialog;
+//
+//	}
+//
+//}


Property changes on: trunk/src/skrueger/geotools/AttributeTableJDialog.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- trunk/src/skrueger/geotools/MapPaneToolBar.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/MapPaneToolBar.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -12,9 +12,13 @@
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
+import javax.swing.JComponent;
 import javax.swing.JToggleButton;
 import javax.swing.JToolBar;
+import javax.swing.JToolBar.Separator;
 
+import jj2000.j2k.NotImplementedError;
+
 import org.apache.log4j.Logger;
 
 import schmitzm.geotools.gui.JMapPane;
@@ -27,39 +31,56 @@
 import com.vividsolutions.jts.geom.Envelope;
 
 /**
- * A toolbar to controll a {@link JMapPane} (Atlas visualization). This contains two types
+ * A toolbar to control an {@link JMapPane} (Atlas visualization). This contains two types
  * of buttons. A group of <i>tools</i> for the mouse actions on the map represented
  * by {@link JToggleButton JToggleButtons}, where only one tool can be activated
  * every time. And some (general) <i>actions</i>, represented by normal
  * {@link JButton JButtons}. 
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * @version 1.2 Stefan Krüger
  */
 public class MapPaneToolBar extends JToolBar {
 	private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class.getName());
 	/** Constant for the tool "Panning" (10). */
 	public static final int TOOL_PAN = 10;
-	/** Constant for the tool "Zoom In" (30). */
-	public static final int TOOL_ZOOMIN = 30;
-	/** Constant for the tool "Zoom Out" (40). */
-	public static final int TOOL_ZOOMOUT = 40;
 	/** Constant for the tool "Info" (20). */
 	public static final int TOOL_INFO = 20;
+	public static final int SEPERATOR0 = 99;
+	
+	/** Constant for the tool "Zoom In" (110). */
+	public static final int TOOL_ZOOMIN = 110;
+	/** Constant for the tool "Zoom Out" (120). */
+	public static final int TOOL_ZOOMOUT = 120;
+	/** Constant for the action "Zoom back" (130). */
+	public static final int ACTION_ZOOM_BACK = 130;
+	/** Constant for the action "Zoom forward" (140). */
+	public static final int ACTION_ZOOM_FORWARD = 140;
+	public static final int SEPERATOR1 = 199;
+	
+	/** Constant for the tool "Select" which sets the Selection to the selected features (210). */
+	public static final int TOOL_SELECTION_SET = 210;
+	/** Constant for the tool "Selection add" which adds the features to the Selection (220). */
+	public static final int TOOL_SELECTION_ADD = 220;
+	/** Constant for the tool "Selection subtract" which removes the selected features from the selection (230). */
+	public static final int TOOL_SELECTION_REMOVE = 230;
+	/** Constant for the tool "Selection Reset" which clears the selection (240). */
+	public static final int TOOL_SELECTION_CLEAR = 240;
+	public static final int SEPERATOR2 = 299;
 
+	/** Constant for the action "Search Labels" (120). */
+	public static final int ACTION_SEARCH = 300;
+
 	/** Tool currently selected */
     protected int selectedTool = TOOL_ZOOMIN;
+    
     /** Holds the tool buttons of the tool bar. */
-    protected SortedMap<Integer, JToggleButton> toolButtons = null;
+    protected SortedMap<Integer, JComponent> toolAndActionButtons = null;
     /** Controls that only one tool button is activated. */
     protected ButtonGroup toolButtonGroup = null;
-    /** Constant for the action "Zoom back" (100). */
-    public static final int ACTION_ZOOM_BACK = 100;
-    /** Constant for the action "Zoom forward" (110). */
-    public static final int ACTION_ZOOM_FORWARD = 110;
-    /** Constant for the action "Search Labels" (120). */
-    public static final int ACTION_SEARCH = 120;
 
-    /** Holds the action buttons of the bar. */
-    protected SortedMap<Integer, JButton> actionButtons = null;
+// SK: Musste ich ändern damit man Tools und Actions in der Reihenfolge mischen kann.    
+//    /** Holds the action buttons of the bar. */
+//    protected SortedMap<Integer, JButton> actionButtons = null;
 
 	/** Holds the {@link JMapPane} this tool bar controls. */
 	protected JMapPane mapPane = null;
@@ -91,9 +112,8 @@
 	 */
 	public MapPaneToolBar(JMapPane mapPane) {
 	  super("Control the map", JToolBar.HORIZONTAL);
-      this.toolButtons     = new TreeMap<Integer,JToggleButton>();
+      this.toolAndActionButtons  = new TreeMap<Integer,JComponent>();
       this.toolButtonGroup = new ButtonGroup();
-      this.actionButtons   = new TreeMap<Integer,JButton>();
       // Create a Listener to sniff the zooms on the JMapPane
       this.mapPaneListener = new JMapPaneListener() {
           public void performMapPaneEvent(JMapPaneEvent e) {
@@ -153,67 +173,95 @@
 	}
 	
 	/**
-	 * Calls {@link #initTools()} and {@link #initActions()} and then puts
+	 * Calls {@link #initToolsAndActions()} and {@link #initActions()} and then puts
 	 * all tool buttons and all actions buttons to the tool bar.
 	 */
 	protected void init() {
-	  initTools();
-	  initActions();
+	  initToolsAndActions();
+      
+	  addSeparator(SEPERATOR0, new JToolBar.Separator());
+      addSeparator(SEPERATOR1, new JToolBar.Separator());
+      addSeparator(SEPERATOR2, new JToolBar.Separator());
+      
 	  initToolBar();
 	}
 
 
 	/**
-	 * Creates the tool buttons, adds them to {@link #toolButtons} and finally
-	 * creates a button group for all tools. So sub-classes which override this
-	 * method should FIRST add their new tool buttons to {@link #toolButtons}
-	 * before calling {@code super.initTools()}.
+	 * Creates the tool buttons and action buttons and seperators, adds them to 
+	 * {@link #toolAndActionButtons} and finally creates a button group for all tools. 
+	 * So sub-classes which override this method should FIRST add their new tool 
+	 * buttons to {@link #toolAndActionButtons} before calling {@code super.initTools()}.
 	 */
-	protected void initTools() {
+	protected void initToolsAndActions() {
       // Panning
       addTool( new MapPaneToolBarAction(
           TOOL_PAN,
           this,
           "",
-          new ImageIcon(MapView.class.getResource("pan.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/pan.png"))
       ), false );
       // Info
       addTool( new MapPaneToolBarAction(
           TOOL_INFO, 
           this, 
           "",
-          new ImageIcon(MapView.class.getResource("info.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/info.png"))
       ), false );
+      
+      // Set Selection
+      addTool( new MapPaneToolBarAction(
+          TOOL_SELECTION_SET, 
+          this, 
+          "",
+          new ImageIcon(MapView.class.getResource("resource/icons/selection_set.png"))
+      ), false );
+
+      // Add Selection
+      addTool( new MapPaneToolBarAction(
+    		  TOOL_SELECTION_ADD, 
+    		  this, 
+    		  "",
+    		  new ImageIcon(MapView.class.getResource("resource/icons/selection_add.png"))
+      ), false );
+
+      // Remove Selection
+      addTool( new MapPaneToolBarAction(
+    		  TOOL_SELECTION_REMOVE, 
+    		  this, 
+    		  "",
+    		  new ImageIcon(MapView.class.getResource("resource/icons/selection_remove.png"))
+      ), false );
+      
+      // ResetSelection
+      addAction( new MapPaneToolBarAction(
+    		  TOOL_SELECTION_CLEAR, 
+    		  this, 
+    		  "",
+    		  new ImageIcon(MapView.class.getResource("resource/icons/selection_clear.png"))
+      ), false );
+      
       // Zoom in
       addTool( new MapPaneToolBarAction(
           TOOL_ZOOMIN,
           this,
           "",
-          new ImageIcon(MapView.class.getResource("zoom_in.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/zoom_in.png"))
       ), false );
       // Zoom out
       addTool( new MapPaneToolBarAction(
           TOOL_ZOOMOUT,
           this,
           "",
-          new ImageIcon(MapView.class.getResource("zoom_out.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/zoom_out.png"))
       ), false );
       
-	  // set the selected tool enabled
-      setSelectedTool(selectedTool);
-      
-	}
-
-    /**
-     * Creates the action buttons and adds them to {@link #actionButtons}.
-     */
-    protected void initActions() {
       // Action button to revert the last zoom
       addAction( new MapPaneToolBarAction(
           ACTION_ZOOM_BACK,
           this,
           "",
-          new ImageIcon(MapView.class.getResource("zoom_back.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/zoom_back.png"))
       ), false);
       setButtonEnabled( ACTION_ZOOM_BACK, false );
 
@@ -222,13 +270,18 @@
           ACTION_ZOOM_FORWARD,
           this,
           "",
-          new ImageIcon(MapView.class.getResource("zoom_forward.png"))
+          new ImageIcon(MapView.class.getResource("resource/icons/zoom_forward.png"))
       ), false);
       setButtonEnabled( ACTION_ZOOM_FORWARD, false );
+      
+      
+	  // set the selected tool enabled
+      setSelectedTool(selectedTool);
+      
+	}
 
-    }
-    
-    /**
+
+	/**
      * Clears the GUI of all components and adds all tool and action buttons to the
      * tool bar.
      */
@@ -240,15 +293,18 @@
       Dimension dimension = new Dimension( 49,10);
       addSeparator(dimension);
       // Tool buttons
-      for (JToggleButton b : toolButtons.values())
+      for (JComponent b : toolAndActionButtons.values())
         add(b);
+    }
       // Space between tool buttons and action buttons
-      Dimension dimension2 = new Dimension( 10,10);
-      this.addSeparator(dimension2);
-      // Action buttons
-      for (JButton b : actionButtons.values())
-        add(b);
-    }
+// SK: Seperators are now als manages like actions and tools      
+//      Dimension dimension2 = new Dimension( 10,10);
+//      this.addSeparator(dimension2);
+      
+//      // Action buttons
+//      for (JButton b : actionButtons.values())
+//        add(b);
+//    }
     
 	/**
 	 * Performs the activation of a tool.
@@ -272,10 +328,19 @@
         case TOOL_INFO: 
           // Set the mouse tool to "Info"
           mapPane.setWindowSelectionState(JMapPane.NONE);
-          mapPane.setState(JMapPane.SELECT_TOP);
-          mapPane.setHighlight(true);
+          mapPane.setState(JMapPane.SELECT_TOP); // Why not: JMapPane.SELECT_TOP_ONEONLY
+          mapPane.setHighlight(false);// SK: Was true, but since it not works properly removed it to save performance
           mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);
           break;
+        case TOOL_SELECTION_SET: 
+        case TOOL_SELECTION_ADD:
+        case TOOL_SELECTION_REMOVE:
+        	// Set the mouse tool to "Select"
+        	mapPane.setWindowSelectionState(JMapPane.SELECT_TOP);
+        	mapPane.setState(JMapPane.SELECT_TOP);
+        	mapPane.setHighlight(false);
+        	mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); // TODO Select Cursor
+        	break;
         case TOOL_ZOOMIN:
           // Set the mouse tool to "Zoom in"
           mapPane.setWindowSelectionState(JMapPane.ZOOM_IN);
@@ -355,7 +420,7 @@
 	  JToggleButton button = new JToggleButton(buttonAction);
 	  button.setBorder( BorderFactory.createRaisedBevelBorder() );
 	  toolButtonGroup.add(button);
-	  toolButtons.put(buttonAction.getID(), button);
+	  toolAndActionButtons.put(buttonAction.getID(), button);
 	  if ( resetToolBar )
 	    initToolBar();
 	}
@@ -382,11 +447,21 @@
         return;
       }
       JButton button = new JButton(buttonAction);
-      actionButtons.put( buttonAction.getID(), button );
+      button.setBorder( BorderFactory.createRaisedBevelBorder() );
+      toolAndActionButtons.put( buttonAction.getID(), button );
       if ( resetToolBar )
         initToolBar();
     }
+    
 
+    private void addSeparator(int id, Separator separator) {
+        if ( isButtonIDUsed(id) ) {
+            LOGGER.warn("addSeparator(.) ignored because ID already used for tool or action. ");
+            return;
+          }
+          toolAndActionButtons.put( id, separator);
+	}
+
     /**
      * Adds an action to the tool bar and resets the toolbar GUI.
      * @param buttonAction action for the toggle button
@@ -397,15 +472,13 @@
     
     /**
      * Returns the button for a specific tool or action.
-     * @param id the constant for a tool
+     * @param id the constant for any button in the {@link MapPaneToolBar}
      * @return a {@link JButton} if {@code id} specifies an {@linkplain #getActionButton(int) action button}
      *         or {@link JToogleButton} if {@code id} specifies a {@linkplain #getToolButton(int) tool button}
      */
     public AbstractButton getButton(int id) {
-      AbstractButton button = toolButtons.get(id);
+      AbstractButton button = (AbstractButton)toolAndActionButtons.get(id);
       if ( button == null )
-        button = actionButtons.get(id);
-      if ( button == null )
         LOGGER.warn("Unknown tool or action ID: "+id);
       return button;
     }
@@ -500,7 +573,7 @@
      * @param tool tool ID
      */
     public boolean isButtonIDUsed(int id) {
-      return toolButtons.get(id) != null || actionButtons.get(id) != null;
+      return toolAndActionButtons.get(id) != null;
     }
 
     /**
@@ -522,7 +595,7 @@
      *                      {@code enabled} is {@code false}
      */
     public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
-      for (int tool : toolButtons.keySet())
+      for (int tool : toolAndActionButtons.keySet())
         setButtonEnabled(tool,enabled,hideOnDisable);
     }	
 
@@ -533,37 +606,41 @@
      *                      {@code enabled} is {@code false}
      */
     public void setAllActionsEnabled(boolean enabled, boolean hideOnDisable) {
-      for (int tool : actionButtons.keySet())
-        setButtonEnabled(tool,enabled,hideOnDisable);
+      for (int id : toolAndActionButtons.keySet()){
+    	  if (toolAndActionButtons.get(id) instanceof JButton){
+    		  setButtonEnabled(id,enabled,hideOnDisable);
+    	  }
+      }
+    	 
     }   
     
     /**
      * Returns the maximum ID of tools. 
      */
     public int getMaxToolID() {
-      return toolButtons.lastKey();
+      return toolAndActionButtons.lastKey();
     }
 
     /**
      * Returns the minimum ID of tools. 
      */
     public int getMinToolID() {
-      return toolButtons.firstKey();
+      return toolAndActionButtons.firstKey();
     }
-
-    /**
-     * Returns the maximum ID of actions. 
-     */
-    public int getMaxActionID() {
-      return actionButtons.lastKey();
-    }
-
-    /**
-     * Returns the minimum ID of actions. 
-     */
-    public int getMinActionID() {
-      return actionButtons.firstKey();
-    }
+//
+//    /**
+//     * Returns the maximum ID of actions. 
+//     */
+//    public int getMaxActionID() {
+//      return actionButtons.lastKey();
+//    }
+//
+//    /**
+//     * Returns the minimum ID of actions. 
+//     */
+//    public int getMinActionID() {
+//      return actionButtons.firstKey();
+//    }
     
     /**
      * Extends the {@link AbstractAction} with maintaining an ID and
@@ -620,9 +697,9 @@
        * or {@link MapPaneToolBar#addAction(MapPaneToolBarAction)}.
        */
       public void actionPerformed(ActionEvent e) {
-        if ( toolBar.toolButtons.get(id) != null )
+        if ( toolBar.toolAndActionButtons.get(id) instanceof JToggleButton)
           toolBar.performToolButton(id, e);
-        if ( toolBar.actionButtons.get(id) != null )
+        else if ( toolBar.toolAndActionButtons.get(id) instanceof JButton )
           toolBar.performActionButton(id, e);
       }
       

Modified: trunk/src/skrueger/geotools/MapView.java
===================================================================
--- trunk/src/skrueger/geotools/MapView.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/MapView.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -15,7 +15,6 @@
 import schmitzm.geotools.gui.MapContextControlPane;
 import schmitzm.geotools.gui.MapPaneStatusBar;
 import schmitzm.geotools.styling.ColorMapManager;
-import schmitzm.swing.SwingUtil;
 
 /**
  * Achtung! Dieser code ist verwuestet

Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -10,11 +10,13 @@
  **/
 package skrueger.geotools;
 
+
 import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
 import org.geotools.data.DefaultQuery;
 import org.geotools.data.FeatureSource;
 import org.geotools.data.Query;
@@ -40,8 +42,9 @@
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
  */
 public class StyledFeatureCollectionTableModel extends FeatureCollectionTableModel {
+  final static private Logger LOGGER = Logger.getLogger(StyledFeatureCollectionTableModel.class);
   /** Holds the data source as styled map. */ 
-  protected StyledMapInterface map = null;
+  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}. */
@@ -122,6 +125,8 @@
         // create a query for the visible attributes
         String[] properties = visibleAttrNames.toArray(new String[0]);
         
+        LOGGER.debug("Query contains the following attributes: " + visibleAttrNames);
+        
         query = new DefaultQuery(fs.getSchema().getTypeName(), filter, properties);
       }
       fc = fs.getFeatures(query);
@@ -190,6 +195,7 @@
     try{
       setFeatureSource(this.featureSource, this.origAMD, filter);
     } catch (Exception err) {
+    	LOGGER.error("Setting the filter of the table model", err);
       throw new RuntimeException(err);
     }
   }

Modified: trunk/src/skrueger/geotools/StyledMapUtil.java
===================================================================
--- trunk/src/skrueger/geotools/StyledMapUtil.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/StyledMapUtil.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -167,7 +167,7 @@
    * @param visible indicated whether the visible or invisible entries are
    *                returned 
    */
-  public static Map<Integer,AttributeMetaData> getVisibleAttributeMetaData(Map<Integer,AttributeMetaData> amdMap, boolean visible) {
+  public static SortedMap<Integer,AttributeMetaData> getVisibleAttributeMetaData(Map<Integer,AttributeMetaData> amdMap, boolean visible) {
     SortedMap<Integer,AttributeMetaData> filteredMap = new TreeMap<Integer,AttributeMetaData>();
     for (AttributeMetaData amd : amdMap.values())
       if ( amd.isVisible() )

Deleted: trunk/src/skrueger/geotools/info.png
===================================================================
(Binary files differ)

Deleted: trunk/src/skrueger/geotools/pan.png
===================================================================
(Binary files differ)

Copied: trunk/src/skrueger/geotools/resource/icons/info.png (from rev 109, trunk/src/skrueger/geotools/info.png)

Copied: trunk/src/skrueger/geotools/resource/icons/pan.png (from rev 109, trunk/src/skrueger/geotools/pan.png)

Added: trunk/src/skrueger/geotools/resource/icons/selection_add.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/selection_add.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/src/skrueger/geotools/resource/icons/selection_clear.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/selection_clear.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/src/skrueger/geotools/resource/icons/selection_remove.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/selection_remove.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/src/skrueger/geotools/resource/icons/selection_set.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/selection_set.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/src/skrueger/geotools/resource/icons/zoom_back (Kopie).png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/zoom_back (Kopie).png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Copied: trunk/src/skrueger/geotools/resource/icons/zoom_back.png (from rev 109, trunk/src/skrueger/geotools/zoom_back.png)
===================================================================
(Binary files differ)

Added: trunk/src/skrueger/geotools/resource/icons/zoom_forward (Kopie).png
===================================================================
(Binary files differ)


Property changes on: trunk/src/skrueger/geotools/resource/icons/zoom_forward (Kopie).png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Copied: trunk/src/skrueger/geotools/resource/icons/zoom_forward.png (from rev 109, trunk/src/skrueger/geotools/zoom_forward.png)
===================================================================
(Binary files differ)

Copied: trunk/src/skrueger/geotools/resource/icons/zoom_in.png (from rev 109, trunk/src/skrueger/geotools/zoom_in.png)

Copied: trunk/src/skrueger/geotools/resource/icons/zoom_out.png (from rev 109, trunk/src/skrueger/geotools/zoom_out.png)

Modified: trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
===================================================================
--- trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -20,35 +20,23 @@
 
 import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import javax.swing.text.Utilities;
 
 import org.geotools.feature.Feature;
+import org.geotools.feature.FeatureCollection;
 import org.geotools.map.MapLayer;
-import org.geotools.styling.PolygonSymbolizer;
-import org.geotools.styling.Rule;
-import org.geotools.styling.RuleImpl;
 import org.geotools.styling.Style;
-import org.geotools.styling.StyleImpl;
-import org.geotools.styling.Symbolizer;
 import org.opengis.filter.Filter;
 import org.opengis.filter.FilterVisitor;
-import org.opengis.layer.StyleURL;
 
-import schmitzm.geotools.FilterUtil;
-import schmitzm.geotools.gui.FeatureCollectionTableModel;
 import schmitzm.geotools.gui.JMapPane;
 import schmitzm.geotools.map.event.FeatureSelectedEvent;
 import schmitzm.geotools.map.event.JMapPaneEvent;
 import schmitzm.geotools.map.event.JMapPaneListener;
 import schmitzm.geotools.styling.StylingUtil;
 import schmitzm.lang.LangUtil;
-import skrueger.geotools.StyledFeatureCollectionInterface;
+import skrueger.geotools.MapPaneToolBar;
 import skrueger.geotools.StyledMapInterface;
-import skrueger.geotools.selection.StyledFeatureLayerSelectionModel;
-import skrueger.geotools.selection.StyledLayerSelectionEvent;
-import skrueger.geotools.selection.StyledLayerSelectionModel;
 
 /**
  * This class keeps the selection of a (feature) {@link JTable} synchronized
@@ -71,6 +59,7 @@
 public class FeatureMapLayerSelectionSynchronizer extends
 		StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel>
 		implements JMapPaneListener {
+	public static final String SELECTION_STYLING = "SELECTION";
 	/**
 	 * Holds the {@link MapLayer} to keep synchronized with the layer selection
 	 * model.
@@ -78,6 +67,7 @@
 	protected final MapLayer mapLayer;
 	protected final StyledMapInterface<?> styledMapLayer;
 	protected final JMapPane mapPane;
+	private final MapPaneToolBar toolBar;
 
 	/**
 	 * Creates a new synchronizer
@@ -92,13 +82,14 @@
 	public FeatureMapLayerSelectionSynchronizer(
 			StyledFeatureLayerSelectionModel layerSelModel,
 			StyledMapInterface<?> styledMapLayer, MapLayer mapLayer,
-			JMapPane mapPane) {
+			JMapPane mapPane, MapPaneToolBar toolBar) {
 
 		super(layerSelModel);
 		this.styledMapLayer = styledMapLayer;
 
 		this.mapLayer = mapLayer;
 		this.mapPane = mapPane;
+		this.toolBar = toolBar;
 	}
 
 	/**
@@ -122,7 +113,7 @@
 			return;
 		// Apply new selection on table (except this event is one of
 		// some more events)
-		Vector<Feature> newSelection = layerSelModel.getSelection();
+		Vector<String> newSelection = layerSelModel.getSelection();
 		if (newSelection == null)
 			return;
 
@@ -135,13 +126,13 @@
 		selectionChangeCausedByMe = false;
 	}
 
-	private void changeLayerStyle(final Vector<Feature> newSelection) {
+	private void changeLayerStyle(final Vector<String> newSelection) {
 		Style selectionMapStyle = null;
 		try {
 			if (newSelection.isEmpty()) {
 
 				selectionMapStyle = styledMapLayer.getStyle();
-				LOGGER.debug("NO SELECTION .. reset original style");
+				LOGGER.debug("NO SELECTION .. set to original style directly");
 
 			} else {
 				LOGGER.debug("SELECTION .. change style");
@@ -151,13 +142,15 @@
 				// TODO This clone is a deep clone and it is slow..
 				selectionMapStyle = StylingUtil
 						.createDefaultStyle(styledMapLayer.getGeoObject());
-				
-//				Symbolizer sss = selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
-//				if (sss instanceof PolygonSymbolizer) {
-//					PolygonSymbolizer ps = (PolygonSymbolizer) sss;
-//					ps.getFill().setOpacity( FilterUtil.FILTER_FAC.literal(0.5));
-//				}
+				selectionMapStyle.getFeatureTypeStyles()[0].setName(SELECTION_STYLING);
 
+				// Symbolizer sss =
+				// selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
+				// if (sss instanceof PolygonSymbolizer) {
+				// PolygonSymbolizer ps = (PolygonSymbolizer) sss;
+				// ps.getFill().setOpacity( FilterUtil.FILTER_FAC.literal(0.5));
+				// }
+
 				// Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();
 				selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0]
 						.setFilter(new Filter() {
@@ -172,9 +165,9 @@
 							public boolean evaluate(Object obj) {
 								if (obj instanceof Feature) {
 									Feature f = (Feature) obj;
-									// TODO BAD CODE
-									for (Feature ff : newSelection) {
-										if (ff.getID().equals(f.getID()))
+									// TODO BAD CODE?
+									for (String ffID : newSelection) {
+										if (ffID.equals(f.getID()))
 											return true;
 									}
 									return false;
@@ -186,8 +179,8 @@
 						});
 
 				selectionMapStyle.setFeatureTypeStyles(LangUtil.extendArray(
-						originalStyle
-								.getFeatureTypeStyles(), selectionMapStyle.getFeatureTypeStyles()));
+						originalStyle.getFeatureTypeStyles(), selectionMapStyle
+								.getFeatureTypeStyles()));
 
 				// selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)
 
@@ -205,61 +198,77 @@
 		}
 	}
 
-	//
-	// /**
-	// * Called when the table selection is changed by the user. When calling
-	// this
-	// * method changes the selection of the {@link StyledLayerSelectionModel}.
-	// *
-	// * @param evt
-	// * an event
-	// */
-	// @Override
-	// public void valueChanged(ListSelectionEvent evt) {
-	//		
-	// }
-
 	@Override
 	public void performMapPaneEvent(JMapPaneEvent e) {
 
+		/**
+		 * Only listen to FeatureSelectionEvents if the appropriate tool is
+		 * selected.
+		 */
+		final int selectedTool = toolBar.getSelectedTool();
+		if (selectedTool != MapPaneToolBar.TOOL_SELECTION_ADD
+				&& selectedTool != MapPaneToolBar.TOOL_SELECTION_REMOVE
+				&& selectedTool != MapPaneToolBar.TOOL_SELECTION_CLEAR
+				&& selectedTool != MapPaneToolBar.TOOL_SELECTION_SET) {
+			return;
+		}
+
 		if (!(e instanceof FeatureSelectedEvent)) {
-//			LOGGER.debug("Ignoring event " + e);
+			// LOGGER.debug("Ignoring event " + e);
 			return;
 		}
 		// only listen to events directly coming from JMapPane
 		// selection (ignore selections from FilterDialog)
-		if ( e.getSourceObject() != this.mapPane )
-		  return;
-		
+		if (e.getSourceObject() != this.mapPane)
+			return;
+
 		FeatureSelectedEvent fse = (FeatureSelectedEvent) e;
-//		LOGGER.debug("Do event " + fse);
-//		LOGGER.debug("Do event " + fse.getSelectionResult());
 
 		// ignore event if it is caused by the DpLayerVectorSelectionModel
 		if (selectionChangeCausedByMe)
 			return;
 
+		LOGGER.debug("Do event " + fse);
+
 		// Avoid event circles in propertyChange(..)
 		selectionChangeCausedByMe = true;
 
-		// reset the selection of the DpLayerSelectionModel
-		// layerSelModel.setValueIsAdjusting(true);
+		if (selectedTool == MapPaneToolBar.TOOL_SELECTION_CLEAR) {
+			layerSelModel.clearSelection();
+		} else {
+			Collection<Feature> selectionResult = (Collection<Feature>) fse
+					.getSelectionResult();
 
-		layerSelModel.addSelection((Collection<Feature>) fse
-				.getSelectionResult());
+			// reset the selection of the DpLayerSelectionModel
+			// layerSelModel.setValueIsAdjusting(true);
 
-		// for (int i = evt.getFirstIndex(); i <= evt.getLastIndex(); i++) {
-		// Feature changedFeature = featureTableModel.getFeature(featureTable
-		// .convertRowIndexToModel(i));
-		// if (featureTable.isRowSelected(i))
-		// layerSelModel.addSelection(changedFeature);
-		// else
-		// layerSelModel.removeSelection(changedFeature);
-		// }
-		// layerSelModel.setValueIsAdjusting(false);
+			if (selectedTool == MapPaneToolBar.TOOL_SELECTION_ADD) {
+				layerSelModel.setValueIsAdjusting(true);
+				for (Feature f : selectionResult) {
+					layerSelModel.addSelection(f.getID());
+				}
+				layerSelModel.setValueIsAdjusting(false);
+			} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_SET) {
+				layerSelModel.setValueIsAdjusting(true);
+				layerSelModel.clearSelection();
 
-		// Show selected feature in the map, which is not automatically done by
-		// the FeatureSelectedEvent
+				for (Feature f : selectionResult) {
+					layerSelModel.addSelection(f.getID());
+				}
+
+				LOGGER.debug("Setting selection to " + selectionResult.size());
+				layerSelModel.setValueIsAdjusting(false);
+			} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_REMOVE) {
+				layerSelModel.setValueIsAdjusting(true);
+				for (Feature f : selectionResult) {
+					layerSelModel.removeSelection(f.getID());
+				}
+				layerSelModel.setValueIsAdjusting(false);
+			}
+		} // els it's not a Clear Selection command
+
+		// Show selected features in the map, which is not automatically done by
+		// the origin: FeatureSelectedEvent
 		changeLayerStyle(layerSelModel.getSelection());
 
 		// Danger of event circles in propertyChange(..) banned

Modified: trunk/src/skrueger/geotools/selection/StyledFeatureLayerSelectionModel.java
===================================================================
--- trunk/src/skrueger/geotools/selection/StyledFeatureLayerSelectionModel.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/selection/StyledFeatureLayerSelectionModel.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -37,7 +37,7 @@
  * {@link StyledFeatureSourceInterface}).
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
  */
-public class StyledFeatureLayerSelectionModel extends StyledLayerSelectionModel<Feature> {
+public class StyledFeatureLayerSelectionModel extends StyledLayerSelectionModel<String> {
   /**
    * Creates a new selection model.
    * @param styledMap styled map the selection is controlled of

Modified: trunk/src/skrueger/geotools/selection/StyledLayerSelectionModel.java
===================================================================
--- trunk/src/skrueger/geotools/selection/StyledLayerSelectionModel.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/selection/StyledLayerSelectionModel.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -142,6 +142,7 @@
    * @return {@code true} if selection has changed by calling this method
    */
   public boolean addSelection(E selectedObject) {
+	 
     if ( selectionObjects.add(selectedObject) ) {
       refreshSelection();
       return true;

Modified: trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java
===================================================================
--- trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java	2009-05-12 14:23:23 UTC (rev 110)
+++ trunk/src/skrueger/geotools/selection/TableSelectionSynchronizer.java	2009-05-12 23:33:14 UTC (rev 111)
@@ -50,7 +50,9 @@
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
  *         (University of Bonn/Germany)
  */
-public class TableSelectionSynchronizer extends StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> implements ListSelectionListener {
+public class TableSelectionSynchronizer extends
+		StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel>
+		implements ListSelectionListener {
 	/**
 	 * Holds the table to keep synchronized with the layer selection model.
 	 */
@@ -67,7 +69,8 @@
 	 * @param table
 	 *            table to keep synchronized with the layer selection model
 	 */
-	public TableSelectionSynchronizer(StyledFeatureLayerSelectionModel layerSelModel, JTable table) {
+	public TableSelectionSynchronizer(
+			StyledFeatureLayerSelectionModel layerSelModel, JTable table) {
 		super(layerSelModel);
 
 		TableModel model = table.getModel();
@@ -102,24 +105,27 @@
 			return;
 		// Apply new selection on table (except this event is one of
 		// some more events)
-		Vector<Feature> newSelection = layerSelModel.getSelection();
+		Vector<String> newSelection = layerSelModel.getSelection();
 		if (newSelection == null)
 			return;
-		
-//		LOGGER.debug("Table pop changed "+selEvt);
-//		LOGGER.debug("Table pop changed to "+newSelection);
 
+		// LOGGER.debug("Table pop changed "+selEvt);
+		// LOGGER.debug("Table pop changed to "+newSelection);
+
 		// Avoid event circles in valueChanged(..)
 		selectionChangeCausedByMe = true;
 
 		ListSelectionModel tableSelModel = featureTable.getSelectionModel();
 		tableSelModel.setValueIsAdjusting(true);
 		tableSelModel.clearSelection();
-		for (Feature f : newSelection) {
-			int modelIdx = featureTableModel.findFeature(f);
+		for (String fid : newSelection) {
+			int modelIdx = featureTableModel.findFeature(fid);
 			if (modelIdx >= 0) {
 				int tableIdx = featureTable.convertRowIndexToView(modelIdx);
 				tableSelModel.addSelectionInterval(tableIdx, tableIdx);
+			} else {
+				LOGGER
+						.warn("Something that is not visible in the Table should be selected");
 			}
 		}
 		tableSelModel.setValueIsAdjusting(false); // event is fired
@@ -150,13 +156,23 @@
 
 		// reset the selection of the DpLayerSelectionModel
 		layerSelModel.setValueIsAdjusting(true);
-		for (int i = evt.getFirstIndex(); i <= evt.getLastIndex(); i++) {
-			Feature changedFeature = featureTableModel.getFeature(featureTable
-					.convertRowIndexToModel(i));
-			if (featureTable.isRowSelected(i))
-				layerSelModel.addSelection(changedFeature);
-			else
-				layerSelModel.removeSelection(changedFeature);
+		LOGGER.debug("valueCahnged in TableSyncronizer vom Index "
+				+ evt.getFirstIndex() + " to " + evt.getLastIndex());
+
+		if (evt == null || (evt != null && evt.getFirstIndex() == -1)){
+			// If the value is changing because the filter has been changed (e.g.
+			// table structure change) the evt.getFirstIndex() is -1, but evt.getLastIndex is > -1
+			layerSelModel.clearSelection();
+		} else{
+			
+			for (int i = evt.getFirstIndex(); i <= evt.getLastIndex(); i++) {
+				int featureIndex = featureTable.convertRowIndexToModel(i);
+				Feature changedFeature = featureTableModel.getFeature(featureIndex);
+				if (featureTable.isRowSelected(i))
+					layerSelModel.addSelection(changedFeature.getID());
+				else
+					layerSelModel.removeSelection(changedFeature.getID());
+			}
 		}
 		layerSelModel.setValueIsAdjusting(false);
 

Deleted: trunk/src/skrueger/geotools/zoom_back.png
===================================================================
(Binary files differ)

Deleted: trunk/src/skrueger/geotools/zoom_forward.png
===================================================================
(Binary files differ)

Deleted: trunk/src/skrueger/geotools/zoom_in.png
===================================================================
(Binary files differ)

Deleted: trunk/src/skrueger/geotools/zoom_out.png
===================================================================
(Binary files differ)



More information about the Schmitzm-commits mailing list