Class SplitMode
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.mapmode.MapMode
-
- org.openstreetmap.josm.actions.mapmode.SplitMode
-
- 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
,PreferenceChangedListener
,Destroyable
public class SplitMode extends MapMode
Map mode for splitting ways.- Since:
- 18759
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SplitMode.SplitWayActionConcrete
Split a specifiedWay
at the given nodes-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description (package private) HighlightHelper
highlight
Helper to keep track of highlighted primitives(package private) static CachingProperty<java.lang.Boolean>
IGNORE_DISABLED_WAYS
Don't consider disabled ways(package private) static CachingProperty<java.lang.Boolean>
PREFER_SELECTED_WAYS
Prioritized selected ways over others when splitting-
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 SplitMode()
Construct a new SplitMode object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHoverHighlightListener(java.awt.Component c, java.util.Collection<OsmPrimitive> prims)
Add a mouse listener to the componentc
which highlightsprims
when the mouse pointer is hovering over the componentprivate void
addNodeAndSplit(MapView mv, java.awt.Point mousePos, Way way)
Add a node to a way and then split itprivate static java.lang.String
createLabelText(OsmPrimitive primitive)
Create the text for aOsmPrimitive
label, including its keysprivate static java.lang.String
createLabelText(OsmPrimitive primitive, boolean includeKeys)
Create the text for aOsmPrimitive
labelprivate javax.swing.JPopupMenu
createPopup(Node n, java.util.Collection<Way> applicableWays)
Create a new split way selection popupvoid
enterMode()
Makes this map mode active.void
exitMode()
Makes this map mode inactive.private static java.util.List<Way>
getApplicableWays(Node n, java.util.Collection<Way> preferredWays)
Get a list of potential ways to be split for a given nodejava.lang.String
getModeHelpText()
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.private static java.util.Optional<OsmPrimitive>
getPrimitiveAtPoint(java.awt.Point p)
boolean
layerIsSupported(Layer l)
Determines if layerl
is supported by this map mode.void
mouseMoved(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
private boolean
removeHighlighting()
Removes all existing highlights.private boolean
updateUserFeedback(java.awt.event.MouseEvent e)
Determine objects to highlight and update highlight-
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode
actionPerformed, isEditableDataLayer, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseReleased, 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
-
PREFER_SELECTED_WAYS
static final CachingProperty<java.lang.Boolean> PREFER_SELECTED_WAYS
Prioritized selected ways over others when splitting
-
IGNORE_DISABLED_WAYS
static final CachingProperty<java.lang.Boolean> IGNORE_DISABLED_WAYS
Don't consider disabled ways
-
highlight
HighlightHelper highlight
Helper to keep track of highlighted primitives
-
-
Constructor Detail
-
SplitMode
public SplitMode()
Construct a new SplitMode object
-
-
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.
-
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
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classMapMode
-
addNodeAndSplit
private void addNodeAndSplit(MapView mv, java.awt.Point mousePos, Way way)
Add a node to a way and then split it- Parameters:
mv
- The current mapviewmousePos
- The mouse positionway
- The nearest way
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
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
-
getPrimitiveAtPoint
private static java.util.Optional<OsmPrimitive> getPrimitiveAtPoint(java.awt.Point p)
-
getApplicableWays
private static java.util.List<Way> getApplicableWays(Node n, java.util.Collection<Way> preferredWays)
Get a list of potential ways to be split for a given node- Parameters:
n
- The node at which ways should be splitpreferredWays
- List of ways that should be prioritized over others. If one or more potential preferred ways are found, other ways are disregarded.- Returns:
- List of potential ways to be split
-
createPopup
private javax.swing.JPopupMenu createPopup(Node n, java.util.Collection<Way> applicableWays)
Create a new split way selection popup- Parameters:
n
- Node at which ways should be splitapplicableWays
- Potential split ways to select from- Returns:
- A new popup object
-
updateUserFeedback
private boolean updateUserFeedback(java.awt.event.MouseEvent e)
Determine objects to highlight and update highlight- Parameters:
e
-MouseEvent
that triggered the update- Returns:
- true if repaint is required
-
removeHighlighting
private boolean removeHighlighting()
Removes all existing highlights.- Returns:
- true if a repaint is required
-
addHoverHighlightListener
private void addHoverHighlightListener(java.awt.Component c, java.util.Collection<OsmPrimitive> prims)
Add a mouse listener to the componentc
which highlightsprims
when the mouse pointer is hovering over the component- Parameters:
c
- The component to add the hover mouse listener toprims
- The primitives to highlight when the component is hovered
-
createLabelText
private static java.lang.String createLabelText(OsmPrimitive primitive)
Create the text for aOsmPrimitive
label, including its keys- Parameters:
primitive
- TheOsmPrimitive
to describe- Returns:
- Text describing the
OsmPrimitive
-
createLabelText
private static java.lang.String createLabelText(OsmPrimitive primitive, boolean includeKeys)
Create the text for aOsmPrimitive
label- Parameters:
primitive
- TheOsmPrimitive
to describeincludeKeys
- Include keys in description- Returns:
- Text describing the
OsmPrimitive
-
-