Class ParallelWayAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- org.openstreetmap.josm.actions.mapmode.ParallelWayAction
-
- 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,ModifierExListener,PreferenceChangedListener,Destroyable
public class ParallelWayAction extends MapMode implements ModifierExListener
MapMode for making parallel ways.All calculations are done in projected coordinates.
TODO:
== Functionality ==
- Use selected nodes as split points for the selected ways.
The ways containing the selected nodes will be split and only the "inner" parts will be copied
- Enter exact offset
- Improve snapping
- Visual cues could be better
- (long term) Parallelize and adjust offsets of existing ways
- The mode, flags, and modifiers might be updated more than necessary.
Not a performance problem, but better if they where more centralized
- Extract generic MapMode services into a super class and/or utility class
- Maybe better to simply draw our own source way highlighting?
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classParallelWayAction.KeyboardModifiersPropertyA property that holds the keyboard modifiers.(package private) static classParallelWayAction.Mode(package private) static classParallelWayAction.Modifierprivate classParallelWayAction.ParallelWayLayer-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
-
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 ParallelWayAction(MapFrame mapFrame)Constructs a newParallelWayAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddSourceWay(Way w)private voidclearSourceWays()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.private booleaninitParallelWays(java.awt.Point p, boolean copyTags)private booleanisModifiersValidForDragMode()booleanlayerIsSupported(Layer l)Determines if layerlis supported by this map mode.private booleanmatchesCurrentModifiers(java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean> spec)private booleanmatchesCurrentModifiers(CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> spec)voidmodifiersExChanged(int modifiers)Called when the extended modifiers are changedvoidmouseDragged(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)private static java.lang.StringprefKey(java.lang.String subKey)private voidremoveSourceWay(Way w)private static voidremoveWayHighlighting(java.util.Collection<Way> ways)private voidresetMouseTrackingState()private booleansanityCheck()private voidsetMode(ParallelWayAction.Mode mode)private voidupdateCursor()private voidupdateFlagsChangeableAlways()private voidupdateFlagsOnlyChangeableOnPress()private booleanupdateModifiersState(int modifiers)-
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode
actionPerformed, isEditableDataLayer, mouseClicked, mouseEntered, mouseExited, mouseMoved, preferenceChanged, readPreferences, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateKeyModifiersEx, 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
-
-
-
-
Field Detail
-
HELPER_LINE_STROKE
private static final CachingProperty<java.awt.BasicStroke> HELPER_LINE_STROKE
-
REF_LINE_STROKE
private static final CachingProperty<java.awt.BasicStroke> REF_LINE_STROKE
-
SNAP_THRESHOLD
private static final CachingProperty<java.lang.Double> SNAP_THRESHOLD
-
SNAP_DEFAULT
private static final CachingProperty<java.lang.Boolean> SNAP_DEFAULT
-
COPY_TAGS_DEFAULT
private static final CachingProperty<java.lang.Boolean> COPY_TAGS_DEFAULT
-
INITIAL_MOVE_DELAY
private static final CachingProperty<java.lang.Integer> INITIAL_MOVE_DELAY
-
SNAP_DISTANCE_METRIC
private static final CachingProperty<java.lang.Double> SNAP_DISTANCE_METRIC
-
SNAP_DISTANCE_IMPERIAL
private static final CachingProperty<java.lang.Double> SNAP_DISTANCE_IMPERIAL
-
SNAP_DISTANCE_CHINESE
private static final CachingProperty<java.lang.Double> SNAP_DISTANCE_CHINESE
-
SNAP_DISTANCE_NAUTICAL
private static final CachingProperty<java.lang.Double> SNAP_DISTANCE_NAUTICAL
-
MAIN_COLOR
private static final CachingProperty<java.awt.Color> MAIN_COLOR
-
SNAP_MODIFIER_COMBO
private static final CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> SNAP_MODIFIER_COMBO
-
COPY_TAGS_MODIFIER_COMBO
private static final CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> COPY_TAGS_MODIFIER_COMBO
-
ADD_TO_SELECTION_MODIFIER_COMBO
private static final CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> ADD_TO_SELECTION_MODIFIER_COMBO
-
TOGGLE_SELECTED_MODIFIER_COMBO
private static final CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> TOGGLE_SELECTED_MODIFIER_COMBO
-
SET_SELECTED_MODIFIER_COMBO
private static final CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> SET_SELECTED_MODIFIER_COMBO
-
mode
private ParallelWayAction.Mode mode
-
copyTags
private boolean copyTags
-
snap
private boolean snap
-
mousePressedPos
private java.awt.Point mousePressedPos
-
mouseIsDown
private boolean mouseIsDown
-
mousePressedTime
private long mousePressedTime
-
mouseHasBeenDragged
private boolean mouseHasBeenDragged
-
referenceSegment
private transient WaySegment referenceSegment
-
pWays
private transient ParallelWays pWays
-
sourceWays
private transient java.util.Set<Way> sourceWays
-
helperLineStart
private EastNorth helperLineStart
-
helperLineEnd
private EastNorth helperLineEnd
-
temporaryLayer
private final ParallelWayAction.ParallelWayLayer temporaryLayer
-
-
Constructor Detail
-
ParallelWayAction
public ParallelWayAction(MapFrame mapFrame)
Constructs a newParallelWayAction.- Parameters:
mapFrame- Map frame
-
-
Method Detail
-
enterMode
public void enterMode()
Description copied from class:MapModeMakes this map mode active.
-
exitMode
public void exitMode()
Description copied from class:MapModeMakes this map mode inactive.
-
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
-
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
-
updateModifiersState
private boolean updateModifiersState(int modifiers)
-
updateCursor
private void updateCursor()
-
setMode
private void setMode(ParallelWayAction.Mode mode)
-
sanityCheck
private boolean sanityCheck()
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Overrides:
mousePressedin classMapMode
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Overrides:
mouseReleasedin classMapMode
-
removeWayHighlighting
private static void removeWayHighlighting(java.util.Collection<Way> ways)
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseDraggedin classMapMode
-
matchesCurrentModifiers
private boolean matchesCurrentModifiers(CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> spec)
-
matchesCurrentModifiers
private boolean matchesCurrentModifiers(java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean> spec)
-
isModifiersValidForDragMode
private boolean isModifiersValidForDragMode()
-
updateFlagsOnlyChangeableOnPress
private void updateFlagsOnlyChangeableOnPress()
-
updateFlagsChangeableAlways
private void updateFlagsChangeableAlways()
-
addSourceWay
private void addSourceWay(Way w)
-
removeSourceWay
private void removeSourceWay(Way w)
-
clearSourceWays
private void clearSourceWays()
-
resetMouseTrackingState
private void resetMouseTrackingState()
-
initParallelWays
private boolean initParallelWays(java.awt.Point p, boolean copyTags)
-
prefKey
private static java.lang.String prefKey(java.lang.String subKey)
-
-