Search this API

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(view).install();
 
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:
Graph2DViewActions(Graph2DView), install()

Nested Class Summary
static class Graph2DViewActions.AbstractGroupingAction
          Abstract base class for grouping related actions.
static class Graph2DViewActions.AddPredecessorsAction
          Action that adds a predecessor node to selected nodes.
static class Graph2DViewActions.AddSuccessorsAction
          Action that adds a successor node to selected nodes.
static class Graph2DViewActions.CloseGroupsAction
          Action that closes multiple group nodes.
static class Graph2DViewActions.DeleteSelectionAction
          Action that deletes selected elements of predefined types.
static class Graph2DViewActions.DuplicateAction
          Action that allows to duplicate nodes or edges.
static class Graph2DViewActions.EditLabelAction
          Action that opens the label editor for interactive text editing.
static class Graph2DViewActions.FoldSelectionAction
          Action that moves multiple nodes in a new folder node.
static class Graph2DViewActions.GroupSelectionAction
          Action that puts multiple nodes in a new group node.
static class Graph2DViewActions.OpenFoldersAction
          Action that closes multiple group nodes.
static class Graph2DViewActions.SelectAllAction
          Action that selects elements of predefined types.
static class Graph2DViewActions.UnfoldSelectionAction
          Action that removes the selected nodes from their folder.
static class Graph2DViewActions.UngroupSelectionAction
          Action that ungroups the selected nodes from their group.
 
Field Summary
static Object ADD_PREDECESSORS
          ActionMap key for action returned by getAddPredecessorsAction().
static Object ADD_SUCCESSORS
          ActionMap key for action returned by getAddSuccessorsAction().
static Object ALIGN_HORIZONTALLY
          ActionMap key for action returned by getAlignHorizontallyAction()
static Object ALIGN_VERTICALLY
          ActionMap key for action returned by getAlignVerticallyAction().
static Object BOTTOM_ALIGN
          ActionMap key for action returned by getBottomAlignAction().
static Object CLOSE_GROUPS
          ActionMap key for action returned by getCloseGroupsAction().
static Object DELETE_SELECTION
          ActionMap key for action returned by getDeleteSelectionAction().
static Object DISTRIBUTE_HORIZONTALLY
          ActionMap key for action returned by getDistributeHorizontallyAction().
static Object DISTRIBUTE_VERTICALLY
          ActionMap key for action returned by getDistributeVerticallyAction().
static Object DUPLICATE_GRAPH
          ActionMap key for action returned by getDuplicateGraphAction().
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 FOLD_SELECTION
          ActionMap key for action returned by getFoldSelectionAction().
static Object GROUP_SELECTION
          ActionMap key for action returned by getGroupSelectionAction().
static Object LEFT_ALIGN
          ActionMap key for action returned by getLeftAlignAction().
static Object OPEN_FOLDERS
          ActionMap key for action returned by getOpenFoldersAction().
static Object RIGHT_ALIGN
          ActionMap key for action returned by getRightAlignAction().
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().
static Object TOP_ALIGN
          ActionMap key for action returned by getTopAlignAction().
static Object UNFOLD_SELECTION
          ActionMap key for action returned by getUnfoldSelectionAction().
static Object UNGROUP_SELECTION
          ActionMap key for action returned by getUngroupSelectionAction().
 
Constructor Summary
Graph2DViewActions()
          Creates a new instance that is not bound to any Graph2DView.
Graph2DViewActions(Graph2DView view)
          Creates a new instance of Graph2DViewActions for the given view.
 
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)
          Deprecated. Use Graph2DViewActions.DeleteSelectionAction.delete(Graph2DView) instead.
protected  void editNode(Graph2DView view)
          Called by the EDIT_NODE action.
 Action getAddPredecessorsAction()
          Returns an action that create children for selected nodes
 Action getAddSuccessorsAction()
          Returns an action that create children for selected nodes
 Action getAlignHorizontallyAction()
           
 Action getAlignVerticallyAction()
           
 Action getBottomAlignAction()
           
 Action getCloseGroupsAction()
          Returns an action that closes one or more group nodes.
 Action getDeleteSelectionAction()
          Returns an action that deletes the currently selected elements from the graph.
 Action getDistributeHorizontallyAction()
           
 Action getDistributeVerticallyAction()
           
 Action getDuplicateGraphAction()
          Returns an action that duplicates selected 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()
          Returns an action that selects a node that is below the currently selected node.
 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 getFoldSelectionAction()
          Returns an action that folds the current selection.
 Action getGroupSelectionAction()
          Returns an action that groups the current selection.
 Action getLeftAlignAction()
           
 Action getOpenFoldersAction()
          Returns an action that opens one or more folder nodes.
 Action getRightAlignAction()
           
 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.
 Action getTopAlignAction()
           
 Action getUnfoldSelectionAction()
          Returns an action that unfolds the current selection.
 Action getUngroupSelectionAction()
          Returns an action that ungroups the current selection.
protected  Graph2DView getView(ActionEvent e)
          Tries to obtain the associated view with the event.
 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 the action into the given view using the specified condition.
 void install(int condition)
          Installs the actions provided by this instance into the view provided to the constructor using the specified input condition.
protected  void selectAll(Graph2DView view)
          Deprecated. Use Graph2DViewActions.SelectAllAction.select(Graph2DView) instead.
 
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().


TOP_ALIGN

public static final Object TOP_ALIGN
ActionMap key for action returned by getTopAlignAction().


ALIGN_VERTICALLY

public static final Object ALIGN_VERTICALLY
ActionMap key for action returned by getAlignVerticallyAction().


BOTTOM_ALIGN

public static final Object BOTTOM_ALIGN
ActionMap key for action returned by getBottomAlignAction().


DISTRIBUTE_VERTICALLY

public static final Object DISTRIBUTE_VERTICALLY
ActionMap key for action returned by getDistributeVerticallyAction().


LEFT_ALIGN

public static final Object LEFT_ALIGN
ActionMap key for action returned by getLeftAlignAction().


ALIGN_HORIZONTALLY

public static final Object ALIGN_HORIZONTALLY
ActionMap key for action returned by getAlignHorizontallyAction()


RIGHT_ALIGN

public static final Object RIGHT_ALIGN
ActionMap key for action returned by getRightAlignAction().


DISTRIBUTE_HORIZONTALLY

public static final Object DISTRIBUTE_HORIZONTALLY
ActionMap key for action returned by getDistributeHorizontallyAction().


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


GROUP_SELECTION

public static final Object GROUP_SELECTION
ActionMap key for action returned by getGroupSelectionAction().


FOLD_SELECTION

public static final Object FOLD_SELECTION
ActionMap key for action returned by getFoldSelectionAction().


UNGROUP_SELECTION

public static final Object UNGROUP_SELECTION
ActionMap key for action returned by getUngroupSelectionAction().


UNFOLD_SELECTION

public static final Object UNFOLD_SELECTION
ActionMap key for action returned by getUnfoldSelectionAction().


OPEN_FOLDERS

public static final Object OPEN_FOLDERS
ActionMap key for action returned by getOpenFoldersAction().


CLOSE_GROUPS

public static final Object CLOSE_GROUPS
ActionMap key for action returned by getCloseGroupsAction().


EDIT_LABEL

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


DUPLICATE_GRAPH

public static final Object DUPLICATE_GRAPH
ActionMap key for action returned by getDuplicateGraphAction().


ADD_SUCCESSORS

public static final Object ADD_SUCCESSORS
ActionMap key for action returned by getAddSuccessorsAction().


ADD_PREDECESSORS

public static final Object ADD_PREDECESSORS
ActionMap key for action returned by getAddPredecessorsAction().

Constructor Detail

Graph2DViewActions

public Graph2DViewActions()
Creates a new instance that is not bound to any Graph2DView. For internal use only. To ensure that all actions are properly working for a specific Graph2DView, clients should use constructor Graph2DViewActions(Graph2DView).


Graph2DViewActions

public Graph2DViewActions(Graph2DView view)
Creates a new instance of Graph2DViewActions for the given view. To install the actions for that view use method install() or install(int).

Parameters:
view - the view acted upon.
Method Detail

install

public void install(int condition)
Installs the actions provided by this instance into the view provided to the constructor using the specified input condition.

Parameters:
condition - the condition as used in JComponent.setInputMap(int,javax.swing.InputMap)
See Also:
Graph2DViewActions(Graph2DView)

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 the action into the given view using the specified condition.

Parameters:
view - the view to install the actions for. This view needs to be the same instance as given in the constructor {Graph2DViewActions(Graph2DView).
condition - the condition as used in JComponent.setInputMap(int,javax.swing.InputMap)
See Also:
install(Graph2DView)

getView

protected Graph2DView getView(ActionEvent e)
Tries to obtain the associated view with the event.

Parameters:
e - The event for which to obtain the view. This is done by getting the parent of the source component.
Returns:
The Graph2DView associated with the event or the view for which this class has been instantiated if unsuccessful.

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()
Returns an action that selects a node that is below 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.


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 final void selectAll(Graph2DView view)
Deprecated. Use Graph2DViewActions.SelectAllAction.select(Graph2DView) instead.

Sets the selected state of either all edges or all nodes and bends to true depending on the current selection states of edges, nodes, and bends.

Parameters:
view - the view to act upon

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.


getTopAlignAction

public Action getTopAlignAction()

getLeftAlignAction

public Action getLeftAlignAction()

getRightAlignAction

public Action getRightAlignAction()

getBottomAlignAction

public Action getBottomAlignAction()

getAlignVerticallyAction

public Action getAlignVerticallyAction()

getAlignHorizontallyAction

public Action getAlignHorizontallyAction()

getDistributeHorizontallyAction

public Action getDistributeHorizontallyAction()

getDistributeVerticallyAction

public Action getDistributeVerticallyAction()

getCloseGroupsAction

public Action getCloseGroupsAction()
Returns an action that closes one or more group nodes.


getOpenFoldersAction

public Action getOpenFoldersAction()
Returns an action that opens one or more folder nodes.


getGroupSelectionAction

public Action getGroupSelectionAction()
Returns an action that groups the current selection.


getFoldSelectionAction

public Action getFoldSelectionAction()
Returns an action that folds the current selection.


getUngroupSelectionAction

public Action getUngroupSelectionAction()
Returns an action that ungroups the current selection.


getUnfoldSelectionAction

public Action getUnfoldSelectionAction()
Returns an action that unfolds the current selection.


deleteSelection

protected final void deleteSelection(Graph2DView view)
Deprecated. Use Graph2DViewActions.DeleteSelectionAction.delete(Graph2DView) instead.

Removes the currently selected bends, labels, edges, and nodes from the specified view's graph.

Parameters:
view - the view to act upon

getDuplicateGraphAction

public Action getDuplicateGraphAction()
Returns an action that duplicates selected graph.


getAddSuccessorsAction

public Action getAddSuccessorsAction()
Returns an action that create children for selected nodes


getAddPredecessorsAction

public Action getAddPredecessorsAction()
Returns an action that create children for selected nodes


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.


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