public class ExtrudeAction extends MapMode implements MapViewPaintable
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ExtrudeAction.Mode |
private class |
ExtrudeAction.ReferenceSegment |
Modifier and Type | Field and Description |
---|---|
private ExtrudeAction.ReferenceSegment |
activeMoveDirection
The direction that is currently active.
|
private AWTEventListener |
altKeyListener
This listener is used to indicate the 'create_new' mode, if the Alt modifier is pressed.
|
private boolean |
alwaysCreateNodes
If true, when extruding create new node even if segments parallel.
|
private Cursor |
cursorCreateNew
The cursor for the 'create_new' mode.
|
private Cursor |
cursorCreateNodes
The cursor for the 'alwaysCreateNodes' submode.
|
private Cursor |
cursorTranslate
The cursor for the 'translate' mode.
|
private Color |
helperColor
drawing settings for helper lines
|
private Stroke |
helperStrokeDash |
private Stroke |
helperStrokeRA |
private boolean |
ignoreSharedNodes
settings value whether shared nodes should be ignored or not
|
private Point |
initialMousePos
The position of the mouse cursor when the drag action was initiated.
|
private int |
initialMoveDelay
The time which needs to pass between click and release before something
counts as a move, in milliseconds
|
private EastNorth |
initialN1en
The initial EastNorths of node1 and node2
|
private EastNorth |
initialN2en |
private Color |
mainColor |
private Stroke |
mainStroke |
private ExtrudeAction.Mode |
mode |
private long |
mouseDownTime |
private MoveCommand |
moveCommand
the command that performed last move.
|
private Collection<OsmPrimitive> |
movingNodeList
Collection of nodes that is moved
|
private EastNorth |
newN1en
The new EastNorths of node1 and node2
|
private EastNorth |
newN2en |
private boolean |
nodeDragWithoutCtrl |
private Stroke |
oldLineStroke |
private List<ExtrudeAction.ReferenceSegment> |
possibleMoveDirections
Possible directions to move to.
|
private Node |
selectedNode |
private WaySegment |
selectedSegment |
private double |
symbolSize |
sc
changeSupport, enabled
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 and Description |
---|
ExtrudeAction(MapFrame mapFrame)
Create a new SelectAction
|
Modifier and Type | Method and Description |
---|---|
private void |
addNewNode(MouseEvent e)
Insert node into nearby segment
|
private EastNorth |
calculateBestMovement(EastNorth mouseEn)
Determine best movenemnt from initialMousePos to current position @param mouseEn,
choosing one of the directions @field possibleMoveDirections
|
private void |
calculatePossibleDirectionsByNode()
Gather possible move directions - along all adjacent segments
|
private void |
calculatePossibleDirectionsBySegment()
Gather possible move directions - perpendicular to the selected segment and parallel to neighbor segments
|
private static EastNorth |
calculateSegmentOffset(EastNorth segmentP1,
EastNorth segmentP2,
EastNorth moveDirection,
EastNorth targetPos)
This method calculates offset amount by witch to move the given segment perpendicularly for it to be in line with mouse position.
|
private void |
createNewRectangle() |
private static Line2D |
createSemiInfiniteLine(Point2D start,
Point2D unitvector,
Graphics2D g)
Create a new Line that extends off the edge of the viewport in one direction
|
private void |
drawAngleSymbol(Graphics2D g2,
Point2D center,
Point2D normal,
boolean mirror) |
void |
enterMode()
Makes this map mode active.
|
void |
exitMode()
Makes this map mode inactive.
|
String |
getModeHelpText() |
private Node |
getNextNode(int index)
Gets a node from selected way after given index.
|
private int |
getNextNodeIndex(int index)
Gets a node from selected way after given index.
|
private Point2D |
getNormalUniVector() |
private Node |
getPreviousNode(int index)
Gets a node from selected way before given index.
|
private int |
getPreviousNodeIndex(int index)
Gets a node from selected way before given index.
|
private boolean |
hasNodeOtherWays(Node node,
Way myWay)
This method tests if a node has other ways apart from the given one.
|
boolean |
layerIsSupported(Layer l) |
void |
mouseDragged(MouseEvent e)
Perform action depending on what mode we're in.
|
void |
mousePressed(MouseEvent e)
If the left mouse button is pressed over a segment, switch
to either extrude, translate or create_new mode depending on whether Ctrl or Alt is held.
|
void |
mouseReleased(MouseEvent e)
Do anything that needs to be done, then switch back to select mode
|
void |
paint(Graphics2D g,
MapView mv,
Bounds box)
Paint the dataset using the engine set.
|
private void |
performExtrusion()
Do actual extrusion of @field selectedSegment
|
actionPerformed, mouseClicked, mouseEntered, mouseExited, mouseMoved, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateStatusLine
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState, updateEnabledState
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
private ExtrudeAction.Mode mode
private boolean alwaysCreateNodes
private boolean nodeDragWithoutCtrl
private long mouseDownTime
private WaySegment selectedSegment
private Node selectedNode
private Stroke mainStroke
private boolean ignoreSharedNodes
private Color helperColor
private Stroke helperStrokeDash
private Stroke helperStrokeRA
private Stroke oldLineStroke
private double symbolSize
private List<ExtrudeAction.ReferenceSegment> possibleMoveDirections
private Collection<OsmPrimitive> movingNodeList
private ExtrudeAction.ReferenceSegment activeMoveDirection
private Point initialMousePos
private int initialMoveDelay
private EastNorth initialN1en
private EastNorth initialN2en
private MoveCommand moveCommand
private final Cursor cursorCreateNew
private final Cursor cursorTranslate
private final Cursor cursorCreateNodes
private final AWTEventListener altKeyListener
public ExtrudeAction(MapFrame mapFrame)
mapFrame
- The MapFrame this action belongs to.public String getModeHelpText()
getModeHelpText
in class MapMode
public boolean layerIsSupported(Layer l)
layerIsSupported
in class MapMode
public void enterMode()
MapMode
public void exitMode()
MapMode
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
mousePressed
in class MapMode
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
mouseDragged
in class MapMode
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
mouseReleased
in class MapMode
private void addNewNode(MouseEvent e)
e
- - current mouse pointprivate void createNewRectangle()
private void performExtrusion()
private boolean hasNodeOtherWays(Node node, Way myWay)
node
- myWay
- private EastNorth calculateBestMovement(EastNorth mouseEn)
private static EastNorth calculateSegmentOffset(EastNorth segmentP1, EastNorth segmentP2, EastNorth moveDirection, EastNorth targetPos)
segmentP1
- segmentP2
- targetPos
- private void calculatePossibleDirectionsBySegment()
private void calculatePossibleDirectionsByNode()
private int getPreviousNodeIndex(int index)
index
- index of current nodeprivate Node getPreviousNode(int index)
index
- index of current nodeprivate int getNextNodeIndex(int index)
index
- index of current nodeprivate Node getNextNode(int index)
index
- index of current nodepublic void paint(Graphics2D g, MapView mv, Bounds box)
MapViewPaintable
paint
in interface MapViewPaintable
mv
- The object that can translate GeoPoints to screen coordinates.private Point2D getNormalUniVector()
private void drawAngleSymbol(Graphics2D g2, Point2D center, Point2D normal, boolean mirror)
private static Line2D createSemiInfiniteLine(Point2D start, Point2D unitvector, Graphics2D g)
start
- The start point of the lineunitvector
- A unit vector denoting the direction of the lineg
- the Graphics2D object it will be used on