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

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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26