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: |
122 |
*/ |
*/ |
123 |
public static final int TOOL_SELECTION_REMOVE = 230; |
public static final int TOOL_SELECTION_REMOVE = 230; |
124 |
|
|
125 |
|
public static final int ACTION_CHARTS = 401; |
126 |
|
|
127 |
/** Tool currently selected */ |
/** Tool currently selected */ |
128 |
protected int selectedTool = TOOL_ZOOMIN; |
protected int selectedTool = TOOL_ZOOMIN; |
129 |
|
|
359 |
// Set the mouse tool to "Panning" |
// Set the mouse tool to "Panning" |
360 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
361 |
mapPane.setState(JMapPane.PAN); |
mapPane.setState(JMapPane.PAN); |
|
mapPane.setHighlight(false); |
|
362 |
mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
363 |
break; |
break; |
364 |
case TOOL_INFO: |
case TOOL_INFO: |
366 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
367 |
mapPane.setState(JMapPane.SELECT_TOP); // Why not: |
mapPane.setState(JMapPane.SELECT_TOP); // Why not: |
368 |
// JMapPane.SELECT_TOP_ONEONLY |
// JMapPane.SELECT_TOP_ONEONLY |
|
mapPane.setHighlight(false);// SK: Was true, but since it not works |
|
369 |
// properly removed it to save |
// properly removed it to save |
370 |
// performance |
// performance |
371 |
mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
374 |
// Set the mouse tool to "Zoom in" |
// Set the mouse tool to "Zoom in" |
375 |
mapPane.setWindowSelectionState(JMapPane.ZOOM_IN); |
mapPane.setWindowSelectionState(JMapPane.ZOOM_IN); |
376 |
mapPane.setState(JMapPane.ZOOM_IN); |
mapPane.setState(JMapPane.ZOOM_IN); |
|
mapPane.setHighlight(false); |
|
377 |
mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
378 |
break; |
break; |
379 |
case TOOL_ZOOMOUT: |
case TOOL_ZOOMOUT: |
380 |
// Set the mouse tool to "Zoom out" |
// Set the mouse tool to "Zoom out" |
381 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
382 |
mapPane.setState(JMapPane.ZOOM_OUT); |
mapPane.setState(JMapPane.ZOOM_OUT); |
|
mapPane.setHighlight(false); |
|
383 |
mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
384 |
break; |
break; |
385 |
default: |
default: |
386 |
// Set map actions to default |
// Set map actions to default |
387 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
388 |
mapPane.setState(JMapPane.NONE); |
mapPane.setState(JMapPane.NONE); |
|
mapPane.setHighlight(false); |
|
389 |
mapPane.setNormalCursor(null); |
mapPane.setNormalCursor(null); |
390 |
break; |
break; |
391 |
} |
} |
469 |
initToolBar(); |
initToolBar(); |
470 |
} |
} |
471 |
|
|
472 |
|
|
473 |
|
|
474 |
/** |
/** |
475 |
* Adds a tool to the tool bar and resets the toolbar GUI. |
* Adds a tool to the tool bar and resets the toolbar GUI. |
476 |
* |
* |
506 |
if (resetToolBar) |
if (resetToolBar) |
507 |
initToolBar(); |
initToolBar(); |
508 |
} |
} |
509 |
|
|
510 |
|
/** |
511 |
|
* Adds any JComponent to the tool bar. Does nothing if a tool or action with the |
512 |
|
* specified ID already exists! |
513 |
|
* |
514 |
|
* @param component A {@link JComponent} that shall be added |
515 |
|
* @param id The ID associaded with the {@link JComponent} |
516 |
|
* @param resetToolBar |
517 |
|
* indicates whether the toolbar GUI is reset after adding the |
518 |
|
* button (if adding several actions it useful only to reset the |
519 |
|
* GUI for the last added tool) |
520 |
|
*/ |
521 |
|
public void addJComponent(JComponent component, int id, |
522 |
|
boolean resetToolBar) { |
523 |
|
|
524 |
|
if (isButtonIDUsed(id)) { |
525 |
|
LOGGER |
526 |
|
.warn("addAction(.) ignored because ID already used for tool or action: " |
527 |
|
+ id); |
528 |
|
return; |
529 |
|
} |
530 |
|
|
531 |
|
toolAndActionButtons.put(id, component); |
532 |
|
if (resetToolBar) |
533 |
|
initToolBar(); |
534 |
|
} |
535 |
|
|
536 |
public void addSeparator(int id, Separator separator) { |
public void addSeparator(int id, Separator separator) { |
537 |
if (isButtonIDUsed(id)) { |
if (isButtonIDUsed(id)) { |