/[schmitzm]/branches/2.0-RC1/src/skrueger/geotools/MapPaneToolBar.java
ViewVC logotype

Diff of /branches/2.0-RC1/src/skrueger/geotools/MapPaneToolBar.java

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

trunk/src/skrueger/geotools/MapPaneToolBar.java revision 244 by alfonx, Wed Jul 29 09:33:33 2009 UTC branches/2.0-RC1/src/skrueger/geotools/MapPaneToolBar.java revision 604 by alfonx, Wed Dec 9 14:15:53 2009 UTC
# Line 2  Line 2 
2   * Copyright (c) 2009 Martin O. J. Schmitz.   * Copyright (c) 2009 Martin O. J. Schmitz.
3   *   *
4   * This file is part of the SCHMITZM library - a collection of utility   * This file is part of the SCHMITZM library - a collection of utility
5   * classes based on Java 1.6, focussing (not only) on Java Swing   * classes based on Java 1.6, focusing (not only) on Java Swing
6   * and the Geotools library.   * and the Geotools library.
7   *   *
8   * The SCHMITZM project is hosted at:   * The SCHMITZM project is hosted at:
# Line 30  Line 30 
30  package skrueger.geotools;  package skrueger.geotools;
31    
32  import java.awt.Color;  import java.awt.Color;
 import java.awt.Dimension;  
33  import java.awt.Graphics;  import java.awt.Graphics;
34  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
35    import java.awt.event.ActionListener;
36  import java.util.ArrayList;  import java.util.ArrayList;
37    import java.util.HashSet;
38  import java.util.Locale;  import java.util.Locale;
39    import java.util.Set;
40  import java.util.SortedMap;  import java.util.SortedMap;
41  import java.util.TreeMap;  import java.util.TreeMap;
42    
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 51  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 76  import com.vividsolutions.jts.geom.Envel Line 79  import com.vividsolutions.jts.geom.Envel
79  public class MapPaneToolBar extends JToolBar {  public class MapPaneToolBar extends JToolBar {
80          private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class          private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class
81                          .getName());                          .getName());
82            
83          public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil          public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
84                          .extendPackagePath(MapPaneToolBar.class,                          .extendPackagePath(MapPaneToolBar.class,
85                                          "resource.locales.mapPaneToolbar"), Locale.ENGLISH);                                          "resource.locales.mapPaneToolbar"), Locale.ENGLISH);
86            
87          public static String R(String key, Object... values) {          public static String R(String key, Object... values) {
88                  return RESOURCE.getString(key, values);                  return RESOURCE.getString(key, values);
89          }          }
# Line 122  public class MapPaneToolBar extends JToo Line 125  public class MapPaneToolBar extends JToo
125           */           */
126          public static final int TOOL_SELECTION_REMOVE = 230;          public static final int TOOL_SELECTION_REMOVE = 230;
127    
128            public static final int ACTION_CHARTS = 401;
129    
130          /** Tool currently selected */          /** Tool currently selected */
131          protected int selectedTool = TOOL_ZOOMIN;          protected int selectedTool = TOOL_ZOOMIN;
132    
133          /** Holds the tool buttons of the tool bar. */          /** Holds the tool buttons of the tool bar. */
134          protected SortedMap<Integer, JComponent> toolAndActionButtons = null;          final protected SortedMap<Integer, JComponent> toolAndActionButtons = new TreeMap<Integer, JComponent>();
135          /** Controls that only one tool button is activated. */          /** Controls that only one tool button is activated. */
136          protected ButtonGroup toolButtonGroup = null;          protected ButtonGroup toolButtonGroup = null;
137    
# Line 135  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 151  public class MapPaneToolBar extends JToo Line 156  public class MapPaneToolBar extends JToo
156    
157          protected boolean zoomBackForwardButtonInAction;          protected boolean zoomBackForwardButtonInAction;
158    
159            /** Listeners what want to be informed about a change of the selected tool **/
160            protected Set<MapPaneToolSelectedListener> toolSelectionListeners = new HashSet<MapPaneToolSelectedListener>();
161    
162            /** This listener is added to all {@link JToggleButton} **/
163            private final ActionListener toolSelectedListener = new ActionListener() {
164    
165                    @Override
166                    public void actionPerformed(ActionEvent e) {
167                            JToggleButton tb = (JToggleButton) e.getSource();
168    
169                            // Inform the listeners about a newly selected tool
170                            for (MapPaneToolSelectedListener l : toolSelectionListeners) {
171                                    l.toolSelected(Integer.valueOf(tb.getName()));
172                            }
173                    }
174    
175            };
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);
183          }          }
184    
185            public void addButtonSelectedListener(MapPaneToolSelectedListener listener) {
186                    toolSelectionListeners.add(listener);
187            }
188    
189            public void removeButtonSelectedListener(
190                            MapPaneToolSelectedListener listener) {
191                    toolSelectionListeners.remove(listener);
192            }
193    
194          /**          /**
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                  this.toolAndActionButtons = new TreeMap<Integer, JComponent>();  
203                    // I want to see nothing on the background
204                    setOpaque(false);
205                    setBorder(null);
206    
207                  this.toolButtonGroup = new ButtonGroup();                  this.toolButtonGroup = new ButtonGroup();
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 183  public class MapPaneToolBar extends JToo Line 219  public class MapPaneToolBar extends JToo
219    
220                                  final MapAreaChangedEvent mapAreaChangedEvent = (MapAreaChangedEvent) e;                                  final MapAreaChangedEvent mapAreaChangedEvent = (MapAreaChangedEvent) e;
221                                  Envelope oldMapArea = mapAreaChangedEvent.getOldMapArea();                                  Envelope oldMapArea = mapAreaChangedEvent.getOldMapArea();
222                                    
223                                  final Envelope mapArea = mapAreaChangedEvent.getNewMapArea();                                  final Envelope mapArea = mapAreaChangedEvent.getNewMapArea();
224                                  if (mapArea == null || mapArea.equals(oldMapArea) ) {                                  if (mapArea == null || mapArea.equals(oldMapArea)
225                                          // If the MapArea didn't change... we don't want to register it as a zoom action.                                                  || Double.isNaN(mapArea.getMinX())
226                                                    || Double.isNaN(mapArea.getMaxX())
227                                                    || Double.isNaN(mapArea.getMinY())
228                                                    || Double.isNaN(mapArea.getMaxY())) {
229                                            // If the MapArea didn't change... we don't want to register
230                                            // it as a zoom action.
231                                          return;                                          return;
232                                  }                                  }
233                                    
234                                  if (lastZooms.size() == 0 && oldMapArea != null) {                                  if (lastZooms.size() == 0
235                                                    && oldMapArea != null
236                                                    && !oldMapArea.isNull()
237                                                    && !(Double.isNaN(oldMapArea.getMinX())
238                                                                    || Double.isNaN(oldMapArea.getMaxX())
239                                                                    || Double.isNaN(oldMapArea.getMinY()) || Double
240                                                                    .isNaN(oldMapArea.getMaxY()))) {
241                                          lastZooms.add(oldMapArea);                                          lastZooms.add(oldMapArea);
242                                          zoomBackIndex = 1;                                          zoomBackIndex = 1;
243                                  }                                  }
# Line 222  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 242  public class MapPaneToolBar extends JToo Line 289  public class MapPaneToolBar extends JToo
289           * puts all tool buttons and all actions buttons to the tool bar.           * puts all tool buttons and all actions buttons to the tool bar.
290           */           */
291          protected void init() {          protected void init() {
292    
293                  initToolsAndActions();                  initToolsAndActions();
294    
295                  addSeparator(SEPERATOR0, new JToolBar.Separator());                  addSeparator(SEPERATOR0, new JToolBar.Separator());
# Line 260  public class MapPaneToolBar extends JToo Line 308  public class MapPaneToolBar extends JToo
308          protected void initToolsAndActions() {          protected void initToolsAndActions() {
309                  // Panning                  // Panning
310                  addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon(                  addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon(
311                                  MapView.class.getResource("resource/icons/pan.png")), R("MapPaneButtons.Pan.TT")), false);                                  MapView.class.getResource("resource/icons/pan.png")),
312                                    R("MapPaneButtons.Pan.TT")), false);
313                  // Info                  // Info
314                  addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon(                  addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon(
315                                  MapView.class.getResource("resource/icons/info.png")),R("MapPaneButtons.Info.TT")), false);                                  MapView.class.getResource("resource/icons/info.png")),
316                                    R("MapPaneButtons.Info.TT")), false);
317    
318                  // Zoom in                  // Zoom in
319                  addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon(                  addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon(
320                                  MapView.class.getResource("resource/icons/zoom_in.png")), R("MapPaneButtons.ZoomIn.TT")),                                  MapView.class.getResource("resource/icons/zoom_in.png")),
321                                  false);                                  R("MapPaneButtons.ZoomIn.TT")), false);
322                  // Zoom out                  // Zoom out
323                  addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon(                  addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon(
324                                  MapView.class.getResource("resource/icons/zoom_out.png")), R("MapPaneButtons.ZoomOut.TT")),                                  MapView.class.getResource("resource/icons/zoom_out.png")),
325                                  false);                                  R("MapPaneButtons.ZoomOut.TT")), false);
326    
327                  // Action button to revert the last zoom                  // Action button to revert the last zoom
328                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "",                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "",
329                                  new ImageIcon(MapView.class                                  new ImageIcon(MapView.class
330                                                  .getResource("resource/icons/zoom_back.png")), R("MapPaneButtons.LastZoom.TT")), false);                                                  .getResource("resource/icons/zoom_back.png")),
331                                    R("MapPaneButtons.LastZoom.TT")), false);
332                  setButtonEnabled(ACTION_ZOOM_BACK, false);                  setButtonEnabled(ACTION_ZOOM_BACK, false);
333    
334                  // Action button to redo the last zoom                  // Action button to redo the last zoom
335                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_FORWARD, this, "",                  addAction(new MapPaneToolBarAction(ACTION_ZOOM_FORWARD, this, "",
336                                  new ImageIcon(MapView.class                                  new ImageIcon(MapView.class
337                                                  .getResource("resource/icons/zoom_forward.png")), R("MapPaneButtons.NextZoom.TT")),                                                  .getResource("resource/icons/zoom_forward.png")),
338                                  false);                                  R("MapPaneButtons.NextZoom.TT")), false);
339                  setButtonEnabled(ACTION_ZOOM_FORWARD, false);                  setButtonEnabled(ACTION_ZOOM_FORWARD, false);
340    
341                  // set the selected tool enabled                  // set the selected tool enabled
# Line 292  public class MapPaneToolBar extends JToo Line 343  public class MapPaneToolBar extends JToo
343    
344          }          }
345    
346            @Override
347            public void paint(Graphics g) {
348                    super.paint(g);
349            }
350    
351          /**          /**
352           * Clears the GUI of all components and adds all tool and action buttons to           * Clears the GUI of all components and adds all tool and action buttons to
353           * the tool bar.           * the tool bar.
354           */           */
355          public void initToolBar() {          public void initToolBar() {
356                  setAlignmentY(1f);                  // setOpaque(true);
357                    //              
358                    // setAlignmentY(1f);
359                    // setAlignmentX(0.5f);
360                  removeAll();                  removeAll();
361                  // Separator to the left of the tool actions to start  
362                  // the tool buttons with the map (not with the coordinate grid)                  // // Separator to the left of the tool actions to start
363                  Dimension dimension = new Dimension(49, 10);                  // // the tool buttons with the map (not with the coordinate grid)
364                  addSeparator(dimension);                  // Dimension dimension = new Dimension(49, 10);
365                    // addSeparator(dimension);
366    
367                  // Tool buttons                  // Tool buttons
368                  for (JComponent b : toolAndActionButtons.values())                  for (Integer bKey : toolAndActionButtons.keySet()) {
369    
370                            JComponent b = toolAndActionButtons.get(bKey);
371    
372                            if (b instanceof JToggleButton) {
373                                    JToggleButton tb = (JToggleButton) b;
374                                    tb.setName(bKey.toString());
375                                    tb.addActionListener(toolSelectedListener);
376                            }
377    
378                          add(b);                          add(b);
379                    }
380    
381                  if (!toolAndActionButtons.containsKey(selectedTool)) {                  if (!toolAndActionButtons.containsKey(selectedTool)) {
382                          /**                          /**
# Line 323  public class MapPaneToolBar extends JToo Line 394  public class MapPaneToolBar extends JToo
394                          }                          }
395    
396                  }                  }
397                    
398                  revalidate();                  revalidate();
399                  repaint();                  repaint();
400          }          }
# Line 355  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.setHighlight(false);  
                         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  
                         mapPane.setHighlight(false);// SK: Was true, but since it not works  
                         // 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.setHighlight(false);  
                         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.setHighlight(false);  
                         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.setHighlight(false);  
                         mapPane.setNormalCursor(null);  
451                          break;                          break;
452                  }                  }
453                  mapPane.updateCursor();  //              mapPane.updateCursorAndRepaintTimer();
454          }          }
455    
456          /**          /**
# Line 464  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 501  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();
568          }          }
569    
570            /**
571             * Adds any JComponent to the tool bar. Does nothing if a tool or action
572             * with the specified ID already exists!
573             *
574             * @param component
575             *            A {@link JComponent} that shall be added
576             * @param id
577             *            The ID associaded with the {@link JComponent}
578             * @param resetToolBar
579             *            indicates whether the toolbar GUI is reset after adding the
580             *            button (if adding several actions it useful only to reset the
581             *            GUI for the last added tool)
582             */
583            public void addJComponent(JComponent component, int id, boolean resetToolBar) {
584    
585                    if (isButtonIDUsed(id)) {
586                            LOGGER
587                                            .warn("addAction(.) ignored because ID already used for tool or action: "
588                                                            + id);
589                            return;
590                    }
591    
592                    toolAndActionButtons.put(id, component);
593                    if (resetToolBar)
594                            initToolBar();
595            }
596    
597          public void addSeparator(int id, Separator separator) {          public void addSeparator(int id, Separator separator) {
598                  if (isButtonIDUsed(id)) {                  if (isButtonIDUsed(id)) {
599                          LOGGER                          LOGGER
# Line 774  public class MapPaneToolBar extends JToo Line 860  public class MapPaneToolBar extends JToo
860                   */                   */
861                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
862                                  String name, Icon icon) {                                  String name, Icon icon) {
863                          this (id, toolBar, name, icon, null);                          this(id, toolBar, name, icon, null);
864                  }                  }
865                    
866                  /**                  /**
867                   * Creates a new action.                   * Creates a new action.
868                   *                   *
# Line 794  public class MapPaneToolBar extends JToo Line 880  public class MapPaneToolBar extends JToo
880                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
881                                  String name, Icon icon, String toolTip) {                                  String name, Icon icon, String toolTip) {
882                          super(name, icon);                          super(name, icon);
883                            
884                          if (toolTip != null && !toolTip.trim().isEmpty()){                          if (toolTip != null && !toolTip.trim().isEmpty()) {
885                                  putValue(Action.SHORT_DESCRIPTION, toolTip);                                  putValue(Action.SHORT_DESCRIPTION, toolTip);
886                          }                          }
887                            
888                          this.id = id;                          this.id = id;
889                          this.toolBar = toolBar;                          this.toolBar = toolBar;
890                  }                  }
# Line 826  public class MapPaneToolBar extends JToo Line 912  public class MapPaneToolBar extends JToo
912                          return id;                          return id;
913                  }                  }
914          }          }
915            
916            /**          /**
917             * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht wird) wird. Dann werden wird der           * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht
918             * Hintergrund auf WEISS gesetzt.           * wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt.
919             *           *
920             * @author <a href="mailto:[email protected]">Stefan Alfons           * @author <a href="mailto:[email protected]">Stefan Alfons
921             *         Kr&uuml;ger</a>           *         Kr&uuml;ger</a>
922             */           */
923            @Override          @Override
924            public void print(Graphics g) {          public void print(Graphics g) {
925                Color orig = getBackground();                  Color orig = getBackground();
926                setBackground(Color.WHITE);                  setBackground(Color.WHITE);
927                // wrap in try/finally so that we always restore the state                  // wrap in try/finally so that we always restore the state
928                try {                  try {
929                    super.print(g);                          super.print(g);
930                } finally {                  } finally {
931                    setBackground(orig);                          setBackground(orig);
932                }                  }
933            }          }
934    
935  }  }

Legend:
Removed from v.244  
changed lines
  Added in v.604

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26