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:
ActionListener
,MouseListener
,MouseMotionListener
,Serializable
,Cloneable
,EventListener
,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 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 Constructor Description ImproveWayAccuracyAction()
Constructs a newImproveWayAccuracyAction
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dataChanged(DataChangedEvent event)
Called after big changes in dataset.protected void
drawIntersectingWayHelperLines(MapView mv, MapViewPath b)
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.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(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
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(Graphics2D g, MapView mv, Bounds bbox)
Redraws temporary layer.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.void
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, candidateSegmentprotected 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
-
-
-
-
Field Detail
-
CROSSHAIR
private static final 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
-
dragging
private boolean dragging
-
cursorSelect
private final Cursor cursorSelect
-
cursorSelectHover
private final Cursor cursorSelectHover
-
cursorImprove
private final Cursor cursorImprove
-
cursorImproveAdd
private final Cursor cursorImproveAdd
-
cursorImproveDelete
private final Cursor cursorImproveDelete
-
cursorImproveAddLock
private final Cursor cursorImproveAddLock
-
cursorImproveLock
private final Cursor cursorImproveLock
-
guideColor
private Color guideColor
-
SELECT_TARGET_WAY_STROKE
private static final CachingProperty<BasicStroke> SELECT_TARGET_WAY_STROKE
-
MOVE_NODE_STROKE
private static final CachingProperty<BasicStroke> MOVE_NODE_STROKE
-
MOVE_NODE_INTERSECTING_STROKE
private static final CachingProperty<BasicStroke> MOVE_NODE_INTERSECTING_STROKE
-
ADD_NODE_STROKE
private static final CachingProperty<BasicStroke> ADD_NODE_STROKE
-
DELETE_NODE_STROKE
private static final CachingProperty<BasicStroke> DELETE_NODE_STROKE
-
DOT_SIZE
private static final CachingProperty<Integer> DOT_SIZE
-
selectionChangedBlocked
private boolean selectionChangedBlocked
-
oldModeHelpText
protected 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 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(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
-
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(MouseEvent e)
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classMapMode
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classMapMode
-
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classMapMode
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classMapMode
-
updateCursor
private void updateCursor()
Sets new cursor depending on state, mouse position
-
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.
-
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
-
-