Class DrawAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- org.openstreetmap.josm.actions.mapmode.DrawAction
-
- 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
,DataSelectionListener
,MapViewPaintable
,KeyPressReleaseListener
,ModifierExListener
,PreferenceChangedListener
,Destroyable
public class DrawAction extends MapMode implements MapViewPaintable, DataSelectionListener, KeyPressReleaseListener, ModifierExListener
Mapmode to add nodes, create and extend ways.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DrawAction.BackSpaceAction
Undo the last command.private class
DrawAction.SnapChangeAction
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.osm.DataSelectionListener
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description private DrawAction.BackSpaceAction
backspaceAction
private Shortcut
backspaceShortcut
private static java.awt.BasicStroke
BASIC_STROKE
private Node
currentBaseNode
private EastNorth
currentMouseEastNorth
private java.awt.Cursor
cursorJoinNode
private java.awt.Cursor
cursorJoinWay
(package private) static CachingProperty<java.lang.Boolean>
DRAW_CONSTRUCTION_GEOMETRY
(package private) static CachingProperty<java.lang.Boolean>
DRAW_HELPER_LINE
(package private) static CachingProperty<java.lang.Boolean>
DRAW_TARGET_HIGHLIGHT
(package private) static CachingProperty<java.awt.BasicStroke>
HELPER_STROKE
(package private) static CachingProperty<java.awt.Color>
HIGHLIGHT_COLOR
(package private) static CachingProperty<java.awt.BasicStroke>
HIGHLIGHT_STROKE
private boolean
ignoreNextKeyRelease
private Node
lastUsedNode
private Node
mouseOnExistingNode
private java.util.Set<Way>
mouseOnExistingWays
private java.awt.Point
mousePos
private java.util.Set<OsmPrimitive>
newHighlights
private java.util.Set<OsmPrimitive>
oldHighlights
private java.awt.Point
oldMousePos
private static java.awt.Color
ORANGE_TRANSPARENT
private Node
previousNode
private java.awt.Point
rightClickPressPos
(package private) static AbstractProperty<java.awt.Color>
RUBBER_LINE_COLOR
(package private) static CachingProperty<java.awt.BasicStroke>
RUBBER_LINE_STROKE
(package private) static CachingProperty<java.lang.Boolean>
SHOW_ANGLE
(package private) static CachingProperty<java.lang.Boolean>
SHOW_PROJECTED_POINT
(package private) static CachingProperty<java.lang.Double>
SNAP_ANGLE_TOLERANCE
(package private) static CachingProperty<java.awt.Color>
SNAP_HELPER_COLOR
(package private) static CachingProperty<java.lang.Double>
SNAP_TO_INTERSECTION_THRESHOLD
(package private) static CachingProperty<java.lang.Boolean>
SNAP_TO_PROJECTIONS
private DrawAction.SnapChangeAction
snapChangeAction
private javax.swing.JCheckBoxMenuItem
snapCheckboxMenuItem
private DrawSnapHelper
snapHelper
private Shortcut
snappingShortcut
private static ArrowPaintHelper
START_WAY_INDICATOR
private double
toleranceMultiplier
(package private) static CachingProperty<java.lang.Boolean>
USE_REPEATED_SHORTCUT
static CachingProperty<java.lang.Boolean>
VIEWPORT_FOLLOWING
If this property is set, the draw action moves the viewport when adding new points.private boolean
wayIsFinished
-
Fields inherited from class org.openstreetmap.josm.actions.mapmode.MapMode
alt, ctrl, cursor, meta, platformMenuShortcutKeyMask, shift
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Constructor Description DrawAction()
Constructs a newDrawAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHighlighting(java.lang.Object event)
Takes the data from computeHelperLine to determine which ways/nodes should be highlighted (if feature enabled).private javax.swing.JCheckBoxMenuItem
addMenuItem()
private static void
addRemoveSelection(DataSet ds, OsmPrimitive toAdd, OsmPrimitive toRemove)
private static void
addSelection(DataSet ds, OsmPrimitive toAdd)
private static void
adjustNode(java.util.Collection<Pair<Node,Node>> segs, Node n)
Adjusts the position of a node to lie on a segment (or a segment intersection).private static void
adjustNodeDefault(java.util.Collection<Pair<Node,Node>> segs, Node n)
private static void
adjustNodeTwoSegments(java.util.Collection<Pair<Node,Node>> segs, Node n)
private static void
clearSelection(DataSet ds, OsmPrimitive toRemove)
private void
computeHelperLine()
This method prepares data required for painting the "helper line" from the last used position to the mouse cursor.private void
continueWayFromNode(Way way, Node node)
if one of the ends ofway
is givennode
, then set currentBaseNode = node and previousNode = adjacent node of wayvoid
destroy()
Called when the object has been destroyed.(package private) static double
det(double a, double b, double c, double d)
private void
determineCurrentBaseNodeAndPreviousNode(java.util.Collection<OsmPrimitive> selection)
Helper function that sets fields currentBaseNode and previousNodevoid
doKeyPressed(java.awt.event.KeyEvent e)
This is called when key press event is actually pressed (no fake events while holding key)void
doKeyReleased(java.awt.event.KeyEvent e)
This is called when key press event is actually released (no fake events while holding key)void
enterMode()
Makes this map mode active.void
exitMode()
Makes this map mode inactive.private Node
findNodeToContinueFrom(Node selectedNode, Way selectedWay)
Finds a node to continue drawing from.private void
finishDrawing()
This function should be called when the user wishes to finish his current draw action.Node
getCurrentBaseNode()
Replies the current base node, after having checked it is still usable (see #11105).java.util.Collection<OsmPrimitive>
getInProgressSelection()
Get selected primitives, while draw action is in progress.java.lang.String
getModeHelpText()
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.private static java.lang.String
getTitle(boolean newNode, Node n, java.util.Collection<OsmPrimitive> newSelection, java.util.Map<Way,java.util.List<Node>> reuseWays, boolean extendedWay)
static Way
getWayForNode(Node n)
Replies the parent way of a node, if it is the end of exactly one usable way.private void
insertNodeIntoAllNearbySegments(java.util.List<WaySegment> wss, Node n, java.util.Collection<OsmPrimitive> newSelection, java.util.Collection<Command> cmds, java.util.Map<Way,java.util.List<Node>> reuseWays)
private boolean
isSelfContainedWay(Way selectedWay, Node currentNode, Node targetNode)
Prevent creation of ways that look like this: <----> This happens if users want to draw a no-exit-sideway from the main way like this: ^ |<----> | The solution isn't ideal because the main way will end in the side way, which is bad for navigation software ("drive straight on") but at least easier to fix.boolean
layerIsSupported(Layer l)
Determines if layerl
is supported by this map mode.void
modifiersExChanged(int modifiers)
redraw to (possibly) get rid of helper line if selection changes.void
mouseDragged(java.awt.event.MouseEvent e)
void
mouseExited(java.awt.event.MouseEvent e)
Repaint on mouse exit so that the helper line goes away.void
mouseMoved(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
If user clicked with the left button, add a node at the current mouse position.void
paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Paint the dataset using the engine set.private void
paintConstructionGeometry(MapView mv, java.awt.Graphics2D g2)
private static void
pruneSuccsAndReverse(java.util.List<java.lang.Integer> is)
private boolean
redrawIfRequired(java.lang.Object e)
Checks if a map redraw is required and does so if needed.private boolean
removeHighlighting(java.lang.Object event)
Removes target highlighting from primitives.void
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
redraw to (possibly) get rid of helper line if selection changes.private static void
setSelection(DataSet ds, java.util.Collection<OsmPrimitive> toSet)
private static void
setSelection(DataSet ds, OsmPrimitive toSet)
(package private) static void
showStatusInfo(double angle, double hdg, double distance, boolean activeFlag)
private void
tryAgain(java.awt.event.MouseEvent e)
private void
tryToMoveNodeOnIntersection(java.util.List<WaySegment> wss, Node n)
private void
tryToSetBaseSegmentForAngleSnap()
This method is used to detect segment under mouse and use it as reference for angle snappingprotected void
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.private static void
updatePreservedFlag(OsmPrimitive osm, boolean state)
-
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode
actionPerformed, isEditableDataLayer, mouseClicked, mouseEntered, preferenceChanged, readPreferences, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateKeyModifiersEx, updateStatusLine
-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
addInvalidationListener, removeInvalidationListener
-
-
-
-
Field Detail
-
VIEWPORT_FOLLOWING
public static final CachingProperty<java.lang.Boolean> VIEWPORT_FOLLOWING
If this property is set, the draw action moves the viewport when adding new points.- Since:
- 12182
-
ORANGE_TRANSPARENT
private static final java.awt.Color ORANGE_TRANSPARENT
-
START_WAY_INDICATOR
private static final ArrowPaintHelper START_WAY_INDICATOR
-
USE_REPEATED_SHORTCUT
static final CachingProperty<java.lang.Boolean> USE_REPEATED_SHORTCUT
-
RUBBER_LINE_STROKE
static final CachingProperty<java.awt.BasicStroke> RUBBER_LINE_STROKE
-
HIGHLIGHT_STROKE
static final CachingProperty<java.awt.BasicStroke> HIGHLIGHT_STROKE
-
HELPER_STROKE
static final CachingProperty<java.awt.BasicStroke> HELPER_STROKE
-
SNAP_ANGLE_TOLERANCE
static final CachingProperty<java.lang.Double> SNAP_ANGLE_TOLERANCE
-
DRAW_CONSTRUCTION_GEOMETRY
static final CachingProperty<java.lang.Boolean> DRAW_CONSTRUCTION_GEOMETRY
-
SHOW_PROJECTED_POINT
static final CachingProperty<java.lang.Boolean> SHOW_PROJECTED_POINT
-
SNAP_TO_PROJECTIONS
static final CachingProperty<java.lang.Boolean> SNAP_TO_PROJECTIONS
-
SHOW_ANGLE
static final CachingProperty<java.lang.Boolean> SHOW_ANGLE
-
SNAP_HELPER_COLOR
static final CachingProperty<java.awt.Color> SNAP_HELPER_COLOR
-
HIGHLIGHT_COLOR
static final CachingProperty<java.awt.Color> HIGHLIGHT_COLOR
-
RUBBER_LINE_COLOR
static final AbstractProperty<java.awt.Color> RUBBER_LINE_COLOR
-
DRAW_HELPER_LINE
static final CachingProperty<java.lang.Boolean> DRAW_HELPER_LINE
-
DRAW_TARGET_HIGHLIGHT
static final CachingProperty<java.lang.Boolean> DRAW_TARGET_HIGHLIGHT
-
SNAP_TO_INTERSECTION_THRESHOLD
static final CachingProperty<java.lang.Double> SNAP_TO_INTERSECTION_THRESHOLD
-
cursorJoinNode
private final java.awt.Cursor cursorJoinNode
-
cursorJoinWay
private final java.awt.Cursor cursorJoinWay
-
lastUsedNode
private transient Node lastUsedNode
-
toleranceMultiplier
private double toleranceMultiplier
-
mouseOnExistingNode
private transient Node mouseOnExistingNode
-
mouseOnExistingWays
private transient java.util.Set<Way> mouseOnExistingWays
-
oldHighlights
private transient java.util.Set<OsmPrimitive> oldHighlights
-
newHighlights
private transient java.util.Set<OsmPrimitive> newHighlights
-
wayIsFinished
private boolean wayIsFinished
-
mousePos
private java.awt.Point mousePos
-
oldMousePos
private java.awt.Point oldMousePos
-
currentBaseNode
private transient Node currentBaseNode
-
previousNode
private transient Node previousNode
-
currentMouseEastNorth
private EastNorth currentMouseEastNorth
-
snapHelper
private final transient DrawSnapHelper snapHelper
-
backspaceShortcut
private final transient Shortcut backspaceShortcut
-
backspaceAction
private final DrawAction.BackSpaceAction backspaceAction
-
snappingShortcut
private final transient Shortcut snappingShortcut
-
ignoreNextKeyRelease
private boolean ignoreNextKeyRelease
-
snapChangeAction
private final DrawAction.SnapChangeAction snapChangeAction
-
snapCheckboxMenuItem
private final javax.swing.JCheckBoxMenuItem snapCheckboxMenuItem
-
BASIC_STROKE
private static final java.awt.BasicStroke BASIC_STROKE
-
rightClickPressPos
private java.awt.Point rightClickPressPos
-
-
Constructor Detail
-
DrawAction
public DrawAction()
Constructs a newDrawAction
.- Since:
- 11713
-
-
Method Detail
-
addMenuItem
private javax.swing.JCheckBoxMenuItem addMenuItem()
-
redrawIfRequired
private boolean redrawIfRequired(java.lang.Object e)
Checks if a map redraw is required and does so if needed. Also updates the status bar.- Parameters:
e
- event, can be null- Returns:
- true if a repaint is needed
-
addRemoveSelection
private static void addRemoveSelection(DataSet ds, OsmPrimitive toAdd, OsmPrimitive toRemove)
-
updatePreservedFlag
private static void updatePreservedFlag(OsmPrimitive osm, boolean state)
-
setSelection
private static void setSelection(DataSet ds, java.util.Collection<OsmPrimitive> toSet)
-
setSelection
private static void setSelection(DataSet ds, OsmPrimitive toSet)
-
addSelection
private static void addSelection(DataSet ds, OsmPrimitive toAdd)
-
clearSelection
private static void clearSelection(DataSet ds, OsmPrimitive toRemove)
-
enterMode
public void enterMode()
Description copied from class:MapMode
Makes this map mode active.
-
exitMode
public void exitMode()
Description copied from class:MapMode
Makes this map mode inactive.
-
modifiersExChanged
public void modifiersExChanged(int modifiers)
redraw to (possibly) get rid of helper line if selection changes.- Specified by:
modifiersExChanged
in interfaceModifierExListener
- Parameters:
modifiers
- The new extended modifiers
-
doKeyPressed
public void doKeyPressed(java.awt.event.KeyEvent e)
Description copied from interface:KeyPressReleaseListener
This is called when key press event is actually pressed (no fake events while holding key)- Specified by:
doKeyPressed
in interfaceKeyPressReleaseListener
- Parameters:
e
- key event
-
doKeyReleased
public void doKeyReleased(java.awt.event.KeyEvent e)
Description copied from interface:KeyPressReleaseListener
This is called when key press event is actually released (no fake events while holding key)- Specified by:
doKeyReleased
in interfaceKeyPressReleaseListener
- Parameters:
e
- key event
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
redraw to (possibly) get rid of helper line if selection changes.- Specified by:
selectionChanged
in interfaceDataSelectionListener
- Parameters:
event
- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
tryAgain
private void tryAgain(java.awt.event.MouseEvent e)
-
finishDrawing
private void finishDrawing()
This function should be called when the user wishes to finish his current draw action. If Potlatch Style is enabled, it will switch to select tool, otherwise simply disable the helper line until the user chooses to draw something else.
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classMapMode
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
If user clicked with the left button, add a node at the current mouse position. If in nodeway mode, insert the node into the way.- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classMapMode
-
getTitle
private static java.lang.String getTitle(boolean newNode, Node n, java.util.Collection<OsmPrimitive> newSelection, java.util.Map<Way,java.util.List<Node>> reuseWays, boolean extendedWay)
-
insertNodeIntoAllNearbySegments
private void insertNodeIntoAllNearbySegments(java.util.List<WaySegment> wss, Node n, java.util.Collection<OsmPrimitive> newSelection, java.util.Collection<Command> cmds, java.util.Map<Way,java.util.List<Node>> reuseWays)
-
isSelfContainedWay
private boolean isSelfContainedWay(Way selectedWay, Node currentNode, Node targetNode)
Prevent creation of ways that look like this: <----> This happens if users want to draw a no-exit-sideway from the main way like this: ^ |<----> | The solution isn't ideal because the main way will end in the side way, which is bad for navigation software ("drive straight on") but at least easier to fix. Maybe users will fix it on their own, too. At least it's better than producing an error.- Parameters:
selectedWay
- the way to checkcurrentNode
- the current node (i.e. the one the connection will be made from)targetNode
- the target node (i.e. the one the connection will be made to)- Returns:
true
if this would create a selfcontaining way,false
otherwise.
-
findNodeToContinueFrom
private Node findNodeToContinueFrom(Node selectedNode, Way selectedWay)
Finds a node to continue drawing from. Decision is based upon given node and way.- Parameters:
selectedNode
- Currently selected node, may be nullselectedWay
- Currently selected way, may be null- Returns:
- Node if a suitable node is found, null otherwise
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseDragged
in classMapMode
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
in classMapMode
-
tryToSetBaseSegmentForAngleSnap
private void tryToSetBaseSegmentForAngleSnap()
This method is used to detect segment under mouse and use it as reference for angle snapping
-
computeHelperLine
private void computeHelperLine()
This method prepares data required for painting the "helper line" from the last used position to the mouse cursor. It duplicates some code from mouseReleased() (FIXME).
-
showStatusInfo
static void showStatusInfo(double angle, double hdg, double distance, boolean activeFlag)
-
determineCurrentBaseNodeAndPreviousNode
private void determineCurrentBaseNodeAndPreviousNode(java.util.Collection<OsmPrimitive> selection)
Helper function that sets fields currentBaseNode and previousNode- Parameters:
selection
- uses also lastUsedNode field
-
continueWayFromNode
private void continueWayFromNode(Way way, Node node)
if one of the ends ofway
is givennode
, then set currentBaseNode = node and previousNode = adjacent node of way- Parameters:
way
- way to continuenode
- starting node
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
Repaint on mouse exit so that the helper line goes away.- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
- Overrides:
mouseExited
in classMapMode
-
getWayForNode
public static Way getWayForNode(Node n)
Replies the parent way of a node, if it is the end of exactly one usable way.- Parameters:
n
- node- Returns:
- If the node is the end of exactly one way, return this.
null
otherwise.
-
getCurrentBaseNode
public Node getCurrentBaseNode()
Replies the current base node, after having checked it is still usable (see #11105).- Returns:
- the current base node (can be null). If not-null, it's guaranteed the node is usable
-
pruneSuccsAndReverse
private static void pruneSuccsAndReverse(java.util.List<java.lang.Integer> is)
-
adjustNode
private static void adjustNode(java.util.Collection<Pair<Node,Node>> segs, Node n)
Adjusts the position of a node to lie on a segment (or a segment intersection). If one or more than two segments are passed, the node is adjusted to lie on the first segment that is passed. If two segments are passed, the node is adjusted to be at their intersection. No action is taken if no segments are passed.- Parameters:
segs
- the segments to use as a reference when adjustingn
- the node to adjust
-
adjustNodeTwoSegments
private static void adjustNodeTwoSegments(java.util.Collection<Pair<Node,Node>> segs, Node n)
-
adjustNodeDefault
private static void adjustNodeDefault(java.util.Collection<Pair<Node,Node>> segs, Node n)
-
det
static double det(double a, double b, double c, double d)
-
tryToMoveNodeOnIntersection
private void tryToMoveNodeOnIntersection(java.util.List<WaySegment> wss, Node n)
-
addHighlighting
private void addHighlighting(java.lang.Object event)
Takes the data from computeHelperLine to determine which ways/nodes should be highlighted (if feature enabled). Also sets the target cursor if appropriate. It adds the to-be- highlighted primitives to newHighlights but does not actually highlight them. This work is done in redrawIfRequired. This means, calling addHighlighting() without redrawIfRequired() will leave the data in an inconsistent state. The status bar derives its information from oldHighlights, so in order to update the status bar both addHighlighting() and repaintIfRequired() are needed, since former fills newHighlights and latter processes them into oldHighlights.- Parameters:
event
- event, can be null
-
removeHighlighting
private boolean removeHighlighting(java.lang.Object event)
Removes target highlighting from primitives. Issues repaint if required.- Parameters:
event
- event, can be null- Returns:
- true if a repaint has been issued.
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Description copied from interface:MapViewPaintable
Paint the dataset using the engine set.- Specified by:
paint
in interfaceMapViewPaintable
- Parameters:
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.box
- Bounding box
-
paintConstructionGeometry
private void paintConstructionGeometry(MapView mv, java.awt.Graphics2D g2)
-
getModeHelpText
public java.lang.String getModeHelpText()
Description copied from class:MapMode
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.- Overrides:
getModeHelpText
in classMapMode
- Returns:
- a short translated help message describing how this map mode can be used
-
getInProgressSelection
public java.util.Collection<OsmPrimitive> getInProgressSelection()
Get selected primitives, while draw action is in progress. While drawing a way, technically the last node is selected. This is inconvenient when the user tries to add/edit tags to the way. For this case, this method returns the current way as selection, to work around this issue. Otherwise the normal selection of the current data layer is returned.- Returns:
- selected primitives, while draw action is in progress
-
layerIsSupported
public boolean layerIsSupported(Layer l)
Description copied from class:MapMode
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- Overrides:
layerIsSupported
in classMapMode
- Parameters:
l
- layer- Returns:
true
if the layer is supported by this map mode
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmAction
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. when a layer is removed or added. SeeJosmAction.updateEnabledState(Collection)
to respond to changes in the collection of selected primitives. Default behavior is empty.- Overrides:
updateEnabledState
in classJosmAction
- See Also:
JosmAction.updateEnabledState(Collection)
,JosmAction.initEnabledState()
,JosmAction.listenToLayerChange()
-
destroy
public void destroy()
Description copied from interface:Destroyable
Called when the object has been destroyed.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classJosmAction
-
-