Search this API

y.view
Class Graph2DViewActions.GroupSelectionAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by y.view.Graph2DViewActions.AbstractGroupingAction
          extended by y.view.Graph2DViewActions.GroupSelectionAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Enclosing class:
Graph2DViewActions

public static class Graph2DViewActions.GroupSelectionAction
extends Graph2DViewActions.AbstractGroupingAction

Action that puts multiple nodes in a new group node.

See Also:
Serialized Form
 

Field Summary
 
Fields inherited from class y.view.Graph2DViewActions.AbstractGroupingAction
view
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
Graph2DViewActions.GroupSelectionAction()
          Creates a new GroupSelectionAction that has no default view.
Graph2DViewActions.GroupSelectionAction(Graph2DView view)
          Creates a new GroupSelectionAction
 
Method Summary
protected  boolean acceptNode(Graph2D graph, Node node)
          Check whether a node should be changed by this action.
 void actionPerformed(java.awt.event.ActionEvent e)
           
protected  void assignGroupName(Node groupNode, Graph2DView view)
          Assigns a name to the group node.
protected  Node createEmptyGroupNode(Graph2DView view)
          Creates an empty group node that is positioned at the center of the view.
protected  java.lang.String createFolderName(Node folderNode, Graph2DView view)
          Creates a name for the group node when it is in folded state.
protected  java.lang.String createGroupName(Node groupNode, Graph2DView view)
          Creates a name for the group node when it is in opened state.
protected  Node createGroupNode(NodeList nodesToGroup, Graph2DView view)
          Creates a new group node.
protected  Node createGroupNodeWithChildren(NodeList nodesToGroup, Graph2DView view)
          Creates a group node from nodesToGroup.
 void groupSelection(Graph2DView view)
          Groups all nodes for which acceptNode(Graph2D,y.base.Node) returns true.
 boolean isEmptySelectionEnabled()
          Returns whether an empty group node should be created if the list of accepted nodes is empty.
protected  void postNodeStateChange(Node groupNode, Graph2D g)
          Performs necessary actions immediately after the node has been closed.
protected  void preNodeStateChange(Node groupNode, Graph2D g)
          Performs necessary actions immediately before the node is closed.
 void setEmptySelectionEnabled(boolean allowEmptySelection)
          Sets whether an empty group node should be created if the list of accepted nodes is empty.
 
Methods inherited from class y.view.Graph2DViewActions.AbstractGroupingAction
getHierarchyManager, getNodeStateChangeHandler, getView, isReselectNodes, setNodeStateChangeHandler, setReselectNodes
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph2DViewActions.GroupSelectionAction

public Graph2DViewActions.GroupSelectionAction()
Creates a new GroupSelectionAction that has no default view. Invoking this constructor is equivalent to:
new GroupSelectionAction(null)


Graph2DViewActions.GroupSelectionAction

public Graph2DViewActions.GroupSelectionAction(Graph2DView view)
Creates a new GroupSelectionAction

Parameters:
view - the default view that is used if the actual view cannot be determined from the information provided by an ActionEvent.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)

groupSelection

public void groupSelection(Graph2DView view)
Groups all nodes for which acceptNode(Graph2D,y.base.Node) returns true.

Parameters:
view - The view where all information is used from.

createGroupNode

protected Node createGroupNode(NodeList nodesToGroup,
                               Graph2DView view)
Creates a new group node.

This method delegates to createEmptyGroupNode(Graph2DView) if nodesToGroup is empty and isEmptySelectionEnabled() returns true or createGroupNodeWithChildren(y.base.NodeList, Graph2DView). If nodesToGroup is empty and isEmptySelectionEnabled() returns false then no node is created and null is returned.

Returns:
The created group node or null.
See Also:
isEmptySelectionEnabled()

assignGroupName

protected void assignGroupName(Node groupNode,
                               Graph2DView view)
Assigns a name to the group node.

This implementation delegates to createGroupName(y.base.Node,Graph2DView) and createFolderName(y.base.Node,Graph2DView)


createFolderName

protected java.lang.String createFolderName(Node folderNode,
                                            Graph2DView view)
Creates a name for the group node when it is in folded state.

Returns:
This implementation returns the literal string "Folder"

createGroupName

protected java.lang.String createGroupName(Node groupNode,
                                           Graph2DView view)
Creates a name for the group node when it is in opened state.

Returns:
This implementation returns the literal string "Group"

createEmptyGroupNode

protected Node createEmptyGroupNode(Graph2DView view)
Creates an empty group node that is positioned at the center of the view.

Returns:
The new group node
See Also:
isEmptySelectionEnabled()

createGroupNodeWithChildren

protected Node createGroupNodeWithChildren(NodeList nodesToGroup,
                                           Graph2DView view)
Creates a group node from nodesToGroup.

Returns:
The new group node

acceptNode

protected boolean acceptNode(Graph2D graph,
                             Node node)
Check whether a node should be changed by this action.

This method should return true iff node should be included in the group. This implementation returns true iff the node is currently selected.

Returns:
true iff node should be grouped.

preNodeStateChange

protected void preNodeStateChange(Node groupNode,
                                  Graph2D g)
Performs necessary actions immediately before the node is closed.

This implementation does nothing.

Overrides:
preNodeStateChange in class Graph2DViewActions.AbstractGroupingAction

postNodeStateChange

protected void postNodeStateChange(Node groupNode,
                                   Graph2D g)
Performs necessary actions immediately after the node has been closed.

This implementation does nothing.

Overrides:
postNodeStateChange in class Graph2DViewActions.AbstractGroupingAction

isEmptySelectionEnabled

public boolean isEmptySelectionEnabled()
Returns whether an empty group node should be created if the list of accepted nodes is empty.

Default value is false.

Returns:
whether an empty group node should be created if the list of accepted nodes is empty.
See Also:
setEmptySelectionEnabled(boolean), acceptNode(Graph2D,y.base.Node), createEmptyGroupNode(Graph2DView)

setEmptySelectionEnabled

public void setEmptySelectionEnabled(boolean allowEmptySelection)
Sets whether an empty group node should be created if the list of accepted nodes is empty.

Default value is false.

Parameters:
allowEmptySelection - whether an empty group node should be created if the list of accepted nodes is empty.
See Also:
isEmptySelectionEnabled(), acceptNode(Graph2D,y.base.Node), createEmptyGroupNode(Graph2DView)

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