Packagecom.yworks.graph.model
Classpublic class LayoutGraphAdapter
InheritanceLayoutGraphAdapter Inheritance 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();
  
Alternatively one can use the 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();
  
Class 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();
  
This class will use the provided 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

GraphLayout
GraphInterface
LayoutMorpherWrapper
CopiedLayoutGraph


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
  
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
  
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
  
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
Protected Methods
 MethodDefined By
  
Factory method that creates an EdgeLayout implementation that wraps the given IEdge.
LayoutGraphAdapter
  
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
Public Constants
 ConstantDefined 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
Property Detail
adaptedGraphproperty
adaptedGraph:IGraph  [read-only]

Yields the original IGraph instance that is adapted by this instance.


Implementation
    public function get adaptedGraph():IGraph
dataProviderKeysproperty 
dataProviderKeys:Vector.<Object>  [read-only]

Returns an array of all data provider look-up keys that are registered with the graph.


Implementation
    public function get dataProviderKeys():Vector.<Object>
selectionModelproperty 
selectionModel:ISelectionModel

Gets the used ISelectionModel for the automatically registered DataProvider instances for LayoutConstants.SELECTED_NODES and LayoutConstants.SELECTED_EDGES.


Implementation
    public function get selectionModel():ISelectionModel
    public function set selectionModel(value:ISelectionModel):void
Constructor Detail
LayoutGraphAdapter()Constructor
public function LayoutGraphAdapter(graph:IGraph, selectionModel:ISelectionModel = null)

Creates the adapter using a given IGraph and ISelectionModel.

Parameters
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

LayoutConstants
Method Detail
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.

Returns
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.

Returns
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.

Returns
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.

Returns
NodeLayout — A wrapper instance.
edgeObjects()method 
public function edgeObjects():Iterator

Returns an iterator that provides access to all edges residing in the graph.

Returns
Iterator
getBoundingBox()method 
public function getBoundingBox():Rectangle

Returns 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.

Returns
Rectangle
getDataProvider()method 
public function getDataProvider(dataKey:Object):DataProvider

Returns 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

Returns
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

Returns
Vector.<Object>
getEdgeLayout()method 
public function getEdgeLayout(edge:Object):EdgeLayout

Returns the layout information for a given edge.

Parameters

edge:Object

Returns
EdgeLayout
getLabelCandidateDescriptor()method 
protected function getLabelCandidateDescriptor(originalLabel:ILabel, dummyLabel:ILabel, parameter:ILabelModelParameter):ILabelCandidateDescriptor

Callback 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.

Returns
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.

Returns
ILabelCandidateDescriptorProvider — The result of a lookup query on graph for ILabelCandidateDescriptorProvider.

See also

IGraph.lookup
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

Returns
Vector.<Object>
getNodeLayout()method 
public function getNodeLayout(node:Object):NodeLayout

Returns the layout information for a given node.

Parameters

node:Object

Returns
NodeLayout
getSource()method 
public function getSource(edgeObject:Object):Object

Returns the source node associated with the given edge.

Parameters

edgeObject:Object

Returns
Object
getTarget()method 
public function getTarget(edgeObject:Object):Object

Returns the target node associated with the given edge.

Parameters

edgeObject:Object

Returns
Object
nodeObjects()method 
public function nodeObjects():Iterator

Returns an iterator that provides access to all nodes residing in the graph.

Returns
Iterator
toYIterator()method 
protected function toYIterator(it:Iterator):Iterator

Parameters

it:Iterator

Returns
Iterator
Constant Detail
EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEYConstant
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_KEYConstant 
public static const EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_KEY:Object = LayoutGraphAdapter.EdgeLabelLayoutPreferredPlacementDpKey
Deprecated: Use the EdgeLabelLayoutPreferredPlacementDescriptorDpKey instead.

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

EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_KEY