|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.mapmode.MapMode
org.openstreetmap.josm.actions.mapmode.DrawAction
public class DrawAction
Mapmode to add nodes, create and extend ways.
Nested Class Summary | |
---|---|
class |
DrawAction.BackSpaceAction
|
private class |
DrawAction.SnapChangeAction
|
private class |
DrawAction.SnapHelper
|
Field Summary | |
---|---|
private Shortcut |
backspaceShortcut
|
private Node |
currentBaseNode
|
private EastNorth |
currentMouseEastNorth
|
private java.awt.Cursor |
cursorJoinNode
|
private java.awt.Cursor |
cursorJoinWay
|
private boolean |
drawHelperLine
|
private boolean |
drawTargetHighlight
|
private Node |
lastUsedNode
|
private Node |
mouseOnExistingNode
|
private java.util.Set<Way> |
mouseOnExistingWays
|
private java.awt.Point |
mousePos
|
private java.util.Set<OsmPrimitive> |
newHighlights
|
private java.util.Set<OsmPrimitive> |
oldHighlights
|
private java.awt.Point |
oldMousePos
|
private double |
PHI
|
private Node |
previousNode
|
private java.awt.event.KeyEvent |
releaseEvent
|
private java.awt.Point |
rightClickPressPos
|
private java.awt.Color |
selectedColor
|
private java.util.TreeSet<java.lang.Integer> |
set
|
private DrawAction.SnapChangeAction |
snapChangeAction
|
private javax.swing.JCheckBoxMenuItem |
snapCheckboxMenuItem
|
private DrawAction.SnapHelper |
snapHelper
|
private Shortcut |
snappingShortcut
|
private javax.swing.Timer |
timer
|
private boolean |
useRepeatedShortcut
|
private boolean |
wayIsFinished
|
Fields inherited from class org.openstreetmap.josm.actions.mapmode.MapMode |
---|
alt, ctrl, cursor, shift |
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 | |
---|---|
DrawAction(MapFrame mapFrame)
|
Method Summary | |
---|---|
private void |
addHighlighting()
Takes the data from computeHelperLine to determine which ways/nodes should be highlighted (if feature enabled). |
private javax.swing.JCheckBoxMenuItem |
addMenuItem()
|
private static void |
adjustNode(java.util.Collection<Pair<Node,Node>> segs,
Node n)
Adjusts the position of a node to lie on a segment (or a segment intersection). |
private void |
computeHelperLine()
This method prepares data required for painting the "helper line" from the last used position to the mouse cursor. |
void |
destroy()
Called when the object has been destroyed. |
(package private) static double |
det(double a,
double b,
double c,
double d)
|
private void |
determineCurrentBaseNodeAndPreviousNode(java.util.Collection<OsmPrimitive> selection)
Helper function that sets fields currentBaseNode and previousNode |
private void |
doKeyPressEvent(java.awt.event.KeyEvent e)
|
private void |
doKeyReleaseEvent(java.awt.event.KeyEvent e)
|
void |
enterMode()
|
void |
eventDispatched(java.awt.AWTEvent event)
redraw to (possibly) get rid of helper line if selection changes. |
void |
exitMode()
|
private Node |
findNodeToContinueFrom(Node selectedNode,
Way selectedWay)
Finds a node to continue drawing from. |
private void |
finishDrawing()
This function should be called when the user wishes to finish his current draw action. |
Node |
getCurrentBaseNode()
|
java.util.Collection<OsmPrimitive> |
getInProgressSelection()
Get selected primitives, while draw action is in progress. |
java.lang.String |
getModeHelpText()
|
static Way |
getWayForNode(Node n)
|
private void |
insertNodeIntoAllNearbySegments(java.util.List<WaySegment> wss,
Node n,
java.util.Collection<OsmPrimitive> newSelection,
java.util.Collection<Command> cmds,
java.util.ArrayList<Way> replacedWays,
java.util.ArrayList<Way> reuseWays)
|
private boolean |
isSelfContainedWay(Way selectedWay,
Node currentNode,
Node targetNode)
Prevent creation of ways that look like this: <----> This happens if users want to draw a no-exit-sideway from the main way like this: ^ |<----> | The solution isn't ideal because the main way will end in the side way, which is bad for navigation software ("drive straight on") but at least easier to fix. |
boolean |
layerIsSupported(Layer l)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
Repaint on mouse exit so that the helper line goes away. |
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
If user clicked with the left button, add a node at the current mouse position. |
void |
paint(java.awt.Graphics2D g,
MapView mv,
Bounds box)
Paint the dataset using the engine set. |
(package private) void |
processKeyEvent(java.awt.event.KeyEvent e)
|
private static void |
pruneSuccsAndReverse(java.util.List<java.lang.Integer> is)
|
private boolean |
redrawIfRequired()
Checks if a map redraw is required and does so if needed. |
private boolean |
removeHighlighting()
Removes target highlighting from primitives. |
void |
selectionChanged(java.util.Collection<? extends OsmPrimitive> newSelection)
redraw to (possibly) get rid of helper line if selection changes. |
private void |
showStatusInfo(double angle,
double hdg,
double distance,
boolean activeFlag)
|
private void |
tryAgain(java.awt.event.MouseEvent e)
|
private void |
tryToMoveNodeOnIntersection(java.util.List<WaySegment> wss,
Node n)
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. |
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode |
---|
actionPerformed, mouseClicked, mouseEntered, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateStatusLine |
Methods inherited from class org.openstreetmap.josm.actions.JosmAction |
---|
getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.awt.Cursor cursorJoinNode
private final java.awt.Cursor cursorJoinWay
private Node lastUsedNode
private double PHI
private Node mouseOnExistingNode
private java.util.Set<Way> mouseOnExistingWays
private java.util.Set<OsmPrimitive> oldHighlights
private java.util.Set<OsmPrimitive> newHighlights
private boolean drawHelperLine
private boolean wayIsFinished
private boolean drawTargetHighlight
private java.awt.Point mousePos
private java.awt.Point oldMousePos
private java.awt.Color selectedColor
private Node currentBaseNode
private Node previousNode
private EastNorth currentMouseEastNorth
private final DrawAction.SnapHelper snapHelper
private Shortcut backspaceShortcut
private final Shortcut snappingShortcut
private final DrawAction.SnapChangeAction snapChangeAction
private final javax.swing.JCheckBoxMenuItem snapCheckboxMenuItem
private boolean useRepeatedShortcut
private final java.util.TreeSet<java.lang.Integer> set
private java.awt.event.KeyEvent releaseEvent
private javax.swing.Timer timer
private java.awt.Point rightClickPressPos
Constructor Detail |
---|
public DrawAction(MapFrame mapFrame)
Method Detail |
---|
private javax.swing.JCheckBoxMenuItem addMenuItem()
private boolean redrawIfRequired()
public void enterMode()
enterMode
in class MapMode
public void exitMode()
exitMode
in class MapMode
public void eventDispatched(java.awt.AWTEvent event)
eventDispatched
in interface java.awt.event.AWTEventListener
void processKeyEvent(java.awt.event.KeyEvent e)
private void doKeyPressEvent(java.awt.event.KeyEvent e)
private void doKeyReleaseEvent(java.awt.event.KeyEvent e)
public void selectionChanged(java.util.Collection<? extends OsmPrimitive> newSelection)
selectionChanged
in interface SelectionChangedListener
newSelection
- The new selection.private void tryAgain(java.awt.event.MouseEvent e)
private void finishDrawing()
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class MapMode
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class MapMode
private void insertNodeIntoAllNearbySegments(java.util.List<WaySegment> wss, Node n, java.util.Collection<OsmPrimitive> newSelection, java.util.Collection<Command> cmds, java.util.ArrayList<Way> replacedWays, java.util.ArrayList<Way> reuseWays)
private boolean isSelfContainedWay(Way selectedWay, Node currentNode, Node targetNode)
Way
- the way to checkNode
- the current node (i.e. the one the connection will be made from)Node
- the target node (i.e. the one the connection will be made to)
private Node findNodeToContinueFrom(Node selectedNode, Way selectedWay)
selectedNode
- Currently selected node, may be nullselectedWay
- Currently selected way, may be null
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class MapMode
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class MapMode
private void computeHelperLine()
private void showStatusInfo(double angle, double hdg, double distance, boolean activeFlag)
private void determineCurrentBaseNodeAndPreviousNode(java.util.Collection<OsmPrimitive> selection)
selection
- uses also lastUsedNode fieldpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class MapMode
public static Way getWayForNode(Node n)
null
otherwise.public Node getCurrentBaseNode()
private static void pruneSuccsAndReverse(java.util.List<java.lang.Integer> is)
private static void adjustNode(java.util.Collection<Pair<Node,Node>> segs, Node n)
segs
- the segments to use as a reference when adjustingn
- the node to adjuststatic double det(double a, double b, double c, double d)
private void tryToMoveNodeOnIntersection(java.util.List<WaySegment> wss, Node n)
private void addHighlighting()
private boolean removeHighlighting()
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
MapViewPaintable
paint
in interface MapViewPaintable
mv
- The object that can translate GeoPoints to screen coordinates.public java.lang.String getModeHelpText()
getModeHelpText
in class MapMode
public java.util.Collection<OsmPrimitive> getInProgressSelection()
public boolean layerIsSupported(Layer l)
layerIsSupported
in class MapMode
protected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.
updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
public void destroy()
Destroyable
destroy
in interface Destroyable
destroy
in class JosmAction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |