95 |
|
|
96 |
/** Constant for the tool "Zoom In" (110). */ |
/** Constant for the tool "Zoom In" (110). */ |
97 |
public static final int TOOL_ZOOMIN = 110; |
public static final int TOOL_ZOOMIN = 110; |
98 |
|
public static final int ACTION_ZOOM_DEFAULT = 150; |
99 |
/** Constant for the tool "Zoom Out" (120). */ |
/** Constant for the tool "Zoom Out" (120). */ |
100 |
public static final int TOOL_ZOOMOUT = 120; |
public static final int TOOL_ZOOMOUT = 120; |
101 |
/** Constant for the action "Zoom back" (130). */ |
/** Constant for the action "Zoom back" (130). */ |
307 |
*/ |
*/ |
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")), |
// MapView.class.getResource("resource/icons/pan.png")), |
312 |
R("MapPaneButtons.Pan.TT")), false); |
// R("MapPaneButtons.Pan.TT")), false); |
313 |
|
|
314 |
|
addTool(new MapPaneToolBarAction(TOOL_PAN, this, XMapPaneTool.PAN), false); |
315 |
|
|
316 |
// Info |
// Info |
317 |
addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon( |
// addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon( |
318 |
MapView.class.getResource("resource/icons/info.png")), |
// MapView.class.getResource("resource/icons/info.png")), |
319 |
R("MapPaneButtons.Info.TT")), false); |
// R("MapPaneButtons.Info.TT")), false); |
320 |
|
addTool(new MapPaneToolBarAction(TOOL_INFO, this, XMapPaneTool.INFO), false); |
321 |
|
|
322 |
// Zoom in |
// Zoom in |
323 |
addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon( |
addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, XMapPaneTool.ZOOM_IN), false); |
324 |
MapView.class.getResource("resource/icons/zoom_in.png")), |
|
|
R("MapPaneButtons.ZoomIn.TT")), false); |
|
325 |
// Zoom out |
// Zoom out |
326 |
addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon( |
addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, XMapPaneTool.ZOOM_OUT), false); |
327 |
MapView.class.getResource("resource/icons/zoom_out.png")), |
|
328 |
R("MapPaneButtons.ZoomOut.TT")), false); |
|
329 |
|
// // Zoom in |
330 |
|
// addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon( |
331 |
|
// MapView.class.getResource("resource/icons/zoom_in.png")), |
332 |
|
// R("MapPaneButtons.ZoomIn.TT")), false); |
333 |
|
// |
334 |
|
// // Zoom out |
335 |
|
// addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon( |
336 |
|
// MapView.class.getResource("resource/icons/zoom_out.png")), |
337 |
|
// R("MapPaneButtons.ZoomOut.TT")), false); |
338 |
|
|
339 |
|
|
340 |
|
|
341 |
// Action button to revert the last zoom |
// Action button to revert the last zoom |
342 |
addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "", |
addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "", |
440 |
switch (tool) { |
switch (tool) { |
441 |
case TOOL_PAN: |
case TOOL_PAN: |
442 |
// Set the mouse tool to "Panning" |
// Set the mouse tool to "Panning" |
443 |
mapPane.setState(SelectableXMapPane.PAN); |
// mapPane.setState(SelectableXMapPane.PAN); |
444 |
|
mapPane.setTool(XMapPaneTool.PAN); |
445 |
// mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
// mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
446 |
break; |
break; |
447 |
case TOOL_INFO: |
case TOOL_INFO: |
448 |
// Set the mouse tool to "Info" |
// Set the mouse tool to "Info" |
449 |
mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); |
mapPane.setTool(XMapPaneTool.INFO); |
450 |
|
// mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); |
451 |
// mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
// mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
452 |
break; |
break; |
453 |
case TOOL_ZOOMIN: |
case TOOL_ZOOMIN: |
454 |
// Set the mouse tool to "Zoom in" |
// Set the mouse tool to "Zoom in" |
455 |
mapPane.setState(SelectableXMapPane.ZOOM_IN); |
mapPane.setTool(XMapPaneTool.ZOOM_IN); |
456 |
// mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
// mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
457 |
break; |
break; |
458 |
case TOOL_ZOOMOUT: |
case TOOL_ZOOMOUT: |
459 |
// Set the mouse tool to "Zoom out" |
// Set the mouse tool to "Zoom out" |
460 |
mapPane.setState(SelectableXMapPane.ZOOM_OUT); |
mapPane.setTool(XMapPaneTool.ZOOM_OUT); |
461 |
|
// mapPane.setState(SelectableXMapPane.ZOOM_OUT); |
462 |
// mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
// mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
463 |
break; |
break; |
464 |
default: |
// default: |
465 |
// Set map actions to default |
// Set map actions to default |
466 |
mapPane.setState(SelectableXMapPane.NONE); |
// mapPane.setState(SelectableXMapPane.NONE); |
467 |
// mapPane.setNormalCursor(null); |
// mapPane.setNormalCursor(null); |
468 |
break; |
// break; |
469 |
} |
} |
470 |
// mapPane.updateCursorAndRepaintTimer(); |
// mapPane.updateCursorAndRepaintTimer(); |
471 |
} |
} |
491 |
protected void performActionButton(int action, ActionEvent e) { |
protected void performActionButton(int action, ActionEvent e) { |
492 |
if (mapPane == null) |
if (mapPane == null) |
493 |
return; |
return; |
494 |
|
|
495 |
// Perform the action "Zoom back": Revert the last zoom |
// Perform the action "Zoom back": Revert the last zoom |
496 |
if (action == ACTION_ZOOM_BACK) { |
if (action == ACTION_ZOOM_BACK) { |
497 |
if (zoomBackIndex <= 1) |
if (zoomBackIndex <= 1) |
641 |
* {@linkplain #getToolButton(int) tool button} |
* {@linkplain #getToolButton(int) tool button} |
642 |
*/ |
*/ |
643 |
public AbstractButton getButton(int id) { |
public AbstractButton getButton(int id) { |
644 |
|
|
645 |
|
//ACHUTNG: Das ist ein SK QUICK FIX! TODO |
646 |
|
if (!(toolAndActionButtons.get(id) instanceof AbstractButton)) return null; |
647 |
|
|
648 |
AbstractButton button = (AbstractButton) toolAndActionButtons.get(id); |
AbstractButton button = (AbstractButton) toolAndActionButtons.get(id); |
649 |
if (button == null) |
if (button == null) |
650 |
LOGGER.warn("Unknown tool or action ID: " + id); |
LOGGER.warn("Unknown tool or action ID: " + id); |
711 |
return -1; |
return -1; |
712 |
return selectedTool; |
return selectedTool; |
713 |
} |
} |
714 |
|
|
715 |
/** |
/** |
716 |
* Sets whether a tool or action is activated or not. The visible property |
* Sets whether a tool or action is activated or not. The visible property |
717 |
* of the button is not affected. |
* of the button is not affected. |
786 |
* is {@code false} |
* is {@code false} |
787 |
*/ |
*/ |
788 |
public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) { |
public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) { |
789 |
for (int tool : toolAndActionButtons.keySet()) |
for (int id : toolAndActionButtons.keySet()) { |
790 |
setButtonEnabled(tool, enabled, hideOnDisable); |
if (toolAndActionButtons.get(id) instanceof JToggleButton) { |
791 |
|
setButtonEnabled(id, enabled, hideOnDisable); |
792 |
|
} |
793 |
|
} |
794 |
} |
} |
795 |
|
|
796 |
/** |
/** |
797 |
* Sets the activation for all actions. |
* Sets the activation for all actions. |
798 |
* |
* |
913 |
this.toolBar = toolBar; |
this.toolBar = toolBar; |
914 |
} |
} |
915 |
|
|
916 |
|
public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, XMapPaneTool tool) { |
917 |
|
this(id, toolBar, "", tool.getIcon(), tool.getToolTip()); |
918 |
|
} |
919 |
|
|
920 |
/** |
/** |
921 |
* Calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)} or |
* Calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)} or |
922 |
* {@link MapPaneToolBar#performActionButton(int, ActionEvent)} |
* {@link MapPaneToolBar#performActionButton(int, ActionEvent)} |