Class MapMode
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,PreferenceChangedListener
,Destroyable
- Direct Known Subclasses:
AddNoteAction
,DeleteAction
,DrawAction
,ExtrudeAction
,ImageryAdjustAction
,ImproveWayAccuracyAction
,ParallelWayAction
,PlayHeadDragMode
,SelectAction
,SelectLassoAction
,SplitMode
,ZoomAction
public abstract class MapMode extends JosmAction implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, PreferenceChangedListener
A class implementing MapMode is able to be selected as an mode for map editing. As example scrolling the map is a MapMode, connecting Nodes to new Ways is another. MapModes should register/deregister all necessary listeners on the map's view control.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
alt
protected boolean
ctrl
protected java.awt.Cursor
cursor
protected boolean
meta
true
if the meta key was pressed (the "Windows" key or the Mac "Command" key)protected boolean
platformMenuShortcutKeyMask
true
if the platform specific menu key was pressed ("ctrl" on Linux/Windows, "cmd" on Mac)protected boolean
shift
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
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)protected
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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 layerl
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, meta mask from given extended modifiers mask.protected void
updateStatusLine()
-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
cursor
protected final java.awt.Cursor cursor
-
ctrl
protected boolean ctrl
-
alt
protected boolean alt
-
shift
protected boolean shift
-
meta
protected boolean meta
true
if the meta key was pressed (the "Windows" key or the Mac "Command" key)- Since:
- 18456
-
platformMenuShortcutKeyMask
protected boolean platformMenuShortcutKeyMask
true
if the platform specific menu key was pressed ("ctrl" on Linux/Windows, "cmd" on Mac)- Since:
- 18456
- See Also:
PlatformHook.getMenuShortcutKeyMaskEx()
-
-
Constructor Detail
-
MapMode
protected 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- Parameters:
name
- the action's texticonName
- icon filename inmapmode
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 active- Since:
- 11713
-
MapMode
protected 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)- Parameters:
name
- the action's texticonName
- icon filename inmapmode
directorytooltip
- a longer description of the action that will be displayed in the tooltip.cursor
- cursor displayed when map mode is active- Since:
- 11713
-
-
Method Detail
-
enterMode
public void enterMode()
Makes this map mode active.
-
exitMode
public void exitMode()
Makes this map mode inactive.
-
updateStatusLine
protected void updateStatusLine()
-
getModeHelpText
public java.lang.String getModeHelpText()
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.- Returns:
- a short translated help message describing how this map mode can be used
-
readPreferences
protected void readPreferences()
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Call selectMapMode(this) on the parent mapFrame.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
layerIsSupported
public boolean layerIsSupported(Layer l)
Determines if layerl
is supported by this map mode. By default, all tools will work with all layers. Can be overwritten to require a special type of layer- Parameters:
l
- layer- Returns:
true
if the layer is supported by this map mode
-
updateKeyModifiers
protected void updateKeyModifiers(java.awt.event.InputEvent e)
Update internal ctrl, alt, shift mask from given input event.- Parameters:
e
- input event
-
updateKeyModifiers
protected void updateKeyModifiers(java.awt.event.MouseEvent e)
Update internal ctrl, alt, shift mask from given mouse event.- Parameters:
e
- mouse event
-
updateKeyModifiers
protected void updateKeyModifiers(java.awt.event.ActionEvent e)
Update internal ctrl, alt, shift mask from given action event.- Parameters:
e
- action event- Since:
- 12526
-
updateKeyModifiersEx
protected void updateKeyModifiersEx(int modifiers)
Update internal ctrl, alt, shift, meta mask from given extended modifiers mask.- Parameters:
modifiers
- event extended modifiers mask- Since:
- 12517
-
mapOldModifiers
private static int mapOldModifiers(int modifiers)
Map old (pre jdk 1.4) modifiers to extended modifiers (only for Ctrl, Alt, Shift).- Parameters:
modifiers
- old modifiers- Returns:
- extended modifiers
-
requestFocusInMapView
protected void requestFocusInMapView()
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListener
Triggered when a preference entry value changes.- Specified by:
preferenceChanged
in interfacePreferenceChangedListener
- Parameters:
e
- the preference change event
-
isEditableDataLayer
protected boolean isEditableDataLayer(Layer l)
Determines if the given layer is a data layer that can be modified. Useful forlayerIsSupported(Layer)
implementations.- Parameters:
l
- layer- Returns:
true
if the given layer is a data layer that can be modified- Since:
- 13434
-
-