Class ImproveWayAccuracyAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- org.openstreetmap.josm.actions.mapmode.ImproveWayAccuracyAction
-
- 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
,DataSetListener
,ModifierExListener
,PreferenceChangedListener
,Destroyable
public class ImproveWayAccuracyAction extends MapMode implements DataSelectionListener, DataSetListener, ModifierExListener
A special map mode that is optimized for improving way geometry. (by efficiently moving, adding and deleting way-nodes)- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ImproveWayAccuracyAction.State
-
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
-
-
Field Summary
Fields Modifier and Type Field Description private static CachingProperty<java.awt.BasicStroke>
ADD_NODE_STROKE
private Node
candidateNode
private WaySegment
candidateSegment
private static java.lang.String
CROSSHAIR
private java.awt.Cursor
cursorImprove
private java.awt.Cursor
cursorImproveAdd
private java.awt.Cursor
cursorImproveAddLock
private java.awt.Cursor
cursorImproveDelete
private java.awt.Cursor
cursorImproveLock
private java.awt.Cursor
cursorSelect
private java.awt.Cursor
cursorSelectHover
private static CachingProperty<java.awt.BasicStroke>
DELETE_NODE_STROKE
private static CachingProperty<java.lang.Integer>
DOT_SIZE
private boolean
dragging
private java.awt.Color
guideColor
private java.awt.Point
mousePos
private static CachingProperty<java.awt.BasicStroke>
MOVE_NODE_INTERSECTING_STROKE
private static CachingProperty<java.awt.BasicStroke>
MOVE_NODE_STROKE
private MapView
mv
protected java.lang.String
oldModeHelpText
private static CachingProperty<java.awt.BasicStroke>
SELECT_TARGET_WAY_STROKE
private boolean
selectionChangedBlocked
private static long
serialVersionUID
private ImproveWayAccuracyAction.State
state
private Way
targetWay
private AbstractMapViewPaintable
temporaryLayer
-
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 ImproveWayAccuracyAction()
Constructs a newImproveWayAccuracyAction
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addNode(DataSet ds)
Add a new node to the currently highlighted segmentvoid
dataChanged(DataChangedEvent event)
Called after big changes in dataset.private void
deleteHighlightedNode()
Delete the highlighted nodeprotected void
drawIntersectingWayHelperLines(MapView mv, MapViewPath b)
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.boolean
layerIsSupported(Layer l)
Determines if layerl
is supported by this map mode.void
modifiersExChanged(int modifiers)
Called when the extended modifiers are changedvoid
mouseDragged(java.awt.event.MouseEvent e)
void
mouseExited(java.awt.event.MouseEvent e)
void
mouseMoved(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
private void
moveHighlightedNode()
Move the highlighted nodevoid
nodeMoved(NodeMovedEvent event)
A node's coordinates were modified.void
otherDatasetChange(AbstractDatasetChangedEvent event)
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.void
paint(java.awt.Graphics2D g, MapView mv, Bounds bbox)
Redraws temporary layer.private void
paintAddNodeStroke(java.awt.Graphics2D g)
Paint the add stroke forImproveWayAccuracyAction.State.IMPROVING
private void
paintDeleteStroke(java.awt.Graphics2D g)
Paint the delete stroke forImproveWayAccuracyAction.State.IMPROVING
private void
paintImprovingPreviewLines(java.awt.Graphics2D g, ILatLon p1, ILatLon p2)
Paint the preview lines forImproveWayAccuracyAction.State.IMPROVING
private void
paintMoveNodeStroke(java.awt.Graphics2D g)
Paint the move stroke forImproveWayAccuracyAction.State.IMPROVING
void
primitivesAdded(PrimitivesAddedEvent event)
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.void
primitivesRemoved(PrimitivesRemovedEvent event)
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.protected void
readPreferences()
void
relationMembersChanged(RelationMembersChangedEvent event)
A relation's members have changed.void
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.private boolean
selectWay(DataSet ds)
Select the initial wayvoid
startImproving(Way targetWay)
Switches to Improving statevoid
startSelecting()
Switches to Selecting statevoid
tagsChanged(TagsChangedEvent event)
There was some change in the tag set of a primitive.private void
updateCursor()
Sets new cursor depending on state, mouse positionvoid
updateCursorDependentObjectsIfNeeded()
Updates these objects under cursor: targetWay, candidateNode, candidateSegmentprivate void
updateCursorImproving()
Update the mouse cursor for theImproveWayAccuracyAction.State.IMPROVING
modeprotected void
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.private void
updateStateByCurrentSelection()
Updates the state according to the current selection.protected void
updateStatusLine()
void
wayNodesChanged(WayNodesChangedEvent event)
A way's node list was changed.-
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode
actionPerformed, isEditableDataLayer, mouseClicked, mouseEntered, mousePressed, preferenceChanged, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateKeyModifiersEx
-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, 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.data.osm.event.DataSetListener
dataChangedIndividualEvents
-
-
-
-
Field Detail
-
CROSSHAIR
private static final java.lang.String CROSSHAIR
- See Also:
- Constant Field Values
-
state
private ImproveWayAccuracyAction.State state
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
candidateNode
private transient Node candidateNode
-
candidateSegment
private transient WaySegment candidateSegment
-
mousePos
private java.awt.Point mousePos
-
dragging
private boolean dragging
-
cursorSelect
private final java.awt.Cursor cursorSelect
-
cursorSelectHover
private final java.awt.Cursor cursorSelectHover
-
cursorImprove
private final java.awt.Cursor cursorImprove
-
cursorImproveAdd
private final java.awt.Cursor cursorImproveAdd
-
cursorImproveDelete
private final java.awt.Cursor cursorImproveDelete
-
cursorImproveAddLock
private final java.awt.Cursor cursorImproveAddLock
-
cursorImproveLock
private final java.awt.Cursor cursorImproveLock
-
guideColor
private java.awt.Color guideColor
-
SELECT_TARGET_WAY_STROKE
private static final CachingProperty<java.awt.BasicStroke> SELECT_TARGET_WAY_STROKE
-
MOVE_NODE_STROKE
private static final CachingProperty<java.awt.BasicStroke> MOVE_NODE_STROKE
-
MOVE_NODE_INTERSECTING_STROKE
private static final CachingProperty<java.awt.BasicStroke> MOVE_NODE_INTERSECTING_STROKE
-
ADD_NODE_STROKE
private static final CachingProperty<java.awt.BasicStroke> ADD_NODE_STROKE
-
DELETE_NODE_STROKE
private static final CachingProperty<java.awt.BasicStroke> DELETE_NODE_STROKE
-
DOT_SIZE
private static final CachingProperty<java.lang.Integer> DOT_SIZE
-
selectionChangedBlocked
private boolean selectionChangedBlocked
-
oldModeHelpText
protected java.lang.String oldModeHelpText
-
temporaryLayer
private final transient AbstractMapViewPaintable temporaryLayer
-
-
Constructor Detail
-
ImproveWayAccuracyAction
public ImproveWayAccuracyAction()
Constructs a newImproveWayAccuracyAction
.- Since:
- 11713
-
-
Method Detail
-
enterMode
public void enterMode()
Description copied from class:MapMode
Makes this map mode active.
-
readPreferences
protected void readPreferences()
- Overrides:
readPreferences
in classMapMode
-
exitMode
public void exitMode()
Description copied from class:MapMode
Makes this map mode inactive.
-
updateStatusLine
protected void updateStatusLine()
- Overrides:
updateStatusLine
in classMapMode
-
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
-
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()
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds bbox)
Redraws temporary layer. Highlights targetWay in select mode. Draws preview lines in improve mode and highlights the candidateNode- Parameters:
g
- The graphicsmv
- The map viewbbox
- The bounding box
-
paintAddNodeStroke
private void paintAddNodeStroke(java.awt.Graphics2D g)
Paint the add stroke forImproveWayAccuracyAction.State.IMPROVING
- Parameters:
g
- The graphics
-
paintMoveNodeStroke
private void paintMoveNodeStroke(java.awt.Graphics2D g)
Paint the move stroke forImproveWayAccuracyAction.State.IMPROVING
- Parameters:
g
- The graphics
-
paintDeleteStroke
private void paintDeleteStroke(java.awt.Graphics2D g)
Paint the delete stroke forImproveWayAccuracyAction.State.IMPROVING
- Parameters:
g
- The graphics
-
paintImprovingPreviewLines
private void paintImprovingPreviewLines(java.awt.Graphics2D g, ILatLon p1, ILatLon p2)
Paint the preview lines forImproveWayAccuracyAction.State.IMPROVING
- Parameters:
g
- The graphicsp1
- The first endpointp2
- The second endpoint
-
drawIntersectingWayHelperLines
protected void drawIntersectingWayHelperLines(MapView mv, MapViewPath b)
-
modifiersExChanged
public void modifiersExChanged(int modifiers)
Description copied from interface:ModifierExListener
Called when the extended modifiers are changed- Specified by:
modifiersExChanged
in interfaceModifierExListener
- Parameters:
modifiers
- The new extended modifiers
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListener
Called whenever the selection is changed. You get notified about the new selection, the elements that were added and removed and the layer that triggered the event.- Specified by:
selectionChanged
in interfaceDataSelectionListener
- Parameters:
event
- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
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
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classMapMode
-
addNode
private void addNode(DataSet ds)
Add a new node to the currently highlighted segment- Parameters:
ds
- The dataset to add the node to
-
deleteHighlightedNode
private void deleteHighlightedNode()
Delete the highlighted node
-
moveHighlightedNode
private void moveHighlightedNode()
Move the highlighted node
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
- Overrides:
mouseExited
in classMapMode
-
updateCursor
private void updateCursor()
Sets new cursor depending on state, mouse position
-
updateCursorImproving
private void updateCursorImproving()
Update the mouse cursor for theImproveWayAccuracyAction.State.IMPROVING
mode
-
updateCursorDependentObjectsIfNeeded
public void updateCursorDependentObjectsIfNeeded()
Updates these objects under cursor: targetWay, candidateNode, candidateSegment
-
startSelecting
public void startSelecting()
Switches to Selecting state
-
startImproving
public void startImproving(Way targetWay)
Switches to Improving state- Parameters:
targetWay
- Way that is going to be improved
-
updateStateByCurrentSelection
private void updateStateByCurrentSelection()
Updates the state according to the current selection. Goes to Improve state if a single way or node is selected. Extracts a way by a node in the second case.
-
selectWay
private boolean selectWay(DataSet ds)
Select the initial way- Parameters:
ds
- The dataset to get the selection from- Returns:
true
if a way was selected
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemoved
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-invisible primitives
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAdded
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-visible primitives
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListener
There was some change in the tag set of a primitive. It can have been a tag addition, tag removal or change in tag value.- Specified by:
tagsChanged
in interfaceDataSetListener
- Parameters:
event
- the event for the primitive, whose tags were affected.
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListener
A node's coordinates were modified.- Specified by:
nodeMoved
in interfaceDataSetListener
- Parameters:
event
- The event for the node that was moved.
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListener
A way's node list was changed.- Specified by:
wayNodesChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the way that was modified.
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListener
A relation's members have changed.- Specified by:
relationMembersChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the relation that was modified.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListener
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChange
in interfaceDataSetListener
- Parameters:
event
- the event for data modification
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListener
Called after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and after operation is completed (Dataset.endUpdate()),DataSetListener.dataChanged(DataChangedEvent event)
is called.- Specified by:
dataChanged
in interfaceDataSetListener
- Parameters:
event
- data change event
-
-