|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.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 its 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.
If the owning edge of the port is deleted while the port is moved this mode reactivates
its parent view mode. If the graph changes which is displayed by the view for which this
view mode is created, then cancelEditing()
is called if this mode is editing.
Field Summary | |
---|---|
protected YList |
candidates
The list of Port Candidates, consisting of YPoint instances. |
protected Port |
port
The port that is 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 | |
---|---|
protected YPoint |
adjustCoordinates(double x,
double y,
boolean disableSnappingModifierPressed,
boolean snapToCandidate)
Callback method that adjusts the mouse coordinates to enable snapping. |
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)
Factory method that creates the hit info that will be used for determining the hit node to which the moving port will connect. |
protected void |
drawPortCandidate(java.awt.Graphics2D gfx,
YPoint p,
Node v,
Edge e)
Draws a single port candidate. |
protected void |
drawPortCandidate(java.awt.Graphics2D gfx,
YPoint p,
Node v,
Edge e,
boolean isSnapActive,
boolean isSnapCandidate)
Draws a single port candidate. |
protected void |
drawTargetNodeIndicator(java.awt.Graphics2D gfx,
NodeRealizer nodeRealizer)
Draws an indicator into the graphics context that highlights the provide node realizer as the target node for the move port operation. |
protected void |
edgeChanged(Edge edge)
Callback method that is invoked when an edge's source and/or target node has been changed in of the mode's mouseReleasedXXX methods. |
java.awt.Cursor |
getDefaultCursor()
Returns the cursor to be used when the mouse is not over a draggable port point. |
int |
getDisableSnappingModifier()
Gets the modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. |
protected YList |
getGeometricPortCandidates(Node v,
Edge e)
Callback method that contains an alternative implementation to NodeRealizer.getPortCandidates(double) . |
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. |
java.awt.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. |
MoveSnapContext |
getSnapContext()
Obtains the MoveSnapContext instance that will be used by this instance during the move operation
if the segment snapping is enabled on
orthogonal edges . |
boolean |
isChangeEdgeEnabled()
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. |
protected boolean |
isDisableSnappingModifierPressed(java.awt.event.MouseEvent e)
Callback used by this mode to determine whether the modifier to disable snapping
has been currently pressed. |
boolean |
isIndicatingTargetNode()
Whether this instance indicates the target node of the move port operation using a Drawable . |
boolean |
isInvertedSnappingBehavior()
Determines whether pressing the disable snapping modifier
actually enables snapping. |
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. |
boolean |
isSegmentSnappingEnabled()
Determines whether orthogonal edge segments that are moved orthogonally
as a result of the movement of the port should snap to other segments. |
boolean |
isSnappingOrthogonalSegments()
Determines whether this instance should snap non- orthogonal edges should
have their ports snapped in such a way that the corresponding last segment will be orthogonally oriented. |
boolean |
isSnappingToNodeBorder()
Determines whether this instance should snap the mouse coordinates in such a way that the port lies at the intersection of the node. |
boolean |
isUsingEdgeDistanceSnapLines()
Determines whether this instance should insert equidistant snap lines from the center of the node in parallel to the corresponding axis. |
boolean |
isUsingNodePortCandidates()
Determines whether or not NodePort s have to be used as
candidates for edge connection points. |
boolean |
isUsingRealizerPortCandidates()
Determines whether this mode should use NodeRealizer.getPortCandidates(double) to obtain the list
of port candidates, or rather use method getGeometricPortCandidates(y.base.Node, y.base.Edge)
as an alternative implementation. |
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 |
mouseReleasedRight(double x,
double y)
Calls mousePressedLeft(double, double) . |
void |
mouseShiftReleasedLeft(double x,
double y)
Terminates the reassignment of a port. |
void |
mouseShiftReleasedRight(double x,
double y)
Calls mouseShiftReleasedLeft(double, double) . |
protected void |
portMoved(Port port,
double x,
double y)
Invoked when the moved port has been assigned its final position. |
protected void |
portWillBeMoved(Port port)
Invoked when the node port that will be moved is first determined. |
void |
setChangeEdgeEnabled(boolean changeEdgeEnabled)
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. |
void |
setDisableSnappingModifier(int disableSnappingModifier)
Sets the modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. |
void |
setIndicatingTargetNode(boolean indicatingTargetNode)
Determines whether this instance indicates the target node of the move port operation using a Drawable . |
void |
setInvertedSnappingBehavior(boolean invertedSnappingBehavior)
Determines whether pressing the disable snapping modifier
actually enables snapping. |
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. |
void |
setSegmentSnappingEnabled(boolean segmentSnappingEnabled)
Determines whether orthogonal edge segments that are moved orthogonally
as a result of the movement of the port should snap to other segments. |
void |
setSnapContext(MoveSnapContext snapContext)
Sets a new MoveSnapContext instance that will be used by this instance during the move operation
if the segment snapping is enabled on
orthogonal edges . |
void |
setSnappingOrthogonalSegments(boolean snappingOrthogonalSegments)
Determines whether this instance should snap non- orthogonal edges should
have their ports snapped in such a way that the corresponding last segment will be orthogonally oriented. |
void |
setSnappingToNodeBorder(boolean snappingToNodeBorder)
Determines whether this instance should snap the mouse coordinates in such a way that the port lies at the intersection of the node. |
void |
setUsingEdgeDistanceSnapLines(boolean usingEdgeDistanceSnapLines)
Determines whether this instance should insert equidistant snap lines from the center of the node in parallel to the corresponding axis. |
void |
setUsingNodePortCandidates(boolean usingNodePortCandidates)
Specifies whether or not NodePort s have to be used as
candidates for edge connection points. |
void |
setUsingRealizerPortCandidates(boolean usingRealizerPortCandidates)
Determines whether this mode should use NodeRealizer.getPortCandidates(double) to obtain the list
of port candidates, or rather use method getGeometricPortCandidates(y.base.Node, y.base.Edge)
as an alternative implementation. |
protected void |
updatePortPosition(double x,
double y)
Helper method that updates the currently dragged port's position. |
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()
public MovePortMode(ViewContainer vc)
vc
- the view container.Method Detail |
---|
public boolean isIndicatingTargetNode()
Drawable
.
The default is false
.
drawTargetNodeIndicator(java.awt.Graphics2D, NodeRealizer)
public void setIndicatingTargetNode(boolean indicatingTargetNode)
Drawable
.
The default is false
.
drawTargetNodeIndicator(java.awt.Graphics2D, NodeRealizer)
public boolean isInvertedSnappingBehavior()
disable snapping modifier
actually enables snapping.
The default is false
.
public void setInvertedSnappingBehavior(boolean invertedSnappingBehavior)
disable snapping modifier
actually enables snapping.
The default is false
.
public boolean isUsingEdgeDistanceSnapLines()
MoveSnapContext.getEdgeToEdgeDistance()
setting.
The default is false
.
public void setUsingEdgeDistanceSnapLines(boolean usingEdgeDistanceSnapLines)
MoveSnapContext.getEdgeToEdgeDistance()
setting.
The default is false
.
public boolean isSegmentSnappingEnabled()
orthogonally
as a result of the movement of the port should snap to other segments.
By default this feature is turned off.
public void setSegmentSnappingEnabled(boolean segmentSnappingEnabled)
orthogonally
as a result of the movement of the port should snap to other segments.
By default this feature is turned off.
public MoveSnapContext getSnapContext()
MoveSnapContext
instance that will be used by this instance during the move operation
if the segment snapping
is enabled on
orthogonal edges
.
setSnapContext(MoveSnapContext)
public void setSnapContext(MoveSnapContext snapContext)
MoveSnapContext
instance that will be used by this instance during the move operation
if the segment snapping
is enabled on
orthogonal edges
.
setSnapContext(MoveSnapContext)
public boolean isSnappingOrthogonalSegments()
orthogonal edges
should
have their ports snapped in such a way that the corresponding last segment will be orthogonally oriented.
By default this features is turned on.
public void setSnappingOrthogonalSegments(boolean snappingOrthogonalSegments)
orthogonal edges
should
have their ports snapped in such a way that the corresponding last segment will be orthogonally oriented.
By default this features is turned on.
public boolean isSnappingToNodeBorder()
NodeRealizer.findIntersection(double, double, double, double, java.awt.geom.Point2D)
method.
By default this feature is turned on.
public void setSnappingToNodeBorder(boolean snappingToNodeBorder)
NodeRealizer.findIntersection(double, double, double, double, java.awt.geom.Point2D)
method.
By default this feature is turned on.
public boolean isUsingRealizerPortCandidates()
NodeRealizer.getPortCandidates(double)
to obtain the list
of port candidates, or rather use method getGeometricPortCandidates(y.base.Node, y.base.Edge)
as an alternative implementation.
By default this is set to true
.
setUsingRealizerPortCandidates(boolean)
public void setUsingRealizerPortCandidates(boolean usingRealizerPortCandidates)
NodeRealizer.getPortCandidates(double)
to obtain the list
of port candidates, or rather use method getGeometricPortCandidates(y.base.Node, y.base.Edge)
as an alternative implementation.
By default this is set to true
.
isUsingRealizerPortCandidates()
,
setUsingNodePortCandidates(boolean)
public boolean isUsingNodePortCandidates()
NodePort
s have to be used as
candidates for edge connection points.
By default this property is true
.
true
if NodePort
s have to be used as
candidates for edge connection points and false
otherwise.setUsingNodePortCandidates(boolean)
public void setUsingNodePortCandidates(boolean usingNodePortCandidates)
NodePort
s have to be used as
candidates for edge connection points.
By default this property is true
.
Note that this setting is ignored unless isUsingRealizerPortCandidates()
returns
true
.
usingNodePortCandidates
- if true
NodePort
s are used as candidates for edge connection points;
if false
candidates returned by
NodeRealizer.getPortCandidates(double)
are used instead.isUsingNodePortCandidates()
,
setUsingRealizerPortCandidates(boolean)
public int getDisableSnappingModifier()
modifier mask
that can be used to determine whether
the user disables snapping via the snap context
temporarily. By default this is set to InputEvent.CTRL_MASK
so that pressing
the CTRL modifier will allow the user to take full control over the movement without the aid of snap lines.
public void setDisableSnappingModifier(int disableSnappingModifier)
modifier mask
that can be used to determine whether
the user disables snapping via the snap context
temporarily. By default this is set to InputEvent.CTRL_MASK
so that pressing
the CTRL modifier will allow the user to take full control over the movement without the aid of snap lines.
protected boolean isDisableSnappingModifierPressed(java.awt.event.MouseEvent e)
modifier to disable snapping
has been currently pressed.
This implementation uses the getDisableSnappingModifier()
to determine whether the modifier is currently applied.
e
- The last mouse event.
getSnapContext()
,
getDisableSnappingModifier()
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
x
- x world coordinatey
- y world coordinate
ViewMode.createHitInfo(double,double,boolean)
public void mousePressedLeft(double x, double y)
mousePressedLeft
in class ViewMode
x
- 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.
protected YList getGeometricPortCandidates(Node v, Edge e)
NodeRealizer.getPortCandidates(double)
.
This method is called by getPortCandidates(y.base.Node, y.base.Edge, double)
if the isUsingRealizerPortCandidates()
yields false
.
It will return port candidates at the center of the node and at all the intersections between the center and
the node border in horizontal and vertical directions. These intersections will be determined using
NodeRealizer.findIntersection(double, double, double, double, java.awt.geom.Point2D)
.
Also the original port location will be added as a candidate location.
v
- The node for which the candidates shall be collected.e
- The edge for which candidates should be collected.
YPoint
instances that indicate the absolute coordinates of the port candidates.public void mouseDraggedLeft(double x, double y)
mouseDraggedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.protected YPoint adjustCoordinates(double x, double y, boolean disableSnappingModifierPressed, boolean snapToCandidate)
x
- The original mouse coordinate at the x axisy
- The original mouse coordinate at the y axisdisableSnappingModifierPressed
- Whether snapping should be disabled temporarily.snapToCandidate
- Whether this method should snap to port candidates, only.
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 ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleasedRight(double x, double y)
mousePressedLeft(double, double)
.
mouseReleasedRight
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftReleasedRight(double x, double y)
mouseShiftReleasedLeft(double, double)
.
mouseShiftReleasedRight
in class ViewMode
x
- 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 ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.protected void edgeChanged(Edge edge)
mouseReleasedXXX
methods.
edge
- the edge whose endpoints have been changed.protected void portWillBeMoved(Port port)
port
- the port that will be moved.protected void portMoved(Port port, double x, double y)
port
- the port who has been moved.x
- the port's final, absolute x-coordinate.y
- the port's final, absolute y-coordinate.protected void drawPortCandidate(java.awt.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 portprotected void drawPortCandidate(java.awt.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 java.lang.UnsupportedOperationException
ViewMode
setEditing(false)
if
ViewMode.isEditing()
returns true
cancelEditing
in class ViewMode
java.lang.UnsupportedOperationException
- if the editing cannot be canceled
for any reason.protected void drawTargetNodeIndicator(java.awt.Graphics2D gfx, NodeRealizer nodeRealizer)
gfx
- The graphics to paint into.nodeRealizer
- The realizer to highlight.public java.awt.Cursor getMovePortCursor()
Cursor.MOVE_CURSOR
is returned.public java.awt.Cursor getDefaultCursor()
Cursor.DEFAULT_CURSOR
is returned.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |