Packagecom.yworks.graph.model
Classpublic class GraphModelManager

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
  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
  hitTestIterator : IHitTestIterator
[read-only] Gets a IHitTestEnumerator that can be used to ietrate 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
  portGroup : ICanvasObjectGroup
[read-only] Gets the ICanvasObjectGroup instance that will be used for installing port styles.
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 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):Iterator
Iterates hits on the canvas at a given world coordinate position.
GraphModelManager
  
removeShield():void
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
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
edgeManagerproperty 
edgeManager:CollectionModelManager  [read-only]Implementation
    yworks_internal function get edgeManager():CollectionModelManager
hitTestIteratorproperty 
hitTestIterator:IHitTestIterator  [read-only]

Gets a IHitTestEnumerator that can be used to ietrate 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
nodeManagerproperty 
nodeManager:CollectionModelManager  [read-only]Implementation
    yworks_internal function get nodeManager():CollectionModelManager
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
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.
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):ICanvasObjectGroupParameters
canvas:CanvasComponent
 
node:INode

Returns
ICanvasObjectGroup
iterateHits()method 
public function iterateHits(x:Number, y:Number):Iterator

Iterates hits on the canvas at a given world coordinate position.

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

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