/[schmitzm]/trunk/src/skrueger/geotools/MapPaneToolBar.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/MapPaneToolBar.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 139 by alfonx, Thu Jun 11 12:52:58 2009 UTC revision 177 by alfonx, Wed Jul 1 15:02:39 2009 UTC
# Line 3  package skrueger.geotools; Line 3  package skrueger.geotools;
3  import java.awt.Dimension;  import java.awt.Dimension;
4  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
5  import java.util.ArrayList;  import java.util.ArrayList;
6    import java.util.Locale;
7  import java.util.SortedMap;  import java.util.SortedMap;
8  import java.util.TreeMap;  import java.util.TreeMap;
9    
10  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
11  import javax.swing.AbstractButton;  import javax.swing.AbstractButton;
12    import javax.swing.Action;
13  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
14  import javax.swing.Icon;  import javax.swing.Icon;
15  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
# Line 22  import schmitzm.geotools.gui.JMapPane; Line 24  import schmitzm.geotools.gui.JMapPane;
24  import schmitzm.geotools.map.event.JMapPaneEvent;  import schmitzm.geotools.map.event.JMapPaneEvent;
25  import schmitzm.geotools.map.event.JMapPaneListener;  import schmitzm.geotools.map.event.JMapPaneListener;
26  import schmitzm.geotools.map.event.MapAreaChangedEvent;  import schmitzm.geotools.map.event.MapAreaChangedEvent;
27    import schmitzm.lang.LangUtil;
28    import schmitzm.lang.ResourceProvider;
29  import schmitzm.swing.ButtonGroup;  import schmitzm.swing.ButtonGroup;
30  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
31    
32  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
33    
34  /**  /**
35   * A toolbar to control an {@link JMapPane} (Atlas visualization). This contains two types   * A toolbar to control an {@link JMapPane} (Atlas visualization). This contains
36   * of buttons. A group of <i>tools</i> for the mouse actions on the map represented   * two types of buttons. A group of <i>tools</i> for the mouse actions on the
37   * by {@link JToggleButton JToggleButtons}, where only one tool can be activated   * map represented by {@link JToggleButton JToggleButtons}, where only one tool
38   * every time. And some (general) <i>actions</i>, represented by normal   * can be activated every time. And some (general) <i>actions</i>, represented
39   * {@link JButton JButtons}.   * by normal {@link JButton JButtons}.
40   * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)   *
41     * @author <a href="mailto:[email protected]">Martin Schmitz</a>
42     *         (University of Bonn/Germany)
43   * @version 1.2 Stefan Krüger   * @version 1.2 Stefan Krüger
44   */   */
45  public class MapPaneToolBar extends JToolBar {  public class MapPaneToolBar extends JToolBar {
46          private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class.getName());          private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class
47                            .getName());
48            
49            public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
50                            .extendPackagePath(MapPaneToolBar.class,
51                                            "resource.locales.mapPaneToolbar"), Locale.ENGLISH);
52            
53            public static String R(String key, Object... values) {
54                    return RESOURCE.getString(key, values);
55            }
56    
57          /** Constant for the tool "Panning" (10). */          /** Constant for the tool "Panning" (10). */
58          public static final int TOOL_PAN = 10;          public static final int TOOL_PAN = 10;
59          /** Constant for the tool "Info" (20). */          /** Constant for the tool "Info" (20). */
60          public static final int TOOL_INFO = 20;          public static final int TOOL_INFO = 20;
61          public static final int SEPERATOR0 = 99;          public static final int SEPERATOR0 = 99;
62            
63          /** Constant for the tool "Zoom In" (110). */          /** Constant for the tool "Zoom In" (110). */
64          public static final int TOOL_ZOOMIN = 110;          public static final int TOOL_ZOOMIN = 110;
65          /** Constant for the tool "Zoom Out" (120). */          /** Constant for the tool "Zoom Out" (120). */
# Line 53  public class MapPaneToolBar extends JToo Line 69  public class MapPaneToolBar extends JToo
69          /** Constant for the action "Zoom forward" (140). */          /** Constant for the action "Zoom forward" (140). */
70          public static final int ACTION_ZOOM_FORWARD = 140;          public static final int ACTION_ZOOM_FORWARD = 140;
71          public static final int SEPERATOR1 = 199;          public static final int SEPERATOR1 = 199;
72            
73          /** Constant for the tool "Select" which sets the Selection to the selected features (210). */          /**
74             * Constant for the tool "Selection Reset" which clears the selection (240).
75             */
76            public static final int TOOL_SELECTION_CLEAR = 240;
77    
78            /**
79             * Constant for the tool "Select" which sets the Selection to the selected
80             * features (210).
81             */
82          public static final int TOOL_SELECTION_SET = 210;          public static final int TOOL_SELECTION_SET = 210;
83          /** Constant for the tool "Selection add" which adds the features to the Selection (220). */          /**
84             * Constant for the tool "Selection add" which adds the features to the
85             * Selection (220).
86             */
87          public static final int TOOL_SELECTION_ADD = 220;          public static final int TOOL_SELECTION_ADD = 220;
88          /** Constant for the tool "Selection subtract" which removes the selected features from the selection (230). */          /**
89             * Constant for the tool "Selection subtract" which removes the selected
90             * features from the selection (230).
91             */
92          public static final int TOOL_SELECTION_REMOVE = 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;  
93    
94          /** Tool currently selected */          /** Tool currently selected */
95      protected int selectedTool = TOOL_ZOOMIN;          protected int selectedTool = TOOL_ZOOMIN;
96        
97      /** Holds the tool buttons of the tool bar. */          /** Holds the tool buttons of the tool bar. */
98      protected SortedMap<Integer, JComponent> toolAndActionButtons = null;          protected SortedMap<Integer, JComponent> toolAndActionButtons = null;
99      /** Controls that only one tool button is activated. */          /** Controls that only one tool button is activated. */
100      protected ButtonGroup toolButtonGroup = null;          protected ButtonGroup toolButtonGroup = null;
101    
102  // SK: Musste ich ändern damit man Tools und Actions in der Reihenfolge mischen kann.              // SK: Musste ich ändern damit man Tools und Actions in der Reihenfolge
103  //    /** Holds the action buttons of the bar. */          // mischen kann.
104  //    protected SortedMap<Integer, JButton> actionButtons = null;          // /** Holds the action buttons of the bar. */
105            // protected SortedMap<Integer, JButton> actionButtons = null;
106    
107          /** Holds the {@link JMapPane} this tool bar controls. */          /** Holds the {@link JMapPane} this tool bar controls. */
108          protected JMapPane mapPane = null;          protected JMapPane mapPane = null;
# Line 92  public class MapPaneToolBar extends JToo Line 117  public class MapPaneToolBar extends JToo
117    
118          /** Listener to sniff the zoom actions on the map. */          /** Listener to sniff the zoom actions on the map. */
119          protected JMapPaneListener mapPaneListener = null;          protected JMapPaneListener mapPaneListener = null;
120            
121          protected boolean zoomBackForwardButtonInAction;          protected boolean zoomBackForwardButtonInAction;
122    
123      /**          /**
124       * Creates a new toolbar. Notice: This toolbar does nothing           * Creates a new toolbar. Notice: This toolbar does nothing until
125       * until {@link #setMapPane(JMapPane)} is called!           * {@link #setMapPane(JMapPane)} is called!
126       */           */
127      public MapPaneToolBar() {          public MapPaneToolBar() {
128        this(null);                  this(null);
129      }          }
130        
131      /**          /**
132           * Creates a new tool bar.           * Creates a new tool bar.
133           * @param mapPane {@link JMapPane} the tool bar controls           *
134             * @param mapPane
135             *            {@link JMapPane} the tool bar controls
136           */           */
137          public MapPaneToolBar(JMapPane mapPane) {          public MapPaneToolBar(JMapPane mapPane) {
138            super("Control the map", JToolBar.HORIZONTAL);                  super("Control the map", JToolBar.HORIZONTAL);
139        this.toolAndActionButtons  = new TreeMap<Integer,JComponent>();                  this.toolAndActionButtons = new TreeMap<Integer, JComponent>();
140        this.toolButtonGroup = new ButtonGroup();                  this.toolButtonGroup = new ButtonGroup();
141        // Create a Listener to sniff the zooms on the JMapPane                  
142        this.mapPaneListener = new JMapPaneListener() {                  // Create a Listener to listen to the zooms on the JMapPane
143            public void performMapPaneEvent(JMapPaneEvent e) {                  this.mapPaneListener = new JMapPaneListener() {
144                if ( !(e instanceof MapAreaChangedEvent) )                          public void performMapPaneEvent(JMapPaneEvent e) {
145                  return;                                  if (!(e instanceof MapAreaChangedEvent))
146                                                            return;
147                if ( zoomBackForwardButtonInAction ) {  
148                  zoomBackForwardButtonInAction = false;                                  if (zoomBackForwardButtonInAction) {
149                  return;                                          zoomBackForwardButtonInAction = false;
150                }                                          return;
151                                                }
152                Envelope oldMapArea = ((MapAreaChangedEvent)e).getOldMapArea();  
153                if (lastZooms.size() == 0 && oldMapArea != null ) {                                  final MapAreaChangedEvent mapAreaChangedEvent = (MapAreaChangedEvent) e;
154                  lastZooms.add(oldMapArea);                                  Envelope oldMapArea = mapAreaChangedEvent.getOldMapArea();
155                  zoomBackIndex = 1;                                  
156                }                                  final Envelope mapArea = mapAreaChangedEvent.getNewMapArea();
157                                    if (mapArea == null || mapArea.equals(oldMapArea) ) {
158                final Envelope mapArea = ((MapAreaChangedEvent)e).getNewMapArea();                                          // If the MapArea didn't change... we don't want to register it as a zoom action.
159                if (mapArea == null)                                          return;
160                  return;                                  }
161                                                  
162                if (lastZooms.size() > 0 && mapArea.equals(lastZooms.get(lastZooms.size() - 1))) {                                  if (lastZooms.size() == 0 && oldMapArea != null) {
163                  // LOGGER.debug("MapAreaChangedEvent ausgelassen bei der Zaehlung der Zoomschritt weil identisch");                                          lastZooms.add(oldMapArea);
164                  return;                                          zoomBackIndex = 1;
165                }                                  }
166                                    if (mapArea == null)
167                if (lastZooms.size() > 0)                                          return;
168                  while (zoomBackIndex < lastZooms.size())  
169                    lastZooms.remove(lastZooms.size() - 1);                                  if (lastZooms.size() > 0
170                                                    && mapArea.equals(lastZooms.get(lastZooms.size() - 1))) {
171                lastZooms.add(mapArea);                                          // LOGGER.debug("MapAreaChangedEvent ausgelassen bei der Zaehlung der Zoomschritt weil identisch");
172                zoomBackIndex = lastZooms.size();                                          return;
173                setButtonEnabled(ACTION_ZOOM_BACK, lastZooms.size() > 1);                                  }
174                setButtonEnabled(ACTION_ZOOM_FORWARD, false);  
175            }                                  if (lastZooms.size() > 0)
176        };                                              while (zoomBackIndex < lastZooms.size())
177                                                        lastZooms.remove(lastZooms.size() - 1);
178        setMapPane(mapPane);  
179            setFloatable(false);                                  lastZooms.add(mapArea);
180            setRollover(true);                                  zoomBackIndex = lastZooms.size();
181                                              setButtonEnabled(ACTION_ZOOM_BACK, lastZooms.size() > 1);
182            init();                                  setButtonEnabled(ACTION_ZOOM_FORWARD, false);
183                            }
184                    };
185    
186                    setMapPane(mapPane);
187                    setFloatable(false);
188                    setRollover(true);
189    
190                    init();
191          }          }
192            
193          /**          /**
194           * Sets the {@link JMapPane} controlled by this tool bar.           * Sets the {@link JMapPane} controlled by this tool bar.
195           * @param mapPane {@link JMapPane} to control (if {@code null} this           *
196           *                tool bar controls NOTHING!)           * @param mapPane
197             *            {@link JMapPane} to control (if {@code null} this tool bar
198             *            controls NOTHING!)
199           */           */
200          public void setMapPane(JMapPane mapPane) {          public void setMapPane(JMapPane mapPane) {
201            // Remove listener from old MapPane                  // Remove listener from old MapPane
202            if ( this.mapPane != null )                  if (this.mapPane != null)
203              this.mapPane.removeMapPaneListener( mapPaneListener );                          this.mapPane.removeMapPaneListener(mapPaneListener);
204        this.mapPane = mapPane;                  this.mapPane = mapPane;
205        if ( this.mapPane != null && mapPaneListener != null )                  if (this.mapPane != null && mapPaneListener != null)
206          this.mapPane.addMapPaneListener( mapPaneListener );                          this.mapPane.addMapPaneListener(mapPaneListener);
207          }          }
208            
209          /**          /**
210           * Calls {@link #initToolsAndActions()} and {@link #initActions()} and then puts           * Calls {@link #initToolsAndActions()} and {@link #initActions()} and then
211           * all tool buttons and all actions buttons to the tool bar.           * puts all tool buttons and all actions buttons to the tool bar.
212           */           */
213          protected void init() {          protected void init() {
214            initToolsAndActions();                  initToolsAndActions();
215          
216            addSeparator(SEPERATOR0, new JToolBar.Separator());                  addSeparator(SEPERATOR0, new JToolBar.Separator());
217        addSeparator(SEPERATOR1, new JToolBar.Separator());                  addSeparator(SEPERATOR1, new JToolBar.Separator());
       addSeparator(SEPERATOR2, new JToolBar.Separator());  
         
           initToolBar();  
         }  
218    
219                    initToolBar();
220            }
221    
222          /**          /**
223           * Creates the tool buttons and action buttons and seperators, adds them to           * Creates the tool buttons and action buttons and seperators, adds them to
224           * {@link #toolAndActionButtons} and finally creates a button group for all tools.           * {@link #toolAndActionButtons} and finally creates a button group for all
225           * So sub-classes which override this method should FIRST add their new tool           * tools. So sub-classes which override this method should FIRST add their
226           * buttons to {@link #toolAndActionButtons} before calling {@code super.initTools()}.           * new tool buttons to {@link #toolAndActionButtons} before calling {@code
227             * super.initTools()}.
228           */           */
229          protected void initToolsAndActions() {          protected void initToolsAndActions() {
230        // Panning                  // Panning
231        addTool( new MapPaneToolBarAction(                  addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon(
232            TOOL_PAN,                                  MapView.class.getResource("resource/icons/pan.png")), R("MapPaneButtons.Pan.TT")), false);
233            this,                  // Info
234            "",                  addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon(
235            new ImageIcon(MapView.class.getResource("resource/icons/pan.png"))                                  MapView.class.getResource("resource/icons/info.png")),R("MapPaneButtons.Info.TT")), false);
236        ), false );  
237        // Info                  // Zoom in
238        addTool( new MapPaneToolBarAction(                  addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon(
239            TOOL_INFO,                                  MapView.class.getResource("resource/icons/zoom_in.png")), R("MapPaneButtons.ZoomIn.TT")),
240            this,                                  false);
241            "",                  // Zoom out
242            new ImageIcon(MapView.class.getResource("resource/icons/info.png"))                  addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon(
243        ), false );                                  MapView.class.getResource("resource/icons/zoom_out.png")), R("MapPaneButtons.ZoomOut.TT")),
244                                          false);
245        // Set Selection  
246        addTool( new MapPaneToolBarAction(                  // Action button to revert the last zoom
247            TOOL_SELECTION_SET,                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "",
248            this,                                  new ImageIcon(MapView.class
249            "",                                                  .getResource("resource/icons/zoom_back.png")), R("MapPaneButtons.LastZoom.TT")), false);
250            new ImageIcon(MapView.class.getResource("resource/icons/selection_set.png"))                  setButtonEnabled(ACTION_ZOOM_BACK, false);
251        ), false );  
252                    // Action button to redo the last zoom
253        // Add Selection                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_FORWARD, this, "",
254        addTool( new MapPaneToolBarAction(                                  new ImageIcon(MapView.class
255                    TOOL_SELECTION_ADD,                                                  .getResource("resource/icons/zoom_forward.png")), R("MapPaneButtons.NextZoom.TT")),
256                    this,                                  false);
257                    "",                  setButtonEnabled(ACTION_ZOOM_FORWARD, false);
258                    new ImageIcon(MapView.class.getResource("resource/icons/selection_add.png"))  
259        ), false );                  // set the selected tool enabled
260                    setSelectedTool(selectedTool);
261        // Remove Selection  
262        addTool( new MapPaneToolBarAction(          }
263                    TOOL_SELECTION_REMOVE,  
264                    this,          /**
265                    "",           * Clears the GUI of all components and adds all tool and action buttons to
266                    new ImageIcon(MapView.class.getResource("resource/icons/selection_remove.png"))           * the tool bar.
267        ), false );           */
268                  public void initToolBar() {
269        // ResetSelection                  setAlignmentY(1f);
270        addAction( new MapPaneToolBarAction(                  removeAll();
271                    TOOL_SELECTION_CLEAR,                  // Separator to the left of the tool actions to start
272                    this,                  // the tool buttons with the map (not with the coordinate grid)
273                    "",                  Dimension dimension = new Dimension(49, 10);
274                    new ImageIcon(MapView.class.getResource("resource/icons/selection_clear.png"))                  addSeparator(dimension);
275        ), false );                  // Tool buttons
276                          for (JComponent b : toolAndActionButtons.values())
277        // Zoom in                          add(b);
278        addTool( new MapPaneToolBarAction(  
279            TOOL_ZOOMIN,                  if (!toolAndActionButtons.containsKey(selectedTool)) {
280            this,                          /**
281            "",                           * This might be a bit specific, but IF selection buttons are
282            new ImageIcon(MapView.class.getResource("resource/icons/zoom_in.png"))                           * available, select one of them.. if not, select the INFO tool.
283        ), false );                           */
284        // Zoom out  
285        addTool( new MapPaneToolBarAction(                          if (toolAndActionButtons.containsKey(TOOL_SELECTION_SET)) {
286            TOOL_ZOOMOUT,                                  setSelectedTool(TOOL_SELECTION_SET);
287            this,                          } else if (toolAndActionButtons.containsKey(TOOL_INFO)) {
288            "",                                  setSelectedTool(TOOL_INFO);
289            new ImageIcon(MapView.class.getResource("resource/icons/zoom_out.png"))                          } else {
290        ), false );                                  // TODO What to do now?!
291                                          setSelectedTool(null);
292        // Action button to revert the last zoom                          }
293        addAction( new MapPaneToolBarAction(  
294            ACTION_ZOOM_BACK,                  }
295            this,                  
296            "",                  revalidate();
297            new ImageIcon(MapView.class.getResource("resource/icons/zoom_back.png"))                  repaint();
298        ), false);          }
299        setButtonEnabled( ACTION_ZOOM_BACK, false );  
300            // Space between tool buttons and action buttons
301        // Action button to redo the last zoom          // SK: Seperators are now als manages like actions and tools
302        addAction( new MapPaneToolBarAction(          // Dimension dimension2 = new Dimension( 10,10);
303            ACTION_ZOOM_FORWARD,          // this.addSeparator(dimension2);
304            this,  
305            "",          // // Action buttons
306            new ImageIcon(MapView.class.getResource("resource/icons/zoom_forward.png"))          // for (JButton b : actionButtons.values())
307        ), false);          // add(b);
308        setButtonEnabled( ACTION_ZOOM_FORWARD, false );          // }
309          
         
           // set the selected tool enabled  
       setSelectedTool(selectedTool);  
         
         }  
   
   
         /**  
      * Clears the GUI of all components and adds all tool and action buttons to the  
      * tool bar.  
      */  
     protected void initToolBar() {  
       setAlignmentY( 1f );  
       removeAll();  
       // Separator to the left of the tool actions to start  
       // the tool buttons with the map (not with the coordinate grid)  
       Dimension dimension = new Dimension( 49,10);  
       addSeparator(dimension);  
       // Tool buttons  
       for (JComponent b : toolAndActionButtons.values())  
         add(b);  
     }  
       // Space between tool buttons and action buttons  
 // 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);  
 //    }  
       
310          /**          /**
311           * Performs the activation of a tool.           * Performs the activation of a tool.
312           * @param tool the tool to activate           *
313           * @param e    the event of the button           * @param tool
314             *            the tool to activate
315             * @param e
316             *            the event of the button
317           */           */
318          public void performToolButton(int tool, ActionEvent e) {          public void performToolButton(int tool, ActionEvent e) {
319            if ( mapPane == null )                  if (mapPane == null)
320              return;                          return;
321              
322            selectedTool = tool;                  selectedTool = tool;
323              
324        switch( tool ) {                  switch (tool) {
325          case TOOL_PAN:                  case TOOL_PAN:
326            // Set the mouse tool to "Panning"                          // Set the mouse tool to "Panning"
327            mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setWindowSelectionState(JMapPane.NONE);
328            mapPane.setState(JMapPane.PAN);                          mapPane.setState(JMapPane.PAN);
329            mapPane.setHighlight(false);                          mapPane.setHighlight(false);
330            mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);                          mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);
331            break;                          break;
332          case TOOL_INFO:                  case TOOL_INFO:
333            // Set the mouse tool to "Info"                          // Set the mouse tool to "Info"
334            mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setWindowSelectionState(JMapPane.NONE);
335            mapPane.setState(JMapPane.SELECT_TOP); // Why not: JMapPane.SELECT_TOP_ONEONLY                          mapPane.setState(JMapPane.SELECT_TOP); // Why not:
336            mapPane.setHighlight(false);// SK: Was true, but since it not works properly removed it to save performance                          // JMapPane.SELECT_TOP_ONEONLY
337            mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);                          mapPane.setHighlight(false);// SK: Was true, but since it not works
338            break;                          // properly removed it to save
339          case TOOL_SELECTION_SET:                          // performance
340          case TOOL_SELECTION_ADD:                          mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);
341          case TOOL_SELECTION_REMOVE:                          break;
342                  // Set the mouse tool to "Select"                  case TOOL_ZOOMIN:
343                  mapPane.setWindowSelectionState(JMapPane.SELECT_TOP);                          // Set the mouse tool to "Zoom in"
344                  mapPane.setState(JMapPane.SELECT_TOP);                          mapPane.setWindowSelectionState(JMapPane.ZOOM_IN);
345                  mapPane.setHighlight(false);                          mapPane.setState(JMapPane.ZOOM_IN);
346                  mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); // TODO Select Cursor                          mapPane.setHighlight(false);
347                  break;                          mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);
348          case TOOL_ZOOMIN:                          break;
349            // Set the mouse tool to "Zoom in"                  case TOOL_ZOOMOUT:
350            mapPane.setWindowSelectionState(JMapPane.ZOOM_IN);                          // Set the mouse tool to "Zoom out"
351            mapPane.setState(JMapPane.ZOOM_IN);                          mapPane.setWindowSelectionState(JMapPane.NONE);
352            mapPane.setHighlight(false);                          mapPane.setState(JMapPane.ZOOM_OUT);
353            mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);                          mapPane.setHighlight(false);
354            break;                          mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
355          case TOOL_ZOOMOUT:                          break;
356            // Set the mouse tool to "Zoom out"                  default:
357            mapPane.setWindowSelectionState(JMapPane.NONE);                          // Set map actions to default
358            mapPane.setState(JMapPane.ZOOM_OUT);                          mapPane.setWindowSelectionState(JMapPane.NONE);
359            mapPane.setHighlight(false);                          mapPane.setState(JMapPane.NONE);
360            mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);                          mapPane.setHighlight(false);
361            break;                          mapPane.setNormalCursor(null);
362          default:                          break;
363            // Set map actions to default                  }
364            mapPane.setWindowSelectionState(JMapPane.NONE);                  mapPane.updateCursor();
           mapPane.setState(JMapPane.NONE);  
           mapPane.setHighlight(false);  
           mapPane.setNormalCursor(null);  
           break;  
       }  
       mapPane.updateCursor();  
365          }          }
366            
367      /**          /**
368       * Performs the action of an action button.           * @param id
369       * @param tool the action           *            The ID of the Component to remove. The change will not be
370       * @param e    the event of the button           *            visible until {@link #initToolBar()} is called.
371       */           * @return <code>null</code> or the component that has been removed.
372             */
373            public JComponent removeId(int id) {
374                    return toolAndActionButtons.remove(id);
375            }
376    
377            /**
378             * Performs the action of an action button.
379             *
380             * @param tool
381             *            the action
382             * @param e
383             *            the event of the button
384             */
385          protected void performActionButton(int action, ActionEvent e) {          protected void performActionButton(int action, ActionEvent e) {
386        if ( mapPane == null )                  if (mapPane == null)
387          return;                          return;
388    
389        // Perform the action "Zoom back": Revert the last zoom                  // Perform the action "Zoom back": Revert the last zoom
390        if ( action == ACTION_ZOOM_BACK ) {                  if (action == ACTION_ZOOM_BACK) {
391              if (zoomBackIndex <= 1)                          if (zoomBackIndex <= 1)
392            return;                                  return;
393      
394          zoomBackForwardButtonInAction = true;                          zoomBackForwardButtonInAction = true;
395          zoomBackIndex--;                          zoomBackIndex--;
396          getButton(ACTION_ZOOM_FORWARD).setEnabled(true);                          getButton(ACTION_ZOOM_FORWARD).setEnabled(true);
397          getButton(ACTION_ZOOM_BACK).setEnabled( zoomBackIndex > 1 );                          getButton(ACTION_ZOOM_BACK).setEnabled(zoomBackIndex > 1);
398      
399          mapPane.setMapArea( lastZooms.get(zoomBackIndex-1) );                          mapPane.setMapArea(lastZooms.get(zoomBackIndex - 1));
400          mapPane.refresh();                          mapPane.refresh();
401        }                  }
402    
403        // Perform the action "Zoom forward": Redo the last zoom                  // Perform the action "Zoom forward": Re-do the last zoom
404        if ( action == ACTION_ZOOM_FORWARD ) {                  if (action == ACTION_ZOOM_FORWARD) {
405          if (zoomBackIndex < lastZooms.size()) {                          if (zoomBackIndex < lastZooms.size()) {
406            zoomBackForwardButtonInAction = true;                                  zoomBackForwardButtonInAction = true;
407            zoomBackIndex++;                                  zoomBackIndex++;
408            getButton(ACTION_ZOOM_BACK).setEnabled(true);                                  getButton(ACTION_ZOOM_BACK).setEnabled(true);
409            getButton(ACTION_ZOOM_FORWARD).setEnabled(zoomBackIndex < lastZooms.size());                                  getButton(ACTION_ZOOM_FORWARD).setEnabled(
410                                                    zoomBackIndex < lastZooms.size());
411            mapPane.setMapArea( lastZooms.get(zoomBackIndex-1) );  
412            mapPane.refresh();                                  mapPane.setMapArea(lastZooms.get(zoomBackIndex - 1));
413          }                                  mapPane.refresh();
414        }                          }
415                          }
       /**  
        * Clear the selection by calling the selection model  
        */  
       if (action == TOOL_SELECTION_CLEAR) {  
           // TODO  
       }  
416          }          }
417            
           
418          /**          /**
419           * Adds a tool to the tool bar. Does nothing if a tool or action with the           * Adds a tool to the tool bar. Does nothing if a tool or action with the
420           * specified ID already exists!           * specified ID already exists!
421           * @param buttonAction action for the toggle button           *
422           * @param resetToolBar indicates whether the toolbar GUI is reset after adding           * @param buttonAction
423           *                     the button (if adding several actions it useful only to           *            action for the toggle button
424           *                     reset the GUI for the last added tool)           * @param resetToolBar
425             *            indicates whether the toolbar GUI is reset after adding the
426             *            button (if adding several actions it useful only to reset the
427             *            GUI for the last added tool)
428           */           */
429          public void addTool(MapPaneToolBarAction buttonAction, boolean resetToolBar) {          public void addTool(MapPaneToolBarAction buttonAction, boolean resetToolBar) {
430            if ( isButtonIDUsed(buttonAction.getID()) ) {                  if (isButtonIDUsed(buttonAction.getID())) {
431              LOGGER.warn("addTool(.) ignored because ID already used for tool or action: "+buttonAction.getID());                          LOGGER
432              return;                                          .warn("addTool(.) ignored because ID already used for tool or action: "
433            }                                                          + buttonAction.getID());
434            JToggleButton button = new JToggleButton(buttonAction);                          return;
435            button.setBorder( BorderFactory.createRaisedBevelBorder() );                  }
436            toolButtonGroup.add(button);                  JToggleButton button = new JToggleButton(buttonAction);
437            toolAndActionButtons.put(buttonAction.getID(), button);                  button.setBorder(BorderFactory.createRaisedBevelBorder());
438            if ( resetToolBar )                  toolButtonGroup.add(button);
439              initToolBar();                  toolAndActionButtons.put(buttonAction.getID(), button);
440          }                  if (resetToolBar)
441                            initToolBar();
442      /**          }
443       * Adds a tool to the tool bar and resets the toolbar GUI.  
444       * @param buttonAction action for the toggle button          /**
445       */           * Adds a tool to the tool bar and resets the toolbar GUI.
446      public void addTool(MapPaneToolBarAction buttonAction) {           *
447        addTool(buttonAction, true);           * @param buttonAction
448      }           *            action for the toggle button
449             */
450      /**          public void addTool(MapPaneToolBarAction buttonAction) {
451       * Adds an action to the tool bar. Does nothing if a tool or action with the                  addTool(buttonAction, true);
452       * specified ID already exists!          }
453       * @param buttonAction action for the button  
454       * @param resetToolBar indicates whether the toolbar GUI is reset after adding          /**
455       *                     the button (if adding several actions it useful only to           * Adds an action to the tool bar. Does nothing if a tool or action with the
456       *                     reset the GUI for the last added tool)           * specified ID already exists!
457       */           *
458      public void addAction(MapPaneToolBarAction buttonAction, boolean resetToolBar) {           * @param buttonAction
459        if ( isButtonIDUsed(buttonAction.getID()) ) {           *            action for the button
460          LOGGER.warn("addAction(.) ignored because ID already used for tool or action: "+buttonAction.getID());           * @param resetToolBar
461          return;           *            indicates whether the toolbar GUI is reset after adding the
462        }           *            button (if adding several actions it useful only to reset the
463        JButton button = new JButton(buttonAction);           *            GUI for the last added tool)
464        button.setBorder( BorderFactory.createRaisedBevelBorder() );           */
465        toolAndActionButtons.put( buttonAction.getID(), button );          public void addAction(MapPaneToolBarAction buttonAction,
466        if ( resetToolBar )                          boolean resetToolBar) {
467          initToolBar();                  if (isButtonIDUsed(buttonAction.getID())) {
468      }                          LOGGER
469                                                .warn("addAction(.) ignored because ID already used for tool or action: "
470                                                            + buttonAction.getID());
471      private void addSeparator(int id, Separator separator) {                          return;
472          if ( isButtonIDUsed(id) ) {                  }
473              LOGGER.warn("addSeparator(.) ignored because ID already used for tool or action. ");                  JButton button = new JButton(buttonAction);
474              return;                  button.setBorder(BorderFactory.createRaisedBevelBorder());
475            }                  toolAndActionButtons.put(buttonAction.getID(), button);
476            toolAndActionButtons.put( id, separator);                  if (resetToolBar)
477          }                          initToolBar();
478            }
479      /**  
480       * Adds an action to the tool bar and resets the toolbar GUI.          public void addSeparator(int id, Separator separator) {
481       * @param buttonAction action for the toggle button                  if (isButtonIDUsed(id)) {
482       */                          LOGGER
483      public void addAction(MapPaneToolBarAction buttonAction) {                                          .warn("addSeparator(.) ignored because ID already used for tool or action. ");
484        addAction(buttonAction, true);                          return;
485      }                  }
486                        toolAndActionButtons.put(id, separator);
487      /**          }
488       * Returns the button for a specific tool or action.  
489       * @param id the constant for any button in the {@link MapPaneToolBar}          /**
490       * @return a {@link JButton} if {@code id} specifies an {@linkplain #getActionButton(int) action button}           * Adds an action to the tool bar and resets the toolbar GUI.
491       *         or {@link JToogleButton} if {@code id} specifies a {@linkplain #getToolButton(int) tool button}           *
492       */           * @param buttonAction
493      public AbstractButton getButton(int id) {           *            action for the toggle button
494        AbstractButton button = (AbstractButton)toolAndActionButtons.get(id);           */
495        if ( button == null )          public void addAction(MapPaneToolBarAction buttonAction) {
496          LOGGER.warn("Unknown tool or action ID: "+id);                  addAction(buttonAction, true);
497        return button;          }
498      }  
499            /**
500      /**           * Returns the button for a specific tool or action.
501       * Returns the button for a specific tool.           *
502       * @param tool the constant for a tool           * @param id
503       */           *            the constant for any button in the {@link MapPaneToolBar}
504             * @return a {@link JButton} if {@code id} specifies an
505             *         {@linkplain #getActionButton(int) action button} or
506             *         {@link JToogleButton} if {@code id} specifies a
507             *         {@linkplain #getToolButton(int) tool button}
508             */
509            public AbstractButton getButton(int id) {
510                    AbstractButton button = (AbstractButton) toolAndActionButtons.get(id);
511                    if (button == null)
512                            LOGGER.warn("Unknown tool or action ID: " + id);
513                    return button;
514            }
515    
516            /**
517             * Returns the button for a specific tool.
518             *
519             * @param tool
520             *            the constant for a tool
521             */
522          public JToggleButton getToolButton(int tool) {          public JToggleButton getToolButton(int tool) {
523        AbstractButton button = getButton(tool);                  AbstractButton button = getButton(tool);
524        if ( button != null && !(button instanceof JToggleButton) ) {                  if (button != null && !(button instanceof JToggleButton)) {
525          LOGGER.warn("ID specifies no tool: "+tool);                          LOGGER.warn("ID specifies no tool: " + tool);
526          button = null;                          button = null;
527        }                  }
528        return (JToggleButton)button;                  return (JToggleButton) button;
529      }          }
   
     /**  
      * Returns the button for a specific action.  
      * @param action the constant an action  
      */  
     public JButton getActionButton(int action) {  
       AbstractButton button = getButton(action);  
       if ( button != null && !(button instanceof JButton) ) {  
         LOGGER.warn("ID specifies no action: "+action);  
         button = null;  
       }  
       return (JButton)button;  
530    
531      }          /**
532             * Returns the button for a specific action.
533             *
534             * @param action
535             *            the constant an action
536             */
537            public JButton getActionButton(int action) {
538                    AbstractButton button = getButton(action);
539                    if (button != null && !(button instanceof JButton)) {
540                            LOGGER.warn("ID specifies no action: " + action);
541                            button = null;
542                    }
543                    return (JButton) button;
544    
545            }
546    
547          /**          /**
548           * Sets the selected tool.           * Sets the selected tool.
549           * @param tool ID of the tool           *
550             * @param tool
551             *            ID of the tool
552           */           */
553          public void setSelectedTool(Integer tool) {          public void setSelectedTool(Integer tool) {
554            if ( tool == null )                  if (tool == null)
555              toolButtonGroup.setUnselected();                          toolButtonGroup.setUnselected();
556              
557            JToggleButton button = getToolButton(tool);                  JToggleButton button = getToolButton(tool);
558            if ( button == null )                  if (button == null)
559              return;                          return;
560            button.setSelected( true );                  button.setSelected(true);
561            button.getAction().actionPerformed(null);                  button.getAction().actionPerformed(null);
562    
563                    selectedTool = tool;
564          }          }
565            
566          /**          /**
567           * Returns the selected tool.           * Returns the selected tool.
568             *
569           * @return -1 if no tool is active           * @return -1 if no tool is active
570           */           */
571          public int getSelectedTool() {          public int getSelectedTool() {
572            if ( toolButtonGroup.getSelectedButton() == null )                  if (toolButtonGroup.getSelectedButton() == null)
573              return -1;                          return -1;
574            return selectedTool;                  return selectedTool;
575          }          }
576            
577      /**          /**
578       * Sets whether a tool or action is activated or not. The visible property           * Sets whether a tool or action is activated or not. The visible property
579       * of the button is not affected.           * of the button is not affected.
580       * @param id tool or actionID           *
581       * @param enabled if {@code true} the tool becomes available           * @param id
582       */           *            tool or actionID
583      public void setButtonEnabled(int id, boolean enabled) {           * @param enabled
584        AbstractButton button = getButton(id);           *            if {@code true} the tool becomes available
585        if ( button == null )           */
586          return;          public void setButtonEnabled(int id, boolean enabled) {
587        button.setEnabled( enabled );                  AbstractButton button = getButton(id);
588      }                  if (button == null)
589                            return;
590      /**                  button.setEnabled(enabled);
591       * Sets whether a tool or action is activated or not.          }
592       * @param id tool or actionID  
593       * @param enabled if {@code true} the tool becomes available          /**
594       * @param hideOnDisable if {@code true} the button is also hidden if           * Sets whether a tool or action is activated or not.
595       *                      {@code enabled} is {@code false}           *
596       */           * @param id
597             *            tool or actionID
598             * @param enabled
599             *            if {@code true} the tool becomes available
600             * @param hideOnDisable
601             *            if {@code true} the button is also hidden if {@code enabled}
602             *            is {@code false}
603             */
604          public void setButtonEnabled(int id, boolean enabled, boolean hideOnDisable) {          public void setButtonEnabled(int id, boolean enabled, boolean hideOnDisable) {
605            AbstractButton button = getButton(id);                  AbstractButton button = getButton(id);
606            if ( button == null )                  if (button == null)
607              return;                          return;
608            button.setEnabled( enabled );                  button.setEnabled(enabled);
609            // if button is enabled, it becomes visible anyway                  // if button is enabled, it becomes visible anyway
610            // if button is disabled and the "hide" option is set, it is also hidden                  // if button is disabled and the "hide" option is set, it is also hidden
611            if ( enabled )                  if (enabled)
612              button.setVisible( true );                          button.setVisible(true);
613            else                  else
614              button.setVisible( !hideOnDisable );                          button.setVisible(!hideOnDisable);
615          }          }
616    
617      /**          /**
618       * Checks whether a ID is already used for a tool or action.           * Checks whether a ID is already used for a tool or action.
619       * @param tool tool ID           *
620       */           * @param tool
621      public boolean isButtonIDUsed(int id) {           *            tool ID
622        return toolAndActionButtons.get(id) != null;           */
623      }          public boolean isButtonIDUsed(int id) {
624                    return toolAndActionButtons.get(id) != null;
625      /**          }
626       * Checks whether a tool is activated.  
627       * @param tool tool ID          /**
628       * @return {@code false} if an unknown ID is specified           * Checks whether a tool is activated.
629       */           *
630      public boolean isButtonEnabled(int id) {           * @param tool
631        AbstractButton button = getButton(id);           *            tool ID
632        if ( button != null )           * @return {@code false} if an unknown ID is specified
633          return button.isEnabled();           */
634        return false;          public boolean isButtonEnabled(int id) {
635      }                  AbstractButton button = getButton(id);
636                    if (button != null)
637      /**                          return button.isEnabled();
638       * Sets the activation for all tools.                  return false;
639       * @param enabled if {@code true} all tools becomes available          }
640       * @param hideOnDisable if {@code true} the buttons are also hidden if  
641       *                      {@code enabled} is {@code false}          /**
642       */           * Sets the activation for all tools.
643      public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {           *
644        for (int tool : toolAndActionButtons.keySet())           * @param enabled
645          setButtonEnabled(tool,enabled,hideOnDisable);           *            if {@code true} all tools becomes available
646      }             * @param hideOnDisable
647             *            if {@code true} the buttons are also hidden if {@code enabled}
648      /**           *            is {@code false}
649       * Sets the activation for all actions.           */
650       * @param enabled if {@code true} all actions becomes available          public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
651       * @param hideOnDisable if {@code true} the buttons are also hidden if                  for (int tool : toolAndActionButtons.keySet())
652       *                      {@code enabled} is {@code false}                          setButtonEnabled(tool, enabled, hideOnDisable);
653       */          }
654      public void setAllActionsEnabled(boolean enabled, boolean hideOnDisable) {  
655        for (int id : toolAndActionButtons.keySet()){          /**
656            if (toolAndActionButtons.get(id) instanceof JButton){           * Sets the activation for all actions.
657                    setButtonEnabled(id,enabled,hideOnDisable);           *
658            }           * @param enabled
659        }           *            if {@code true} all actions becomes available
660                     * @param hideOnDisable
661      }             *            if {@code true} the buttons are also hidden if {@code enabled}
662                 *            is {@code false}
663      /**           */
664       * Returns the maximum ID of tools.          public void setAllActionsEnabled(boolean enabled, boolean hideOnDisable) {
665       */                  for (int id : toolAndActionButtons.keySet()) {
666      public int getMaxToolID() {                          if (toolAndActionButtons.get(id) instanceof JButton) {
667        return toolAndActionButtons.lastKey();                                  setButtonEnabled(id, enabled, hideOnDisable);
668      }                          }
669                    }
670      /**  
671       * Returns the minimum ID of tools.          }
672       */  
673      public int getMinToolID() {          /**
674        return toolAndActionButtons.firstKey();           * Returns the maximum ID of tools.
675      }           */
676            public int getMaxToolID() {
677      /**                  return toolAndActionButtons.lastKey();
678       * Extends the {@link AbstractAction} with maintaining an ID and          }
679       * the {@link MapPaneToolBar} the actions controls.  
680       * Additionally this class automatically calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)}          /**
681       * or {@link MapPaneToolBar#performActionButton(int, ActionEvent)}           * Returns the minimum ID of tools.
682       * depending on whether the action is added via {@link MapPaneToolBar#addTool(MapPaneToolBarAction)}           */
683       * or {@link MapPaneToolBar#addAction(MapPaneToolBarAction)}.          public int getMinToolID() {
684       * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)                  return toolAndActionButtons.firstKey();
685       */          }
686      public static class MapPaneToolBarAction extends AbstractAction {  
687        /** The ID of the action */          /**
688        protected int id = -1;           * Extends the {@link AbstractAction} with maintaining an ID and the
689        /** The tool bar, this action is made for. */           * {@link MapPaneToolBar} the actions controls. Additionally this class
690        protected MapPaneToolBar toolBar = null;           * automatically calls
691             * {@link MapPaneToolBar#performToolButton(int, ActionEvent)} or
692        /**           * {@link MapPaneToolBar#performActionButton(int, ActionEvent)} depending on
693         * Creates a new action with a dummy description and no icon.           * whether the action is added via
694         * @param id      unique ID for the action           * {@link MapPaneToolBar#addTool(MapPaneToolBarAction)} or
695         * @param toolBar toolbar this action is made for           * {@link MapPaneToolBar#addAction(MapPaneToolBarAction)}.
696         */           *
697        public MapPaneToolBarAction(int id, MapPaneToolBar toolBar) {           * @author <a href="mailto:[email protected]">Martin Schmitz</a>
698          this(id,toolBar,""+id);           *         (University of Bonn/Germany)
699        }           */
700            public static class MapPaneToolBarAction extends AbstractAction {
701        /**                  /** The ID of the action */
702         * Creates a new action without an icon.                  protected int id = -1;
703         * @param id      unique ID for the action                  /** The tool bar, this action is made for. */
704         * @param toolBar toolbar this action is made for                  protected MapPaneToolBar toolBar = null;
705         * @param name    description used for buttons or menus  
706         */                  /**
707        public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, String name) {                   * Creates a new action with a dummy description and no icon.
708          this(id,toolBar,name,null);                   *
709        }                   * @param id
710                     *            unique ID for the action
711        /**                   * @param toolBar
712         * Creates a new action.                   *            toolbar this action is made for
713         * @param id      unique ID for the action                   */
714         * @param toolBar toolbar this action is made for                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar) {
715         * @param name    description used for buttons or menus                          this(id, toolBar, "" + id);
716         * @param icon    icon used for buttons or menus                  }
717         */  
718        public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, String name, Icon icon) {                  /**
719          super(name,icon);                   * Creates a new action without an icon.
720          this.id      = id;                   *
721          this.toolBar = toolBar;                   * @param id
722        }                   *            unique ID for the action
723                           * @param toolBar
724        /**                   *            toolbar this action is made for
725         * Calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)}                   * @param name
726         * or {@link MapPaneToolBar#performActionButton(int, ActionEvent)}                   *            description used for buttons or menus
727         * depending on whether the action is added to the toolbar via                   */
728         * {@link MapPaneToolBar#addTool(MapPaneToolBarAction)}                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, String name) {
729         * or {@link MapPaneToolBar#addAction(MapPaneToolBarAction)}.                          this(id, toolBar, name, null);
730         */                  }
731        public void actionPerformed(ActionEvent e) {  
732          if ( toolBar.toolAndActionButtons.get(id) instanceof JToggleButton)                  /**
733            toolBar.performToolButton(id, e);                   * Creates a new action.
734          else if ( toolBar.toolAndActionButtons.get(id) instanceof JButton )                   *
735            toolBar.performActionButton(id, e);                   * @param id
736        }                   *            unique ID for the action
737                           * @param toolBar
738        /**                   *            toolbar this action is made for
739         * Returns the (unique) id of this action.                   * @param name
740         * @return                   *            description used for buttons or menus
741         */                   * @param icon
742        public int getID() {                   *            icon used for buttons or menus
743          return id;                   */
744        }                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
745      }                                  String name, Icon icon) {
746                            this (id, toolBar, name, icon, null);
747                    }
748                    
749                    /**
750                     * Creates a new action.
751                     *
752                     * @param id
753                     *            unique ID for the action
754                     * @param toolBar
755                     *            The {@link MapPaneToolBar} this action is made for
756                     * @param name
757                     *            description used for buttons or menus
758                     * @param icon
759                     *            icon used for buttons or menus
760                     * @param toolTip
761                     *            Tooltip to use for the button or menu
762                     */
763                    public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
764                                    String name, Icon icon, String toolTip) {
765                            super(name, icon);
766                            
767                            if (toolTip != null && !toolTip.trim().isEmpty()){
768                                    putValue(Action.SHORT_DESCRIPTION, toolTip);
769                            }
770                            
771                            this.id = id;
772                            this.toolBar = toolBar;
773                    }
774    
775                    /**
776                     * Calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)} or
777                     * {@link MapPaneToolBar#performActionButton(int, ActionEvent)}
778                     * depending on whether the action is added to the toolbar via
779                     * {@link MapPaneToolBar#addTool(MapPaneToolBarAction)} or
780                     * {@link MapPaneToolBar#addAction(MapPaneToolBarAction)}.
781                     */
782                    public void actionPerformed(ActionEvent e) {
783                            if (toolBar.toolAndActionButtons.get(id) instanceof JToggleButton)
784                                    toolBar.performToolButton(id, e);
785                            else if (toolBar.toolAndActionButtons.get(id) instanceof JButton)
786                                    toolBar.performActionButton(id, e);
787                    }
788    
789                    /**
790                     * Returns the (unique) id of this action.
791                     *
792                     * @return
793                     */
794                    public int getID() {
795                            return id;
796                    }
797            }
798  }  }

Legend:
Removed from v.139  
changed lines
  Added in v.177

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26