| Package | com.yworks.graph.model |
| Class | public class LayoutGraphAdapter |
| Inheritance | LayoutGraphAdapter Object |
| Implements | GraphLayout, GraphInterface |
Adapter class that can be used to obtain a GraphLayout and GraphInterface
from an IGraph.
This adapter needs to be used in order to apply layout algorithms to IGraph instances.
The following pattern should be used:
// build the adapter var adapter:LayoutGraphAdapter = new LayoutGraphAdapter(graph, selectionModel); // create a copy for improved performance and stability var layoutGraph:CopiedLayoutGraph = new CopiedLayoutGraph(adapter, adapter); // perform the layout on the copy layouter.doLayout(layoutGraph); // apply the results to the original IGraph layoutGraph.commitLayoutToOriginalGraph();
LayoutMorpherWrapper to morph the layout:
// build the adapter var adapter:LayoutGraphAdapter = new LayoutGraphAdapter(graph, selectionModel); // create a copy for improved performance and stability var layoutGraph:CopiedLayoutGraph = new CopiedLayoutGraph(adapter, adapter); // perform the layout on the copy layouter.doLayout(layoutGraph); // create the animation object var morpher:LayoutMorpherWrapper = LayoutMorpherWrapper.createWrapperForCopiedGraph(graphCanvas, layoutGraph); // and play morpher.play();
CopiedLayoutIGraph is a convenience class that can be used
to quickly assign new layouts to an IGraph:
// build the adapter copy CopiedLayoutIGraph copy = new CopiedLayoutIGraph(graph); // perform the layout on the copy layouter.doLayout(copy); // apply the results to the original IGraph copy.commitLayoutToOriginalGraph();
SelectionModel to attach DataProvider
instances to the GraphInterface for the LayoutConstants.SELECTED_NODES
and LayoutConstants.SELECTED_EDGES data provider keys. Also it will automatically
wrap IMapper instances registered with the IMapperRegistry found in
the ILookup.lookup of the IGraph and wrap those instances in
DataProvider instances.
See also
| Property | Defined By | ||
|---|---|---|---|
| adaptedGraph : IGraph [read-only]
Yields the original IGraph instance that is adapted by this instance. | LayoutGraphAdapter | ||
| dataProviderKeys : Vector.<Object> [read-only]
Returns an array of all data provider look-up keys that are registered with the graph. | LayoutGraphAdapter | ||
| selectionModel : ISelectionModel
Gets the used ISelectionModel for the automatically registered DataProvider
instances for LayoutConstants.SELECTED_NODES and LayoutConstants.SELECTED_EDGES. | LayoutGraphAdapter | ||
| Method | Defined By | ||
|---|---|---|---|
LayoutGraphAdapter(graph:IGraph, selectionModel:ISelectionModel = null)
Creates the adapter using a given IGraph and ISelectionModel. | LayoutGraphAdapter | ||
createEdgeLabelCandidate(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter, labelLayout:EdgeLabelLayout):EdgeLabelCandidate
Creates the EdgeLabelCandidate for a given label and ILabelModelParameter combination. | LayoutGraphAdapter | ||
createNodeLabelCandidate(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter, ownerLayout:NodeLabelLayout):NodeLabelCandidate
Creates a NodeLabelCandidate for a given label and ILabelModelParameter combination. | LayoutGraphAdapter | ||
Returns an iterator that provides access to all edges residing in the graph. | LayoutGraphAdapter | ||
Returns the bounding box of the graph layout. | LayoutGraphAdapter | ||
getDataProvider(dataKey:Object):DataProvider
Returns the data provider that is registered with the graph using the given look-up key. | LayoutGraphAdapter | ||
getEdgeLabelLayout(edge:Object):Vector.<Object>
Returns an array of layout information for all edge labels belonging to the given edge. | LayoutGraphAdapter | ||
getEdgeLayout(edge:Object):EdgeLayout
Returns the layout information for a given edge. | LayoutGraphAdapter | ||
getNodeLabelLayout(node:Object):Vector.<Object>
Returns an array of layout information for all node labels belonging to the given node. | LayoutGraphAdapter | ||
getNodeLayout(node:Object):NodeLayout
Returns the layout information for a given node. | LayoutGraphAdapter | ||
getSource(edgeObject:Object):Object
Returns the source node associated with the given edge. | LayoutGraphAdapter | ||
getTarget(edgeObject:Object):Object
Returns the target node associated with the given edge. | LayoutGraphAdapter | ||
Returns an iterator that provides access to all nodes residing in the graph. | LayoutGraphAdapter | ||
| Method | Defined By | ||
|---|---|---|---|
createEdgeLayout(edge:IEdge):EdgeLayout
Factory method that creates an EdgeLayout implementation that wraps the given IEdge. | LayoutGraphAdapter | ||
createNodeLayout(node:INode):NodeLayout
Factory method that creates an NodeLayout implementation that wraps the given INode. | LayoutGraphAdapter | ||
getLabelCandidateDescriptor(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter):ILabelCandidateDescriptor
Callback that retrieves the label candidate descriptor for the given label and parameter. | LayoutGraphAdapter | ||
getLabelCandidateDescriptorProvider(graph:IGraph):ILabelCandidateDescriptorProvider
Callback method that gets the label candidate descriptor provider for the given IGraph. | LayoutGraphAdapter | ||
toYIterator(it:Iterator):Iterator | LayoutGraphAdapter | ||
| Constant | Defined By | ||
|---|---|---|---|
| EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEY : Object = LayoutGraphAdapter.EdgeLabelLayoutPreferredPlacementDescriptorDpKey [static]
An IMapperRegistry tag for an IMapper
that provides for the edge labels in the adaptedGraph a
PreferredPlacementDescriptor instance. | LayoutGraphAdapter | ||
| EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_KEY : Object = LayoutGraphAdapter.EdgeLabelLayoutPreferredPlacementDpKey Deprecated: Use the EdgeLabelLayoutPreferredPlacementDescriptorDpKey instead. [static]
An IMapperRegistry tag for a IMapper
that provides for the edge in the adaptedGraph a
LabelLayoutConstants constant. | LayoutGraphAdapter | ||
| adaptedGraph | property |
adaptedGraph:IGraph [read-only]
Yields the original IGraph instance that is adapted by this instance.
public function get adaptedGraph():IGraph| dataProviderKeys | property |
dataProviderKeys:Vector.<Object> [read-only] Returns an array of all data provider look-up keys that are registered with the graph.
public function get dataProviderKeys():Vector.<Object>| selectionModel | property |
selectionModel:ISelectionModel
Gets the used ISelectionModel for the automatically registered DataProvider
instances for LayoutConstants.SELECTED_NODES and LayoutConstants.SELECTED_EDGES.
public function get selectionModel():ISelectionModel public function set selectionModel(value:ISelectionModel):void| LayoutGraphAdapter | () | Constructor |
public function LayoutGraphAdapter(graph:IGraph, selectionModel:ISelectionModel = null)
Creates the adapter using a given IGraph and ISelectionModel.
graph:IGraph — The graph to build an adapter for.
| |
selectionModel:ISelectionModel (default = null) — The selection model to use by the LayoutConstants.SELECTED_NODES and
LayoutConstants.SELECTED_EDGES DataProvider instances that are automatically bound to this adapter.
|
See also
| createEdgeLabelCandidate | () | method |
public function createEdgeLabelCandidate(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter, labelLayout:EdgeLabelLayout):EdgeLabelCandidate
Creates the EdgeLabelCandidate for a given label and ILabelModelParameter combination.
Parameters
originalLabel:ILabel — The original label.
| |
dummyLabel:ILabel — The dummy label that describes the current laid out label.
| |
parameter:ILabelModelParameter — The parameter to create a candidate for.
| |
labelLayout:EdgeLabelLayout — The EdgeLabelLayout of the label to pass to the candidate.
|
EdgeLabelCandidate — A candidate to yield for the labeling algorithms or null.
|
| createEdgeLayout | () | method |
protected function createEdgeLayout(edge:IEdge):EdgeLayout
Factory method that creates an EdgeLayout implementation that wraps the given IEdge.
Parameters
edge:IEdge — The edge to wrap.
|
EdgeLayout — A wrapper instance.
|
| createNodeLabelCandidate | () | method |
public function createNodeLabelCandidate(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter, ownerLayout:NodeLabelLayout):NodeLabelCandidate
Creates a NodeLabelCandidate for a given label and ILabelModelParameter combination.
Parameters
originalLabel:ILabel — The original label.
| |
dummyLabel:ILabel — The dummy label that describes the current laid out label.
| |
parameter:ILabelModelParameter — The parameter to create a candidate for.
| |
ownerLayout:NodeLabelLayout — The NodeLabelLayout of the label to pass to the candidate.
|
NodeLabelCandidate — A candidate to yield for the labeling algorithms or null.
|
| createNodeLayout | () | method |
protected function createNodeLayout(node:INode):NodeLayout
Factory method that creates an NodeLayout implementation that wraps the given INode.
Parameters
node:INode — The node to wrap.
|
NodeLayout — A wrapper instance.
|
| edgeObjects | () | method |
public function edgeObjects():IteratorReturns an iterator that provides access to all edges residing in the graph.
ReturnsIterator |
| getBoundingBox | () | method |
public function getBoundingBox():RectangleReturns the bounding box of the graph layout. That is the smallest rectangular area that contains all defined layout elements. If there are no elements in this graph layout, the resulting rectangle will have negative width and height.
ReturnsRectangle |
| getDataProvider | () | method |
public function getDataProvider(dataKey:Object):DataProviderReturns the data provider that is registered with the graph using the given look-up key. The look-up domain of a returned data provider normally consists of either the nodes of the graph, or its edges, or both.
Parameters
dataKey:Object |
DataProvider |
| getEdgeLabelLayout | () | method |
public function getEdgeLabelLayout(edge:Object):Vector.<Object>Returns an array of layout information for all edge labels belonging to the given edge.
Parameters
edge:Object |
Vector.<Object> |
| getEdgeLayout | () | method |
public function getEdgeLayout(edge:Object):EdgeLayoutReturns the layout information for a given edge.
Parameters
edge:Object |
EdgeLayout |
| getLabelCandidateDescriptor | () | method |
protected function getLabelCandidateDescriptor(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter):ILabelCandidateDescriptorCallback that retrieves the label candidate descriptor for the given label and parameter.
Parameters
originalLabel:ILabel — The original label to which a parameter will be applied.
| |
dummyLabel:ILabel — The dummy label to which the parameter will be applied.
| |
parameter:ILabelModelParameter — The parameter to apply.
|
ILabelCandidateDescriptor — A descriptor of null.
|
See also
| getLabelCandidateDescriptorProvider | () | method |
protected function getLabelCandidateDescriptorProvider(graph:IGraph):ILabelCandidateDescriptorProvider
Callback method that gets the label candidate descriptor provider for the given IGraph.
This implementation uses the IGraph's ILookup to find an implementation
of the ILabelCandidateDescriptorProvider.
Parameters
graph:IGraph — The graph.
|
ILabelCandidateDescriptorProvider — The result of a lookup query on graph for ILabelCandidateDescriptorProvider.
|
See also
| getNodeLabelLayout | () | method |
public function getNodeLabelLayout(node:Object):Vector.<Object>Returns an array of layout information for all node labels belonging to the given node.
Parameters
node:Object |
Vector.<Object> |
| getNodeLayout | () | method |
public function getNodeLayout(node:Object):NodeLayoutReturns the layout information for a given node.
Parameters
node:Object |
NodeLayout |
| getSource | () | method |
public function getSource(edgeObject:Object):ObjectReturns the source node associated with the given edge.
Parameters
edgeObject:Object |
Object |
| getTarget | () | method |
public function getTarget(edgeObject:Object):ObjectReturns the target node associated with the given edge.
Parameters
edgeObject:Object |
Object |
| nodeObjects | () | method |
public function nodeObjects():IteratorReturns an iterator that provides access to all nodes residing in the graph.
ReturnsIterator |
| toYIterator | () | method |
| EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEY | Constant |
public static const EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEY:Object = LayoutGraphAdapter.EdgeLabelLayoutPreferredPlacementDescriptorDpKey
An IMapperRegistry tag for an IMapper
that provides for the edge labels in the adaptedGraph a
PreferredPlacementDescriptor instance.
If there is an IMapper in the graph's mapperRegistry
it will be queried for each edge label
to set the EdgeLabelLayout#preferredPlacementDescriptor property of the adapted
implementation.
| EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_KEY | Constant |
public static const EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_KEY:Object = LayoutGraphAdapter.EdgeLabelLayoutPreferredPlacementDpKey
An IMapperRegistry tag for a IMapper
that provides for the edge in the adaptedGraph a
LabelLayoutConstants constant.
This technique is obsolete and superseded by the more powerful PreferredPlacementDescriptor API,
which is leveraged by the EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEY.
If there is an IMapper in the graph's mapperRegistry
it will be queried for each edge label
to set the preferredPlacementDescriptor property of the adapted
implementation.
See also