Search this API

y.view
Class PortAssignmentMoveSelectionMode

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

public class PortAssignmentMoveSelectionMode
extends MoveSelectionMode

ViewMode that can be used to interactively assign PortConstraints to the edges of a graph. If this mode is registered as the MoveSelectionMode in an EditMode it will assign port constraints to edges if the first or last bend of an edge is moved. During the move the user is presented a drawable.

 

Field Summary
protected  Drawable hintDrawable
          Holds the drawable that is displayed during the move
protected  DataMap spc
          Holds the map for the source port constraints
protected  DataMap tpc
          Holds the map for the target port constraints
 
Fields inherited from class y.view.MoveSelectionMode
FIXED_AUTOBOUNDS_INSETS, FIXED_MINIMUM_GROUP_BOUNDS
 
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
PortAssignmentMoveSelectionMode(DataMap spc, DataMap tpc)
          Creates a new instance of PortAssignmentMoveSelectionMode using the given DataMap as containers for the source port constraints and target port constraints.
PortAssignmentMoveSelectionMode(ViewContainer view, DataMap spc, DataMap tpc)
          Creates a new instance of PortAssignmentMoveSelectionMode for the given ViewContainer using the DataMaps as containers for the source port constraints and target port constraints.
 
Method Summary
protected  Drawable createHintDrawable(Bend selectedBend)
          Callback method used by selectionMovedAction(double, double, double, double).
protected  Drawable createPortConstraintDrawable(PortConstraint pc, Node atNode, Edge forEdge, boolean source, boolean valid)
          Creates a drawable that represents a PortConstraint
protected  void destroyDrawable(Drawable d)
          Callback method used by selectionMovedAction(double, double, double, double).
 float getMaxDistance()
          Returns the maximum distance a bend may have from the adjacent port so that it will still be considered a port assignment.
protected  PortConstraint getPortConstraint(Bend selectedBend, boolean source)
          Determines a PortConstraint instance for the given bend.
 DataMap getSpc()
          Returns the DataMap that contains the SPCs
 DataMap getTpc()
          Returns the DataMap that contains the TPCs
protected  PortConstraint[] getValidPortConstraints(Edge edge, boolean source)
          Returns an array of valid port constraints for each edge
 boolean isDirectedArrows()
          Returns whether the arrow indicators should point in the direction of the edge or always away from the nodes.
protected  boolean isPortReassignmentAllowed(Edge edge, boolean source)
          Determines whether port reassignment is allowed for a given edge
protected  boolean isSourceBend(Bend selectedBend)
          Callback method used by selectionMovedAction(double, double, double, double).
protected  boolean isTargetBend(Bend selectedBend)
          Callback method used by selectionMovedAction(double, double, double, double).
protected  void portConstraintsUpdated(Edge onEdge)
          Callback called by selectionMovedAction(double, double, double, double) if the PortConstraints might have changed for the given edge.
protected  void selectionMovedAction(double dx, double dy, double x, double y)
          Called at the end of the move - updates the drawables.
protected  void selectionOnMove(double dx, double dy, double x, double y)
          Called at the beginning and during the move.
 void setDirectedArrows(boolean directedArrows)
          Sets whether the arrow indicators should point in the direction of the edge or always away from the nodes.
 void setMaxDistance(float maxDistance)
          Sets the maximum distance a bend may have from the adjacent port so that it will still be considered a port assignment.
 void setSpc(DataMap spc)
          Sets the DataMap that contains the SPCs.
 void setTpc(DataMap tpc)
          Sets the DataMap that contains the TPCs.
protected  Drawable updateDrawable(Drawable d, Bend selectedBend)
          Updates the drawable to reflect the new bend position.
 
Methods inherited from class y.view.MoveSelectionMode
activate, cancelEditing, createDropTargetHitInfo, createSnapContext, drawTargetNodeIndicator, findAdditionalElements, findAdditionalElements, getBendsToBeMoved, getDisableSnappingModifier, getGroupBoundsPolicy, getGroupingDropTarget, getHierarchyManager, getNodesToBeMoved, getSnapContext, getTargetNodeIndicatorBounds, isDisableSnappingModifierPressed, isGroupReassignmentEnabled, isIndicatingTargetGroup, isOrthogonalRouting, isRemovingInnerBends, isSnappingEnabled, mouseDraggedLeft, mouseDraggedRight, mousePressedLeft, mouseReleased, mouseReleasedLeft, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftReleasedLeft, reactivateParent, selectionMoveStarted, setDisableSnappingModifier, setGroupBoundsPolicy, setGroupReassignmentEnabled, setIndicatingTargetGroup, setRemovingInnerBends, setSnapContext, setSnappingEnabled
 
Methods inherited from class y.view.ViewMode
addPropertyChangeListener, addPropertyChangeListener, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleasedMiddle, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, mouseShiftReleasedRight, 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

spc

protected DataMap spc
Holds the map for the source port constraints


tpc

protected DataMap tpc
Holds the map for the target port constraints


hintDrawable

protected Drawable hintDrawable
Holds the drawable that is displayed during the move

Constructor Detail

PortAssignmentMoveSelectionMode

public PortAssignmentMoveSelectionMode(DataMap spc,
                                       DataMap tpc)
Creates a new instance of PortAssignmentMoveSelectionMode using the given DataMap as containers for the source port constraints and target port constraints.


PortAssignmentMoveSelectionMode

public PortAssignmentMoveSelectionMode(ViewContainer view,
                                       DataMap spc,
                                       DataMap tpc)
Creates a new instance of PortAssignmentMoveSelectionMode for the given ViewContainer using the DataMaps as containers for the source port constraints and target port constraints.

Method Detail

selectionMovedAction

protected void selectionMovedAction(double dx,
                                    double dy,
                                    double x,
                                    double y)
Called at the end of the move - updates the drawables.

Overrides:
selectionMovedAction in class MoveSelectionMode
See Also:
isSourceBend(Bend), isTargetBend(Bend), isPortReassignmentAllowed(Edge, boolean), portConstraintsUpdated(Edge)

portConstraintsUpdated

protected void portConstraintsUpdated(Edge onEdge)
Callback called by selectionMovedAction(double, double, double, double) if the PortConstraints might have changed for the given edge.


selectionOnMove

protected void selectionOnMove(double dx,
                               double dy,
                               double x,
                               double y)
Called at the beginning and during the move. Updates the drawable.

Overrides:
selectionOnMove in class MoveSelectionMode
Parameters:
dx - the difference between the given x-coordinate and the x-coordinate of the last mouse event handled by this mode.
dy - the difference between the given y-coordinate and the y-coordinate of the last mouse event handled by this mode.
x - the x-coordinate of the triggering mouse event in the world coordinate system.
y - the y-coordinate of the triggering mouse event in the world coordinate system.
See Also:
createHintDrawable(Bend), updateDrawable(Drawable, Bend)

isSourceBend

protected boolean isSourceBend(Bend selectedBend)
Callback method used by selectionMovedAction(double, double, double, double). This method determines whether a given bend is considered a bend that controls the SPC.


isTargetBend

protected boolean isTargetBend(Bend selectedBend)
Callback method used by selectionMovedAction(double, double, double, double). This method determines whether a given bend is considered a bend that controls the TPC.


createHintDrawable

protected Drawable createHintDrawable(Bend selectedBend)
Callback method used by selectionMovedAction(double, double, double, double). This method creates and returns an appropriate drawable that gives a hint to the user.


destroyDrawable

protected void destroyDrawable(Drawable d)
Callback method used by selectionMovedAction(double, double, double, double). This method destroys a previously created drawable that gave hints to the user.


getPortConstraint

protected PortConstraint getPortConstraint(Bend selectedBend,
                                           boolean source)
Determines a PortConstraint instance for the given bend.


updateDrawable

protected Drawable updateDrawable(Drawable d,
                                  Bend selectedBend)
Updates the drawable to reflect the new bend position.


getValidPortConstraints

protected PortConstraint[] getValidPortConstraints(Edge edge,
                                                   boolean source)
Returns an array of valid port constraints for each edge


createPortConstraintDrawable

protected Drawable createPortConstraintDrawable(PortConstraint pc,
                                                Node atNode,
                                                Edge forEdge,
                                                boolean source,
                                                boolean valid)
Creates a drawable that represents a PortConstraint


isPortReassignmentAllowed

protected boolean isPortReassignmentAllowed(Edge edge,
                                            boolean source)
Determines whether port reassignment is allowed for a given edge


getSpc

public DataMap getSpc()
Returns the DataMap that contains the SPCs

Returns:
the map of SPCs

setSpc

public void setSpc(DataMap spc)
Sets the DataMap that contains the SPCs.

Parameters:
spc - the map of SPCs

getTpc

public DataMap getTpc()
Returns the DataMap that contains the TPCs

Returns:
the map of TPCs

setTpc

public void setTpc(DataMap tpc)
Sets the DataMap that contains the TPCs.

Parameters:
tpc - the map of TPCs

getMaxDistance

public float getMaxDistance()
Returns the maximum distance a bend may have from the adjacent port so that it will still be considered a port assignment.

Returns:
the maximum distance

setMaxDistance

public void setMaxDistance(float maxDistance)
Sets the maximum distance a bend may have from the adjacent port so that it will still be considered a port assignment.

Parameters:
maxDistance - the maximum distance

isDirectedArrows

public boolean isDirectedArrows()
Returns whether the arrow indicators should point in the direction of the edge or always away from the nodes.


setDirectedArrows

public void setDirectedArrows(boolean directedArrows)
Sets whether the arrow indicators should point in the direction of the edge or always away from the nodes.

Parameters:
directedArrows - whether to use the direction of the edge

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