y.view
Class EditMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.EditMode
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener
Direct Known Subclasses:
HierarchyEditMode

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 unselect 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).

 
Your browser does not support SVG content.

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 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 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 features of the displayed graph.
 void allowMoving(boolean b)
          Allows or disallows moving the viewport of the view via the right mouse button.
 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 to assign a generic node label for newly created nodes.
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  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  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  MouseInputMode createMouseInputMode()
          Factory method, which creates the MouseInputMode.
protected  ViewMode createMoveLabelMode()
          Factory method, which creates the MoveLabelMode.
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  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()
          Whether or not to allow moving around the selected features of the displayed graph.
 boolean doAllowMoving()
          Whether or not to allow moving the viewport of the view via right mouse drag action.
 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()
          Whether or not to allow resizing of nodes by dragging at the selection hotspots.
 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  boolean editNode(Node hitNode, 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.
 Cursor getDefaultCursor()
          Returns the default cursor displayed by this mode if no other cursor can be found.
protected  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
 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 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  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.
 boolean isAdjustScrollBarPolicy()
          Returns true if the scroll bars in Graph2DView will be shown (if needed) when this mode is activated (default).
protected  boolean isCreateEdgeGesture(MouseEvent lastPress, MouseEvent lastDrag)
          Determines whether the last press and drag initiates a create edge gesture.
protected  boolean isEditNodeGesture(Node hitNode, MouseEvent lastPressEvent, MouseEvent lastReleaseEvent, MouseEvent lastClickEvent)
          Determines if the given gesture is considered a gesture to start node editing.
 boolean isMixedSelectionEnabled()
          Returns whether this instance allows mixed selections (node/bend selections and edge selections).
 boolean isOrthogonalEdgeRouting()
          Returns whether 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  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.
 void mouseClicked(double x, double y)
          Called when the mouse was clicked
 void mouseDraggedLeft(double x, double y)
          Activates a minor mode.
 void mouseMoved(double x, double y)
          When moving the mouse, the mouse cursor has to be adjusted.
 void mousePressed(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 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 paperClicked(Graph2D graph, double x, double y, boolean modifierSet)
          Callback called by both mouseReleasedLeft(double, double) and mouseShiftReleasedLeft(double, double) when a the canvas has been clicked.
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 setCreateEdgeMode(ViewMode mode)
          Sets the minor create edge mode associated with this mode.
 void setDefaultCursor(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 setHotSpotMode(ViewMode hotSpotMode)
          Setter for child mode HotSpotMode.
 void setMixedSelectionEnabled(boolean enable)
          Allows or disallows mixed selections (node/bend selections and edge selections) 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 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.
 void setSelectionBoxMode(ViewMode mode)
          Sets the minor selection box mode associated with this mode.
 void showEdgeTips(boolean b)
          If set to true this mode will show a tip displaying whatever is returned by getEdgeTip(Edge e).
 void showNodeTips(boolean b)
          If set to true this mode will show a tip displaying whatever is returned by getNodeTip(Node v).
 boolean startEditor(MouseInputEditor editor)
          Tries to start the given MouseInputEditor if mouse input is currently allowed and the corresponding MouseInputMode is available.
 
Methods inherited from class y.view.ViewMode
addPropertyChangeListener, addPropertyChangeListener, cancelEditing, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastHitInfo, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mousePressedMiddle, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.


ORTHOGONAL_ROUTING_DPKEY

public static final 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).

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 HotSpotMode

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 HotSpotMode

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 HotSpotMode

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 HotSpotMode

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

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

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 (node/bend selections and edge selections) to exist at the same time. If disabled this instance will clear the selection if the user selects an item of the other kind while holding the modifier. The default is true.


isMixedSelectionEnabled

public boolean isMixedSelectionEnabled()
Returns whether this instance allows mixed selections (node/bend selections and edge selections). The default is true.


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 special support for orthogonal edge paths is enabled for all edges. The default is false.

See Also:
setOrthogonalEdgeRouting(boolean)

assignNodeLabel

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


allowNodeCreation

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


allowNodeEditing

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


allowEdgeCreation

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


allowBendCreation

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


allowMoveSelection

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


allowMoveLabels

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


allowMovePorts

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


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.


allowResizeNodes

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


allowMouseInput

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


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.


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.


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.


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.


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.


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.


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.


doAllowMoveSelection

public boolean doAllowMoveSelection()
Whether or not to allow moving around the selected features of the displayed graph.


doAllowMoving

public boolean doAllowMoving()
Whether or not to allow moving the viewport of the view via right mouse drag action.


doAllowResizeNodes

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


showNodeTips

public void showNodeTips(boolean b)
If set to true this mode will show a tip displaying whatever is returned by getNodeTip(Node v).


doShowNodeTips

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


showEdgeTips

public void showEdgeTips(boolean b)
If set to true this mode will show a tip displaying whatever is returned by getEdgeTip(Edge e).


doShowEdgeTips

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


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

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

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 a 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(MouseEvent e)
Description copied from class: ViewMode
A mouse button gets pressed.

Specified by:
mousePressed in interface 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.

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. 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
Returns:
the newly created node or null if no node should be 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.

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.

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)

getNodeTip

protected 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 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 triggers no action. Subclasses that want to listen to node clicks can overwrite this method.


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.


isCreateEdgeGesture

protected boolean isCreateEdgeGesture(MouseEvent lastPress,
                                      MouseEvent lastDrag)
Determines whether the last press and drag initiates a create edge gesture.

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

isEditNodeGesture

protected boolean isEditNodeGesture(Node hitNode,
                                    MouseEvent lastPressEvent,
                                    MouseEvent lastReleaseEvent,
                                    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 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(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,
                           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.