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; |
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 |
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 |
} |
} |
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 |
158 |
/** Listeners what want to be informed about a change of the selected tool **/ |
/** Listeners what want to be informed about a change of the selected tool **/ |
159 |
protected Set<MapPaneToolSelectedListener> toolSelectionListeners = new HashSet<MapPaneToolSelectedListener>(); |
protected Set<MapPaneToolSelectedListener> toolSelectionListeners = new HashSet<MapPaneToolSelectedListener>(); |
160 |
|
|
161 |
/** This listener is added to all {@link JToggleButton} **/ |
/** This listener is added to all {@link JToggleButton} **/ |
162 |
private final ActionListener toolSelectedListener = new ActionListener(){ |
private final ActionListener toolSelectedListener = new ActionListener() { |
163 |
|
|
164 |
@Override |
@Override |
165 |
public void actionPerformed(ActionEvent e) { |
public void actionPerformed(ActionEvent e) { |
166 |
JToggleButton tb = (JToggleButton) e.getSource(); |
JToggleButton tb = (JToggleButton) e.getSource(); |
167 |
|
|
168 |
// Inform the listeners about a newly selected tool |
// Inform the listeners about a newly selected tool |
169 |
for (MapPaneToolSelectedListener l : toolSelectionListeners) { |
for (MapPaneToolSelectedListener l : toolSelectionListeners) { |
170 |
l.toolSelected(Integer.valueOf( tb.getName() ) ) ; |
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 ) { |
public void addButtonSelectedListener(MapPaneToolSelectedListener listener) { |
185 |
toolSelectionListeners.add(listener); |
toolSelectionListeners.add(listener); |
186 |
} |
} |
187 |
|
|
188 |
public void removeButtonSelectedListener(MapPaneToolSelectedListener listener ) { |
public void removeButtonSelectedListener( |
189 |
toolSelectionListeners .remove(listener); |
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 |
|
|
202 |
// I want to see nothing on the background |
// I want to see nothing on the background |
203 |
setOpaque(false); |
setOpaque(false); |
204 |
setBorder(null); |
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 |
|
|
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 |
} |
} |
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); |
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()); |
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 |
341 |
setSelectedTool(selectedTool); |
setSelectedTool(selectedTool); |
342 |
|
|
343 |
} |
} |
344 |
|
|
345 |
@Override |
@Override |
346 |
public void paint(Graphics g) { |
public void paint(Graphics g) { |
347 |
super.paint(g); |
super.paint(g); |
352 |
* the tool bar. |
* the tool bar. |
353 |
*/ |
*/ |
354 |
public void initToolBar() { |
public void initToolBar() { |
355 |
// setOpaque(true); |
// setOpaque(true); |
356 |
// |
// |
357 |
// setAlignmentY(1f); |
// setAlignmentY(1f); |
358 |
// setAlignmentX(0.5f); |
// setAlignmentX(0.5f); |
359 |
removeAll(); |
removeAll(); |
360 |
|
|
361 |
// // Separator to the left of the tool actions to start |
// // Separator to the left of the tool actions to start |
362 |
// // the tool buttons with the map (not with the coordinate grid) |
// // the tool buttons with the map (not with the coordinate grid) |
363 |
// Dimension dimension = new Dimension(49, 10); |
// Dimension dimension = new Dimension(49, 10); |
364 |
// addSeparator(dimension); |
// addSeparator(dimension); |
365 |
|
|
|
|
|
366 |
// Tool buttons |
// Tool buttons |
367 |
for (Integer bKey : toolAndActionButtons.keySet()) { |
for (Integer bKey : toolAndActionButtons.keySet()) { |
368 |
|
|
369 |
JComponent b = toolAndActionButtons.get(bKey); |
JComponent b = toolAndActionButtons.get(bKey); |
370 |
|
|
371 |
if (b instanceof JToggleButton) { |
if (b instanceof JToggleButton) { |
372 |
JToggleButton tb = (JToggleButton) b; |
JToggleButton tb = (JToggleButton) b; |
373 |
tb.setName(bKey.toString()); |
tb.setName(bKey.toString()); |
374 |
tb.addActionListener( toolSelectedListener ); |
tb.addActionListener(toolSelectedListener); |
375 |
} |
} |
376 |
|
|
377 |
add(b); |
add(b); |
378 |
} |
} |
379 |
|
|
393 |
} |
} |
394 |
|
|
395 |
} |
} |
396 |
|
|
397 |
revalidate(); |
revalidate(); |
398 |
repaint(); |
repaint(); |
399 |
} |
} |
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 |
/** |
/** |
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) |
530 |
initToolBar(); |
initToolBar(); |
531 |
} |
} |
532 |
|
|
|
|
|
|
|
|
533 |
/** |
/** |
534 |
* Adds a tool to the tool bar and resets the toolbar GUI. |
* Adds a tool to the tool bar and resets the toolbar GUI. |
535 |
* |
* |
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 with the |
* Adds any JComponent to the tool bar. Does nothing if a tool or action |
571 |
* specified ID already exists! |
* with the specified ID already exists! |
572 |
* |
* |
573 |
* @param component A {@link JComponent} that shall be added |
* @param component |
574 |
* @param id The ID associaded with the {@link JComponent} |
* A {@link JComponent} that shall be added |
575 |
|
* @param id |
576 |
|
* The ID associaded with the {@link JComponent} |
577 |
* @param resetToolBar |
* @param resetToolBar |
578 |
* indicates whether the toolbar GUI is reset after adding the |
* indicates whether the toolbar GUI is reset after adding the |
579 |
* button (if adding several actions it useful only to reset the |
* button (if adding several actions it useful only to reset the |
580 |
* GUI for the last added tool) |
* GUI for the last added tool) |
581 |
*/ |
*/ |
582 |
public void addJComponent(JComponent component, int id, |
public void addJComponent(JComponent component, int id, boolean resetToolBar) { |
|
boolean resetToolBar) { |
|
583 |
|
|
584 |
if (isButtonIDUsed(id)) { |
if (isButtonIDUsed(id)) { |
585 |
LOGGER |
LOGGER |
586 |
.warn("addAction(.) ignored because ID already used for tool or action: " |
.warn("addAction(.) ignored because ID already used for tool or action: " |
587 |
+ id); |
+ id); |
588 |
return; |
return; |
589 |
} |
} |
590 |
|
|
591 |
toolAndActionButtons.put(id, component); |
toolAndActionButtons.put(id, component); |
592 |
if (resetToolBar) |
if (resetToolBar) |
593 |
initToolBar(); |
initToolBar(); |
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 |
* |
* |
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 |
} |
} |
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üger</a> |
* Krü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 |
} |
} |