Search this API

y.view
Class EditMode

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

public class EditMode
extends ViewMode

This view mode is the default edit mode for a Graph2DView. With this mode it is possible to

  1. create nodes
  2. create edges
  3. create bends
  4. select and deselect graph elements
  5. display context sensitive popup menus for graph elements and the view background
  6. reassign port positions
  7. reassign label positions

This complex mode makes use of other minor modes that have specialized responsibilities. It is possible to exchange these minor modes by customized versions.
Optionally, this mode and its associated minor modes provide special support for maintaining orthogonal edge paths. See ORTHOGONAL_ROUTING_DPKEY, isOrthogonalRouting(y.base.Edge), and setOrthogonalEdgeRouting(boolean).

 

Field Summary
protected  ViewMode createEdgeMode
          The minor create edge mode associated with this mode.
protected  ViewMode editNodeMode
          The minor edit node mode associated with this mode.
protected  ViewMode hotSpotMode
          Child mode HotSpotMode
protected  MouseInputMode mouseInputMode
          The minor mouse input mode associated with this mode.
protected  ViewMode moveLabelMode
          The minor move label mode associated with this mode.
protected  ViewMode moveNodePortMode
          The minor move node port mode associated with this mode.
protected  ViewMode movePortMode
          The minor move port mode associated with this mode.
protected  ViewMode moveSelectionMode
          The minor move selection mode associated with this mode.
protected  ViewMode moveViewPortMode
          The minor move viewport mode associated with this mode.
static java.lang.Object ORTHOGONAL_ROUTING_DPKEY
          A DataProvider that can be registered with the graph to determine whether an edge should be routed orthogonally.
protected  ViewMode popupMode
          The minor popup mode associated with this mode
protected  Node pressedNode
          Will be set when the mouse was pressed over a node.
protected  ViewMode selectionBoxMode
          The minor selection box mode associated with this mode.
 
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
EditMode()
          Instantiates a new EditMode
EditMode(ViewContainer vc)
          Instantiates a new EditMode for a given ViewContainer
 
Method Summary
 void activate(boolean activate)
          Invoked when the Mode is activated/deactivated from the ViewControl or via the setChild() and reactivateParent operations This behaves like a bound property using ViewMode.ACTIVE_PROPERTY as the property name.
 void allowBendCreation(boolean b)
          Allows or disallows bend creation.
 void allowEdgeCreation(boolean b)
          Allows or disallows edge creation.
 void allowLabelSelection(boolean b)
          Allows or disallows selecting labels by clicking on them.
 void allowMouseInput(boolean b)
          Allows or disallows the delegation of events to a MouseInputMode.
 void allowMoveLabels(boolean b)
          Allows or disallows moving around labels in the displayed graph.
 void allowMovePorts(boolean b)
          Allows or disallows moving around ports in the displayed graph.
 void allowMoveSelection(boolean b)
          Allows or disallows moving around the selected elements of the displayed graph.
 void allowMoving(boolean b)
          Allows or disallows moving the viewport of the view via the right mouse button.
 void allowMovingWithPopup(boolean b)
          Allows or disallows moving the viewport of the view via the right mouse button even if a popup menu is present.
 void allowNodeCreation(boolean b)
          Allows or disallows node creation.
 void allowNodeEditing(boolean b)
          Allows or disallows node editing.
 void allowResizeNodes(boolean b)
          Allows or disallows resizing of nodes by dragging at the selection hotspots.
 void assignNodeLabel(boolean b)
          Determines whether or not to assign a generic node label for newly created nodes.
protected  void beforeSelectionCycling(YCursor cyclicHits)
          This method is called before cycling the selection.
protected  void bendClicked(Graph2D graph, Bend bend, boolean wasSelected, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a Bend has been clicked.
protected  void bendCreated(Graph2D graph, Edge edge, Bend bend, double x, double y)
          This method gets called after a new bend has been created by this mode.
protected  void bendDragged(Graph2D graph, Bend bend, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a Bend is being dragged.
 void cancelEditing()
          This can be used to cleanly exit an edit that is currently in progress.
protected  void configureNode(Graph2D graph, Node node)
          Callback called by createNode(Graph2D,double,double,y.base.Node) right after a new node has been created (and prior to assigning the new node a parent node).
protected  Bend createBend(Graph2D graph, Edge edge, double x, double y)
          Callback called by mouseDraggedLeft(double,double) when a bend should be created.
protected  ViewMode createCreateEdgeMode()
          Factory method, which creates the CreateEdgeMode.
protected  HitInfo createCyclicHitInfo(double x, double y)
           
protected  ViewMode createEditNodeMode()
          Factory method, which can create the minor mode that is responsible for node editing.
protected  ViewMode createHotSpotMode()
          Factory method, which creates the HotSpotMode.
protected  HitInfo createLabelHitInfo(double x, double y)
          Performs a hit test for a group node label at the specified location.
protected  MouseInputMode createMouseInputMode()
          Factory method, which creates the MouseInputMode.
protected  ViewMode createMoveLabelMode()
          Factory method, which creates the MoveLabelMode.
protected  ViewMode createMoveNodePortMode()
          Factory method, which creates the MoveNodePortMode.
protected  ViewMode createMovePortMode()
          Factory method, which creates the MovePortMode.
protected  ViewMode createMoveSelectionMode()
          Factory method, which creates the MoveSelectionMode.
protected  ViewMode createMoveViewPortMode()
          Factory method, which creates the MoveViewPortMode.
protected  Node createNode(Graph2D graph, double x, double y)
          Callback called by paperClicked(Graph2D,double,double,boolean) when a node should be created.
protected  Node createNode(Graph2D graph, double x, double y, Node parent)
          Callback called by groupNodeClicked(y.base.Node) when a node should be created.
protected  ViewMode createOrthogonalMoveBendsMode()
          Factory method that creates an OrthogonalMoveBendsMode.
protected  ViewMode createPopupMode()
          Factory method, which can create the PopupMode.
protected  ViewMode createSelectionBoxMode()
          Factory method, which creates the SelectionBoxMode.
 boolean doAllowBendCreation()
          Returns true iff the creation of bends should be allowed.
 boolean doAllowEdgeCreation()
          Returns true iff the creation of edges should be allowed.
 boolean doAllowLabelSelection()
          Returns true iff the selection of labels via mouse clicks should be allowed.
 boolean doAllowMouseInput()
          Returns true iff events will be handled by a MouseInputMode first.
 boolean doAllowMoveLabels()
          Returns true iff the moving of labels should be allowed.
 boolean doAllowMovePorts()
          Returns true iff the moving of ports should be allowed.
 boolean doAllowMoveSelection()
          Returns whether or not to allow moving around the selected elements of the displayed graph.
 boolean doAllowMoving()
          Returns whether or not to allow moving the viewport of the view via right mouse drag action.
 boolean doAllowMovingWithPopup()
          Returns whether or not to allow moving the viewport of the view via right mouse drag action in the presence of a popup menu.
 boolean doAllowNodeCreation()
          Returns true iff the creation of nodes should be allowed.
 boolean doAllowNodeEditing()
          Returns true iff the editing of nodes should be allowed.
 boolean doAllowResizeNodes()
          Returns whether or not to allow resizing of nodes by dragging at the selection hotspots.
 boolean doAssignNodeLabel()
          Returns true iff a generic node label is assigned for newly created nodes.
 boolean doShowEdgeTips()
          Returns true if this mode should display tip text for an edge.
 boolean doShowNodeTips()
          Returns true if this mode should display tip text for a node.
protected  void edgeClicked(Graph2D graph, Edge edge, boolean wasSelected, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when an Edge has been clicked.
protected  void edgeDragged(Graph2D graph, Edge edge, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when an Edge is being dragged.
protected  boolean editNode(Node hitNode, java.util.EventObject e)
          Tries to start editing the given Node using the current editNodeMode.
 ViewMode getCreateEdgeMode()
          Returns the minor create edge mode associated with this mode.
 int getCyclicSelectionModifierMask()
           
 java.awt.Cursor getDefaultCursor()
          Returns the default cursor displayed by this mode if no other cursor can be found.
protected  java.lang.String getEdgeTip(Edge e)
          Returns the tip text displayed for the given edge.
 ViewMode getEditNodeMode()
          Returns the minor mode for node editing associated with this mode
 int getGroupBorderWidth()
          returns the width the active group node border.
 ViewMode getHotSpotMode()
          Getter for child mode HotSpotMode.
 MouseInputMode getMouseInputMode()
          Returns the minor mode for delegating mouse input, i.e., mouse events, to.
 ViewMode getMoveLabelMode()
          Getter for child mode MoveLabelMode.
 ViewMode getMoveNodePortMode()
          Getter for child mode MoveNodePortMode.
 ViewMode getMovePortMode()
          Getter for child mode MovePortMode.
 ViewMode getMoveSelectionMode()
          Returns the minor move selection mode associated with this mode.
 ViewMode getMoveViewPortMode()
          Getter for child mode MoveViewPortMode.
protected  java.lang.String getNodeTip(Node v)
          Returns the tip text displayed for the given node.
 ViewMode getOrthogonalMoveBendsMode()
          Getter for child mode OrthogonalMoveBendsMode.
 ViewMode getPopupMode()
          Returns the minor popup mode associated with this mode
 ViewMode getSelectionBoxMode()
          Returns the minor selection box mode associated with this mode.
protected  void groupNodeClicked(Node v)
          This method gets called after a left mouse click on a group node occurred.
protected  void hotSpotDragged(Graph2D graph, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a node hot spot is being dragged.
 boolean isAdjustScrollBarPolicy()
          Returns true if the scroll bars in Graph2DView will be shown (if needed) when this mode is activated (default).
 boolean isChildNodeCreationEnabled()
          Determines whether child nodes may be created when clicking on a group node.
protected  boolean isCreateEdgeGesture(java.awt.event.MouseEvent lastPress, java.awt.event.MouseEvent lastDrag)
          Determines whether the last press and drag initiates a create edge gesture.
 boolean isCreateEdgeOnGroupNodeLabelEnabled()
          Returns whether or not a bend will be created when the mouse is released on the first label of a group node.
 boolean isCyclicSelectionEnabled()
           
protected  boolean isCyclicSelectionModifierPressed()
           
protected  boolean isEditNodeGesture(Node hitNode, java.awt.event.MouseEvent lastPressEvent, java.awt.event.MouseEvent lastReleaseEvent, java.awt.event.MouseEvent lastClickEvent)
          Determines if the given gesture is considered a gesture to start node editing.
protected  boolean isGroupNodeBorderHit(Graph2D graph, Node node, double x, double y, boolean considerGroupNodeLabel)
          Determines whether the specified coordinates lie within the border area of a group node.
 boolean isMixedSelectionEnabled()
          Determines whether or not this instance allows mixed selections of different kinds of graph elements (nodes/bends, edges, labels, node ports) to exist at the same time.
 boolean isOrthogonalEdgeRouting()
          Returns whether or not special support for orthogonal edge paths is enabled for all edges.
protected  boolean isOrthogonalRouting(Edge edge)
          Callback that determines whether an edge should be treated as an orthogonally routed edge.
protected  boolean isSelected(Graph2D graph, Bend bend)
          Returns true if the specified bend is currently selected; false otherwise.
protected  boolean isSelected(Graph2D graph, Edge edge)
          Returns true if the specified edge is currently selected; false otherwise.
protected  boolean isSelected(Graph2D graph, Node node)
          Returns true if the specified node is currently selected; false otherwise.
protected  boolean isSelected(Graph2D graph, NodePort port)
          Returns true if the specified port is currently selected; false otherwise.
protected  boolean isSelected(Graph2D graph, YLabel label)
          Returns true if the specified label is currently selected; false otherwise.
protected  boolean isSelectionEmpty(Graph2D graph)
          Returns true if there are no selected nodes, node labels, node ports, edges, edge labels, and/or bends in the specified graph and false otherwise.
 boolean isSelectOnGroupNodeLabelEnabled()
          Determines whether clicking on a group node's default label should select the node instead of creating a child node when child node creation is enabled.
protected  void labelClicked(Graph2D graph, YLabel label, boolean wasSelected, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a YLabel has been clicked.
protected  void labelClicked(YLabel label)
          This method gets called after a left mouse click on a label occurred.
protected  void labelDragged(Graph2D graph, EdgeLabel label, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when an EdgeLabel is being dragged.
protected  void labelDragged(Graph2D graph, NodeLabel label, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a NodeLabel is being dragged.
 void mouseClicked(double x, double y)
          Called when the mouse was clicked
 void mouseDraggedLeft(double x, double y)
          Activates a minor mode.
 void mouseDraggedRight(double x, double y)
          Called when the mouse was dragged with the right button down.
 void mouseEntered(java.awt.event.MouseEvent e)
          The mouse enters the viewer component.
 void mouseMoved(double x, double y)
          When moving the mouse, the mouse cursor has to be adjusted.
 void mousePressed(java.awt.event.MouseEvent e)
          A mouse button gets pressed.
 void mousePressedLeft(double x, double y)
          Takes the given coordinate and performs with it a hit test on all graph elements.
 void mousePressedRight(double x, double y)
          If a popup mode is associates with this mode then it will be activated.
 void mouseReleasedLeft(double x, double y)
          Depending on the history, actions are triggered, but only if Mouse was not moved since the button was pressed.
 void mouseReleasedRight(double x, double y)
          Called when the right mouse button was released
 void mouseShiftPressedLeft(double x, double y)
          Takes the given coordinate and performs with it a hit test on all graph elements.
 void mouseShiftReleasedLeft(double x, double y)
          Depending on the history, actions are triggered, but only if Mouse was not moved since the button was pressed.
protected  void nodeClicked(Graph2D graph, Node node, boolean wasSelected, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a Node has been clicked.
protected  void nodeClicked(Node v)
          This method gets called after a left mouse click on a node occurred.
protected  void nodeCreated(Node v)
          This method gets called after a new node was completely created by this mode.
protected  void nodeDragged(Graph2D graph, Node node, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a Node is being dragged.
protected  void nodePortClicked(Graph2D graph, NodePort port, boolean wasSelected, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a NodePort has been clicked.
protected  void nodePortDragged(Graph2D graph, NodePort port, boolean wasSelected, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a NodePort is being dragged.
protected  void paperClicked(Graph2D graph, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when the canvas has been clicked.
protected  void paperDragged(Graph2D graph, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a drag operation is performed on the empty graph canvas.
protected  void portDragged(Graph2D graph, Port port, double x, double y, boolean firstDrag)
          Callback called by mouseDraggedLeft(double,double) when a Port is being dragged.
protected  void prepareView(Graph2DView view)
          Callback called by activate(true) to initialize the view.
 void setAdjustScrollBarPolicy(boolean adjustScrollBarPolicy)
          Whether the scroll bars will be shown (if needed) when this mode is activated.
 void setChild(ViewMode child, java.awt.event.MouseEvent pressEvent, java.awt.event.MouseEvent dragEvent, java.awt.event.MouseEvent releaseEvent)
          Sets a child mode for this mode.
 void setChildNodeCreationEnabled(boolean enabled)
          Specifies whether child nodes may be created when clicking on a group node.
 void setCreateEdgeMode(ViewMode mode)
          Sets the minor create edge mode associated with this mode.
 void setCreateEdgeOnGroupNodeLabelEnabled(boolean enabled)
          Whether or not to connect an edge to a group node when the mouse is released on its first label.
 void setCyclicSelectionEnabled(boolean enabled)
          If set to true this mode will cycle the selection through all hits at the current position when the left mouse button is clicked while pressing the modifier(s) specified in setCyclicSelectionModifierMask(int).
 void setCyclicSelectionModifierMask(int modifierMask)
          The given modifier mask is used for cyclic selection.
 void setDefaultCursor(java.awt.Cursor defaultCursor)
          Sets the default cursor displayed by this mode if no other cursor is determined.
 void setEditNodeMode(ViewMode mode)
          Sets the minor mode for node editing associated with this mode.
 void setGroupBorderWidth(int groupBorderWidth)
          Sets the width of the active group node border.
 void setHotSpotMode(ViewMode hotSpotMode)
          Setter for child mode HotSpotMode.
 void setMixedSelectionEnabled(boolean enable)
          Allows or disallows mixed selections of different kinds of graph elements (nodes/bends, edges, labels, node ports) to exist at the same time.
 void setMouseInputMode(MouseInputMode mode)
          Sets the minor mouse input mode associated with this mode.
 void setMoveLabelMode(ViewMode moveLabelMode)
          Setter for child mode MoveLabelMode.
 void setMoveNodePortMode(ViewMode moveNodePortMode)
          Setter for child mode MoveNodePortMode.
 void setMovePortMode(ViewMode movePortMode)
          Setter for child mode MovePortMode.
 void setMoveSelectionMode(ViewMode mode)
          Sets the minor move selection mode associated with this mode.
 void setMoveViewPortMode(ViewMode moveViewPortMode)
          Setter for child mode MovePortMode.
 void setOrthogonalEdgeRouting(boolean enable)
          Sets whether special support for orthogonal edge paths should be enabled for all edges.
 void setOrthogonalMoveBendsMode(ViewMode orthogonalMoveBendMode)
          Setter for child mode OrthogonalMoveBendsMode.
 void setPopupMode(ViewMode mode)
          Sets the minor popup mode associated with this mode.
protected  void setSelected(Graph2D graph, Bend bend, boolean state)
          Sets the specified selection state for the specified bend.
protected  void setSelected(Graph2D graph, Edge edge, boolean state)
          Sets the specified selection state for the specified edge.
protected  void setSelected(Graph2D graph, Node node, boolean state)
          Sets the specified selection state for the specified node.
protected  void setSelected(Graph2D graph, NodePort port, boolean state)
          Sets the specified selection state for the specified node port.
protected  void setSelected(Graph2D graph, YLabel label, boolean state)
          Sets the specified selection state for the specified label.
 void setSelectionBoxMode(ViewMode mode)
          Sets the minor selection box mode associated with this mode.
 void setSelectOnGroupNodeLabelEnabled(boolean enabled)
          Specifies whether clicking on a group node's default label should select the node instead of creating a child node when child node creation is enabled.
 void setSnappingEnabled(boolean snapping)
          Convenience method that tries to configure the various child modes of this mode to enable or disable snapping accordingly.
 void showEdgeTips(boolean b)
          Specifies whether or not this mode will show a tool tip for edges.
 void showNodeTips(boolean b)
          Specifies whether or not this mode will show a tool tip for nodes.
 boolean startEditor(MouseInputEditor editor)
          Tries to start the given MouseInputEditor if mouse input is currently allowed and the corresponding MouseInputMode is available.
protected  void unselectAll(Graph2D graph)
          Sets the selection state of all nodes, node labels, node ports, edges, edge labels, and bends to false.
protected  void unselectBends(Graph2D graph)
          Sets the selection state of all bends in the specified graph to false.
protected  void unselectNodes(Graph2D graph)
          Sets the selection state of all nodes in the specified graph to false.
 
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, mouseDragged, mouseDraggedMiddle, mouseExited, mouseMoved, mousePressedMiddle, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, 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

pressedNode

protected Node pressedNode
Will be set when the mouse was pressed over a node.


popupMode

protected ViewMode popupMode
The minor popup mode associated with this mode


hotSpotMode

protected ViewMode hotSpotMode
Child mode HotSpotMode


selectionBoxMode

protected ViewMode selectionBoxMode
The minor selection box mode associated with this mode.


createEdgeMode

protected ViewMode createEdgeMode
The minor create edge mode associated with this mode.


moveSelectionMode

protected ViewMode moveSelectionMode
The minor move selection mode associated with this mode.


moveLabelMode

protected ViewMode moveLabelMode
The minor move label mode associated with this mode.


movePortMode

protected ViewMode movePortMode
The minor move port mode associated with this mode.


editNodeMode

protected ViewMode editNodeMode
The minor edit node mode associated with this mode.


moveViewPortMode

protected ViewMode moveViewPortMode
The minor move viewport mode associated with this mode.


mouseInputMode

protected MouseInputMode mouseInputMode
The minor mouse input mode associated with this mode.


moveNodePortMode

protected ViewMode moveNodePortMode
The minor move node port mode associated with this mode.


ORTHOGONAL_ROUTING_DPKEY

public static final java.lang.Object ORTHOGONAL_ROUTING_DPKEY
A DataProvider that can be registered with the graph to determine whether an edge should be routed orthogonally. The DataProvider should return a boolean for each Edge object it is queried for. Note that if no DataProvider is bound to the graph instance this mode will automatically register one that delegates the request to isOrthogonalRouting(y.base.Edge).

See Also:
isOrthogonalRouting(y.base.Edge)
Constructor Detail

EditMode

public EditMode(ViewContainer vc)
Instantiates a new EditMode for a given ViewContainer


EditMode

public EditMode()
Instantiates a new EditMode

Method Detail

isAdjustScrollBarPolicy

public boolean isAdjustScrollBarPolicy()
Returns true if the scroll bars in Graph2DView will be shown (if needed) when this mode is activated (default).

Returns:
true if the scroll bars in Graph2DView will be shown when this mode is activated (default).

setAdjustScrollBarPolicy

public void setAdjustScrollBarPolicy(boolean adjustScrollBarPolicy)
Whether the scroll bars will be shown (if needed) when this mode is activated.

Parameters:
adjustScrollBarPolicy - true if the scroll bars in Graph2DView should be shown (if needed) when this mode is activated (default).

setSnappingEnabled

public void setSnappingEnabled(boolean snapping)
Convenience method that tries to configure the various child modes of this mode to enable or disable snapping accordingly. This method will call the following methods: Note that for most use cases this is not enough. There are plenty of other properties in the corresponding ViewModes that allow for customization of the snapping behavior, they should be set one-by-one to appropriate values depending on the use case.

Parameters:
snapping - Whether to enable snapping.

createHotSpotMode

protected ViewMode createHotSpotMode()
Factory method, which creates the HotSpotMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized HotSpotMode.

createMouseInputMode

protected MouseInputMode createMouseInputMode()
Factory method, which creates the MouseInputMode. Subclasses can override this method in order to return a more specialized version.

Returns:
A new MouseInputMode.

createMovePortMode

protected ViewMode createMovePortMode()
Factory method, which creates the MovePortMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized MovePortMode.

createMoveViewPortMode

protected ViewMode createMoveViewPortMode()
Factory method, which creates the MoveViewPortMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized MoveViewPortMode.

createMoveLabelMode

protected ViewMode createMoveLabelMode()
Factory method, which creates the MoveLabelMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized MoveLabelMode.

createMoveSelectionMode

protected ViewMode createMoveSelectionMode()
Factory method, which creates the MoveSelectionMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized MoveSelectionMode.

createCreateEdgeMode

protected ViewMode createCreateEdgeMode()
Factory method, which creates the CreateEdgeMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized CreateEdgeMode.

createSelectionBoxMode

protected ViewMode createSelectionBoxMode()
Factory method, which creates the SelectionBoxMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized SelectionBoxMode.

createPopupMode

protected ViewMode createPopupMode()
Factory method, which can create the PopupMode. Subclasses can override this method in order to return an instance.

Returns:
null.

createEditNodeMode

protected ViewMode createEditNodeMode()
Factory method, which can create the minor mode that is responsible for node editing. Subclasses can override this method in order to return an instance.

Returns:
null.

createMoveNodePortMode

protected ViewMode createMoveNodePortMode()
Factory method, which creates the MoveNodePortMode. Subclasses can override this method in order to return a more specialized version.

Returns:
a specialized MoveNodePortMode.

activate

public void activate(boolean activate)
Description copied from class: ViewMode
Invoked when the Mode is activated/deactivated from the ViewControl or via the setChild() and reactivateParent operations This behaves like a bound property using ViewMode.ACTIVE_PROPERTY as the property name.

Overrides:
activate in class ViewMode
Parameters:
activate - set true when mode was activated false otherwise

cancelEditing

public void cancelEditing()
                   throws java.lang.UnsupportedOperationException
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.

setChild

public void setChild(ViewMode child,
                     java.awt.event.MouseEvent pressEvent,
                     java.awt.event.MouseEvent dragEvent,
                     java.awt.event.MouseEvent releaseEvent)
Description copied from class: ViewMode
Sets a child mode for this mode. All mouse events will be delegated this child mode until the child calls ViewMode.reactivateParent(). After the child mode is installed it will receive the given press, drag and release events before any other mouse events. Only non-null events will be delegated.
Prior to that the child mode will be informed about the active view, its new parent, the last HitInfo, and will be activated.
If null is passed as the child or the child calls its ViewMode.reactivateParent() method, the previously installed child will be deactivated and have its parent set to null. This behaves like a bound property using ViewMode.CHILD_MODE_PROPERTY as the property name.

Overrides:
setChild in class ViewMode

prepareView

protected void prepareView(Graph2DView view)
Callback called by activate(true) to initialize the view. This implementation sets the scrollbar policy and the cursor.

Parameters:
view - the view to initialize.

setMixedSelectionEnabled

public void setMixedSelectionEnabled(boolean enable)
Allows or disallows mixed selections of different kinds of graph elements (nodes/bends, edges, labels, node ports) to exist at the same time.

If disabled, this instance will clear the selection if the user selects an item of another kind while holding the modifier.

The default is false.

See Also:
isMixedSelectionEnabled()

isMixedSelectionEnabled

public boolean isMixedSelectionEnabled()
Determines whether or not this instance allows mixed selections of different kinds of graph elements (nodes/bends, edges, labels, node ports) to exist at the same time.

The default is false.

See Also:
setMixedSelectionEnabled(boolean)

setOrthogonalEdgeRouting

public void setOrthogonalEdgeRouting(boolean enable)
Sets whether special support for orthogonal edge paths should be enabled for all edges. The default is false.

See ORTHOGONAL_ROUTING_DPKEY and isOrthogonalRouting(y.base.Edge) for information on how to enable this special support for only a subset of edges.

Parameters:
enable - true if all edges should be treated as being orthogonal.
See Also:
isOrthogonalEdgeRouting()

isOrthogonalEdgeRouting

public boolean isOrthogonalEdgeRouting()
Returns whether or not special support for orthogonal edge paths is enabled for all edges. The default is false.

Returns:
true if special support for orthogonal edge paths is enabled; false otherwise.
See Also:
setOrthogonalEdgeRouting(boolean)

assignNodeLabel

public void assignNodeLabel(boolean b)
Determines whether or not to assign a generic node label for newly created nodes. The default is true.

See Also:
doAssignNodeLabel()

allowNodeCreation

public void allowNodeCreation(boolean b)
Allows or disallows node creation. By default node creation is allowed.

See Also:
doAllowNodeCreation()

allowNodeEditing

public void allowNodeEditing(boolean b)
Allows or disallows node editing. By default node editing is allowed but no mode is set.

See Also:
doAllowNodeEditing()

allowEdgeCreation

public void allowEdgeCreation(boolean b)
Allows or disallows edge creation. By default edge creation is allowed.

See Also:
doAllowEdgeCreation()

allowBendCreation

public void allowBendCreation(boolean b)
Allows or disallows bend creation. By default bend creation is allowed.

See Also:
doAllowBendCreation()

allowMoveSelection

public void allowMoveSelection(boolean b)
Allows or disallows moving around the selected elements of the displayed graph.

By default moving around selected elements is allowed.

See Also:
doAllowMoveSelection()

allowMoveLabels

public void allowMoveLabels(boolean b)
Allows or disallows moving around labels in the displayed graph.

By default moving around labels is allowed.

See Also:
doAllowMoveLabels()

allowMovePorts

public void allowMovePorts(boolean b)
Allows or disallows moving around ports in the displayed graph.

By default moving around ports is allowed.

See Also:
doAllowMovePorts()

allowLabelSelection

public void allowLabelSelection(boolean b)
Allows or disallows selecting labels by clicking on them. The default is true.

See Also:
doAllowLabelSelection()

allowMoving

public void allowMoving(boolean b)
Allows or disallows moving the viewport of the view via the right mouse button. If a popup listener is set for this mode then moving is not possible anymore.

By default moving the viewport is allowed.

See Also:
allowMovingWithPopup(boolean), doAllowMoving()

allowMovingWithPopup

public void allowMovingWithPopup(boolean b)
Allows or disallows moving the viewport of the view via the right mouse button even if a popup menu is present. This setting supersedes allowMoving(boolean), if it is set.

By default moving the viewport in the presence of a popup menu is not allowed.

Parameters:
b - whether or not to allow moving with the right mouse button in the presence of a popup menu.
See Also:
allowMoving(boolean), doAllowMovingWithPopup()

allowResizeNodes

public void allowResizeNodes(boolean b)
Allows or disallows resizing of nodes by dragging at the selection hotspots.

By default node resizing is allowed.

See Also:
doAllowResizeNodes()

allowMouseInput

public void allowMouseInput(boolean b)
Allows or disallows the delegation of events to a MouseInputMode.

By default event delegation to MouseInputMode is allowed.

See Also:
doAllowMouseInput()

doAssignNodeLabel

public boolean doAssignNodeLabel()
Returns true iff a generic node label is assigned for newly created nodes. This mode will act according to the return value of this method.

See Also:
assignNodeLabel(boolean)

doAllowNodeCreation

public boolean doAllowNodeCreation()
Returns true iff the creation of nodes should be allowed. This mode will act according to the return value of this method.

See Also:
allowNodeCreation(boolean)

doAllowNodeEditing

public boolean doAllowNodeEditing()
Returns true iff the editing of nodes should be allowed. This mode will act according to the return value of this method.

See Also:
allowNodeEditing(boolean)

doAllowEdgeCreation

public boolean doAllowEdgeCreation()
Returns true iff the creation of edges should be allowed. This mode will act according to the return value of this method.

See Also:
allowEdgeCreation(boolean)

doAllowBendCreation

public boolean doAllowBendCreation()
Returns true iff the creation of bends should be allowed. This mode will act according to the return value of this method.

See Also:
allowBendCreation(boolean)

doAllowLabelSelection

public boolean doAllowLabelSelection()
Returns true iff the selection of labels via mouse clicks should be allowed. This mode will act according to the return value of this method. The default value is true.

See Also:
allowLabelSelection(boolean)

doAllowMoveLabels

public boolean doAllowMoveLabels()
Returns true iff the moving of labels should be allowed. This mode will act according to the return value of this method.

See Also:
allowMoveLabels(boolean)

doAllowMovePorts

public boolean doAllowMovePorts()
Returns true iff the moving of ports should be allowed. This mode will act according to the return value of this method.

See Also:
allowMovePorts(boolean)

doAllowMouseInput

public boolean doAllowMouseInput()
Returns true iff events will be handled by a MouseInputMode first. This mode will act according to the return value of this method.

See Also:
allowMouseInput(boolean)

doAllowMoveSelection

public boolean doAllowMoveSelection()
Returns whether or not to allow moving around the selected elements of the displayed graph.

Returns:
true if selected elements may be moved around; false otherwise.
See Also:
allowMoveSelection(boolean)

doAllowMoving

public boolean doAllowMoving()
Returns whether or not to allow moving the viewport of the view via right mouse drag action. Moving is not allowed, if a popup menu is present unless doAllowMovingWithPopup() returns true.

Returns:
true if the viewport may be moved; false otherwise.
See Also:
doAllowMovingWithPopup(), allowMoving(boolean)

doAllowMovingWithPopup

public boolean doAllowMovingWithPopup()
Returns whether or not to allow moving the viewport of the view via right mouse drag action in the presence of a popup menu.

Returns:
true if the viewport may be moved in the presence of a popup menu; false otherwise.
See Also:
doAllowMoving(), allowMovingWithPopup(boolean)

doAllowResizeNodes

public boolean doAllowResizeNodes()
Returns whether or not to allow resizing of nodes by dragging at the selection hotspots.

Returns:
true if nodes may be resized by dragging at the selection hotspots; false otherwise.
See Also:
allowResizeNodes(boolean)

showNodeTips

public void showNodeTips(boolean b)
Specifies whether or not this mode will show a tool tip for nodes. The tool tip text is determined by getNodeTip(Node).

By default no node tips are displayed.

See Also:
doShowNodeTips(), doShowEdgeTips(), showEdgeTips(boolean)

doShowNodeTips

public boolean doShowNodeTips()
Returns true if this mode should display tip text for a node.

See Also:
showNodeTips(boolean), doShowEdgeTips(), showEdgeTips(boolean)

showEdgeTips

public void showEdgeTips(boolean b)
Specifies whether or not this mode will show a tool tip for edges. The tool tip text is determined by getEdgeTip(Edge).

By default no edge tips are displayed.

See Also:
doShowEdgeTips(), doShowNodeTips(), showNodeTips(boolean)

doShowEdgeTips

public boolean doShowEdgeTips()
Returns true if this mode should display tip text for an edge.

See Also:
showEdgeTips(boolean), doShowNodeTips(), showNodeTips(boolean)

setCyclicSelectionEnabled

public void setCyclicSelectionEnabled(boolean enabled)
If set to true this mode will cycle the selection through all hits at the current position when the left mouse button is clicked while pressing the modifier(s) specified in setCyclicSelectionModifierMask(int).

Parameters:
enabled - whether to activate this feature
See Also:
isCyclicSelectionEnabled()

isCyclicSelectionEnabled

public boolean isCyclicSelectionEnabled()
Returns:
true if this mode will cycle the selection through all hits at the current position when the left mouse button is clicked while pressing the modifier(s) specified in setCyclicSelectionModifierMask(int).
See Also:
setCyclicSelectionEnabled(boolean)

setCyclicSelectionModifierMask

public void setCyclicSelectionModifierMask(int modifierMask)
The given modifier mask is used for cyclic selection. By default this is the CTRL key.

Parameters:
modifierMask - the modifier(s) for cyclic selection
See Also:
setCyclicSelectionEnabled(boolean), getCyclicSelectionModifierMask()

getCyclicSelectionModifierMask

public int getCyclicSelectionModifierMask()
Returns:
the modifier mask used for cyclic selection.
See Also:
setCyclicSelectionModifierMask(int), isCyclicSelectionEnabled()

getEditNodeMode

public ViewMode getEditNodeMode()
Returns the minor mode for node editing associated with this mode


setEditNodeMode

public void setEditNodeMode(ViewMode mode)
Sets the minor mode for node editing associated with this mode. If an edit mode is set for this mode, then it gets activated by a double click on a node.


getPopupMode

public ViewMode getPopupMode()
Returns the minor popup mode associated with this mode


setPopupMode

public void setPopupMode(ViewMode mode)
Sets the minor popup mode associated with this mode. If a popup mode is set for this mode, then it gets activated by a right click of the mouse.


getMoveSelectionMode

public ViewMode getMoveSelectionMode()
Returns the minor move selection mode associated with this mode.


setMoveSelectionMode

public void setMoveSelectionMode(ViewMode mode)
Sets the minor move selection mode associated with this mode. If graph elements are selected then by starting to drag the mouse this mode gets activated and moves the selection around.


getMouseInputMode

public MouseInputMode getMouseInputMode()
Returns the minor mode for delegating mouse input, i.e., mouse events, to.


setMouseInputMode

public void setMouseInputMode(MouseInputMode mode)
Sets the minor mouse input mode associated with this mode. The mouse input mode gets activated whenever the mouse hovers above elements from the view (either node, edge, drawable, or else) that provide a so-called mouse input editor.


getCreateEdgeMode

public ViewMode getCreateEdgeMode()
Returns the minor create edge mode associated with this mode.


setCreateEdgeMode

public void setCreateEdgeMode(ViewMode mode)
Sets the minor create edge mode associated with this mode. If a drag starts from a non-selected node this mode gets activated and starts to create a new edge starting at that node.


getSelectionBoxMode

public ViewMode getSelectionBoxMode()
Returns the minor selection box mode associated with this mode.


setSelectionBoxMode

public void setSelectionBoxMode(ViewMode mode)
Sets the minor selection box mode associated with this mode. If a drag starts from a background location this mode gets activated and starts to open up a selection box


mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Takes the given coordinate and performs with it a hit test on all graph elements. The so collected information will be used when the mouse gets released or dragged next.

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.

mouseShiftPressedLeft

public void mouseShiftPressedLeft(double x,
                                  double y)
Takes the given coordinate and performs with it a hit test on all graph elements. The so collected information will be used when the mouse gets released or dragged next.

Overrides:
mouseShiftPressedLeft 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)
Depending on the history, actions are triggered, but only if Mouse was not moved since the button was pressed. That means this is essentially a routine that processes mouse clicks.

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.

labelClicked

protected void labelClicked(Graph2D graph,
                            YLabel label,
                            boolean wasSelected,
                            double x,
                            double y,
                            boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a YLabel has been clicked. This method implements the default operations of EditMode that are performed when a label has been clicked.

Parameters:
graph - the graph the label's associated node or edge resides in.
label - the label which has been clicked
wasSelected - whether the element is already selected
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double), false otherwise

labelClicked

protected void labelClicked(YLabel label)
This method gets called after a left mouse click on a label occurred. The default implementation triggers no action. Subclasses that want to listen to label clicks can overwrite this method.


mouseShiftReleasedLeft

public void mouseShiftReleasedLeft(double x,
                                   double y)
Depending on the history, actions are triggered, but only if Mouse was not moved since the button was pressed. That means this is essentially a routine that processes mouse clicks.

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.

nodePortClicked

protected void nodePortClicked(Graph2D graph,
                               NodePort port,
                               boolean wasSelected,
                               double x,
                               double y,
                               boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a NodePort has been clicked. This method implements the default operations of EditMode that are performed when a node port has been clicked.

Parameters:
graph - the graph the specified port's associated node resides in.
port - the node port that has been clicked.
wasSelected - true if the specified port is already selected; false otherwise.
x - the world coordinate that corresponds the mouse event's x-coordinate.
y - the world coordinate that corresponds the mouse event's y-coordinate.
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double); false otherwise.

nodeClicked

protected void nodeClicked(Graph2D graph,
                           Node node,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a Node has been clicked. This method implements the default operations of EditMode that are performed when a node has been clicked.

Parameters:
graph - the graph the node resides in
node - the node which has been clicked
wasSelected - whether the element is already selected
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double), false otherwise

beforeSelectionCycling

protected void beforeSelectionCycling(YCursor cyclicHits)
This method is called before cycling the selection. The first element returned from the cursor will be the next selected element.

Parameters:
cyclicHits - the current list of elements for cyclic selection

isGroupNodeBorderHit

protected boolean isGroupNodeBorderHit(Graph2D graph,
                                       Node node,
                                       double x,
                                       double y,
                                       boolean considerGroupNodeLabel)
Determines whether the specified coordinates lie within the border area of a group node. The border area is defined as the inner points of the specified node's bounds for which the distance to the specified node's border is less than getGroupBorderWidth().

Parameters:
graph - the graph to which the specified node belongs.
node - the node to be checked.
x - the x-coordinate of the hit event.
y - the y-coordinate of the hit event.
considerGroupNodeLabel - specifies whether the bounds of the default label should be considered to be part of the border area.
Returns:
true if the specified node is a group node and the specified coordinates lie within its border area; false otherwise.

bendClicked

protected void bendClicked(Graph2D graph,
                           Bend bend,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when a Bend has been clicked. This method implements the default operations of EditMode that are performed when a bend has been clicked.

Parameters:
graph - the graph the bend resides in
bend - the bend which has been clicked
wasSelected - whether the element is already selected
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double), false otherwise

edgeClicked

protected void edgeClicked(Graph2D graph,
                           Edge edge,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when an Edge has been clicked. This method implements the default operations of EditMode that are performed when a edge has been clicked.

Parameters:
graph - the graph the edge resides in
edge - the edge which has been clicked
wasSelected - whether the element is already selected
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double), false otherwise

paperClicked

protected void paperClicked(Graph2D graph,
                            double x,
                            double y,
                            boolean modifierSet)
Callback called by both mouseReleasedLeft(double,double) and mouseShiftReleasedLeft(double,double) when the canvas has been clicked. This method implements the default operations of EditMode that are performed when nothing is clicked. By default this method calls createNode(Graph2D,double,double) when node creation is allowed and nothing is currently selected.

Parameters:
graph - the graph which resides in the canvas
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
modifierSet - true if the caller is mouseShiftReleasedLeft(double,double), false otherwise

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
A mouse button gets pressed.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class ViewMode

mouseDraggedLeft

public void mouseDraggedLeft(double x,
                             double y)
Activates a minor mode. Which minor mode gets activated depends on the kind of graph element that was hit when pressing the mouse button down.

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.

bendDragged

protected void bendDragged(Graph2D graph,
                           Bend bend,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a Bend is being dragged. This method implements the default operations of EditMode that are performed when a bend is being dragged.

Parameters:
graph - the graph the bend resides in.
bend - the bend which is being dragged.
wasSelected - whether the element is already selected.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

edgeDragged

protected void edgeDragged(Graph2D graph,
                           Edge edge,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when an Edge is being dragged. This method implements the default operations of EditMode that are performed when an edge is being dragged.

Parameters:
graph - the graph the edge resides in.
edge - the edge which is being dragged.
wasSelected - whether the element is already selected.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

hotSpotDragged

protected void hotSpotDragged(Graph2D graph,
                              double x,
                              double y,
                              boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a node hot spot is being dragged. This method implements the default operations of EditMode that are performed when a hot spot is being dragged.

Parameters:
graph - the graph for which the event occurred.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

labelDragged

protected void labelDragged(Graph2D graph,
                            EdgeLabel label,
                            boolean wasSelected,
                            double x,
                            double y,
                            boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when an EdgeLabel is being dragged. This method implements the default operations of EditMode that are performed when an edge label is being dragged.

Parameters:
graph - the graph the edge resides in.
label - the edge label which is being dragged.
wasSelected - whether the element is already selected.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

labelDragged

protected void labelDragged(Graph2D graph,
                            NodeLabel label,
                            boolean wasSelected,
                            double x,
                            double y,
                            boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a NodeLabel is being dragged. This method implements the default operations of EditMode that are performed when a node label is being dragged.

Parameters:
graph - the graph the edge resides in.
label - the node label which is being dragged.
wasSelected - whether the element is already selected.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

nodeDragged

protected void nodeDragged(Graph2D graph,
                           Node node,
                           boolean wasSelected,
                           double x,
                           double y,
                           boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a Node is being dragged. This method implements the default operations of EditMode that are performed when a node is being dragged.

Parameters:
graph - the graph the node resides in.
node - the node which is being dragged.
wasSelected - whether the element is already selected.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

nodePortDragged

protected void nodePortDragged(Graph2D graph,
                               NodePort port,
                               boolean wasSelected,
                               double x,
                               double y,
                               boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a NodePort is being dragged. This method implements the default operations of EditMode that are performed when a node port is being dragged.

Parameters:
graph - the graph the specified port's associated node resides in.
port - the node port which is being dragged.
wasSelected - true if the specified port is already selected; false otherwise.
x - the world coordinate that corresponds the mouse drag event's x-coordinate.
y - the world coordinate that corresponds the mouse drag event's y-coordinate.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

paperDragged

protected void paperDragged(Graph2D graph,
                            double x,
                            double y,
                            boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a drag operation is performed on the empty graph canvas. This method implements the default operations of EditMode that are performed when a drag operation is performed on the empty graph canvas.

Parameters:
graph - the graph which resides in the canvas
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

portDragged

protected void portDragged(Graph2D graph,
                           Port port,
                           double x,
                           double y,
                           boolean firstDrag)
Callback called by mouseDraggedLeft(double,double) when a Port is being dragged. This method implements the default operations of EditMode that are performed when a port is being dragged.

Parameters:
graph - the graph the edge resides in.
port - the port which is being dragged.
x - the x coordinate of the current mouse drag event point.
y - the y coordinate of the current mouse drag event point.
firstDrag - true if the previous mouse event captured by this ViewMode was not a drag event; false otherwise.

setSelected

protected void setSelected(Graph2D graph,
                           NodePort port,
                           boolean state)
Sets the specified selection state for the specified node port. Subclasses may override this method to add notifications for node port selection state changes.

Parameters:
graph - the graph the specified port's associated node resides in.
port - the node port whose selection state has to be changed.
state - the new selection state for the specified node port.

setSelected

protected void setSelected(Graph2D graph,
                           Node node,
                           boolean state)
Sets the specified selection state for the specified node. Subclasses may override this method to add notifications for node selection state changes.

The default implementation sets the selection state of the specified node as well as the states of all bends in self loop edges incident to the specified node.

Parameters:
graph - the graph the specified node resides in.
node - the node whose selection state has to be changed.
state - the new selection state for the specified node.

setSelected

protected void setSelected(Graph2D graph,
                           YLabel label,
                           boolean state)
Sets the specified selection state for the specified label. Subclasses may override this method to add notifications for label selection state changes.

Parameters:
graph - the graph the specified label's associated node or edge resides in.
label - the label whose selection state has to be changed.
state - the new selection state for the specified label.

setSelected

protected void setSelected(Graph2D graph,
                           Edge edge,
                           boolean state)
Sets the specified selection state for the specified edge. Subclasses may override this method to add notifications for edge selection state changes.

Parameters:
graph - the graph the specified edge resides in.
edge - the edge whose selection state has to be changed.
state - the new selection state for the specified edge.

setSelected

protected void setSelected(Graph2D graph,
                           Bend bend,
                           boolean state)
Sets the specified selection state for the specified bend. Subclasses may override this method to add notifications for bend selection state changes.

Parameters:
graph - the graph the specified bend's associated edge resides in.
bend - the bend whose selection state has to be changed.
state - the new selection state for the specified bend.

unselectNodes

protected void unselectNodes(Graph2D graph)
Sets the selection state of all nodes in the specified graph to false.

Parameters:
graph - the graph whose nodes' selection states have to be changed.

unselectBends

protected void unselectBends(Graph2D graph)
Sets the selection state of all bends in the specified graph to false.

Parameters:
graph - the graph whose bends' selection states have to be changed.

unselectAll

protected void unselectAll(Graph2D graph)
Sets the selection state of all nodes, node labels, node ports, edges, edge labels, and bends to false.

Parameters:
graph - the graph whose elements' selection states have to be changed.

isSelectionEmpty

protected boolean isSelectionEmpty(Graph2D graph)
Returns true if there are no selected nodes, node labels, node ports, edges, edge labels, and/or bends in the specified graph and false otherwise.

Parameters:
graph - the graph whose elements' selection states are checked.
Returns:
true if there are no selected nodes, node labels, node ports, edges, edge labels, and/or bends in the specified graph and false otherwise.

isSelected

protected boolean isSelected(Graph2D graph,
                             Bend bend)
Returns true if the specified bend is currently selected; false otherwise.

Parameters:
graph - the graph that holds the specified bend's associated edge.
bend - the bend whose selection state is checked.
Returns:
true if the specified bend is currently selected; false otherwise.

isSelected

protected boolean isSelected(Graph2D graph,
                             Edge edge)
Returns true if the specified edge is currently selected; false otherwise.

Parameters:
graph - the graph that holds the specified edge.
edge - the edge whose selection state is checked.
Returns:
true if the specified edge is currently selected; false otherwise.

isSelected

protected boolean isSelected(Graph2D graph,
                             YLabel label)
Returns true if the specified label is currently selected; false otherwise.

Parameters:
graph - the graph that holds the specified label's associated edge or node.
label - the label whose selection state is checked.
Returns:
true if the specified label is currently selected; false otherwise.

isSelected

protected boolean isSelected(Graph2D graph,
                             Node node)
Returns true if the specified node is currently selected; false otherwise.

Parameters:
graph - the graph that holds the specified node.
node - the node whose selection state is checked.
Returns:
true if the specified node is currently selected; false otherwise.

isSelected

protected boolean isSelected(Graph2D graph,
                             NodePort port)
Returns true if the specified port is currently selected; false otherwise.

Parameters:
graph - the graph that holds the specified port's associated node.
port - the node port whose selection state is checked.
Returns:
true if the specified port is currently selected; false otherwise.

isOrthogonalRouting

protected boolean isOrthogonalRouting(Edge edge)
Callback that determines whether an edge should be treated as an orthogonally routed edge.

Parameters:
edge - the edge to determine the attribute for
Returns:
true if the edge should be routed orthogonally
See Also:
ORTHOGONAL_ROUTING_DPKEY, OrthogonalMoveBendsMode, HotSpotMode.isOrthogonalRouting(y.base.Edge), MoveSelectionMode.isOrthogonalRouting(y.base.Edge), MovePortMode.isOrthogonalRouting(y.base.Edge), CreateEdgeMode.setOrthogonalEdgeCreation(boolean)

createBend

protected Bend createBend(Graph2D graph,
                          Edge edge,
                          double x,
                          double y)
Callback called by mouseDraggedLeft(double,double) when a bend should be created. This method implements the default bend creation code of EditMode: graph.getRealizer(edge).insertBend(x,y)

Parameters:
graph - the graph which resided in the canvas
edge - the edge to create the bend on
x - the x coordinate where the mouse was dragged
y - the y coordinate where the mouse was dragged
Returns:
the newly created bend or null if no bend should be created

createNode

protected Node createNode(Graph2D graph,
                          double x,
                          double y)
Callback called by paperClicked(Graph2D,double,double,boolean) when a node should be created. Invoking this method is equivalent to:
createNode(graph, x, y, null);

Parameters:
graph - the graph which resided in the canvas
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
Returns:
the newly created node or null if no node should be created.

createNode

protected Node createNode(Graph2D graph,
                          double x,
                          double y,
                          Node parent)
Callback called by groupNodeClicked(y.base.Node) when a node should be created. This method implements the default node creation code of EditMode.

Parameters:
graph - the graph which resided in the canvas
x - the x coordinate where the mouse was clicked
y - the y coordinate where the mouse was clicked
parent - the parent group node for the newly created node. If null, the new node will be a top level node.
Returns:
the newly created node or null if no node should be created.

configureNode

protected void configureNode(Graph2D graph,
                             Node node)
Callback called by createNode(Graph2D,double,double,y.base.Node) right after a new node has been created (and prior to assigning the new node a parent node). The default implementation sets an initial label text for the specified node's default NodeLabel if doAssignNodeLabel() returns true.

Parameters:
graph - the graph which resided in the canvas.
node - the node for which the label is created.

mousePressedRight

public void mousePressedRight(double x,
                              double y)
If a popup mode is associates with this mode then it will be activated. Otherwise the right mouse press serves as activation point for dragging the view port of the underlying view.

Overrides:
mousePressedRight 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.

mouseDraggedRight

public void mouseDraggedRight(double x,
                              double y)
Description copied from class: ViewMode
Called when the mouse was dragged with the right button down.

Overrides:
mouseDraggedRight 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)
Description copied from class: ViewMode
Called when the right mouse button was released

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.

mouseMoved

public void mouseMoved(double x,
                       double y)
When moving the mouse, the mouse cursor has to be adjusted.

Overrides:
mouseMoved 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.

mouseClicked

public void mouseClicked(double x,
                         double y)
Description copied from class: ViewMode
Called when the mouse was clicked

Overrides:
mouseClicked 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.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
The mouse enters the viewer component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class ViewMode

startEditor

public boolean startEditor(MouseInputEditor editor)
Tries to start the given MouseInputEditor if mouse input is currently allowed and the corresponding MouseInputMode is available.

Parameters:
editor - the editor to start
Returns:
whether the editor was successfully initialized
See Also:
doAllowMouseInput(), setMouseInputMode(MouseInputMode)

isCyclicSelectionModifierPressed

protected boolean isCyclicSelectionModifierPressed()

createCyclicHitInfo

protected HitInfo createCyclicHitInfo(double x,
                                      double y)

getNodeTip

protected java.lang.String getNodeTip(Node v)
Returns the tip text displayed for the given node. This method will be called to get the tip text associated with the given node. The tip text will only be displayed if node tip display was activated via showNodeTips.

By default the label text of the node will be returned. Subclasses may want to overwrite this behavior.


getEdgeTip

protected java.lang.String getEdgeTip(Edge e)
Returns the tip text displayed for the given edge. This method will be called to get the tip text associated with the given edge. the tip text will only be displayed if edge tip display was activated via showEdgeTips.

By default the first label text of the edge will be returned. Subclasses may want to overwrite this behavior.


nodeCreated

protected void nodeCreated(Node v)
This method gets called after a new node was completely created by this mode. It serves as a hook to perform some actions after this event has happened. By default this method does nothing.


bendCreated

protected void bendCreated(Graph2D graph,
                           Edge edge,
                           Bend bend,
                           double x,
                           double y)
This method gets called after a new bend has been created by this mode. It serves as a hook to perform some actions after this event has happened. By default this method does nothing.


nodeClicked

protected void nodeClicked(Node v)
This method gets called after a left mouse click on a node occurred. The default implementation delegates to groupNodeClicked(y.base.Node) for group nodes and triggers no action for all other nodes. Subclasses that want to listen to node clicks can overwrite this method.

Parameters:
v - the node that was clicked on.
See Also:
HierarchyManager.isGroupNode(y.base.Node)

groupNodeClicked

protected void groupNodeClicked(Node v)
This method gets called after a left mouse click on a group node occurred. The default implementation creates a child node of the specified node, if child node creation is enabled, the specified node is not selected, and the mouse click did not occur in the specified node's border area as defined by isGroupNodeBorderHit. Subclasses that want to listen to group node clicks can overwrite this method.

Parameters:
v - the group node that was clicked on.
See Also:
HierarchyManager.isGroupNode(y.base.Node), isChildNodeCreationEnabled(), isGroupNodeBorderHit(Graph2D,y.base.Node,double,double,boolean), isSelectOnGroupNodeLabelEnabled(), getGroupBorderWidth()

getMoveViewPortMode

public ViewMode getMoveViewPortMode()
Getter for child mode MoveViewPortMode. This mode gets activated when the user right-drags with the mouse if there is no popup mode

Returns:
the MoveViewPortMode

getMoveLabelMode

public ViewMode getMoveLabelMode()
Getter for child mode MoveLabelMode. This mode gets activated when the user drags a node or edge label.

Returns:
Value of property moveLabelMode.

setMoveViewPortMode

public void setMoveViewPortMode(ViewMode moveViewPortMode)
Setter for child mode MovePortMode. This mode gets activated when the user drags the highlighted end points of a selected edge. By default an instance of MovePortMode is set.

Parameters:
moveViewPortMode - the new mode

setMoveLabelMode

public void setMoveLabelMode(ViewMode moveLabelMode)
Setter for child mode MoveLabelMode. This mode gets activated when the user drags a node or edge label. By default an instance of MoveLabelMode is set.

Parameters:
moveLabelMode - New value of property moveLabelMode.

getMovePortMode

public ViewMode getMovePortMode()
Getter for child mode MovePortMode. This mode gets activated when the user drags the highlighted end points of a selected edge.

Returns:
Value of property movePortMode.

setMovePortMode

public void setMovePortMode(ViewMode movePortMode)
Setter for child mode MovePortMode. This mode gets activated when the user drags the highlighted end points of a selected edge. By default an instance of MovePortMode is set.

Parameters:
movePortMode - New value of property movePortMode.

getHotSpotMode

public ViewMode getHotSpotMode()
Getter for child mode HotSpotMode. This mode gets activated when the user drags one of the eight hotspots (resize handles) displayed around a selected node.

Returns:
Value of property hotSpotMode.

setHotSpotMode

public void setHotSpotMode(ViewMode hotSpotMode)
Setter for child mode HotSpotMode. This mode gets activated when the user drags one of the eight hotspots (resize handles) displayed around a selected node. By default an instance of HotSpotMode is set.


getMoveNodePortMode

public ViewMode getMoveNodePortMode()
Getter for child mode MoveNodePortMode. This mode gets activated when the user drags a selected node port.

Returns:
Value of property moveNodePortMode.

setMoveNodePortMode

public void setMoveNodePortMode(ViewMode moveNodePortMode)
Setter for child mode MoveNodePortMode. This mode gets activated when the user drags a selected node port. By default an instance of MoveNodePortMode is set.

Parameters:
moveNodePortMode - the ViewMode instance to handle moving selected node ports.

isCreateEdgeGesture

protected boolean isCreateEdgeGesture(java.awt.event.MouseEvent lastPress,
                                      java.awt.event.MouseEvent lastDrag)
Determines whether the last press and drag initiates a create edge gesture. Group nodes are treated differently. As an additional constraint for creating an edge that starts from a group node it is required that the mouse hits the group nodes at its border region or, optionally, that it hits the first label of the group node. The width of the border region is the value returned by getGroupBorderWidth(). Activation of the label hit acceptance is controlled by isCreateEdgeOnGroupNodeLabelEnabled().

Parameters:
lastPress - the last press event
lastDrag - the last drag event
Returns:
whether to start the CreateEdgeMode

isEditNodeGesture

protected boolean isEditNodeGesture(Node hitNode,
                                    java.awt.event.MouseEvent lastPressEvent,
                                    java.awt.event.MouseEvent lastReleaseEvent,
                                    java.awt.event.MouseEvent lastClickEvent)
Determines if the given gesture is considered a gesture to start node editing. This implementation returns true if the clickCount of lastClickEvent is 2.

Parameters:
hitNode - the node that was hit
lastPressEvent - the last mouse pressed event
lastReleaseEvent - the last mouse released event
lastClickEvent - the last mouse clicked event
Returns:
whether to consider the gesture as a start node editing gesture

getDefaultCursor

public java.awt.Cursor getDefaultCursor()
Returns the default cursor displayed by this mode if no other cursor can be found.

Returns:
the current default cursor

setDefaultCursor

public void setDefaultCursor(java.awt.Cursor defaultCursor)
Sets the default cursor displayed by this mode if no other cursor is determined.

Parameters:
defaultCursor - the cursor to use by default

editNode

protected boolean editNode(Node hitNode,
                           java.util.EventObject e)
Tries to start editing the given Node using the current editNodeMode. If the current editNodeMode is a CellEditorMode, this method asks the mode whether the node is editable and then invokes CellEditorMode.editNode(y.base.Node,java.util.EventObject).
Otherwise the view mode is set as the current child of this mode.

Parameters:
hitNode - the node that has been hit and should be edited
e - the event object that can be used to trigger the editing, may be null
Returns:
whether the editing was initiated successfully

getOrthogonalMoveBendsMode

public ViewMode getOrthogonalMoveBendsMode()
Getter for child mode OrthogonalMoveBendsMode.

Returns:
The OrthogonalMoveBendsMode that is currently registered.
See Also:
setOrthogonalMoveBendsMode(ViewMode), createOrthogonalMoveBendsMode()

setOrthogonalMoveBendsMode

public void setOrthogonalMoveBendsMode(ViewMode orthogonalMoveBendMode)
Setter for child mode OrthogonalMoveBendsMode. This mode gets activated when the user drags an edge segment and isOrthogonalRouting(y.base.Edge) returns true for the edge. By default, this mode does not get activated.

Parameters:
orthogonalMoveBendMode - The OrthogonalMoveBendsMode that should be used for moving edge segments and maintaining an orthogonal edge path.
See Also:
getOrthogonalMoveBendsMode(), ORTHOGONAL_ROUTING_DPKEY

createOrthogonalMoveBendsMode

protected ViewMode createOrthogonalMoveBendsMode()
Factory method that creates an OrthogonalMoveBendsMode. Subclasses may override this method in order to return a more specialized version.

Returns:
A new OrthogonalMoveBendsMode.

createLabelHitInfo

protected HitInfo createLabelHitInfo(double x,
                                     double y)
Performs a hit test for a group node label at the specified location.


setGroupBorderWidth

public void setGroupBorderWidth(int groupBorderWidth)
Sets the width of the active group node border. By default the border width is set to 10.

See Also:
isCreateEdgeGesture(java.awt.event.MouseEvent,java.awt.event.MouseEvent)

getGroupBorderWidth

public int getGroupBorderWidth()
returns the width the active group node border.

See Also:
setGroupBorderWidth(int)

isCreateEdgeOnGroupNodeLabelEnabled

public boolean isCreateEdgeOnGroupNodeLabelEnabled()
Returns whether or not a bend will be created when the mouse is released on the first label of a group node.


setCreateEdgeOnGroupNodeLabelEnabled

public void setCreateEdgeOnGroupNodeLabelEnabled(boolean enabled)
Whether or not to connect an edge to a group node when the mouse is released on its first label. By default this feature is enabled.

See Also:
isCreateEdgeGesture(java.awt.event.MouseEvent,java.awt.event.MouseEvent)

isChildNodeCreationEnabled

public boolean isChildNodeCreationEnabled()
Determines whether child nodes may be created when clicking on a group node.

Returns:
true if a child node should be created when clicking on a group node; false otherwise.
See Also:
setChildNodeCreationEnabled(boolean), groupNodeClicked(y.base.Node)

setChildNodeCreationEnabled

public void setChildNodeCreationEnabled(boolean enabled)
Specifies whether child nodes may be created when clicking on a group node.

Parameters:
enabled - true if child node creation should be enabled; false otherwise.
See Also:
isChildNodeCreationEnabled(), groupNodeClicked(y.base.Node)

isSelectOnGroupNodeLabelEnabled

public boolean isSelectOnGroupNodeLabelEnabled()
Determines whether clicking on a group node's default label should select the node instead of creating a child node when child node creation is enabled.

Returns:
true if clicking on a group node's default label should select the node instead of creating a child node; false otherwise.
See Also:
setSelectOnGroupNodeLabelEnabled(boolean), isChildNodeCreationEnabled()

setSelectOnGroupNodeLabelEnabled

public void setSelectOnGroupNodeLabelEnabled(boolean enabled)
Specifies whether clicking on a group node's default label should select the node instead of creating a child node when child node creation is enabled.

Parameters:
enabled - true if label hits should select the node; false otherwise.
See Also:
isSelectOnGroupNodeLabelEnabled(), isChildNodeCreationEnabled()

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