|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.ViewMode
y.view.MovePortMode
public class MovePortMode
A view mode that allows interactive reassignment of edge ports.
A Port of a selected edge can be moved to another position by pressing the left mouse button on it and then dragging the port around. While dragging port candidate boxes will appear. These boxes mark the positions that are available for the port. The set of available port positions depends on the return value of the node realizer methodNodeRealizer.getPortCandidates(double).
The mode terminates it's action when the mouse is released again.
The port will then automatically snap to the closest available
port position.
If the portSnappingEnabled property is set to false,
holding the shift modifier while releasing the mouse button assigns the exact
current position as the new port position.
Optionally this mode can be configured to change
an edge's source or target node by dragging the corresponding port to another node.
| Field Summary | |
|---|---|
protected YList |
candidates
The list of Port Candidates, consisting of YPoint instances. |
protected Port |
port
The port that is being currently being moved. |
| 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 | |
|---|---|
MovePortMode()
Instantiates a new MovePortMode |
|
MovePortMode(ViewContainer vc)
Instantiates a new MovePortMode for a given ViewContainer |
|
| Method Summary | |
|---|---|
void |
cancelEditing()
This can be used to cleanly exit an edit that is currently in progress. |
protected EdgeRealizer |
createDummyEdgeRealizer(EdgeRealizer edgeRealizer)
Creates a dummy EdgeRealizer for the dummy edge that is used during changeEdge
operations. |
protected NodeRealizer |
createDummySourceNodeRealizer(NodeRealizer nodeRealizer)
Creates a dummy NodeRealizer for the source node of the dummy edge By default, this method returns This will only be used if setChangeEdgeEnabled(boolean) is set to true. |
protected NodeRealizer |
createDummyTargetNodeRealizer(double x,
double y)
Creates a dummy node for the other end of the edge. |
protected HitInfo |
createHitNodeHitInfo(double x,
double y)
|
protected void |
drawPortCandidate(Graphics2D gfx,
YPoint p,
Node v,
Edge e)
Draws a single port candidate. |
protected void |
drawPortCandidate(Graphics2D gfx,
YPoint p,
Node v,
Edge e,
boolean isSnapActive,
boolean isSnapCandidate)
Draws a single port candidate. |
Cursor |
getDefaultCursor()
Returns the cursor to be used when the mouse is not over a draggable port point. |
protected HitInfo |
getHitInfo(double x,
double y)
Returns the first hit port, only. |
protected Node |
getHitNode(double x,
double y)
Returns the possible new node for the currently moved port. |
Cursor |
getMovePortCursor()
Returns the cursor to be used when the mouse is over a draggable port point. |
protected YList |
getPortCandidates(Node v,
Edge e,
double gridSpacing)
Returns a list of YPoint objects each of which represents an allowed port location for the given edge at the given node. |
boolean |
isChangeEdgeEnabled()
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. |
protected boolean |
isOrthogonalRouting(Edge edge)
Determines whether the given edge instance should be routed orthogonally. |
boolean |
isPortSnappingEnabled()
Returns whether this mode should snap the port to one of the predefined port positions, even if the shift modifier is pressed. |
void |
mouseDraggedLeft(double x,
double y)
Moves the port. |
void |
mousePressedLeft(double x,
double y)
Initiates reassignment of a hit port. |
void |
mouseReleasedLeft(double x,
double y)
Terminates the reassignment of a port. |
void |
mouseShiftReleasedLeft(double x,
double y)
Terminates the reassignment of a port. |
void |
setChangeEdgeEnabled(boolean changeEdgeEnabled)
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. |
void |
setPortSnappingEnabled(boolean portSnappingEnabled)
Sets whether this mode should snap the port to one of the predefined port positions, even if the modifier is pressed. |
protected void |
updatePortPosition(double x,
double y)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Port port
protected YList candidates
YPoint instances.
| Constructor Detail |
|---|
public MovePortMode(ViewContainer vc)
public MovePortMode()
| Method Detail |
|---|
public boolean isChangeEdgeEnabled()
false.
Graph.changeEdge(y.base.Edge, y.base.Node, y.base.Node)public void setChangeEdgeEnabled(boolean changeEdgeEnabled)
false.
changeEdgeEnabled - whether to allow changing of edgesGraph.changeEdge(y.base.Edge, y.base.Node, y.base.Node)
protected HitInfo getHitInfo(double x,
double y)
getHitInfo in class ViewMode
public void mousePressedLeft(double x,
double y)
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 EdgeRealizer createDummyEdgeRealizer(EdgeRealizer edgeRealizer)
changeEdge
operations.
This will only be used if setChangeEdgeEnabled(boolean) is set to true.
By default, this method returns
edgeRealizer.createCopy();
protected NodeRealizer createDummySourceNodeRealizer(NodeRealizer nodeRealizer)
setChangeEdgeEnabled(boolean) is set to true.
nodeRealizer.createCopy();
protected NodeRealizer createDummyTargetNodeRealizer(double x,
double y)
setChangeEdgeEnabled(boolean) is set to true.
This implementation returns a zero width/ zero height ShapeNodeRealizer
x - the initial x coordinatey - the initial y coordinate
protected YList getPortCandidates(Node v,
Edge e,
double gridSpacing)
NodeRealizer.getPortCandidates(double).
Subclasses may override this method to change the behavior of
this method.
v - the node that yields the port candidatese - the edge that requests the port candidatesgridSpacing - the current gridSpacing.
public void mouseDraggedLeft(double x,
double y)
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 Node getHitNode(double x,
double y)
createHitNodeHitInfo(x, y).getHitNode() is returned.
x - the x world coordinatey - the y world coordinate
null
protected HitInfo createHitNodeHitInfo(double x,
double y)
protected void updatePortPosition(double x,
double y)
protected boolean isOrthogonalRouting(Edge edge)
DataProvider bound to the current
graph via the EditMode.ORTHOGONAL_ROUTING_DPKEY data provider key
to determine whether the given edge should be routed orthogonally.
edge - the edge to decide
true if the edge should be routed orthogonally.EditMode.isOrthogonalRouting(y.base.Edge)
public void mouseShiftReleasedLeft(double x,
double y)
portSnappingEnabled is true mouseReleasedLeft(double, double)
gets invoked instead.
mouseShiftReleasedLeft 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 void mouseReleasedLeft(double x,
double y)
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.
protected void drawPortCandidate(Graphics2D gfx,
YPoint p,
Node v,
Edge e)
drawPortCandidate(java.awt.Graphics2D, y.geom.YPoint, y.base.Node, y.base.Edge, boolean, boolean).
gfx - the active graphics contextp - the absolute port locationv - the node that yields the porte - the edge that requests the port
protected void drawPortCandidate(Graphics2D gfx,
YPoint p,
Node v,
Edge e,
boolean isSnapActive,
boolean isSnapCandidate)
gfx - the active graphics contextp - the absolute port locationv - the node that yields the porte - the edge that requests the portisSnapActive - whether or not port snapping is currently activeisSnapCandidate - whether or not the given port candidate is the candidate that will be snapped to.public boolean isPortSnappingEnabled()
public void setPortSnappingEnabled(boolean portSnappingEnabled)
modifier is pressed.
Default is true.
public void cancelEditing()
throws UnsupportedOperationException
ViewModesetEditing(false) if
ViewMode.isEditing() returns true
cancelEditing in class ViewModeUnsupportedOperationException - if the editing cannot be canceled
for any reason.public Cursor getMovePortCursor()
Cursor.MOVE_CURSOR is returned.public Cursor getDefaultCursor()
Cursor.DEFAULT_CURSOR is returned.
|
© Copyright 2000-2008, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||