Packageorg.un.flex.graphLayout.visual
Classpublic class VisualGraph
InheritanceVisualGraph Inheritance mx.containers.Canvas
ImplementsIVisualGraph

This component can visualize and layout a graph data structure in a Flex application. It is derived from canvas and thus behaves much like that in general. Currently the graphs are required to be connected. And for most layouts a root node is required (as they are tree based). A graph object needs to be specified as well as a layouter object that implements the ILayoutAlgorithm interface. XXX provide example code here



Public Properties
 PropertyDefined by
  addItemEffect : Effect
If set, this effect will be applied if a view is created (e.g.
VisualGraph
  center : Point
[read-only] Provide access to the center point of the VGraph's drawing surface, used by layouters to properly center their layout.
VisualGraph
  currentRootSID : String
[read-only] This was added for testing.
VisualGraph
  currentRootVNode : IVisualNode
Set or get the current root node (or focused node).
VisualGraph
  displayEdgeLabels : Boolean
Specify whether to display edge labels or not.
VisualGraph
  dragLockCenter : Boolean = false
This property controls whether the mouse cursor should be locked in the dragged node's center or not.
VisualGraph
  edgeLabelRenderer : IFactory
Allow to provide an EdgeLabelRenderer in order to display edge labels.
VisualGraph
  edgeRenderer : IEdgeRenderer
Allow the provision of an EdgeRenderer to allow drawing of edges in a customised way.
VisualGraph
  graph : IGraph
This property allows access and setting of the underlying graph object.
VisualGraph
  itemRenderer : IFactory
Access to a parameter Object to preset various settings for the drawing of Edges.
VisualGraph
  layouter : ILayoutAlgorithm
Access to the layouter to be used for the layout of the graph.
VisualGraph
  maxVisibleDistance : int
Limit the currently visible nodes to those in a limited distance (in terms of degrees of separation) from the current root node.
VisualGraph
  moveNodeInDrag : Boolean
[write-only]
VisualGraph
  newNodesDefaultVisible : Boolean = false
Default visibility setting for new nodes.
VisualGraph
  noVisibleVNodes : uint
[read-only] Returns the number of currently visible nodes.
VisualGraph
  origin : Point
[read-only] Provide access to the current origin of the of the Visual Graph which is required for proper drawing.
VisualGraph
  removeItemEffect : Effect
If set, this effect will be applied if a view is removed (e.g.
VisualGraph
  scale : Number
The scale property of VGraph will affect the scaleX and scaleY properties and also will ensure drag&drop works properly.
VisualGraph
  scrollBackgroundInDrag : Boolean
[write-only]
VisualGraph
  showHistory : Boolean
This property controls whether to show the history of root nodes (or focused nodes) or not.
VisualGraph
  visibilityLimitActive : Boolean
Specifies if any visibility limits should be active or not.
VisualGraph
  visibleEdges : Dictionary
[read-only] Provide access to a list of currently visible edges, i.e.
VisualGraph
  visibleVNodes : Dictionary
[read-only] Provide access to a list of currently visible VNodes.
VisualGraph
Public Methods
 MethodDefined by
  
The constructor just initialises most data structures, but not all required.
VisualGraph
  
Calculate and return the current bounding box of all visible nodes.
VisualGraph
  
clearHistory():void
Clears the current history of root nodes.
VisualGraph
  
createNode(sid:String = "", o:Object = null):IVisualNode
Create a new Node in this VisualGraph, this automatically creates an underlying Node in the Graph object.
VisualGraph
  
draw():void
Calling this forces a full calculation and redraw of the layout including all edges.
VisualGraph
  
This initialises a VGraph from a Graph object.
VisualGraph
  
Links two nodes, thus creating an edge.
VisualGraph
  
redrawEdges():void
Redraw all edges, this is called from the updateDisplayList() method.
VisualGraph
  
refresh():void
VisualGraph
  
Removes a node from this VisualGraph.
VisualGraph
  
scroll(deltaX:Number, deltaY:Number):void
Scrolls all objects according to the specified coordinates (used as an offset).
VisualGraph
  
Unlinks two nodes, thus removing the edge between them, if it exists.
VisualGraph
Protected Methods
 MethodDefined by
  
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
This calls the base updateDisplayList() method of the Canvas and in addition redraws all edges if the layouter indicates that the layout has changed.
VisualGraph
Events
 EventSummaryDefined by
   Dispatched when there is any change to the nodes and/or links of this graph.VisualGraph
Property detail
addItemEffectproperty
public var addItemEffect:Effect

If set, this effect will be applied if a view is created (e.g. while a node becomes visible or if a new node is created).

centerproperty 
center:Point  [read-only]

Provide access to the center point of the VGraph's drawing surface, used by layouters to properly center their layout.

Implementation
    public function get center():Point
currentRootSIDproperty 
currentRootSID:String  [read-only]

This was added for testing. It may be removed again.

Implementation
    public function get currentRootSID():String
currentRootVNodeproperty 
currentRootVNode:IVisualNode  [read-write]

Set or get the current root node (or focused node). Setting this property will result in a redraw of the graph to reflect the change (if it was actually a change).

This property can be used as the source for data binding.

Implementation
    public function get currentRootVNode():IVisualNode
    public function set currentRootVNode(value:IVisualNode):void
displayEdgeLabelsproperty 
displayEdgeLabels:Boolean  [read-write]

Specify whether to display edge labels or not. If no edge label renderer is present a default will be used.

Implementation
    public function get displayEdgeLabels():Boolean
    public function set displayEdgeLabels(value:Boolean):void
dragLockCenterproperty 
public var dragLockCenter:Boolean = false

This property controls whether the mouse cursor should be locked in the dragged node's center or not.

edgeLabelRendererproperty 
edgeLabelRenderer:IFactory  [read-write]

Allow to provide an EdgeLabelRenderer in order to display edge labels. The created instances must be UIComponents.

Implementation
    public function get edgeLabelRenderer():IFactory
    public function set edgeLabelRenderer(value:IFactory):void
edgeRendererproperty 
edgeRenderer:IEdgeRenderer  [read-write]

Allow the provision of an EdgeRenderer to allow drawing of edges in a customised way. The edgeRenderer has to implement the IEdgeRenderer interface.

Implementation
    public function get edgeRenderer():IEdgeRenderer
    public function set edgeRenderer(value:IEdgeRenderer):void
graphproperty 
graph:IGraph  [read-write]

This property allows access and setting of the underlying graph object. If set, it will automatically initialise the VGraph from the Graph object, i.e. create VNodes and VEdges for each Graph node and Graph edge. If there was already a Graph present, the VGraph is purged, but no other cleanup is done, which means that there could still be some references floating around thus leaking memory. For now, avoid setting it more than once in the same VGraph.

Implementation
    public function get graph():IGraph
    public function set graph(value:IGraph):void
itemRendererproperty 
itemRenderer:IFactory  [read-write]

Access to a parameter Object to preset various settings for the drawing of Edges. The Object is a hash with the following properties: "alpha" "thickness" "color" "distcolor" which are to be used by an Edge Renderer

Implementation
    public function get itemRenderer():IFactory
    public function set itemRenderer(value:IFactory):void
layouterproperty 
layouter:ILayoutAlgorithm  [read-write]

Access to the layouter to be used for the layout of the graph.

Implementation
    public function get layouter():ILayoutAlgorithm
    public function set layouter(value:ILayoutAlgorithm):void
maxVisibleDistanceproperty 
maxVisibleDistance:int  [read-write]

Limit the currently visible nodes to those in a limited distance (in terms of degrees of separation) from the current root node. If showHistory is enabled, the previous root nodes will be shown regardless of this limit.

This property can be used as the source for data binding.

Implementation
    public function get maxVisibleDistance():int
    public function set maxVisibleDistance(value:int):void
moveNodeInDragproperty 
moveNodeInDrag:Boolean  [write-only]Implementation
    public function set moveNodeInDrag(value:Boolean):void
newNodesDefaultVisibleproperty 
public var newNodesDefaultVisible:Boolean = false

Default visibility setting for new nodes. If set all new nodes are created visible and with a view component. Beware of that if you have many nodes.

noVisibleVNodesproperty 
noVisibleVNodes:uint  [read-only]

Returns the number of currently visible nodes.

Implementation
    public function get noVisibleVNodes():uint
originproperty 
origin:Point  [read-only]

Provide access to the current origin of the of the Visual Graph which is required for proper drawing.

Implementation
    public function get origin():Point
removeItemEffectproperty 
public var removeItemEffect:Effect

If set, this effect will be applied if a view is removed (e.g. a node becomes invisible or is removed).

scaleproperty 
scale:Number  [read-write]

The scale property of VGraph will affect the scaleX and scaleY properties and also will ensure drag&drop works properly.

Implementation
    public function get scale():Number
    public function set scale(value:Number):void
scrollBackgroundInDragproperty 
scrollBackgroundInDrag:Boolean  [write-only]Implementation
    public function set scrollBackgroundInDrag(value:Boolean):void
showHistoryproperty 
showHistory:Boolean  [read-write]

This property controls whether to show the history of root nodes (or focused nodes) or not. If enabled, these previous root nodes will be shown even though they are are now more degrees of separation away from the current root node than the limit allows. Also any intermediate node from a previous root node to the current root node will be shown to have a complete link and not a disconnected graph.

Implementation
    public function get showHistory():Boolean
    public function set showHistory(value:Boolean):void
visibilityLimitActiveproperty 
visibilityLimitActive:Boolean  [read-write]

Specifies if any visibility limits should be active or not. If not active, always all nodes are visible. If you have many nodes, this could have a severe impact on your performance so handle with care.

This property can be used as the source for data binding.

Implementation
    public function get visibilityLimitActive():Boolean
    public function set visibilityLimitActive(value:Boolean):void
visibleEdgesproperty 
visibleEdges:Dictionary  [read-only]

Provide access to a list of currently visible edges, i.e. edges whose both nodes are visible and thus need to be drawn. Likewise this can save a lot of CPU if the layouter only needs to consider the currently visible edges.

Implementation
    public function get visibleEdges():Dictionary
visibleVNodesproperty 
visibleVNodes:Dictionary  [read-only]

Provide access to a list of currently visible VNodes. This is very important for layouters, if we have many many nodes, but only a few of them are visible at a time. Layouters typically will only layout the currently visible nodes.

Implementation
    public function get visibleVNodes():Dictionary
Constructor detail
VisualGraph()constructor
public function VisualGraph()

The constructor just initialises most data structures, but not all required. Currently it does neither set a Graph object, nor a Layouter object. Reasonable defaults may be added as an option.

Method detail
calcNodesBoundingBox()method
public function calcNodesBoundingBox():Rectangle

Calculate and return the current bounding box of all visible nodes. This is required by some layouters.

Returns
Rectangle — The bounding box rectangle of all visible nodes.
clearHistory()method 
public function clearHistory():void

Clears the current history of root nodes.

createNode()method 
public function createNode(sid:String = "", o:Object = null):IVisualNode

Create a new Node in this VisualGraph, this automatically creates an underlying Node in the Graph object. It does not link the node to any other node, yet and it does not trigger a layout pass. The reason is that currently all layouters require a CONNECTED graph, since the new node would create a disconnected graph (since it is not linked, yet) this would break things.

Parameters
sid:String (default = "") — The string id of the new node.
 
o:Object (default = null) — The data object of this new node.

Returns
IVisualNode — The created VisualNode object.
draw()method 
public function draw():void

Calling this forces a full calculation and redraw of the layout including all edges.

initFromGraph()method 
public function initFromGraph():void

This initialises a VGraph from a Graph object. I.e. it crates a VNode for every Node found in the Graph and a VEdge for every Edge in the Graph. Careful, this currently does not check if the VGraph was already initialised and it does not purge anything. Things could break of used on an already initialized VGraph.

linkNodes()method 
public function linkNodes(v1:IVisualNode, v2:IVisualNode):IVisualEdge

Links two nodes, thus creating an edge. If the underlying Graph is directional, the order matters, not otherwise. If the nodes are already linked, simply returns the existing edge between them.

Parameters
v1:IVisualNode — The first node (from node) to link.
 
v2:IVisualNode — The second node (to node) to link.

Returns
IVisualEdge — The created VisualEdge.
redrawEdges()method 
public function redrawEdges():void

Redraw all edges, this is called from the updateDisplayList() method. This forces a redraw of all edges

refresh()method 
public function refresh():void

removeNode()method 
public function removeNode(vn:IVisualNode):void

Removes a node from this VisualGraph. This removes any associated VEdges and Edges with the node and of course the underlying Node from the Graph datastructure.

Parameters
vn:IVisualNode — The VisualNode to be removed.
scroll()method 
public function scroll(deltaX:Number, deltaY:Number):void

Scrolls all objects according to the specified coordinates (used as an offset).

Parameters
deltaX:Number
 
deltaY:Number
unlinkNodes()method 
public function unlinkNodes(v1:IVisualNode, v2:IVisualNode):void

Unlinks two nodes, thus removing the edge between them, if it exists. Does nothing if the nodes were not linked. Again, order matters of the graph is directional.

Parameters
v1:IVisualNode — The first node to unlink.
 
v2:IVisualNode — The second node to unlink.
updateDisplayList()method 
protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

This calls the base updateDisplayList() method of the Canvas and in addition redraws all edges if the layouter indicates that the layout has changed.

Parameters
unscaledWidth:Number
 
unscaledHeight:Number
Event detail
VGRAPH_CHANGEDevent 
Event object type: org.un.flex.utils.events.VGraphEvent

Dispatched when there is any change to the nodes and/or links of this graph.