public abstract class MapMode extends JosmAction implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, PreferenceChangedListener
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
protected boolean |
alt |
protected boolean |
ctrl |
protected java.awt.Cursor |
cursor |
protected boolean |
shift |
sc
Constructor and Description |
---|
MapMode(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
java.awt.Cursor cursor)
Constructor for mapmodes with a menu (no shortcut will be registered)
|
MapMode(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut,
java.awt.Cursor cursor)
Constructor for mapmodes without a menu
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Call selectMapMode(this) on the parent mapFrame.
|
void |
enterMode()
Makes this map mode active.
|
void |
exitMode()
Makes this map mode inactive.
|
java.lang.String |
getModeHelpText()
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.
|
protected boolean |
isEditableDataLayer(Layer l)
Determines if the given layer is a data layer that can be modified.
|
boolean |
layerIsSupported(Layer l)
Determines if layer
l is supported by this map mode. |
private static int |
mapOldModifiers(int modifiers)
Map old (pre jdk 1.4) modifiers to extended modifiers (only for Ctrl, Alt, Shift).
|
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.
|
protected void |
readPreferences() |
protected void |
requestFocusInMapView() |
protected void |
updateKeyModifiers(java.awt.event.ActionEvent e)
Update internal ctrl, alt, shift mask from given action event.
|
protected void |
updateKeyModifiers(java.awt.event.InputEvent e)
Update internal ctrl, alt, shift mask from given input event.
|
protected void |
updateKeyModifiers(java.awt.event.MouseEvent e)
Update internal ctrl, alt, shift mask from given mouse event.
|
protected void |
updateKeyModifiersEx(int modifiers)
Update internal ctrl, alt, shift mask from given extended modifiers mask.
|
protected void |
updateStatusLine() |
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setTooltip, updateEnabledState, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
protected final java.awt.Cursor cursor
protected boolean ctrl
protected boolean alt
protected boolean shift
public MapMode(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, java.awt.Cursor cursor)
name
- the action's texticonName
- icon filename in mapmode
directorytooltip
- a longer description of the action that will be displayed in the tooltip.shortcut
- a ready-created shortcut object or null if you don't want a shortcut.cursor
- cursor displayed when map mode is activepublic MapMode(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, java.awt.Cursor cursor)
name
- the action's texticonName
- icon filename in mapmode
directorytooltip
- a longer description of the action that will be displayed in the tooltip.cursor
- cursor displayed when map mode is activepublic void enterMode()
public void exitMode()
protected void updateStatusLine()
public java.lang.String getModeHelpText()
protected void readPreferences()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public boolean layerIsSupported(Layer l)
l
is supported by this map mode.
By default, all tools will work with all layers.
Can be overwritten to require a special type of layerl
- layertrue
if the layer is supported by this map modeprotected void updateKeyModifiers(java.awt.event.InputEvent e)
e
- input eventprotected void updateKeyModifiers(java.awt.event.MouseEvent e)
e
- mouse eventprotected void updateKeyModifiers(java.awt.event.ActionEvent e)
e
- action eventprotected void updateKeyModifiersEx(int modifiers)
modifiers
- event extended modifiers maskprivate static int mapOldModifiers(int modifiers)
modifiers
- old modifiersprotected void requestFocusInMapView()
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void preferenceChanged(PreferenceChangeEvent e)
PreferenceChangedListener
preferenceChanged
in interface PreferenceChangedListener
e
- the preference change eventprotected boolean isEditableDataLayer(Layer l)
layerIsSupported(Layer)
implementations.l
- layertrue
if the given layer is a data layer that can be modified