Search this API

y.view
Class Graph2DViewActions.DuplicateAction

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

Action that allows to duplicate nodes or edges. The nodes and edges to duplicate are determined by the cursors returned by Graph2D.selectedNodes() and Graph2D.selectedEdges(), respectively. If there is at least one selected node, the selected edges are ignored and the edges to duplicate are induced by the selected nodes instead.

See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map), 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.DuplicateAction(Graph2DView view)
          Creates a new instance of DuplicateAction.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Invokes duplicate(Graph2DView) for the view returned by getView(e).
protected  void createDuplicates(Graph2D graph, NodeList newNodes, EdgeList newEdges, java.util.Map mappedNodes, java.util.Map mappedEdges)
          Duplicates nodes or edges.
protected  void createLabelDuplicates(Graph2D graph, java.util.List newNodeLabels, java.util.List newEdgeLabels, java.util.Map mappedNodeLabels, java.util.Map mappedEdgeLabels)
          Duplicates node or edge labels.
 void duplicate(Graph2DView view)
          Duplicates selected nodes or selected edges of the specified view.
protected  java.util.List getEdgeLabelsToDuplicate(Graph2D graph)
          Determines the edge labels to duplicate.
protected  EdgeList getEdgesToDuplicate(Graph2D graph)
          Determines the edges to duplicate.
protected  java.util.List getNodeLabelsToDuplicate(Graph2D graph)
          Determines the node labels to duplicate.
protected  NodeList getNodesToDuplicate(Graph2D graph)
          Determines the nodes to duplicate.
protected  Graph2DView getView(java.awt.event.ActionEvent e)
          Determines the view in which to duplicate graph elements.
protected  void layoutDuplicates(Graph2D graph, NodeList newNodes, EdgeList newEdges, java.util.Map mappedNodes, java.util.Map mappedEdges)
          Lays out the nodes and/or edges created by createDuplicates.
protected  void placeLabelDuplicates(Graph2D graph, java.util.List newNodeLabels, java.util.List newEdgeLabels, java.util.Map mappedNodeLabels, java.util.Map mappedEdgeLabels)
          Places the node and/or edge labels created by createLabelDuplicates.
protected  void selectDuplicates(Graph2D graph, NodeList newNodes, EdgeList newEdges, java.util.Map mappedNodes, java.util.Map mappedEdges)
          Selects the nodes and/or edges created by createDuplicates.
protected  void selectLabelDuplicates(Graph2D graph, java.util.List newNodeLabels, java.util.List newEdgeLabels, java.util.Map mappedNodeLabels, java.util.Map mappedEdgeLabels)
          Selects the node and/or edge labels created by createLabelDuplicates.
 
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.DuplicateAction

public Graph2DViewActions.DuplicateAction(Graph2DView view)
Creates a new instance of DuplicateAction.

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 duplicate(Graph2DView) for the view returned by getView(e).

Parameters:
e - the ActionEvent that triggers the duplication of graph elements.

duplicate

public void duplicate(Graph2DView view)
Duplicates selected nodes or selected edges of the specified view.

Parameters:
view - the related Graph2DView.
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

createDuplicates

protected void createDuplicates(Graph2D graph,
                                NodeList newNodes,
                                EdgeList newEdges,
                                java.util.Map mappedNodes,
                                java.util.Map mappedEdges)
Duplicates nodes or edges. The nodes or edges to duplicate are determined by the cursors returned by getNodesToDuplicate(Graph2D) and getEdgesToDuplicate(Graph2D), respectively. If there is at least one selected node, the selected edges are ignored and the edges to duplicate are induced by the selected nodes instead.

For each selected node, a new (duplicate) node is created and connected to the same non-selected neighbors as the original one. Additionally, each duplicate is connected to the duplicates of the selected neighbors of its original node.

If there is no selected node, for each selected edge a new edge is created with the same source and target node.

Parameters:
graph - the related graph.
newNodes - the created nodes are stored in this list.
newEdges - the created edges are stored in this list.
mappedNodes - for each new node, the mapping to its original node is stored in this map.
mappedEdges - for each new edge, the mapping to its original edge is stored in this map.

getNodesToDuplicate

protected NodeList getNodesToDuplicate(Graph2D graph)
Determines the nodes to duplicate. The default implementation returns the currently selected nodes.

Parameters:
graph - the related graph.
Returns:
a list of nodes to duplicate.
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

getEdgesToDuplicate

protected EdgeList getEdgesToDuplicate(Graph2D graph)
Determines the edges to duplicate. The default implementation returns the currently selected edges.

Parameters:
graph - the related graph.
Returns:
a list of edges to duplicate.
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

layoutDuplicates

protected void layoutDuplicates(Graph2D graph,
                                NodeList newNodes,
                                EdgeList newEdges,
                                java.util.Map mappedNodes,
                                java.util.Map mappedEdges)
Lays out the nodes and/or edges created by createDuplicates.

Parameters:
graph - the related graph.
newNodes - the newly created nodes.
newEdges - the newly created edges.
mappedNodes - mappings from new nodes to original nodes (i.e. nodes that were duplicated).
mappedEdges - mappings from new edges to original edges (i.e. edges that were duplicated).
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

selectDuplicates

protected void selectDuplicates(Graph2D graph,
                                NodeList newNodes,
                                EdgeList newEdges,
                                java.util.Map mappedNodes,
                                java.util.Map mappedEdges)
Selects the nodes and/or edges created by createDuplicates.

Parameters:
graph - the related graph.
newNodes - the newly created nodes.
newEdges - the newly created edges.
mappedNodes - mappings from new nodes to original nodes (i.e. nodes that were duplicated).
mappedEdges - mappings from new edges to original edges (i.e. edges that were duplicated).
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

createLabelDuplicates

protected void createLabelDuplicates(Graph2D graph,
                                     java.util.List newNodeLabels,
                                     java.util.List newEdgeLabels,
                                     java.util.Map mappedNodeLabels,
                                     java.util.Map mappedEdgeLabels)
Duplicates node or edge labels. The labels to duplicate are determined by the cursors returned by getNodeLabelsToDuplicate(Graph2D) or getEdgeLabelsToDuplicate(Graph2D), respectively.

For each selected label, a new (duplicate) label is created and connected to the same non-selected node or edge as the original one.

Parameters:
graph - the related graph.
newNodeLabels - the created node labels are stored in this list.
newEdgeLabels - the created edge labels are stored in this list.
mappedNodeLabels - for each new node label, the mapping to its original node label is stored in this map.
mappedEdgeLabels - for each new edge label, the mapping to its original edge label is stored in this map.

getNodeLabelsToDuplicate

protected java.util.List getNodeLabelsToDuplicate(Graph2D graph)
Determines the node labels to duplicate. The default implementation returns the currently selected node labels.

Parameters:
graph - the related graph.
Returns:
a list of node labels to duplicate.
See Also:
createLabelDuplicates(Graph2D, java.util.List, java.util.List, java.util.Map, java.util.Map)

getEdgeLabelsToDuplicate

protected java.util.List getEdgeLabelsToDuplicate(Graph2D graph)
Determines the edge labels to duplicate. The default implementation returns the currently selected edge labels.

Parameters:
graph - the related graph.
Returns:
a list of edge labels to duplicate.
See Also:
createLabelDuplicates(Graph2D, java.util.List, java.util.List, java.util.Map, java.util.Map)

placeLabelDuplicates

protected void placeLabelDuplicates(Graph2D graph,
                                    java.util.List newNodeLabels,
                                    java.util.List newEdgeLabels,
                                    java.util.Map mappedNodeLabels,
                                    java.util.Map mappedEdgeLabels)
Places the node and/or edge labels created by createLabelDuplicates.

Node and edge labels are set to one of the remaining label positions a discrete label model offers. If all positions are in use, the label is placed over its original. In case the label has a free label model, the label is placed below its original.

Parameters:
graph - the related graph.
newNodeLabels - the newly created node labels.
newEdgeLabels - the newly created edge labels.
mappedNodeLabels - mappings from new node labels to original node labels (i.e. labels that were duplicated).
mappedEdgeLabels - mappings from new edge labels to original edge labels (i.e. labels that were duplicated).
See Also:
createLabelDuplicates(Graph2D, java.util.List, java.util.List, java.util.Map, java.util.Map)

selectLabelDuplicates

protected void selectLabelDuplicates(Graph2D graph,
                                     java.util.List newNodeLabels,
                                     java.util.List newEdgeLabels,
                                     java.util.Map mappedNodeLabels,
                                     java.util.Map mappedEdgeLabels)
Selects the node and/or edge labels created by createLabelDuplicates.

Parameters:
graph - the related graph.
newNodeLabels - the newly created node labels.
newEdgeLabels - the newly created edge labels.
mappedNodeLabels - mappings from new node labels to original node labels (i.e. labels that were duplicated).
mappedEdgeLabels - mappings from new edge labels to original edge labels (i.e. labels that were duplicated).
See Also:
createDuplicates(Graph2D, y.base.NodeList, y.base.EdgeList, java.util.Map, java.util.Map)

getView

protected Graph2DView getView(java.awt.event.ActionEvent e)
Determines the view in which to duplicate graph elements.

Parameters:
e - the ActionEvent that triggers the duplication of graph elements.
Returns:
the related view.
See Also:
actionPerformed(java.awt.event.ActionEvent), Graph2DViewActions.DuplicateAction(y.view.Graph2DView)

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