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 class
ParallelWayAction.KeyboardModifiersProperty
A property that holds the keyboard modifiers.(package private) static class
ParallelWayAction.Mode
(package private) static class
ParallelWayAction.Modifier
private class
ParallelWayAction.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 void
addSourceWay(Way w)
private void
clearSourceWays()
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.private boolean
initParallelWays(java.awt.Point p, boolean copyTags)
private boolean
isModifiersValidForDragMode()
boolean
layerIsSupported(Layer l)
Determines if layerl
is supported by this map mode.private boolean
matchesCurrentModifiers(java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean> spec)
private boolean
matchesCurrentModifiers(CachingProperty<java.util.Map<ParallelWayAction.Modifier,java.lang.Boolean>> spec)
void
modifiersExChanged(int modifiers)
Called when the extended modifiers are changedvoid
mouseDragged(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
private static java.lang.String
prefKey(java.lang.String subKey)
private void
removeSourceWay(Way w)
private static void
removeWayHighlighting(java.util.Collection<Way> ways)
private void
resetMouseTrackingState()
private boolean
sanityCheck()
private void
setMode(ParallelWayAction.Mode mode)
private void
updateCursor()
private void
updateFlagsChangeableAlways()
private void
updateFlagsOnlyChangeableOnPress()
private boolean
updateModifiersState(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:MapMode
Makes this map mode active.
-
exitMode
public void exitMode()
Description copied from class:MapMode
Makes this map mode inactive.
-
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
-
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
-
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:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classMapMode
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classMapMode
-
removeWayHighlighting
private static void removeWayHighlighting(java.util.Collection<Way> ways)
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseDragged
in 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)
-
-