Class MapMode
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- All Implemented Interfaces:
ActionListener
,MouseListener
,MouseMotionListener
,Serializable
,Cloneable
,EventListener
,Action
,PreferenceChangedListener
,Destroyable
- Direct Known Subclasses:
AddNoteAction
,DeleteAction
,DrawAction
,ExtrudeAction
,ImageryAdjustAction
,ImproveWayAccuracyAction
,ParallelWayAction
,PlayHeadDragMode
,SelectAction
,SelectLassoAction
,ZoomAction
public abstract class MapMode extends JosmAction implements MouseListener, 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 Cursor
cursor
protected boolean
shift
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MapMode(String name, String iconName, String tooltip, Cursor cursor)
Constructor for mapmodes with a menu (no shortcut will be registered)protected
MapMode(String name, String iconName, String tooltip, Shortcut shortcut, 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(ActionEvent e)
Call selectMapMode(this) on the parent mapFrame.void
enterMode()
Makes this map mode active.void
exitMode()
Makes this map mode inactive.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(MouseEvent e)
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.protected void
readPreferences()
protected void
requestFocusInMapView()
protected void
updateKeyModifiers(ActionEvent e)
Update internal ctrl, alt, shift mask from given action event.protected void
updateKeyModifiers(InputEvent e)
Update internal ctrl, alt, shift mask from given input event.protected void
updateKeyModifiers(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()
-
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
-
-
-
-
Constructor Detail
-
MapMode
protected MapMode(String name, String iconName, String tooltip, Shortcut shortcut, 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(String name, String iconName, String tooltip, 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 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(ActionEvent e)
Call selectMapMode(this) on the parent mapFrame.- Specified by:
actionPerformed
in interfaceActionListener
-
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(InputEvent e)
Update internal ctrl, alt, shift mask from given input event.- Parameters:
e
- input event
-
updateKeyModifiers
protected void updateKeyModifiers(MouseEvent e)
Update internal ctrl, alt, shift mask from given mouse event.- Parameters:
e
- mouse event
-
updateKeyModifiers
protected void updateKeyModifiers(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 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(MouseEvent e)
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
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
-
-