y.view
Class Graph2DViewActions

java.lang.Object
  extended by y.view.Graph2DViewActions

public class Graph2DViewActions
extends Object

This class provides actions for Graph2DView.

The easiest way to add the provided actions to an instance of Graph2DView is demonstrated below:

   new Graph2DViewActions().install(view);
 
However, the behavior may be tweaked a lot using the following technique:
   Graph2DViewActions actions = new Graph2DViewActions(view);
   ActionMap amap = actions.createActionMap();
   InputMap imap = actions.createDefaultInputMap(amap);
   view.getCanvasComponent().setActionMap(amap);
   view.getCanvasComponent().setInputMap(JComponent.WHEN_FOCUSED, imap);
 

See Also:
install(Graph2DView)
 

Field Summary
static Object DELETE_SELECTION
          ActionMap key for action returned by getDeleteSelectionAction().
static Object EDIT_LABEL
          ActionMap key for action returned by getEditLabelAction().
static Object EDIT_NODE
          ActionMap key for action returned by getEditNodeAction().
static Object FOCUS_BOTTOM_NODE
          ActionMap key for action returned by getFocusBottomNodeAction().
static Object FOCUS_LEFT_NODE
          ActionMap key for action returned by getFocusLeftNodeAction().
static Object FOCUS_RIGHT_NODE
          ActionMap key for action returned by getFocusRightNodeAction().
static Object FOCUS_TOP_NODE
          ActionMap key for action returned by getFocusTopNodeAction().
static Object SELECT_ALL
          ActionMap key for action returned by getSelectAllAction().
static Object SELECT_BOTTOM_EDGE
          ActionMap key for action returned by getSelectBottomEdgeAction().
static Object SELECT_LEFT_EDGE
          ActionMap key for action returned by getSelectLeftEdgeAction().
static Object SELECT_RIGHT_EDGE
          ActionMap key for action returned by getSelectRightEdgeAction().
static Object SELECT_TOP_EDGE
          ActionMap key for action returned by getSelectTopEdgeAction().
 
Constructor Summary
Graph2DViewActions()
          Creates a new instance that can later be installed into a Graph2DView using the install(Graph2DView, int) methods.
Graph2DViewActions(Graph2DView view)
          Creates a new instance of Graph2DViewActions.
 
Method Summary
 ActionMap createActionMap()
          Returns a new ActionMap that contains the actions provided by this class.
 InputMap createDefaultInputMap()
          Returns a default key binding for the actions provided by this class.
 InputMap createDefaultInputMap(ActionMap amap)
          Returns a default key binding for the actions provided by this class that are also bound by the given ActionMap.
protected  void deleteSelection(Graph2DView view)
          Called by the DELETE_SELECTION action.
protected  void editNode(Graph2DView view)
          Called by the EDIT_NODE action.
 Action getDeleteSelectionAction()
          Returns an action that deletes the currently selected elements from the graph.
 Action getEditLabelAction()
          Returns an action that triggers the inline label editor.
 Action getEditNodeAction()
          Returns an action that starts editing a selected node if the current ViewMode is either a suitable EditMode or CellEditorMode instance.
 Action getFocusBottomNodeAction()
           
 Action getFocusLeftNodeAction()
          Returns an action that selects a node that is to the left of the currently selected node.
 Action getFocusRightNodeAction()
          Returns an action that selects a node that is to the right of the currently selected node.
 Action getFocusTopNodeAction()
          Returns an action that selects a node that is above the currently selected node.
 Action getSelectAllAction()
          Returns an action that selects the all nodes and bends or alternatively all edges if at least one edge is currently selected.
 Action getSelectBottomEdgeAction()
          Returns an action that selects the bottommost edge connected to the currently selected node.
 Action getSelectLeftEdgeAction()
          Returns an action that selects the leftmost edge connected to the currently selected node.
 Action getSelectRightEdgeAction()
          Returns an action that selects the rightmost edge connected to the currently selected node.
 Action getSelectTopEdgeAction()
          Returns an action that selects the topmost edge connected to the currently selected node.
 void install()
          Install the actions provided by this instance into the view provided to the constructor
 void install(Graph2DView view)
          Installs this instance into the given view using JComponent.WHEN_FOCUSED as the condition.
 void install(Graph2DView view, int condition)
          Installs this instance into the given view using the specified condition.
protected  void selectAll(Graph2DView view)
          Called by the SELECT_ALL action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOCUS_RIGHT_NODE

public static final Object FOCUS_RIGHT_NODE
ActionMap key for action returned by getFocusRightNodeAction().


EDIT_NODE

public static final Object EDIT_NODE
ActionMap key for action returned by getEditNodeAction().


FOCUS_LEFT_NODE

public static final Object FOCUS_LEFT_NODE
ActionMap key for action returned by getFocusLeftNodeAction().


FOCUS_TOP_NODE

public static final Object FOCUS_TOP_NODE
ActionMap key for action returned by getFocusTopNodeAction().


FOCUS_BOTTOM_NODE

public static final Object FOCUS_BOTTOM_NODE
ActionMap key for action returned by getFocusBottomNodeAction().


SELECT_ALL

public static final Object SELECT_ALL
ActionMap key for action returned by getSelectAllAction().


SELECT_LEFT_EDGE

public static final Object SELECT_LEFT_EDGE
ActionMap key for action returned by getSelectLeftEdgeAction().


SELECT_RIGHT_EDGE

public static final Object SELECT_RIGHT_EDGE
ActionMap key for action returned by getSelectRightEdgeAction().


SELECT_TOP_EDGE

public static final Object SELECT_TOP_EDGE
ActionMap key for action returned by getSelectTopEdgeAction().


SELECT_BOTTOM_EDGE

public static final Object SELECT_BOTTOM_EDGE
ActionMap key for action returned by getSelectBottomEdgeAction().


DELETE_SELECTION

public static final Object DELETE_SELECTION
ActionMap key for action returned by getDeleteSelectionAction().


EDIT_LABEL

public static final Object EDIT_LABEL
ActionMap key for action returned by getEditLabelAction().

Constructor Detail

Graph2DViewActions

public Graph2DViewActions()
Creates a new instance that can later be installed into a Graph2DView using the install(Graph2DView, int) methods.


Graph2DViewActions

public Graph2DViewActions(Graph2DView view)
Creates a new instance of Graph2DViewActions.

Parameters:
view - the view acted upon.
Method Detail

install

public void install()
Install the actions provided by this instance into the view provided to the constructor

Throws:
IllegalStateException - if no view had been provided to the constructor.

install

public void install(Graph2DView view)
Installs this instance into the given view using JComponent.WHEN_FOCUSED as the condition.

Parameters:
view - the to install the actions for
See Also:
install(Graph2DView, int)

install

public void install(Graph2DView view,
                    int condition)
Installs this instance into the given view using the specified condition.

Parameters:
view - the to install the actions for
condition - the condition as used in JComponent.setInputMap(int, javax.swing.InputMap)
See Also:
install(Graph2DView)

getEditNodeAction

public Action getEditNodeAction()
Returns an action that starts editing a selected node if the current ViewMode is either a suitable EditMode or CellEditorMode instance.


getFocusLeftNodeAction

public Action getFocusLeftNodeAction()
Returns an action that selects a node that is to the left of the currently selected node. The viewport of the view will moved in a way that the newly selected node gets displayed in the center of the view.


getFocusRightNodeAction

public Action getFocusRightNodeAction()
Returns an action that selects a node that is to the right of the currently selected node. The viewport of the view will moved in a way that the newly selected node gets displayed in the center of the view.


getFocusTopNodeAction

public Action getFocusTopNodeAction()
Returns an action that selects a node that is above the currently selected node. The viewport of the view will moved in a way that the newly selected node gets displayed in the center of the view.


getFocusBottomNodeAction

public Action getFocusBottomNodeAction()

getSelectLeftEdgeAction

public Action getSelectLeftEdgeAction()
Returns an action that selects the leftmost edge connected to the currently selected node. Once an edge has been selected this way, the next time the action will select the counterclockwise next edge around the previously selected node. If initially no elements are selected the action will select an edge that is closest to the center of the view.


getSelectRightEdgeAction

public Action getSelectRightEdgeAction()
Returns an action that selects the rightmost edge connected to the currently selected node. Once an edge has been selected this way, the next time the action will select the clockwise next edge around the previously selected node. If initially no elements are selected the action will select an edge that is closest to the center of the view.


getSelectAllAction

public Action getSelectAllAction()
Returns an action that selects the all nodes and bends or alternatively all edges if at least one edge is currently selected.


selectAll

protected void selectAll(Graph2DView view)
Called by the SELECT_ALL action

Parameters:
view -

getSelectTopEdgeAction

public Action getSelectTopEdgeAction()
Returns an action that selects the topmost edge connected to the currently selected node. Once an edge has been selected this way, the next time the action will select the clockwise next edge around the previously selected node. If initially no elements are selected the action will select an edge that is closest to the center of the view.


getSelectBottomEdgeAction

public Action getSelectBottomEdgeAction()
Returns an action that selects the bottommost edge connected to the currently selected node. Once an edge has been selected this way, the next time the action will select the counterclockwise next edge around the previously selected node. If initially no elements are selected the action will select an edge that is closest to the center of the view.


getDeleteSelectionAction

public Action getDeleteSelectionAction()
Returns an action that deletes the currently selected elements from the graph.


deleteSelection

protected void deleteSelection(Graph2DView view)
Called by the DELETE_SELECTION action.

Parameters:
view - the view to act upon

getEditLabelAction

public Action getEditLabelAction()
Returns an action that triggers the inline label editor.


createActionMap

public ActionMap createActionMap()
Returns a new ActionMap that contains the actions provided by this class.


createDefaultInputMap

public InputMap createDefaultInputMap()
Returns a default key binding for the actions provided by this class.


createDefaultInputMap

public InputMap createDefaultInputMap(ActionMap amap)
Returns a default key binding for the actions provided by this class that are also bound by the given ActionMap.


editNode

protected void editNode(Graph2DView view)
Called by the EDIT_NODE action.

Parameters:
view -

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