Search this API

y.view
Class Graph2DViewActions.AddSuccessorsAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by y.view.Graph2DViewActions.AddSuccessorsAction
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.AddSuccessorsAction
extends javax.swing.AbstractAction

Action that adds a successor node to selected nodes. A successor node or neighbor node is a new node such that there is an edge each selected node to the new node. To add more than a single successor node at once, customize the method createNeighborNodes(Graph2D, y.base.NodeList).

See Also:
Serialized Form
 

Field Summary
 
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.AddSuccessorsAction(Graph2DView view)
          Initializes a new AddSuccessorsAction instance.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Invokes addNeighbors(Graph2DView) for the view returned by getView(e).
 void addNeighbors(Graph2DView view)
          Adds new neighbor nodes for the nodes returned by getReferenceNodes(Graph2D).
protected  NodeList createNeighborNodes(Graph2D graph, NodeList referenceNodes)
          Creates the new neighbor nodes.
protected  NodeList getReferenceNodes(Graph2D graph)
          Determines the nodes for which a neighbor node should be added.
protected  Graph2DView getView(java.awt.event.ActionEvent e)
          Determines the view in which to add new nodes.
protected  void layoutNeighborNodes(Graph2D graph, NodeList neighborNodes, NodeList referenceNodes)
          Calculates layout for newly created neighbor nodes.
protected  void selectNeighborNodes(Graph2D graph, NodeList neighborNodes, NodeList referenceNodes)
          Selects the nodes created by createNeighborNodes.
 
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.AddSuccessorsAction

public Graph2DViewActions.AddSuccessorsAction(Graph2DView view)
Initializes a new AddSuccessorsAction 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

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Invokes addNeighbors(Graph2DView) for the view returned by getView(e).

Parameters:
e - the ActionEvent that triggers the addition of new nodes.

addNeighbors

public void addNeighbors(Graph2DView view)
Adds new neighbor nodes for the nodes returned by getReferenceNodes(Graph2D). In this context, a neighbor node is a new node such that there is an edge connecting each reference node to the new node.

Parameters:
view - the related view.

createNeighborNodes

protected NodeList createNeighborNodes(Graph2D graph,
                                       NodeList referenceNodes)
Creates the new neighbor nodes. The default implementation creates exactly one neighbor node that is connected to each of the specified reference nodes.

Parameters:
graph - the graph in which to add new nodes.
referenceNodes - the nodes to which the newly created nodes have to be connected.
Returns:
a list of newly created neighbor nodes.

getReferenceNodes

protected NodeList getReferenceNodes(Graph2D graph)
Determines the nodes for which a neighbor node should be added. The default implementation returns the currently selected nodes. Called from addNeighbors(Graph2DView).

Parameters:
graph - the graph in which to add neighbor nodes.
Returns:
a list of nodes to which new neighbor nodes have to be connected.

layoutNeighborNodes

protected void layoutNeighborNodes(Graph2D graph,
                                   NodeList neighborNodes,
                                   NodeList referenceNodes)
Calculates layout for newly created neighbor nodes. Called from addNeighbors(Graph2DView).

Parameters:
graph - the graph in which to layout new nodes.
neighborNodes - the neighbor nodes.
referenceNodes - the nodes to which the new neighbor nodes are connected.
See Also:
addNeighbors(Graph2DView)

selectNeighborNodes

protected void selectNeighborNodes(Graph2D graph,
                                   NodeList neighborNodes,
                                   NodeList referenceNodes)
Selects the nodes created by createNeighborNodes. Called from addNeighbors(Graph2DView).

Parameters:
graph - the graph in which to select neighbor nodes.
neighborNodes - the neighbor nodes.
referenceNodes - the nodes to which the new neighbor nodes are connected.
See Also:
createNeighborNodes(Graph2D, y.base.NodeList)

getView

protected Graph2DView getView(java.awt.event.ActionEvent e)
Determines the view in which to add new nodes.

Parameters:
e - the ActionEvent that triggers the addition of new nodes.
Returns:
the view in which to add new nodes.
See Also:
actionPerformed(java.awt.event.ActionEvent)

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