y.view
Class Graph2DViewActions.DeleteSelectionAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by y.view.Graph2DViewActions.DeleteSelectionAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Enclosing class:
Graph2DViewActions

public static class Graph2DViewActions.DeleteSelectionAction
extends AbstractAction

Action that deletes selected elements of predefined types.

See Also:
Serialized Form
 

Field Summary
static int ALL_TYPES_MASK
          Deletion type mask representing all element types.
static int NODE_TYPES_MASK
          Deletion type mask representing all node types.
static int TYPE_BEND
          Deletion type mask specifier to consider bends for deletion.
static int TYPE_EDGE
          Deletion type mask specifier to consider edges for deletion.
static int TYPE_EDGE_LABEL
          Deletion type mask specifier to consider edge labels for deletion.
static int TYPE_GROUP_NODE
          Deletion type mask specifier to consider group nodes for deletion.
static int TYPE_NODE_LABEL
          Deletion type mask specifier to consider node labels for deletion.
static int TYPE_SIMPLE_NODE
          Deletion type mask specifier to consider simple nodes for deletion.
static int TYPE_TABLE_COLUMN
          Deletion type mask specifier to consider columns of table nodes for deletion.
static int TYPE_TABLE_NODE
          Deletion type mask specifier to consider table nodes for deletion.
static int TYPE_TABLE_ROW
          Deletion type mask specifier to consider rows of table nodes for deletion.
 
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.DeleteSelectionAction()
          Creates a new DeleteSelectionAction that has no default view, i.e. if the view cannot be determined from the event that triggers a delete action, nothing is deleted.
Graph2DViewActions.DeleteSelectionAction(Graph2DView view)
          Creates a new DeleteSelectionAction
 
Method Summary
protected  boolean acceptBend(Edge edge, Bend bend)
          Returns true if the specified bend should be deleted or false otherwise.
protected  boolean acceptEdge(Graph2D graph, Edge edge)
          Returns true if the specified edge should be deleted or false otherwise.
protected  boolean acceptEdgeLabel(Edge edge, EdgeLabel label)
          Returns true if the specified edge label should be deleted or false otherwise.
protected  boolean acceptNode(Graph2D graph, Node node)
          Returns true if the specified node should be deleted or false otherwise.
protected  boolean acceptNodeLabel(Node node, NodeLabel label)
          Returns true if the specified node label should be deleted or false otherwise.
protected  boolean acceptTableColumn(Node node, TableGroupNodeRealizer.Column column)
          Returns true if the specified table column should be deleted or false otherwise.
protected  boolean acceptTableRow(Node node, TableGroupNodeRealizer.Row row)
          Returns true if the specified table row should be deleted or false otherwise.
 void actionPerformed(ActionEvent e)
          Invokes delete for the view returned by delete.
 void delete(Graph2DView view)
          Deletes graph elements in the specified view.
protected  void deleteEdgeElements(Graph2D graph, Edge edge)
          Deletes the graph elements associated to the specified edge and the edge itself if these elements are accepted by the corresponding acceptXXX methods.
protected  void deleteNodeElements(Graph2D graph, Node node)
          Deletes the graph elements associated to the specified node and the node itself if these elements are accepted by the corresponding acceptXXX methods.
 int getDeletionMask()
          Returns the bit mask that determines the element types to consider for deletion.
protected  Graph2DView getView(ActionEvent e)
          Determines the view in which to delete graph elements.
 boolean isKeepingTableNodesOnTableContentDeletion()
          Determines whether or not table nodes should be deleted if one or more of their columns or rows have been deleted.
 void setDeletionMask(int mask)
          Specifies the bit mask that determines the element types to consider for deletion.
 void setKeepingTableNodesOnTableContentDeletion(boolean keepingTableNodesOnTableContentDeletion)
          Specifies whether or not table nodes should be deleted if one or more of their columns or rows have been deleted.
 
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
 

Field Detail

TYPE_BEND

public static final int TYPE_BEND
Deletion type mask specifier to consider bends for deletion.

See Also:
Constant Field Values

TYPE_EDGE

public static final int TYPE_EDGE
Deletion type mask specifier to consider edges for deletion.

See Also:
Constant Field Values

TYPE_EDGE_LABEL

public static final int TYPE_EDGE_LABEL
Deletion type mask specifier to consider edge labels for deletion.

See Also:
Constant Field Values

TYPE_SIMPLE_NODE

public static final int TYPE_SIMPLE_NODE
Deletion type mask specifier to consider simple nodes for deletion. In this context, a node is considered a simple node if it is neither a group node nor a table node.

See Also:
TYPE_GROUP_NODE, TYPE_TABLE_NODE, Constant Field Values

TYPE_GROUP_NODE

public static final int TYPE_GROUP_NODE
Deletion type mask specifier to consider group nodes for deletion. In this context, a node is considered a group node if its associated graph has an associated HierarchyManager whose isGroupNode method returns true, and the node is not a table node.

See Also:
TYPE_SIMPLE_NODE, TYPE_TABLE_NODE, Constant Field Values

TYPE_TABLE_NODE

public static final int TYPE_TABLE_NODE
Deletion type mask specifier to consider table nodes for deletion. In this context, a node is considered a table node if its associated realizer is of type TableGroupNodeRealizer.

See Also:
TYPE_SIMPLE_NODE, TYPE_GROUP_NODE, Constant Field Values

TYPE_NODE_LABEL

public static final int TYPE_NODE_LABEL
Deletion type mask specifier to consider node labels for deletion.

See Also:
Constant Field Values

TYPE_TABLE_COLUMN

public static final int TYPE_TABLE_COLUMN
Deletion type mask specifier to consider columns of table nodes for deletion.

See Also:
TYPE_TABLE_NODE, Constant Field Values

TYPE_TABLE_ROW

public static final int TYPE_TABLE_ROW
Deletion type mask specifier to consider rows of table nodes for deletion.

See Also:
TYPE_TABLE_NODE, Constant Field Values

NODE_TYPES_MASK

public static final int NODE_TYPES_MASK
Deletion type mask representing all node types.

See Also:
TYPE_SIMPLE_NODE, TYPE_GROUP_NODE, TYPE_TABLE_NODE, Constant Field Values

ALL_TYPES_MASK

public static final int ALL_TYPES_MASK
Deletion type mask representing all element types.

See Also:
Constant Field Values
Constructor Detail

Graph2DViewActions.DeleteSelectionAction

public Graph2DViewActions.DeleteSelectionAction()
Creates a new DeleteSelectionAction that has no default view, i.e. if the view cannot be determined from the event that triggers a delete action, nothing is deleted. Invoking this constructor is equivalent to:
new DeleteSelectionAction(null)


Graph2DViewActions.DeleteSelectionAction

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

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

getDeletionMask

public int getDeletionMask()
Returns the bit mask that determines the element types to consider for deletion.

Returns:
the bit mask that determines the element types to consider for deletion.

setDeletionMask

public void setDeletionMask(int mask)
Specifies the bit mask that determines the element types to consider for deletion.

Parameters:
mask - the bit mask that determines the element types to consider for deletion.

isKeepingTableNodesOnTableContentDeletion

public boolean isKeepingTableNodesOnTableContentDeletion()
Determines whether or not table nodes should be deleted if one or more of their columns or rows have been deleted.

Returns:
true if table nodes should not be deleted if one or more of their columns or rows have been deleted; false otherwise.

setKeepingTableNodesOnTableContentDeletion

public void setKeepingTableNodesOnTableContentDeletion(boolean keepingTableNodesOnTableContentDeletion)
Specifies whether or not table nodes should be deleted if one or more of their columns or rows have been deleted.

Parameters:
keepingTableNodesOnTableContentDeletion - true if table nodes should not be deleted if one or more of their columns or rows have been deleted; false otherwise.

acceptEdgeLabel

protected boolean acceptEdgeLabel(Edge edge,
                                  EdgeLabel label)
Returns true if the specified edge label should be deleted or false otherwise. The default implementation accepts selected labels if the deletion mask includes TYPE_EDGE_LABEL.

Parameters:
edge - the Edge that holds the label.
label - the EdgeLabel that is checked for deletion.
Returns:
true if the specified edge label should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptBend

protected boolean acceptBend(Edge edge,
                             Bend bend)
Returns true if the specified bend should be deleted or false otherwise. The default implementation accepts selected bends if the deletion mask includes TYPE_BEND.

Parameters:
edge - the Edge that holds the bend.
bend - the Bend that is checked for deletion.
Returns:
true if the specified bend should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptEdge

protected boolean acceptEdge(Graph2D graph,
                             Edge edge)
Returns true if the specified edge should be deleted or false otherwise. The default implementation accepts selected edges if the deletion mask includes TYPE_EDGE.

Parameters:
graph - the Graph2D that holds the edge.
edge - the Edge that is checked for deletion.
Returns:
true if the specified edge should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptNodeLabel

protected boolean acceptNodeLabel(Node node,
                                  NodeLabel label)
Returns true if the specified node label should be deleted or false otherwise. The default implementation accepts selected labels if the deletion mask includes TYPE_NODE_LABEL.

Parameters:
node - the Node that holds the label.
label - the NodeLabel that is checked for deletion.
Returns:
true if the specified node label should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptTableColumn

protected boolean acceptTableColumn(Node node,
                                    TableGroupNodeRealizer.Column column)
Returns true if the specified table column should be deleted or false otherwise. The default implementation accepts selected columns if the deletion mask includes TYPE_TABLE_COLUMN.

Parameters:
node - the Node that is represented by the table that holds the column.
column - the Column that is checked for deletion.
Returns:
true if the specified table column should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptTableRow

protected boolean acceptTableRow(Node node,
                                 TableGroupNodeRealizer.Row row)
Returns true if the specified table row should be deleted or false otherwise. The default implementation accepts selected rows if the deletion mask includes TYPE_TABLE_ROW.

Parameters:
node - the Node that is represented by the table that holds the row.
row - the Row that is checked for deletion.
Returns:
true if the specified table row should be deleted or false otherwise.
See Also:
getDeletionMask()

acceptNode

protected boolean acceptNode(Graph2D graph,
                             Node node)
Returns true if the specified node should be deleted or false otherwise. The default implementation accepts selected nodes whose type (one of TYPE_SIMPLE_NODE, TYPE_GROUP_NODE, and TYPE_TABLE_NODE) is included in the deletion mask, and in the case of table nodes keepingTableNodesOnTableContentDeletion is either false or neither associated columns nor rows have been deleted.

Parameters:
graph - the Graph2D that holds the node.
node - the Node that is checked for deletion.
Returns:
true if the specified node should be deleted or false otherwise.
See Also:
getDeletionMask()

deleteNodeElements

protected void deleteNodeElements(Graph2D graph,
                                  Node node)
Deletes the graph elements associated to the specified node and the node itself if these elements are accepted by the corresponding acceptXXX methods.

Parameters:
graph - the Graph2D that holds the node.
node - the Node to be deleted.
See Also:
acceptNode(Graph2D,y.base.Node), acceptNodeLabel(y.base.Node,NodeLabel), acceptTableColumn(y.base.Node,y.view.tabular.TableGroupNodeRealizer.Column), acceptTableRow(y.base.Node,y.view.tabular.TableGroupNodeRealizer.Row)

actionPerformed

public void actionPerformed(ActionEvent e)
Invokes delete for the view returned by delete.

Parameters:
e - the ActionEvent that triggers the deletion of graph elements.
See Also:
getView(java.awt.event.ActionEvent), delete(y.view.Graph2DView)

delete

public void delete(Graph2DView view)
Deletes graph elements in the specified view. The elements that are deleted are determined using the appropriate acceptXXX methods. Deleting a node will automatically delete all edges incident to the deleted node, too, no matter if they are accepted or not. This method backs up realizers for undo-/redoability if necessary.

Throws:
NullPointerException - if the specified view is null.
Parameters:
view - the view in which to delete graph elements.
See Also:
acceptBend(y.base.Edge,y.view.Bend), acceptEdge(y.view.Graph2D,y.base.Edge), acceptEdgeLabel(y.base.Edge,y.view.EdgeLabel), acceptNode(y.view.Graph2D,y.base.Node), acceptNodeLabel(y.base.Node,y.view.NodeLabel), acceptTableColumn(y.base.Node,y.view.tabular.TableGroupNodeRealizer.Column), acceptTableRow(y.base.Node,y.view.tabular.TableGroupNodeRealizer.Row)

deleteEdgeElements

protected void deleteEdgeElements(Graph2D graph,
                                  Edge edge)
Deletes the graph elements associated to the specified edge and the edge itself if these elements are accepted by the corresponding acceptXXX methods.

Parameters:
graph - the Graph2D that holds the edge.
edge - the Edge to be deleted.
See Also:
acceptEdge(y.view.Graph2D,y.base.Edge), acceptEdgeLabel(y.base.Edge,y.view.EdgeLabel), acceptBend(y.base.Edge,y.view.Bend)

getView

protected Graph2DView getView(ActionEvent e)
Determines the view in which to delete graph elements.

Parameters:
e - the ActionEvent that triggers the deletion of graph elements.
Returns:
the view in which to delete graph elements.
See Also:
actionPerformed(java.awt.event.ActionEvent), Graph2DViewActions.DeleteSelectionAction(y.view.Graph2DView)

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