|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.ViewMode
y.view.OrthogonalMoveBendsMode
public class OrthogonalMoveBendsMode
A specialized ViewMode that moves or creates bends in such a way that
an edge's path is always orthogonal.
This mode should be used as a child mode of a ViewMode that is delegated to whenever
the user begins a drag on an edge.
In particular, this also includes dragging an edge segment, which results in
the edge segment being moved such that the orthogonal edge path is maintained.
Note that this does not apply to the first and last edge segments.
To create additional bends/edge segments while preserving an orthogonal edge
path, a modifier key has to be pressed while clicking on or dragging an edge
segment.
This is the default behavior for the first and last edge segments.
It can be suppressed by setting the autoBendsInsertionEnabled
property to false.
See methods ViewMode.isModifierPressed(java.awt.event.MouseEvent) and
ViewMode.setModifierMask(int).
The default is MouseEvent.SHIFT_MASK.
![]() |
![]() |
| Nested Class Summary | |
|---|---|
static class |
OrthogonalMoveBendsMode.MinMax
Utility class that holds a valid coordinate range and properly crops coordinates. |
| Field Summary |
|---|
| Fields inherited from class y.view.ViewMode |
|---|
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view |
| Constructor Summary | |
|---|---|
OrthogonalMoveBendsMode()
|
|
| Method Summary | |
|---|---|
protected void |
dragFinished(Bend bend,
double x,
double y)
Callback method that is called once the dragging has been finished. |
protected Bend |
getBend()
Yields the main bend that is currently being dragged. |
protected OrthogonalMoveBendsMode.MinMax |
getMinMax()
Returns the data structure that describes the current valid range for the bend. |
protected OrthogonalMoveBendsMode.MinMax |
getMinMax(EdgeRealizer realizer,
Bend bend,
int index)
Creates the data structure that describes the valid range of the movement for a given bend. |
protected EdgeRealizer |
getRealizer()
Gets the realizer whose bends are being dragged. |
double |
getSnapEpsilon()
Gets the value to use that determines the distance to snap a moving segment to an adjacent segment. |
protected Bend |
initDrag(EdgeRealizer realizer,
Bend hitBend)
Initializes the dragging for a given realizer and hit bend. |
protected Bend |
initDrag(EdgeRealizer realizer,
double x,
double y)
Initializes a drag for a given realizer and location. |
boolean |
isAutoBendInsertionEnabled()
Determines whether bends should be inserted automatically if the first or last segment is dragged by the user. |
boolean |
isBendSelectionEnabled()
Whether the bend that is being moved is automatically selected. |
void |
mouseDraggedLeft(double x,
double y)
Called when the mouse was dragged with the left button down. |
void |
mousePressedLeft(double x,
double y)
Called when the left mouse button was pressed. |
void |
mouseReleasedLeft(double x,
double y)
Called when the left mouse button was released. |
static boolean |
normalizeBends(EdgeRealizer er)
Utility method that adjusts the bends of the given realizer so that they form an orthogonal path. |
protected void |
relocateBend(EdgeRealizer realizer,
Bend bend,
double x,
double y)
Actually moves a bend to the given location. |
static int |
removeDuplicateBends(EdgeRealizer er,
int pointCount)
Utility method that removes duplicate bends from an EdgeRealizer |
protected void |
removeDuplicates(EdgeRealizer realizer)
Removes duplicate and colinear bends from the given realizer. |
void |
setAutoBendInsertionEnabled(boolean autoBendInsertionEnabled)
Determines whether bends should be inserted automatically if the first or last segment is dragged by the user. |
void |
setBendSelectionEnabled(boolean bendSelectionEnabled)
Determines whether the bend that is being moved is automatically selected. |
void |
setSnapEpsilon(double snapEpsilon)
Sets the value to use that determines the distance to snap a moving segment to an adjacent segment. |
protected void |
snapPoint(Point2D.Double point)
Implements the snapping logic. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OrthogonalMoveBendsMode()
| Method Detail |
|---|
public boolean isAutoBendInsertionEnabled()
true.
public void setAutoBendInsertionEnabled(boolean autoBendInsertionEnabled)
true.
autoBendInsertionEnabled - Whether to automatically create bends for the first and last segments.public boolean isBendSelectionEnabled()
public void setBendSelectionEnabled(boolean bendSelectionEnabled)
bendSelectionEnabled - whether to select the bendpublic double getSnapEpsilon()
0.0 effectively disables snapping.
The default is 5.0.
public void setSnapEpsilon(double snapEpsilon)
0.0d effectively disables snapping.
The default is 5.0.
snapEpsilon - the distance to snap a segment during a drag.
public void mousePressedLeft(double x,
double y)
ViewMode
mousePressedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.protected Bend getBend()
protected EdgeRealizer getRealizer()
protected OrthogonalMoveBendsMode.MinMax getMinMax()
protected OrthogonalMoveBendsMode.MinMax getMinMax(EdgeRealizer realizer,
Bend bend,
int index)
realizer - The realizer that owns the bend.bend - the bendindex - the index of the bend in the realizer's list.
protected Bend initDrag(EdgeRealizer realizer,
Bend hitBend)
protected Bend initDrag(EdgeRealizer realizer,
double x,
double y)
realizer - the realizer to create a bend forx - the location of the mouse pressy - the location of the mouse press
public void mouseDraggedLeft(double x,
double y)
ViewMode
mouseDraggedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.
protected void relocateBend(EdgeRealizer realizer,
Bend bend,
double x,
double y)
OrthogonalMoveBendsMode.MinMax.adjust(java.awt.geom.Point2D)
method to calculate the new location and automatically adjusts the neighboring bends to keep the edge orthogonal.
realizer - The realizer the bend belongs to.bend - the bend to movex - the new locationy - the new locationprotected void snapPoint(Point2D.Double point)
point - The point that will be snapped if it needs to be snapped.
public void mouseReleasedLeft(double x,
double y)
ViewMode
mouseReleasedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.public static boolean normalizeBends(EdgeRealizer er)
er - the realizer to adjust.
public static int removeDuplicateBends(EdgeRealizer er,
int pointCount)
er - the realizer to remove duplicate bends from.pointCount - the number of points, bendCount + 2
protected void dragFinished(Bend bend,
double x,
double y)
bend - the bend that has been movedx - the new locationy - the new locationprotected void removeDuplicates(EdgeRealizer realizer)
realizer - the realizer from which duplicate bends should be removed.
|
© Copyright 2000-2008, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||