public class CopiedLayoutGraph extends LayoutGraph
CopiedLayoutGraph
is a LayoutGraph
that serves as a copy of another graph with layout
information.
A CopiedLayoutGraph
comes to use if a layout algorithm
should not run directly on the
original graph. Using a copy, the calculated layout will not be applied to the original graph before the layout
algorithm finished successfully. This can prevent inconsistencies in case something goes wrong during layout
calculations.
CopiedLayoutGraph
contains corresponding nodes and edges for each node and edge in the original
graph and copies the labels of the original nodes and edges. It also delegates all
IDataProvider
s registered with the original graph.
To preserve the relations between the original elements and the copied elements in this graph, CopiedLayoutGraph
updates mappings between those elements.
If there are structural changes to the original graph, they can be transferred to this copied graph using
syncStructure()
. Then the copied graph will be altered, adding and removing elements, until it corresponds
to the original again.
Method commitLayoutToOriginalGraph()
will transfer updated layout information to the original graph. The
original graph will stay unchanged until this method is called.
BufferedLayout
Constructor and Description |
---|
CopiedLayoutGraph(LayoutGraph graph)
Creates a new
CopiedLayoutGraph instance which is a copy of the given graph. |
Modifier and Type | Method and Description |
---|---|
void |
commitLayoutToOriginalGraph()
Writes the current layout information of all elements of this copied graph to the original graph.
|
Edge |
createEdge(Object originalEdge)
Creates an edge in the copied graph that corresponds to the given original edge.
|
protected ILabelLayoutFactory |
createLabelFactory()
Creates a new
ILabelLayoutFactory for this CopiedLayoutGraph . |
Node |
createNode(Object originalNode)
Creates a node in the copied graph that corresponds to the given original node.
|
Edge |
getCopiedEdge(Object originalEdge)
Returns the copied edge that corresponds to the given original edge.
|
Node |
getCopiedNode(Object originalNode)
Returns the copied node that corresponds to the given original node.
|
IEdgeLabelLayout[] |
getLabelLayout(Edge copiedEdge)
Returns the layout information for all labels associated with the given edge of the copied graph.
|
INodeLabelLayout[] |
getLabelLayout(Node copiedNode)
Returns the layout information for all labels associated with the given node of the copied graph.
|
IEdgeLayout |
getLayout(Edge copiedEdge)
Returns the layout information for the given edge of the copied graph.
|
INodeLayout |
getLayout(Node copiedNode)
Returns the layout information for the given node of the copied graph.
|
Object |
getOriginalEdge(Edge copiedEdge)
Returns the original edge that corresponds to the given copied edge.
|
Object |
getOriginalNode(Node copiedNode)
Returns the original node that corresponds to the given copied node.
|
Edge |
getOwner(IEdgeLabelLayout labelLayout)
Returns the edge of the copied graph to which the given
IEdgeLabelLayout belongs. |
Node |
getOwner(INodeLabelLayout labelLayout)
Returns the edge of the copied graph to which the given
IEdgeLabelLayout belongs. |
void |
syncStructure()
Synchronizes the structure of the
CopiedLayoutGraph with the actual structure of the underlying original graph. |
getBoundingBox, getBoundingBox, getCenter, getCenterX, getCenterY, getEdgeList, getHeight, getLocation, getPath, getPathList, getPointList, getPoints, getSize, getSourcePointAbs, getSourcePointRel, getTargetPointAbs, getTargetPointRel, getWidth, getX, getY, moveBy, setCenter, setCenter, setEndPointsAbs, setLocation, setLocation, setPath, setPath, setPoints, setPoints, setSize, setSize, setSourcePointAbs, setSourcePointRel, setTargetPointAbs, setTargetPointRel
addDataProvider, changeEdge, changeEdge, changeEdge, clear, contains, contains, containsEdge, createCopy, createEdge, createEdge, createEdgeMap, createGraph, createNode, createNodeMap, disposeEdgeMap, disposeNodeMap, edgeCount, edgeObjects, firstEdge, firstNode, firstOutEdge, getDataProvider, getDataProviderKeys, getEdgeArray, getEdgeCursor, getEdges, getNodeArray, getNodeCursor, getNodes, getRegisteredEdgeMaps, getRegisteredNodeMaps, getSource, getTarget, hasListeners, hide, hide, isEmpty, lastEdge, lastNode, moveToFirst, moveToFirst, moveToLast, moveToLast, nodeCount, nodeObjects, printNodeSlotSize, reInsertEdge, reInsertNode, removeDataProvider, removeEdge, removeNode, reverseEdge, sortEdges, sortEdges, sortNodes, toString, unhide, unhide
public CopiedLayoutGraph(LayoutGraph graph)
CopiedLayoutGraph
instance which is a copy of the given graph.graph
- the original graphpublic void commitLayoutToOriginalGraph()
public Edge createEdge(Object originalEdge)
The edge will connect to the copies of the source and target of the original edge. All labels of the original edge will be also copied and assigned to this edge.
The mappings are updated. Hence, it is possible to look up the newly created edge by using getCopiedEdge(Object)
or the original edge by using getOriginalEdge(Edge)
.
This method can be used for keeping the CopiedLayoutGraph
in sync with the original graph.
originalEdge
- the original edgeprotected ILabelLayoutFactory createLabelFactory()
ILabelLayoutFactory
for this CopiedLayoutGraph
.
Subclasses overriding this method must provide an instance that manages the mapping between copied and original
ILabelLayout
s.
createLabelFactory
in class LayoutGraph
public Node createNode(Object originalNode)
All labels of the original node will be copied and assigned to this node.
The mappings are updated. Hence, it is possible to look up the newly created node by using getCopiedNode(Object)
or the original node by using getOriginalNode(Node)
.
This method can be used for keeping the CopiedLayoutGraph
in sync with the original graph.
originalNode
- the original nodepublic Edge getCopiedEdge(Object originalEdge)
originalEdge
- an edge of the original graph whose copy resides in this graphpublic Node getCopiedNode(Object originalNode)
originalNode
- a node of the original graph whose copy resides in this graphpublic IEdgeLabelLayout[] getLabelLayout(Edge copiedEdge)
If there is no layout information for a label, yet, a new implementation of IEdgeLabelLayout
is created.
getLabelLayout
in class LayoutGraph
copiedEdge
- the edgepublic INodeLabelLayout[] getLabelLayout(Node copiedNode)
If there is no layout information for a label, yet, a new implementation of INodeLabelLayout
is created.
getLabelLayout
in class LayoutGraph
copiedNode
- the nodepublic IEdgeLayout getLayout(Edge copiedEdge)
If there is no layout information for this edge, yet, a new implementation of IEdgeLayout
is returned.
getLayout
in class LayoutGraph
copiedEdge
- the edgepublic INodeLayout getLayout(Node copiedNode)
If there is no layout information for this node, yet, a new implementation of INodeLayout
is returned.
getLayout
in class LayoutGraph
copiedNode
- the nodepublic Object getOriginalEdge(Edge copiedEdge)
copiedEdge
- the edge in this graph that is a copy of the returned edgepublic Object getOriginalNode(Node copiedNode)
copiedNode
- the node in this graph that is a copy of the returned nodepublic Edge getOwner(IEdgeLabelLayout labelLayout)
IEdgeLabelLayout
belongs.getOwner
in class LayoutGraph
labelLayout
- a label layout information of an edge in the copied graphpublic Node getOwner(INodeLabelLayout labelLayout)
IEdgeLabelLayout
belongs.getOwner
in class LayoutGraph
labelLayout
- a label layout information of a node in the copied graphpublic void syncStructure()
CopiedLayoutGraph
with the actual structure of the underlying original graph.