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 booleanaltprotected booleanctrlprotected java.awt.Cursorcursorprotected booleanmetatrueif the meta key was pressed (the "Windows" key or the Mac "Command" key)protected booleanplatformMenuShortcutKeyMasktrueif the platform specific menu key was pressed ("ctrl" on Linux/Windows, "cmd" on Mac)protected booleanshift-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMapMode(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)protectedMapMode(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 voidactionPerformed(java.awt.event.ActionEvent e)Call selectMapMode(this) on the parent mapFrame.voidenterMode()Makes this map mode active.voidexitMode()Makes this map mode inactive.java.lang.StringgetModeHelpText()Returns a short translated help message describing how this map mode can be used, to be displayed in status line.protected booleanisEditableDataLayer(Layer l)Determines if the given layer is a data layer that can be modified.booleanlayerIsSupported(Layer l)Determines if layerlis supported by this map mode.private static intmapOldModifiers(int modifiers)Map old (pre jdk 1.4) modifiers to extended modifiers (only for Ctrl, Alt, Shift).voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidpreferenceChanged(PreferenceChangeEvent e)Triggered when a preference entry value changes.protected voidreadPreferences()protected voidrequestFocusInMapView()protected voidupdateKeyModifiers(java.awt.event.ActionEvent e)Update internal ctrl, alt, shift mask from given action event.protected voidupdateKeyModifiers(java.awt.event.InputEvent e)Update internal ctrl, alt, shift mask from given input event.protected voidupdateKeyModifiers(java.awt.event.MouseEvent e)Update internal ctrl, alt, shift mask from given mouse event.protected voidupdateKeyModifiersEx(int modifiers)Update internal ctrl, alt, shift, meta mask from given extended modifiers mask.protected voidupdateStatusLine()-
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
trueif the meta key was pressed (the "Windows" key or the Mac "Command" key)- Since:
- 18456
-
platformMenuShortcutKeyMask
protected boolean platformMenuShortcutKeyMask
trueif 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 inmapmodedirectorytooltip- 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 inmapmodedirectorytooltip- 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:
actionPerformedin interfacejava.awt.event.ActionListener
-
layerIsSupported
public boolean layerIsSupported(Layer l)
Determines if layerlis 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:
trueif 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:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListenerTriggered when a preference entry value changes.- Specified by:
preferenceChangedin 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:
trueif the given layer is a data layer that can be modified- Since:
- 13434
-
-