/[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

branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolBar.java revision 445 by alfonx, Wed Oct 7 13:17:02 2009 UTC branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java revision 621 by alfonx, Thu Jan 28 10:06:05 2010 UTC
# Line 43  import java.util.TreeMap; Line 43  import java.util.TreeMap;
43  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
44  import javax.swing.AbstractButton;  import javax.swing.AbstractButton;
45  import javax.swing.Action;  import javax.swing.Action;
 import javax.swing.BorderFactory;  
46  import javax.swing.Icon;  import javax.swing.Icon;
47  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
48  import javax.swing.JButton;  import javax.swing.JButton;
# Line 53  import javax.swing.JToolBar; Line 52  import javax.swing.JToolBar;
52    
53  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
54    
55  import schmitzm.geotools.gui.JMapPane;  import schmitzm.geotools.gui.SelectableXMapPane;
 import schmitzm.geotools.map.event.JMapPaneEvent;  
56  import schmitzm.geotools.map.event.JMapPaneListener;  import schmitzm.geotools.map.event.JMapPaneListener;
57  import schmitzm.geotools.map.event.MapAreaChangedEvent;  import schmitzm.geotools.map.event.MapAreaChangedEvent;
58    import schmitzm.geotools.map.event.MapPaneEvent;
59  import schmitzm.lang.LangUtil;  import schmitzm.lang.LangUtil;
60  import schmitzm.lang.ResourceProvider;  import schmitzm.lang.ResourceProvider;
61  import schmitzm.swing.ButtonGroup;  import schmitzm.swing.ButtonGroup;
62  import schmitzm.swing.SwingUtil;  import skrueger.swing.SmallButton;
63    import skrueger.swing.SmallToggleButton;
64    
65  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
66    
67  /**  /**
68   * A toolbar to control an {@link JMapPane} (Atlas visualization). This contains   * A toolbar to control an {@link SelectableXMapPane} (Atlas visualization). This contains
69   * two types of buttons. A group of <i>tools</i> for the mouse actions on the   * two types of buttons. A group of <i>tools</i> for the mouse actions on the
70   * map represented by {@link JToggleButton JToggleButtons}, where only one tool   * map represented by {@link JToggleButton JToggleButtons}, where only one tool
71   * can be activated every time. And some (general) <i>actions</i>, represented   * can be activated every time. And some (general) <i>actions</i>, represented
# Line 139  public class MapPaneToolBar extends JToo Line 139  public class MapPaneToolBar extends JToo
139          // /** Holds the action buttons of the bar. */          // /** Holds the action buttons of the bar. */
140          // protected SortedMap<Integer, JButton> actionButtons = null;          // protected SortedMap<Integer, JButton> actionButtons = null;
141    
142          /** Holds the {@link JMapPane} this tool bar controls. */          /** Holds the {@link SelectableXMapPane} this tool bar controls. */
143          protected JMapPane mapPane = null;          protected SelectableXMapPane mapPane = null;
144    
145          /**          /**
146           * A List to remember the last Envelopes that have been watched. Used for           * A List to remember the last Envelopes that have been watched. Used for
# Line 175  public class MapPaneToolBar extends JToo Line 175  public class MapPaneToolBar extends JToo
175    
176          /**          /**
177           * Creates a new toolbar. Notice: This toolbar does nothing until           * Creates a new toolbar. Notice: This toolbar does nothing until
178           * {@link #setMapPane(JMapPane)} is called!           * {@link #setMapPane(SelectableXMapPane)} is called!
179           */           */
180          public MapPaneToolBar() {          public MapPaneToolBar() {
181                  this(null);                  this(null);
# Line 194  public class MapPaneToolBar extends JToo Line 194  public class MapPaneToolBar extends JToo
194           * Creates a new tool bar.           * Creates a new tool bar.
195           *           *
196           * @param mapPane           * @param mapPane
197           *            {@link JMapPane} the tool bar controls           *            {@link SelectableXMapPane} the tool bar controls
198           */           */
199          public MapPaneToolBar(JMapPane mapPane) {          public MapPaneToolBar(SelectableXMapPane mapPane) {
200                  super("Control the map", JToolBar.HORIZONTAL);                  super("Control the map", JToolBar.HORIZONTAL);
201    
202                  // I want to see nothing on the background                  // I want to see nothing on the background
# Line 207  public class MapPaneToolBar extends JToo Line 207  public class MapPaneToolBar extends JToo
207    
208                  // Create a Listener to listen to the zooms on the JMapPane                  // Create a Listener to listen to the zooms on the JMapPane
209                  this.mapPaneListener = new JMapPaneListener() {                  this.mapPaneListener = new JMapPaneListener() {
210                          public void performMapPaneEvent(JMapPaneEvent e) {                          public void performMapPaneEvent(MapPaneEvent e) {
211                                  if (!(e instanceof MapAreaChangedEvent))                                  if (!(e instanceof MapAreaChangedEvent))
212                                          return;                                          return;
213    
# Line 268  public class MapPaneToolBar extends JToo Line 268  public class MapPaneToolBar extends JToo
268          }          }
269    
270          /**          /**
271           * Sets the {@link JMapPane} controlled by this tool bar.           * Sets the {@link SelectableXMapPane} controlled by this tool bar.
272           *           *
273           * @param mapPane           * @param mapPane
274           *            {@link JMapPane} to control (if {@code null} this tool bar           *            {@link SelectableXMapPane} to control (if {@code null} this tool bar
275           *            controls NOTHING!)           *            controls NOTHING!)
276           */           */
277          public void setMapPane(JMapPane mapPane) {          public void setMapPane(SelectableXMapPane mapPane) {
278                  // Remove listener from old MapPane                  // Remove listener from old MapPane
279                  if (this.mapPane != null)                  if (this.mapPane != null)
280                          this.mapPane.removeMapPaneListener(mapPaneListener);                          this.mapPane.removeMapPaneListener(mapPaneListener);
# Line 425  public class MapPaneToolBar extends JToo Line 425  public class MapPaneToolBar extends JToo
425                  switch (tool) {                  switch (tool) {
426                  case TOOL_PAN:                  case TOOL_PAN:
427                          // Set the mouse tool to "Panning"                          // Set the mouse tool to "Panning"
428                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.PAN);
429                          mapPane.setState(JMapPane.PAN);  //                      mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);  
430                          break;                          break;
431                  case TOOL_INFO:                  case TOOL_INFO:
432                          // Set the mouse tool to "Info"                          // Set the mouse tool to "Info"
433                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP);
434                          mapPane.setState(JMapPane.SELECT_TOP); // Why not:  //                      mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);
                         // JMapPane.SELECT_TOP_ONEONLY  
                         // properly removed it to save  
                         // performance  
                         mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);  
435                          break;                          break;
436                  case TOOL_ZOOMIN:                  case TOOL_ZOOMIN:
437                          // Set the mouse tool to "Zoom in"                          // Set the mouse tool to "Zoom in"
438                          mapPane.setWindowSelectionState(JMapPane.ZOOM_IN);                          mapPane.setState(SelectableXMapPane.ZOOM_IN);
439                          mapPane.setState(JMapPane.ZOOM_IN);  //                      mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);  
440                          break;                          break;
441                  case TOOL_ZOOMOUT:                  case TOOL_ZOOMOUT:
442                          // Set the mouse tool to "Zoom out"                          // Set the mouse tool to "Zoom out"
443                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.ZOOM_OUT);
444                          mapPane.setState(JMapPane.ZOOM_OUT);  //                      mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);  
445                          break;                          break;
446                  default:                  default:
447                          // Set map actions to default                          // Set map actions to default
448                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.NONE);
449                          mapPane.setState(JMapPane.NONE);  //                      mapPane.setNormalCursor(null);
                         mapPane.setNormalCursor(null);  
450                          break;                          break;
451                  }                  }
452                  mapPane.updateCursor();  //              mapPane.updateCursorAndRepaintTimer();
453          }          }
454    
455          /**          /**
# Line 529  public class MapPaneToolBar extends JToo Line 521  public class MapPaneToolBar extends JToo
521                                                          + buttonAction.getID());                                                          + buttonAction.getID());
522                          return;                          return;
523                  }                  }
524                  JToggleButton button = new JToggleButton(buttonAction);                  JToggleButton button = new SmallToggleButton(buttonAction);
525                  button.setBorder(BorderFactory.createRaisedBevelBorder());                  
526    //              button.setBorder(BorderFactory.createRaisedBevelBorder());
527                  toolButtonGroup.add(button);                  toolButtonGroup.add(button);
528                  toolAndActionButtons.put(buttonAction.getID(), button);                  toolAndActionButtons.put(buttonAction.getID(), button);
529                  if (resetToolBar)                  if (resetToolBar)
# Line 566  public class MapPaneToolBar extends JToo Line 559  public class MapPaneToolBar extends JToo
559                                                          + buttonAction.getID());                                                          + buttonAction.getID());
560                          return;                          return;
561                  }                  }
562                  JButton button = new JButton(buttonAction);                  JButton button = new SmallButton(buttonAction);
563                  button.setBorder(BorderFactory.createRaisedBevelBorder());  //              button.setBorder(BorderFactory.createRaisedBevelBorder());
564                  toolAndActionButtons.put(buttonAction.getID(), button);                  toolAndActionButtons.put(buttonAction.getID(), button);
565                  if (resetToolBar)                  if (resetToolBar)
566                          initToolBar();                          initToolBar();

Legend:
Removed from v.445  
changed lines
  Added in v.621

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26