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 classImproveWayAccuracyAction.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_STROKEprivate NodecandidateNodeprivate WaySegmentcandidateSegmentprivate static java.lang.StringCROSSHAIRprivate java.awt.CursorcursorImproveprivate java.awt.CursorcursorImproveAddprivate java.awt.CursorcursorImproveAddLockprivate java.awt.CursorcursorImproveDeleteprivate java.awt.CursorcursorImproveLockprivate java.awt.CursorcursorSelectprivate java.awt.CursorcursorSelectHoverprivate static CachingProperty<java.awt.BasicStroke>DELETE_NODE_STROKEprivate static CachingProperty<java.lang.Integer>DOT_SIZEprivate booleandraggingprivate java.awt.ColorguideColorprivate java.awt.PointmousePosprivate static CachingProperty<java.awt.BasicStroke>MOVE_NODE_INTERSECTING_STROKEprivate static CachingProperty<java.awt.BasicStroke>MOVE_NODE_STROKEprivate MapViewmvprotected java.lang.StringoldModeHelpTextprivate static CachingProperty<java.awt.BasicStroke>SELECT_TARGET_WAY_STROKEprivate booleanselectionChangedBlockedprivate static longserialVersionUIDprivate ImproveWayAccuracyAction.Statestateprivate WaytargetWayprivate AbstractMapViewPaintabletemporaryLayer-
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 voidaddNode(DataSet ds)Add a new node to the currently highlighted segmentvoiddataChanged(DataChangedEvent event)Called after big changes in dataset.private voiddeleteHighlightedNode()Delete the highlighted nodeprotected voiddrawIntersectingWayHelperLines(MapView mv, MapViewPath b)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.booleanlayerIsSupported(Layer l)Determines if layerlis supported by this map mode.voidmodifiersExChanged(int modifiers)Called when the extended modifiers are changedvoidmouseDragged(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)private voidmoveHighlightedNode()Move the highlighted nodevoidnodeMoved(NodeMovedEvent event)A node's coordinates were modified.voidotherDatasetChange(AbstractDatasetChangedEvent event)Minor dataset change, currently only changeset id changed is supported, but can be extended in future.voidpaint(java.awt.Graphics2D g, MapView mv, Bounds bbox)Redraws temporary layer.private voidpaintAddNodeStroke(java.awt.Graphics2D g)Paint the add stroke forImproveWayAccuracyAction.State.IMPROVINGprivate voidpaintDeleteStroke(java.awt.Graphics2D g)Paint the delete stroke forImproveWayAccuracyAction.State.IMPROVINGprivate voidpaintImprovingPreviewLines(java.awt.Graphics2D g, ILatLon p1, ILatLon p2)Paint the preview lines forImproveWayAccuracyAction.State.IMPROVINGprivate voidpaintMoveNodeStroke(java.awt.Graphics2D g)Paint the move stroke forImproveWayAccuracyAction.State.IMPROVINGvoidprimitivesAdded(PrimitivesAddedEvent event)A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.voidprimitivesRemoved(PrimitivesRemovedEvent event)A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.protected voidreadPreferences()voidrelationMembersChanged(RelationMembersChangedEvent event)A relation's members have changed.voidselectionChanged(DataSelectionListener.SelectionChangeEvent event)Called whenever the selection is changed.private booleanselectWay(DataSet ds)Select the initial wayvoidstartImproving(Way targetWay)Switches to Improving statevoidstartSelecting()Switches to Selecting statevoidtagsChanged(TagsChangedEvent event)There was some change in the tag set of a primitive.private voidupdateCursor()Sets new cursor depending on state, mouse positionvoidupdateCursorDependentObjectsIfNeeded()Updates these objects under cursor: targetWay, candidateNode, candidateSegmentprivate voidupdateCursorImproving()Update the mouse cursor for theImproveWayAccuracyAction.State.IMPROVINGmodeprotected voidupdateEnabledState()Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.private voidupdateStateByCurrentSelection()Updates the state according to the current selection.protected voidupdateStatusLine()voidwayNodesChanged(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:MapModeMakes this map mode active.
-
readPreferences
protected void readPreferences()
- Overrides:
readPreferencesin classMapMode
-
exitMode
public void exitMode()
Description copied from class:MapModeMakes this map mode inactive.
-
updateStatusLine
protected void updateStatusLine()
- Overrides:
updateStatusLinein classMapMode
-
getModeHelpText
public java.lang.String getModeHelpText()
Description copied from class:MapModeReturns a short translated help message describing how this map mode can be used, to be displayed in status line.- Overrides:
getModeHelpTextin 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:MapModeDetermines 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- Overrides:
layerIsSupportedin classMapMode- Parameters:
l- layer- Returns:
trueif the layer is supported by this map mode
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmActionOverride 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:
updateEnabledStatein 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:ModifierExListenerCalled when the extended modifiers are changed- Specified by:
modifiersExChangedin interfaceModifierExListener- Parameters:
modifiers- The new extended modifiers
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListenerCalled 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:
selectionChangedin interfaceDataSelectionListener- Parameters:
event- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseDraggedin classMapMode
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseMovedin classMapMode
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Overrides:
mouseReleasedin 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:
mouseExitedin interfacejava.awt.event.MouseListener- Overrides:
mouseExitedin classMapMode
-
updateCursor
private void updateCursor()
Sets new cursor depending on state, mouse position
-
updateCursorImproving
private void updateCursorImproving()
Update the mouse cursor for theImproveWayAccuracyAction.State.IMPROVINGmode
-
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:
trueif a way was selected
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListenerA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemovedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-invisible primitives
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListenerA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAddedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-visible primitives
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListenerThere 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:
tagsChangedin interfaceDataSetListener- Parameters:
event- the event for the primitive, whose tags were affected.
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListenerA node's coordinates were modified.- Specified by:
nodeMovedin interfaceDataSetListener- Parameters:
event- The event for the node that was moved.
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListenerA way's node list was changed.- Specified by:
wayNodesChangedin interfaceDataSetListener- Parameters:
event- The event for the way that was modified.
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListenerA relation's members have changed.- Specified by:
relationMembersChangedin interfaceDataSetListener- Parameters:
event- The event for the relation that was modified.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListenerMinor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChangein interfaceDataSetListener- Parameters:
event- the event for data modification
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListenerCalled 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:
dataChangedin interfaceDataSetListener- Parameters:
event- data change event
-
-