Search this API

y.view
Class MovePortMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.MovePortMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class MovePortMode
extends ViewMode

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 method NodeRealizer.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 NodePorts 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 NodePorts 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 y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

port

protected Port port
The port that is being moved.


candidates

protected YList candidates
The list of Port Candidates, consisting of YPoint instances.

Constructor Detail

MovePortMode

public MovePortMode()
Instantiates a new MovePortMode.


MovePortMode

public MovePortMode(ViewContainer vc)
Instantiates a new MovePortMode for a given ViewContainer.

Parameters:
vc - the view container.
Method Detail

isIndicatingTargetNode

public boolean isIndicatingTargetNode()
Whether this instance indicates the target node of the move port operation using a Drawable. The default is false.

See Also:
drawTargetNodeIndicator(java.awt.Graphics2D, NodeRealizer)

setIndicatingTargetNode

public void setIndicatingTargetNode(boolean indicatingTargetNode)
Determines whether this instance indicates the target node of the move port operation using a Drawable. The default is false.

See Also:
drawTargetNodeIndicator(java.awt.Graphics2D, NodeRealizer)

isInvertedSnappingBehavior

public boolean isInvertedSnappingBehavior()
Determines whether pressing the disable snapping modifier actually enables snapping. The default is false.


setInvertedSnappingBehavior

public void setInvertedSnappingBehavior(boolean invertedSnappingBehavior)
Determines whether pressing the disable snapping modifier actually enables snapping. The default is false.


isUsingEdgeDistanceSnapLines

public boolean isUsingEdgeDistanceSnapLines()
Determines whether this instance should insert equidistant snap lines from the center of the node in parallel to the corresponding axis. The distance between these snap lines is obtained from the MoveSnapContext.getEdgeToEdgeDistance() setting. The default is false.


setUsingEdgeDistanceSnapLines

public 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. The distance between these snap lines is obtained from the MoveSnapContext.getEdgeToEdgeDistance() setting. The default is false.


isSegmentSnappingEnabled

public 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. By default this feature is turned off.


setSegmentSnappingEnabled

public 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. By default this feature is turned off.


getSnapContext

public 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.

See Also:
setSnapContext(MoveSnapContext)

setSnapContext

public 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.

See Also:
setSnapContext(MoveSnapContext)

isSnappingOrthogonalSegments

public 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. By default this features is turned on.


setSnappingOrthogonalSegments

public 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. By default this features is turned on.


isSnappingToNodeBorder

public 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. The intersection is determined using the NodeRealizer.findIntersection(double, double, double, double, java.awt.geom.Point2D) method. By default this feature is turned on.


setSnappingToNodeBorder

public 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. The intersection is determined using the NodeRealizer.findIntersection(double, double, double, double, java.awt.geom.Point2D) method. By default this feature is turned on.


isUsingRealizerPortCandidates

public 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. By default this is set to true.

See Also:
setUsingRealizerPortCandidates(boolean)

setUsingRealizerPortCandidates

public 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. By default this is set to true.

See Also:
isUsingRealizerPortCandidates(), setUsingNodePortCandidates(boolean)

isUsingNodePortCandidates

public boolean isUsingNodePortCandidates()
Determines whether or not NodePorts have to be used as candidates for edge connection points.

By default this property is true.

Returns:
true if NodePorts have to be used as candidates for edge connection points and false otherwise.
See Also:
setUsingNodePortCandidates(boolean)

setUsingNodePortCandidates

public void setUsingNodePortCandidates(boolean usingNodePortCandidates)
Specifies whether or not NodePorts 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.

Parameters:
usingNodePortCandidates - if true NodePorts are used as candidates for edge connection points; if false candidates returned by NodeRealizer.getPortCandidates(double) are used instead.
See Also:
isUsingNodePortCandidates(), setUsingRealizerPortCandidates(boolean)

getDisableSnappingModifier

public int getDisableSnappingModifier()
Gets the 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.


setDisableSnappingModifier

public void setDisableSnappingModifier(int disableSnappingModifier)
Sets the 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.


isDisableSnappingModifierPressed

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. This implementation uses the getDisableSnappingModifier() to determine whether the modifier is currently applied.

Parameters:
e - The last mouse event.
Returns:
Whether the modifier is active, i.e. whether snapping should be disabled temporarily.
See Also:
getSnapContext(), getDisableSnappingModifier()

isChangeEdgeEnabled

public boolean isChangeEdgeEnabled()
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. The default is false.

Returns:
whether to allow changing of edges
See Also:
Graph.changeEdge(y.base.Edge, y.base.Node, y.base.Node)

setChangeEdgeEnabled

public void setChangeEdgeEnabled(boolean changeEdgeEnabled)
Determines whether this mode allows the changing of edges so that they connect to different source and target nodes. The default is false.

Parameters:
changeEdgeEnabled - whether to allow changing of edges
See Also:
Graph.changeEdge(y.base.Edge, y.base.Node, y.base.Node)

getHitInfo

protected HitInfo getHitInfo(double x,
                             double y)
Returns the first hit port, only.

Overrides:
getHitInfo in class ViewMode
Parameters:
x - x world coordinate
y - y world coordinate
Returns:
A HitInfo object that holds the first graph element that was hit at the given world coordinate.
See Also:
ViewMode.createHitInfo(double,double,boolean)

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Initiates reassignment of a hit port.

Overrides:
mousePressedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

createDummyEdgeRealizer

protected EdgeRealizer createDummyEdgeRealizer(EdgeRealizer edgeRealizer)
Creates a dummy EdgeRealizer for the dummy edge that is used during changeEdge operations. This will only be used if setChangeEdgeEnabled(boolean) is set to true. By default, this method returns edgeRealizer.createCopy();


createDummySourceNodeRealizer

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. nodeRealizer.createCopy();


createDummyTargetNodeRealizer

protected NodeRealizer createDummyTargetNodeRealizer(double x,
                                                     double y)
Creates a dummy node for the other end of the edge. This will only be used if setChangeEdgeEnabled(boolean) is set to true. This implementation returns a zero width/ zero height ShapeNodeRealizer

Parameters:
x - the initial x coordinate
y - the initial y coordinate
Returns:
the created dummy target realizer

getPortCandidates

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. The port coordinates are given in absolute world (graph) coordinates. The default implementation calls the given node's node realizer method NodeRealizer.getPortCandidates(double). Subclasses may override this method to change the behavior of this method.

Parameters:
v - the node that yields the port candidates
e - the edge that requests the port candidates
gridSpacing - the current gridSpacing.
Returns:
a list of YPoint objects that represent absolute port coordinates.

getGeometricPortCandidates

protected YList getGeometricPortCandidates(Node v,
                                           Edge e)
Callback method that contains an alternative implementation to 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.

Parameters:
v - The node for which the candidates shall be collected.
e - The edge for which candidates should be collected.
Returns:
A list of YPoint instances that indicate the absolute coordinates of the port candidates.

mouseDraggedLeft

public void mouseDraggedLeft(double x,
                             double y)
Moves the port.

Overrides:
mouseDraggedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

adjustCoordinates

protected YPoint adjustCoordinates(double x,
                                   double y,
                                   boolean disableSnappingModifierPressed,
                                   boolean snapToCandidate)
Callback method that adjusts the mouse coordinates to enable snapping.

Parameters:
x - The original mouse coordinate at the x axis
y - The original mouse coordinate at the y axis
disableSnappingModifierPressed - Whether snapping should be disabled temporarily.
snapToCandidate - Whether this method should snap to port candidates, only.
Returns:
The final new coordinates.

getHitNode

protected Node getHitNode(double x,
                          double y)
Returns the possible new node for the currently moved port. This implementation returns the original node first, and if the original node is not hit, the node returned by createHitNodeHitInfo(x, y).getHitNode() is returned.

Parameters:
x - the x world coordinate
y - the y world coordinate
Returns:
the new candidate to use as a replacement or null

createHitNodeHitInfo

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.


updatePortPosition

protected void updatePortPosition(double x,
                                  double y)
Helper method that updates the currently dragged port's position.


isOrthogonalRouting

protected boolean isOrthogonalRouting(Edge edge)
Determines whether the given edge instance should be routed orthogonally. This implementation uses the 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.

Parameters:
edge - the edge to decide
Returns:
true if the edge should be routed orthogonally.
See Also:
EditMode.isOrthogonalRouting(y.base.Edge)

mouseShiftReleasedLeft

public void mouseShiftReleasedLeft(double x,
                                   double y)
Terminates the reassignment of a port. The port will be assigned to the exact current position. If portSnappingEnabled is true mouseReleasedLeft(double, double) gets invoked instead.

Overrides:
mouseShiftReleasedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseReleasedRight

public void mouseReleasedRight(double x,
                               double y)
Calls mousePressedLeft(double, double).

Overrides:
mouseReleasedRight in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseShiftReleasedRight

public void mouseShiftReleasedRight(double x,
                                    double y)
Calls mouseShiftReleasedLeft(double, double).

Overrides:
mouseShiftReleasedRight in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseReleasedLeft

public void mouseReleasedLeft(double x,
                              double y)
Terminates the reassignment of a port. The port will automatically snap to the closest available port position.

Overrides:
mouseReleasedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

edgeChanged

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.

Parameters:
edge - the edge whose endpoints have been changed.

portWillBeMoved

protected void portWillBeMoved(Port port)
Invoked when the node port that will be moved is first determined.

Parameters:
port - the port that will be moved.

portMoved

protected void portMoved(Port port,
                         double x,
                         double y)
Invoked when the moved port has been assigned its final position.

Parameters:
port - the port who has been moved.
x - the port's final, absolute x-coordinate.
y - the port's final, absolute y-coordinate.

drawPortCandidate

protected void drawPortCandidate(java.awt.Graphics2D gfx,
                                 YPoint p,
                                 Node v,
                                 Edge e)
Draws a single port candidate. Subclasses can change the look of a port candidate by overriding this method. By default this method delegates to method drawPortCandidate(java.awt.Graphics2D, y.geom.YPoint, y.base.Node, y.base.Edge, boolean, boolean).

Parameters:
gfx - the active graphics context
p - the absolute port location
v - the node that yields the port
e - the edge that requests the port

drawPortCandidate

protected void drawPortCandidate(java.awt.Graphics2D gfx,
                                 YPoint p,
                                 Node v,
                                 Edge e,
                                 boolean isSnapActive,
                                 boolean isSnapCandidate)
Draws a single port candidate. Subclasses can change the look of a port candidate by overriding this method. Additional parameters give contextual information that will allow to draw single port candidates differently, depending on context.

Parameters:
gfx - the active graphics context
p - the absolute port location
v - the node that yields the port
e - the edge that requests the port
isSnapActive - whether or not port snapping is currently active
isSnapCandidate - whether or not the given port candidate is the candidate that will be snapped to.

isPortSnappingEnabled

public boolean isPortSnappingEnabled()
Returns whether this mode should snap the port to one of the predefined port positions, even if the shift modifier is pressed.


setPortSnappingEnabled

public 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. Default is true.


cancelEditing

public void cancelEditing()
                   throws java.lang.UnsupportedOperationException
Description copied from class: ViewMode
This can be used to cleanly exit an edit that is currently in progress.
The implementation and interpretation of "canceling" is left to subclasses. This implementation does nothing but calls setEditing(false) if ViewMode.isEditing() returns true

Overrides:
cancelEditing in class ViewMode
Throws:
java.lang.UnsupportedOperationException - if the editing cannot be canceled for any reason.

drawTargetNodeIndicator

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.

Parameters:
gfx - The graphics to paint into.
nodeRealizer - The realizer to highlight.

getMovePortCursor

public java.awt.Cursor getMovePortCursor()
Returns the cursor to be used when the mouse is over a draggable port point.

Returns:
by default Cursor.MOVE_CURSOR is returned.

getDefaultCursor

public java.awt.Cursor getDefaultCursor()
Returns the cursor to be used when the mouse is not over a draggable port point.

Returns:
by default Cursor.DEFAULT_CURSOR is returned.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.