Search this API

y.view
Class Graph2DViewActions.DeleteSelectionAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by y.view.Graph2DViewActions.DeleteSelectionAction
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.DeleteSelectionAction
extends javax.swing.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_NODE_PORT
          Deletion type mask specifier to consider node ports 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()
          Initializes a new DeleteSelectionAction instance that has no default view, that means if the view cannot be determined from the event that triggers a delete action, nothing is deleted.
Graph2DViewActions.DeleteSelectionAction(Graph2DView view)
          Initializes a new DeleteSelectionAction instance.
 
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 acceptNodePort(Node node, NodePort port)
          Returns true if the specified node port 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(java.awt.event.ActionEvent e)
          Invokes delete for the view returned by getView.
 void delete(Graph2DView view)
          Deletes graph elements in the specified view.
protected  void deleteBend(EdgeRealizer er, Bend bend)
          Deletes the specified bend.
protected  void deleteEdge(Graph2D graph, Edge edge)
          Deletes the specified edge.
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 deleteEdgeLabel(EdgeRealizer realizer, EdgeLabel label, int index)
          Deletes the specified edge label.
protected  void deleteNode(Graph2D graph, Node node)
          Deletes the specified node.
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.
protected  void deleteNodeLabel(NodeRealizer realizer, NodeLabel label, int index)
          Deletes the specified node label.
protected  void deleteNodePort(NodeRealizer realizer, NodePort port, int index)
          Deletes the specified node port.
protected  void deleteTableColumn(Node node, TableGroupNodeRealizer.Column column)
          Deletes the specified table column.
protected  void deleteTableRow(Node node, TableGroupNodeRealizer.Row row)
          Deletes the specified table row.
 int getDeletionMask()
          Returns the bit mask that determines the element types to consider for deletion.
protected  Graph2DView getView(java.awt.event.ActionEvent e)
          Determines the view in which to delete graph elements.
 boolean isKeepingParentGroupNodeSizes()
          Returns whether or not group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get deleted.
 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 setKeepingParentGroupNodeSizes(boolean keepingParentGroupNodeSizes)
          Specifies whether or not group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get deleted.
 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

TYPE_NODE_PORT

public static final int TYPE_NODE_PORT
Deletion type mask specifier to consider node ports for deletion.

See Also:
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()
Initializes a new DeleteSelectionAction instance that has no default view, that means 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)
Initializes a new DeleteSelectionAction instance.

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.

isKeepingParentGroupNodeSizes

public boolean isKeepingParentGroupNodeSizes()
Returns whether or not group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get deleted.

Returns:
true if group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get deleted; false otherwise.

setKeepingParentGroupNodeSizes

public void setKeepingParentGroupNodeSizes(boolean keepingParentGroupNodeSizes)
Specifies whether or not group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get deleted.

Parameters:
keepingParentGroupNodeSizes - true if group nodes with enabled auto bounds feature should keep their size if a child node or one of its labels get 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 and edges that connect to node ports that will be deleted according to acceptNodePort(y.base.Node, NodePort).

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

acceptNodePort

protected boolean acceptNodePort(Node node,
                                 NodePort port)
Returns true if the specified node port should be deleted or false otherwise. The default implementation accepts selected node ports if the deletion mask includes TYPE_NODE_PORT.

Parameters:
node - the Node that holds the node port.
port - the NodePort that is checked for deletion.
Returns:
true if the specified node port 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(java.awt.event.ActionEvent e)
Invokes delete for the view returned by getView.

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.

Parameters:
view - the view in which to delete graph elements.
Throws:
java.lang.NullPointerException - if the specified view is null.
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(java.awt.event.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)

deleteEdge

protected void deleteEdge(Graph2D graph,
                          Edge edge)
Deletes the specified edge.

Client code that overwrites this method must ensure that the edge is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptEdge(Graph2D, y.base.Edge).

Parameters:
graph - the Graph2D that holds the edge.
edge - the Edge that is deleted.

deleteEdgeLabel

protected void deleteEdgeLabel(EdgeRealizer realizer,
                               EdgeLabel label,
                               int index)
Deletes the specified edge label.

Client code that overwrites this method must ensure that the label is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptEdgeLabel(y.base.Edge, EdgeLabel) .

Parameters:
realizer - the EdgeRealizer that holds the label.
label - the EdgeLabel that is deleted.
index - the index of the label in the given realizer's list of labels.

deleteBend

protected void deleteBend(EdgeRealizer er,
                          Bend bend)
Deletes the specified bend.

Client code that overwrites this method must ensure that the bend is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptBend(y.base.Edge, Bend).

Parameters:
er - the EdgeRealizer holding the bend.
bend - the Bend that is deleted.

deleteNode

protected void deleteNode(Graph2D graph,
                          Node node)
Deletes the specified node.

Client code that overwrites this method must ensure that the node is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptNode(Graph2D, y.base.Node).

Parameters:
graph - the Graph2D that holds the node.
node - the Node that is deleted.

deleteNodeLabel

protected void deleteNodeLabel(NodeRealizer realizer,
                               NodeLabel label,
                               int index)
Deletes the specified node label.

Client code that overwrites this method must ensure that the label is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptNodeLabel(y.base.Node, NodeLabel).

Parameters:
realizer - the NodeRealizer that holds the label.
label - the NodeLabel that is deleted.
index - the index of the label in the given realizer's list of labels.

deleteNodePort

protected void deleteNodePort(NodeRealizer realizer,
                              NodePort port,
                              int index)
Deletes the specified node port.

Client code that overwrites this method must ensure that the port is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptNodePort(y.base.Node, NodePort).

Parameters:
realizer - the NodeRealizer that holds the port.
port - the NodePort that is deleted.
index - the index of the NodePort in the given NodeRealizer's list of ports.

deleteTableColumn

protected void deleteTableColumn(Node node,
                                 TableGroupNodeRealizer.Column column)
Deletes the specified table column.

Client code that overwrites this method must ensure that the column is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptTableColumn(y.base.Node, y.view.tabular.TableGroupNodeRealizer.Column).

Parameters:
node - the Node that is represented by the table that holds the row.
column - the Column that is deleted.

deleteTableRow

protected void deleteTableRow(Node node,
                              TableGroupNodeRealizer.Row row)
Deletes the specified table row.

Client code that overwrites this method must ensure that the row is properly removed to prevent inconsistent state with regards to the result of the corresponding call to acceptTableRow(y.base.Node, y.view.tabular.TableGroupNodeRealizer.Row).

Parameters:
node - the Node that is represented by the table that holds the row.
row - the Row that is deleted.

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