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 classSplitMode.SplitWayActionConcreteSplit a specifiedWayat 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) HighlightHelperhighlightHelper to keep track of highlighted primitives(package private) static CachingProperty<java.lang.Boolean>IGNORE_DISABLED_WAYSDon't consider disabled ways(package private) static CachingProperty<java.lang.Boolean>PREFER_SELECTED_WAYSPrioritized 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 voidaddHoverHighlightListener(java.awt.Component c, java.util.Collection<OsmPrimitive> prims)Add a mouse listener to the componentcwhich highlightsprimswhen the mouse pointer is hovering over the componentprivate voidaddNodeAndSplit(MapView mv, java.awt.Point mousePos, Way way)Add a node to a way and then split itprivate static java.lang.StringcreateLabelText(OsmPrimitive primitive)Create the text for aOsmPrimitivelabel, including its keysprivate static java.lang.StringcreateLabelText(OsmPrimitive primitive, boolean includeKeys)Create the text for aOsmPrimitivelabelprivate javax.swing.JPopupMenucreatePopup(Node n, java.util.Collection<Way> applicableWays)Create a new split way selection popupvoidenterMode()Makes this map mode active.voidexitMode()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.StringgetModeHelpText()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)booleanlayerIsSupported(Layer l)Determines if layerlis supported by this map mode.voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)private booleanremoveHighlighting()Removes all existing highlights.private booleanupdateUserFeedback(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:MapModeMakes this map mode active.
-
exitMode
public void exitMode()
Description copied from class:MapModeMakes this map mode inactive.
-
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
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Overrides:
mousePressedin 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:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseMovedin 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
-
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-MouseEventthat 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 componentcwhich highlightsprimswhen 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 aOsmPrimitivelabel, including its keys- Parameters:
primitive- TheOsmPrimitiveto describe- Returns:
- Text describing the
OsmPrimitive
-
createLabelText
private static java.lang.String createLabelText(OsmPrimitive primitive, boolean includeKeys)
Create the text for aOsmPrimitivelabel- Parameters:
primitive- TheOsmPrimitiveto describeincludeKeys- Include keys in description- Returns:
- Text describing the
OsmPrimitive
-
-