/[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 445 by alfonx, Wed Oct 7 13:17:02 2009 UTC revision 509 by alfonx, Thu Nov 5 08:51:33 2009 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;
56  import schmitzm.geotools.map.event.JMapPaneEvent;  import schmitzm.geotools.map.event.MapPaneEvent;
57  import schmitzm.geotools.map.event.JMapPaneListener;  import schmitzm.geotools.map.event.JMapPaneListener;
58  import schmitzm.geotools.map.event.MapAreaChangedEvent;  import schmitzm.geotools.map.event.MapAreaChangedEvent;
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 schmitzm.swing.SwingUtil;
63    import skrueger.swing.SmallButton;
64    import skrueger.swing.SmallToggleButton;
65    
66  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
67    
68  /**  /**
69   * A toolbar to control an {@link JMapPane} (Atlas visualization). This contains   * A toolbar to control an {@link SelectableXMapPane} (Atlas visualization). This contains
70   * 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
71   * map represented by {@link JToggleButton JToggleButtons}, where only one tool   * map represented by {@link JToggleButton JToggleButtons}, where only one tool
72   * 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 140  public class MapPaneToolBar extends JToo
140          // /** Holds the action buttons of the bar. */          // /** Holds the action buttons of the bar. */
141          // protected SortedMap<Integer, JButton> actionButtons = null;          // protected SortedMap<Integer, JButton> actionButtons = null;
142    
143          /** Holds the {@link JMapPane} this tool bar controls. */          /** Holds the {@link SelectableXMapPane} this tool bar controls. */
144          protected JMapPane mapPane = null;          protected SelectableXMapPane mapPane = null;
145    
146          /**          /**
147           * 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 176  public class MapPaneToolBar extends JToo
176    
177          /**          /**
178           * Creates a new toolbar. Notice: This toolbar does nothing until           * Creates a new toolbar. Notice: This toolbar does nothing until
179           * {@link #setMapPane(JMapPane)} is called!           * {@link #setMapPane(SelectableXMapPane)} is called!
180           */           */
181          public MapPaneToolBar() {          public MapPaneToolBar() {
182                  this(null);                  this(null);
# Line 194  public class MapPaneToolBar extends JToo Line 195  public class MapPaneToolBar extends JToo
195           * Creates a new tool bar.           * Creates a new tool bar.
196           *           *
197           * @param mapPane           * @param mapPane
198           *            {@link JMapPane} the tool bar controls           *            {@link SelectableXMapPane} the tool bar controls
199           */           */
200          public MapPaneToolBar(JMapPane mapPane) {          public MapPaneToolBar(SelectableXMapPane mapPane) {
201                  super("Control the map", JToolBar.HORIZONTAL);                  super("Control the map", JToolBar.HORIZONTAL);
202    
203                  // I want to see nothing on the background                  // I want to see nothing on the background
# Line 207  public class MapPaneToolBar extends JToo Line 208  public class MapPaneToolBar extends JToo
208    
209                  // Create a Listener to listen to the zooms on the JMapPane                  // Create a Listener to listen to the zooms on the JMapPane
210                  this.mapPaneListener = new JMapPaneListener() {                  this.mapPaneListener = new JMapPaneListener() {
211                          public void performMapPaneEvent(JMapPaneEvent e) {                          public void performMapPaneEvent(MapPaneEvent e) {
212                                  if (!(e instanceof MapAreaChangedEvent))                                  if (!(e instanceof MapAreaChangedEvent))
213                                          return;                                          return;
214    
# Line 268  public class MapPaneToolBar extends JToo Line 269  public class MapPaneToolBar extends JToo
269          }          }
270    
271          /**          /**
272           * Sets the {@link JMapPane} controlled by this tool bar.           * Sets the {@link SelectableXMapPane} controlled by this tool bar.
273           *           *
274           * @param mapPane           * @param mapPane
275           *            {@link JMapPane} to control (if {@code null} this tool bar           *            {@link SelectableXMapPane} to control (if {@code null} this tool bar
276           *            controls NOTHING!)           *            controls NOTHING!)
277           */           */
278          public void setMapPane(JMapPane mapPane) {          public void setMapPane(SelectableXMapPane mapPane) {
279                  // Remove listener from old MapPane                  // Remove listener from old MapPane
280                  if (this.mapPane != null)                  if (this.mapPane != null)
281                          this.mapPane.removeMapPaneListener(mapPaneListener);                          this.mapPane.removeMapPaneListener(mapPaneListener);
# Line 425  public class MapPaneToolBar extends JToo Line 426  public class MapPaneToolBar extends JToo
426                  switch (tool) {                  switch (tool) {
427                  case TOOL_PAN:                  case TOOL_PAN:
428                          // Set the mouse tool to "Panning"                          // Set the mouse tool to "Panning"
429                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.PAN);
430                          mapPane.setState(JMapPane.PAN);  //                      mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);  
431                          break;                          break;
432                  case TOOL_INFO:                  case TOOL_INFO:
433                          // Set the mouse tool to "Info"                          // Set the mouse tool to "Info"
434                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP);
435                          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);  
436                          break;                          break;
437                  case TOOL_ZOOMIN:                  case TOOL_ZOOMIN:
438                          // Set the mouse tool to "Zoom in"                          // Set the mouse tool to "Zoom in"
439                          mapPane.setWindowSelectionState(JMapPane.ZOOM_IN);                          mapPane.setState(SelectableXMapPane.ZOOM_IN);
440                          mapPane.setState(JMapPane.ZOOM_IN);  //                      mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);  
441                          break;                          break;
442                  case TOOL_ZOOMOUT:                  case TOOL_ZOOMOUT:
443                          // Set the mouse tool to "Zoom out"                          // Set the mouse tool to "Zoom out"
444                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.ZOOM_OUT);
445                          mapPane.setState(JMapPane.ZOOM_OUT);  //                      mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
                         mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);  
446                          break;                          break;
447                  default:                  default:
448                          // Set map actions to default                          // Set map actions to default
449                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setState(SelectableXMapPane.NONE);
450                          mapPane.setState(JMapPane.NONE);  //                      mapPane.setNormalCursor(null);
                         mapPane.setNormalCursor(null);  
451                          break;                          break;
452                  }                  }
453                  mapPane.updateCursor();  //              mapPane.updateCursorAndRepaintTimer();
454          }          }
455    
456          /**          /**
# Line 529  public class MapPaneToolBar extends JToo Line 522  public class MapPaneToolBar extends JToo
522                                                          + buttonAction.getID());                                                          + buttonAction.getID());
523                          return;                          return;
524                  }                  }
525                  JToggleButton button = new JToggleButton(buttonAction);                  JToggleButton button = new SmallToggleButton(buttonAction);
526                  button.setBorder(BorderFactory.createRaisedBevelBorder());                  
527    //              button.setBorder(BorderFactory.createRaisedBevelBorder());
528                  toolButtonGroup.add(button);                  toolButtonGroup.add(button);
529                  toolAndActionButtons.put(buttonAction.getID(), button);                  toolAndActionButtons.put(buttonAction.getID(), button);
530                  if (resetToolBar)                  if (resetToolBar)
# Line 566  public class MapPaneToolBar extends JToo Line 560  public class MapPaneToolBar extends JToo
560                                                          + buttonAction.getID());                                                          + buttonAction.getID());
561                          return;                          return;
562                  }                  }
563                  JButton button = new JButton(buttonAction);                  JButton button = new SmallButton(buttonAction);
564                  button.setBorder(BorderFactory.createRaisedBevelBorder());  //              button.setBorder(BorderFactory.createRaisedBevelBorder());
565                  toolAndActionButtons.put(buttonAction.getID(), button);                  toolAndActionButtons.put(buttonAction.getID(), button);
566                  if (resetToolBar)                  if (resetToolBar)
567                          initToolBar();                          initToolBar();

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26