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

 

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 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 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.
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.
 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 mousePressedLeft(double x, double y)
          Takes the given coordiante 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 actived.
 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 coordiante 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 occured.
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