Packagecom.yworks.graph.model
Classpublic class GraphModelManager
InheritanceGraphModelManager Inheritance Object

Manages the visual appearance of an IGraph instance in a CanvasComponent.

This class monitors the structural changes of an IGraph implementation and installs the necessary ICanvasObject instances in the canvas for each item in the graph. The actual installation of the items is delegated to different IModelItemInstaller instances depending on the type of the item. Typically one would use instances of this class as follows: var manager:GraphModelManager = new GraphModelManager( canvasComponent ); manager.graph = graph; Note that GraphCanvasComponent has an instance of this type built-in already.



Public Properties
 PropertyDefined By
  contentGroup : ICanvasObjectGroup
[read-only] Gets the content group this manager instance uses to add visual representation of the graph to.
GraphModelManager
  drawEdgesBehindGroupedNodes : Boolean
Determines whether edges should be drawn behind nodes if a grouped graph is displayed.
GraphModelManager
  edgeGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing edge styles.
GraphModelManager
  edgeLabelGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing edge label styles.
GraphModelManager
  edgeLabelInstaller : LabelStyleInstaller
[read-only] Gets the StyleInstaller instance used for installing an ILabel of an IEdge into the canvas. If the field has not yet been initialized upon first access, the factory method createEdgeLabelInstaller will be called.
GraphModelManager
  edgeStyleInstaller : EdgeStyleInstaller
[read-only] Gets the StyleInstaller instance used for installing an IEdge into the canvas. If the field has not yet been initialized upon first access, the factory method createEdgeStyleInstaller will be called.
GraphModelManager
  filteredHitTestIterator : IFilteredHitTestIterator
[read-only] Gets an IFilteredHitTestIterator that can be used to iterate hits on the canvas at a given world coordinate position and filter those hits by a given filter function.
GraphModelManager
  graph : IGraph
Gets or sets the graph this manager manages.
GraphModelManager
  hitTestIterator : IHitTestIterator
[read-only] Gets an IHitTestIterator that can be used to iterate hits on the canvas at a given world coordinate position.
GraphModelManager
  nodeGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing node styles.
GraphModelManager
  nodeLabelGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing node label styles.
GraphModelManager
  nodeLabelInstaller : LabelStyleInstaller
[read-only] Gets the StyleInstaller instance used for installing an ILabel of an INode into the canvas. If the field has not yet been initialized upon first access, the factory method createNodeLabelInstaller will be called.
GraphModelManager
  nodeStyleInstaller : NodeStyleInstaller
[read-only] Gets the StyleInstaller instance used for installing an INode into the canvas. If the field has not yet been initialized upon first access, the factory method createNodeStyleInstaller will be called.
GraphModelManager
  portGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing port styles.
GraphModelManager
  portStyleInstaller : PortStyleInstaller
[read-only] Factory method for the PortStyleInstaller property.
GraphModelManager
Public Methods
 MethodDefined By
  
Creates a manager instance for the given control.
GraphModelManager
  
addShield():void
Adds a "shield" to each canvas object group.
GraphModelManager
  
Retrieves all canvas objects that have been registered for the given item or null.
GraphModelManager
  
Retrieves the Canvas Object group to use for the given edge.
GraphModelManager
  
Retrieves the main canvas object that has been registered for the given item or null.
GraphModelManager
  
Retrieves the corresponding IModelItem for the given canvas object.
GraphModelManager
  
iterateHits(x:Number, y:Number, filter:Function = null):Iterator
Iterates hits on the canvas at a given world coordinate position.
GraphModelManager
  
Removes the "shield" from the canvas object groups.
GraphModelManager
Protected Methods
 MethodDefined By
  
Creates an ICanvasGroupProvider instance that returns for each edge queried an ICanvasObjectGroup that will be provided to the EdgeStyleInstaller for each edge to be installed.
GraphModelManager
  
Factory method for the edgeGroup property.
GraphModelManager
  
Creates an ICanvasGroupProvider instance that returns for each edge label queried an ICanvasObjectGroup that will be provided to the edgeLabelInstaller for each edge label to be installed.
GraphModelManager
  
Factory method for the edgeLabelGroup property.
GraphModelManager
  
Factory method for the edgeLabelinstaller property.
GraphModelManager
  
Factory method for the EdgeStyleInstaller property.
GraphModelManager
  
Creates an ICanvasGroupProvider instance that returns for each node queried an ICanvasObjectGroup that will be provided to the nodeStyleInstaller for each node to be installed.
GraphModelManager
  
Factory method for the nodeGroup property.
GraphModelManager
  
Creates an ICanvasGroupProvider instance that returns for each node label queried an ICanvasObjectGroup that will be provided to the NodeLabelInstaller for each node label to be installed.
GraphModelManager
  
Factory method for the nodeLabelGroup property.
GraphModelManager
  
Factory method for the NodeLabelinstaller property.
GraphModelManager
  
Factory method for the NodeStyleInstaller property.
GraphModelManager
  
Creates an ICanvasGroupProvider instance that returns for each port queried an ICanvasObjectGroup that will be provided to the portStyleInstaller for each port to be installed.
GraphModelManager
  
Factory method for the portGroup property.
GraphModelManager
  
Factory method for the portStyleInstaller property.
GraphModelManager
  
Retrieves the Canvas Object group to use for the given node.
GraphModelManager
Property Detail
contentGroupproperty
contentGroup:ICanvasObjectGroup  [read-only]

Gets the content group this manager instance uses to add visual representation of the graph to.


Implementation
    public function get contentGroup():ICanvasObjectGroup
drawEdgesBehindGroupedNodesproperty 
drawEdgesBehindGroupedNodes:Boolean

Determines whether edges should be drawn behind nodes if a grouped graph is displayed.

The default value is false.


Implementation
    public function get drawEdgesBehindGroupedNodes():Boolean
    public function set drawEdgesBehindGroupedNodes(value:Boolean):void
edgeGroupproperty 
edgeGroup:ICanvasObjectGroup  [read-only]

Gets the ICanvasObjectGroup instance that will be used for installing edge styles.

If the field has not yet been initialized upon first access, the factory method createEdgeGroup will be called.


Implementation
    public function get edgeGroup():ICanvasObjectGroup
edgeLabelGroupproperty 
edgeLabelGroup:ICanvasObjectGroup  [read-only]

Gets the ICanvasObjectGroup instance that will be used for installing edge label styles.

If the field has not yet been initialized upon first access, the factory method createEdgeLabelGroup will be called.


Implementation
    public function get edgeLabelGroup():ICanvasObjectGroup
edgeLabelInstallerproperty 
edgeLabelInstaller:LabelStyleInstaller  [read-only]

Gets the StyleInstaller instance used for installing an ILabel of an IEdge into the canvas.

If the field has not yet been initialized upon first access, the factory method createEdgeLabelInstaller will be called.


Implementation
    public function get edgeLabelInstaller():LabelStyleInstaller
edgeManagerproperty 
edgeManager:CollectionModelManager  [read-only]


Implementation
    yworks_internal function get edgeManager():CollectionModelManager
edgeStyleInstallerproperty 
edgeStyleInstaller:EdgeStyleInstaller  [read-only]

Gets the StyleInstaller instance used for installing an IEdge into the canvas.

If the field has not yet been initialized upon first access, the factory method createEdgeStyleInstaller will be called.


Implementation
    public function get edgeStyleInstaller():EdgeStyleInstaller
filteredHitTestIteratorproperty 
filteredHitTestIterator:IFilteredHitTestIterator  [read-only]

Gets an IFilteredHitTestIterator that can be used to iterate hits on the canvas at a given world coordinate position and filter those hits by a given filter function.

This iterator will iterate hits in the order so that the visually topmost element will be reported first.


Implementation
    public function get filteredHitTestIterator():IFilteredHitTestIterator
graphproperty 
graph:IGraph

Gets or sets the graph this manager manages.


Implementation
    public function get graph():IGraph
    public function set graph(value:IGraph):void
hitTestIteratorproperty 
hitTestIterator:IHitTestIterator  [read-only]

Gets an IHitTestIterator that can be used to iterate hits on the canvas at a given world coordinate position.

This iterator will iterate hits in the order so that the visually topmost element will be reported first.


Implementation
    public function get hitTestIterator():IHitTestIterator
nodeGroupproperty 
nodeGroup:ICanvasObjectGroup  [read-only]

Gets the ICanvasObjectGroup instance that will be used for installing node styles.

If the field has not yet been initialized upon first access, the factory method createNodeGroup will be called.


Implementation
    public function get nodeGroup():ICanvasObjectGroup
nodeLabelGroupproperty 
nodeLabelGroup:ICanvasObjectGroup  [read-only]

Gets the ICanvasObjectGroup instance that will be used for installing node label styles.

If the field has not yet been initialized upon first access, the factory method createNodeLabelGroup will be called.


Implementation
    public function get nodeLabelGroup():ICanvasObjectGroup
nodeLabelInstallerproperty 
nodeLabelInstaller:LabelStyleInstaller  [read-only]

Gets the StyleInstaller instance used for installing an ILabel of an INode into the canvas.

If the field has not yet been initialized upon first access, the factory method createNodeLabelInstaller will be called.


Implementation
    public function get nodeLabelInstaller():LabelStyleInstaller
nodeManagerproperty 
nodeManager:CollectionModelManager  [read-only]


Implementation
    yworks_internal function get nodeManager():CollectionModelManager
nodeStyleInstallerproperty 
nodeStyleInstaller:NodeStyleInstaller  [read-only]

Gets the StyleInstaller instance used for installing an INode into the canvas.

If the field has not yet been initialized upon first access, the factory method createNodeStyleInstaller will be called.


Implementation
    public function get nodeStyleInstaller():NodeStyleInstaller
portGroupproperty 
portGroup:ICanvasObjectGroup  [read-only]

Gets the ICanvasObjectGroup instance that will be used for installing port styles.

If the field has not yet been initialized upon first access, the factory method createPortGroup will be called.


Implementation
    public function get portGroup():ICanvasObjectGroup
portStyleInstallerproperty 
portStyleInstaller:PortStyleInstaller  [read-only]

Factory method for the PortStyleInstaller property. This method will be called upon first access to the portStyleInstaller" property.


Implementation
    public function get portStyleInstaller():PortStyleInstaller
Constructor Detail
GraphModelManager()Constructor
public function GraphModelManager(canvas:CanvasComponent, contentGroup:ICanvasObjectGroup)

Creates a manager instance for the given control. The contents of the graph will be added to given group that is must be part of the canvas.

In order to get anything useful out of this instance the graph property should be set to an instance after construction.

Parameters
canvas:CanvasComponent — the canvas to manage the visual appearance of a graph for.
 
contentGroup:ICanvasObjectGroup — the group to add the graph's visual content to.
Method Detail
addShield()method
public function addShield():void

Adds a "shield" to each canvas object group. A shield is a (transparent) sprite which is laid over the display area.

Mouse Hovering over a Sprite with a large number of children seriously increases the Flash Player's CPU usage. When the mouse hovers over a child of that sprite, the CPU usage goes back to zero.

The "shield" ensures that the mouse is always hovering over a child sprite.

By default, the "shields" are already added to the canvas object groups

createEdgeCanvasGroupProvider()method 
protected function createEdgeCanvasGroupProvider():ICanvasGroupProvider

Creates an ICanvasGroupProvider instance that returns for each edge queried an ICanvasObjectGroup that will be provided to the EdgeStyleInstaller for each edge to be installed.

Returns
ICanvasGroupProvider — a constant provider that returns the edgeGroup
createEdgeGroup()method 
protected function createEdgeGroup():ICanvasObjectGroup

Factory method for the edgeGroup property. This method will be called upon first access to the edgeGroup property.

Returns
ICanvasObjectGroup — a new instance of ICanvasObjectGroup
createEdgeLabelCanvasGroupProvider()method 
protected function createEdgeLabelCanvasGroupProvider():ICanvasGroupProvider

Creates an ICanvasGroupProvider instance that returns for each edge label queried an ICanvasObjectGroup that will be provided to the edgeLabelInstaller for each edge label to be installed.

Returns
ICanvasGroupProvider — a constant provider that returns the edgeLabelGroup
createEdgeLabelGroup()method 
protected function createEdgeLabelGroup():ICanvasObjectGroup

Factory method for the edgeLabelGroup property. This method will be called upon first access to the edgeLabelGroup property.

Returns
ICanvasObjectGroup — a new instance of ICanvasObjectGroup
createEdgeLabelInstaller()method 
protected function createEdgeLabelInstaller():LabelStyleInstaller

Factory method for the edgeLabelinstaller property. This method will be called upon first access to the edgeLabelInstaller property.

Returns
LabelStyleInstaller — a new instance of LabelStyleInstaller
createEdgeStyleInstaller()method 
protected function createEdgeStyleInstaller():EdgeStyleInstaller

Factory method for the EdgeStyleInstaller property. This method will be called upon first access to the edgeStyleInstaller property.

Returns
EdgeStyleInstaller — A new instance of EdgeStyleInstaller
createNodeCanvasGroupProvider()method 
protected function createNodeCanvasGroupProvider():ICanvasGroupProvider

Creates an ICanvasGroupProvider instance that returns for each node queried an ICanvasObjectGroup that will be provided to the nodeStyleInstaller for each node to be installed.

Returns
ICanvasGroupProvider — a constant provider that returns the nodeGroup
createNodeGroup()method 
protected function createNodeGroup():ICanvasObjectGroup

Factory method for the nodeGroup property. This method will be called upon first access to the NodeGroup property.

Returns
ICanvasObjectGroup — a new instance of ICanvasObjectGroup
createNodeLabelCanvasGroupProvider()method 
protected function createNodeLabelCanvasGroupProvider():ICanvasGroupProvider

Creates an ICanvasGroupProvider instance that returns for each node label queried an ICanvasObjectGroup that will be provided to the NodeLabelInstaller for each node label to be installed.

Returns
ICanvasGroupProvider — a constant provider that returns the nodeLabelGroup
createNodeLabelGroup()method 
protected function createNodeLabelGroup():ICanvasObjectGroup

Factory method for the nodeLabelGroup property. This method will be called upon first access to the nodeLabelGroup property.

Returns
ICanvasObjectGroup — a new instance of ICanvasObjectGroup
createNodeLabelInstaller()method 
protected function createNodeLabelInstaller():LabelStyleInstaller

Factory method for the NodeLabelinstaller property. This method will be called upon first access to the nodeLabelInstaller property.

Returns
LabelStyleInstaller — a new instance of LabelStyleInstaller
createNodeStyleInstaller()method 
protected function createNodeStyleInstaller():NodeStyleInstaller

Factory method for the NodeStyleInstaller property. This method will be called upon first access to the nodeStyleInstaller property.

Returns
NodeStyleInstaller
createPortCanvasGroupProvider()method 
protected function createPortCanvasGroupProvider():ICanvasGroupProvider

Creates an ICanvasGroupProvider instance that returns for each port queried an ICanvasObjectGroup that will be provided to the portStyleInstaller for each port to be installed.

Returns
ICanvasGroupProvider — a constant provider that returns the portGroup
createPortGroup()method 
protected function createPortGroup():ICanvasObjectGroup

Factory method for the portGroup property. This method will be called upon first access to the portGroup property.

Returns
ICanvasObjectGroup — a new instance of ICanvasObjectGroup
createPortStyleInstaller()method 
protected function createPortStyleInstaller():PortStyleInstaller

Factory method for the portStyleInstaller property. This method will be called upon first access to the portStyleInstaller property.

Returns
PortStyleInstaller — A new instance of PortStyleInstaller
getCanvasObjectGroup()method 
protected function getCanvasObjectGroup(canvas:CanvasComponent, node:INode):ICanvasObjectGroup

Retrieves the Canvas Object group to use for the given node.

This implementation is called by the default instance that is assigned to createNodeCanvasGroupProvider

Parameters

canvas:CanvasComponent — The canvas to return the a group for.
 
node:INode — The node that will be installed in the canvas.

Returns
ICanvasObjectGroup — The group to use.

See also

getCanvasObjects()method 
public function getCanvasObjects(item:IModelItem):Array

Retrieves all canvas objects that have been registered for the given item or null.

Parameters

item:IModelItem — The item to retrieve the canvas objects for.

Returns
Array — An array of canvas object instances or null.
getEdgeCanvasObjectGroup()method 
public function getEdgeCanvasObjectGroup(canvas:CanvasComponent, edge:IEdge):ICanvasObjectGroup

Retrieves the Canvas Object group to use for the given edge.

This implementation is called by the default instance that is assigned to createEdgeCanvasGroupProvider()

Parameters

canvas:CanvasComponent — The canvas to return the a group for.
 
edge:IEdge — The edge that will be installed in the canvas.

Returns
ICanvasObjectGroup — The group to use.

See also

getMainCanvasObject()method 
public function getMainCanvasObject(item:IModelItem):ICanvasObject

Retrieves the main canvas object that has been registered for the given item or null.

This implementation treats the first element in the array of canvas objects installed into the canvas for the item as the main object.

Parameters

item:IModelItem — The item to retrieve "the" canvas object for.

Returns
ICanvasObject — A canvas object instance or null.
getModelItem()method 
public function getModelItem(canvasObject:ICanvasObject):IModelItem

Retrieves the corresponding IModelItem for the given canvas object.

Parameters

canvasObject:ICanvasObject

Returns
IModelItem
internal_getCanvasObjectGroup()method 
yworks_internal function internal_getCanvasObjectGroup(canvas:CanvasComponent, node:INode):ICanvasObjectGroup

Parameters

canvas:CanvasComponent
 
node:INode

Returns
ICanvasObjectGroup
iterateHits()method 
public function iterateHits(x:Number, y:Number, filter:Function = null):Iterator

Iterates hits on the canvas at a given world coordinate position. Only if the given filter function returns true for a hit ICanvasObject, it is included in the iterator.

The instance returned will enumerate hits in the order so that the topmost visual element will be reported first.

Parameters

x:Number — the x world coordinate to perform the hit test
 
y:Number — the y world coordinate to perform the hit test
 
filter:Function (default = null) — a filter function applied to the ICanvasObjects

Returns
Iterator — An iterator that will enumerate the hits at the given coordinates
removeShield()method 
public function removeShield():void

Removes the "shield" from the canvas object groups. A shield is a (transparent) sprite which is laid over the display area to work around Flash Player's performance issues.

If one uses UIComponets like buttons and set them, or the canvas object group they belong to, to the back, they may be hidden by the "shield", i.e. no longer acessible.

This method removes the "shield", so such components will be accessible.

See also