Package | com.adobe.flex.extras.controls.springgraph |
Class | public class SpringGraph |
Inheritance | SpringGraph mx.containers.Canvas |
Subclasses | Roamer |
The set of objects, and the links between them, is defined by this component's dataProvider property. For each Item in the dataProvider, there is a corresonding itemRenderer, which is any UIComponent that implements the IDataRenderer interface. You define these via the itemRenderer or viewFactory properties. Each itemRenderer's 'data' property is a reference to its corresponding Item.
SpringGraph does its drawing of lines and items inside the area that you define as the height and width of this component.
You can control what links look like, in 4 ways:
1. do nothing. The edges will draw in a default width and color
2. set 'lineColor'. The edges will draw with that color, in a default width.
3. use Graph.link() to add a data object to any particular link. If that data object contains a field called 'settings', then the value of 'settings' should be an object with fields 'color', 'thickness', and 'alpha'. For example:
var data: Object = {settings: {alpha: 0.5, color: 0, thickness: 2}};
g.link(fromItem, toItem, data);
4. define an EdgeRenderer (see 'edgeRenderer' below)
This component allows the user to click on items and drag them around.
This component was written by Mark Shepherd of Adobe Flex Builder Engineering. The force-directed layout algorithm was translated and adapted to ActionScript 3 from Java code written by Alexander Shapiro of TouchGraph, Inc. (http://www.touchgraph.com).
MXML Syntax Hide MXML SyntaxThe <SpringGraph>
tag inherits all the tag attributes of its superclass, and adds the following tag attributes:
<mx:SpringGraph Properties dataProvider="null" itemRenderer="null" lineColor="0xcccccc" replusionFactor="0.75" />
Property | Defined by | ||
---|---|---|---|
addItemEffect : Effect
An effect that applied to all itemRenderer instances when they are add to the spring graph.
|
SpringGraph | ||
autoFit : Boolean
[write-only] Enable/disable the auto-fit feature.
|
SpringGraph | ||
dataProvider : Object
Defines the data model for this springgraph.
|
SpringGraph | ||
edgeRenderer : IEdgeRenderer
[write-only] Defines an Edge Renderer object that we will use to render edges.
|
SpringGraph | ||
itemRenderer : IFactory
[write-only] Defines the UIComponent class for rendering an item.
|
SpringGraph | ||
lineColor : int
[write-only] The color we use to draw the lines that represent links between items.
|
SpringGraph | ||
motionThreshold : Number
[for experimental use].
|
SpringGraph | ||
removeItemEffect : Effect
An effect that is applied to all itemRenderer instances when they are removed from the spring graph.
|
SpringGraph | ||
repulsionFactor : Number
How strongly do items push each other away.
|
SpringGraph | ||
viewFactory : IViewFactory
[write-only] A factory that can create views for specific Items.
|
SpringGraph | ||
xmlNames : Array
[write-only]The XML element and attribute names to use when parsing an XML dataProvider.
|
SpringGraph |
Method | Defined by | ||
---|---|---|---|
SpringGraph | |||
empty():void
Throw away the dataProvider, leaving an empty graph.
|
SpringGraph | ||
refresh():void
Redraw everything.
|
SpringGraph |
addItemEffect | property |
public var addItemEffect:Effect
An effect that applied to all itemRenderer instances when they are add to the spring graph.
autoFit | property |
autoFit:Boolean
[write-only]
Enable/disable the auto-fit feature. When enabled, we automatically and continuously adjust the 'repulsionFactor' property, as well as scroll the viewing area of the roamer, so that the graph items are entirely contained within, and nicely spread out over the entire rectangle of this component. When disabled, we obey whatever value you set into the 'repulsionFactor' property, and scrolling must be done manually. When autoFit is enabled, you may still set repulsionFactor and scroll - the component will smoothly continue from wherever you left it.
Implementation public function set autoFit(value:Boolean):void
dataProvider | property |
dataProvider:Object
[read-write]
Defines the data model for this springgraph. The data is a set of items which can be linked to each other. You can provide the data as XML, or as a Graph object.
To use XML, provide an object of type XML with the following format:
When the dataProvider is set to XML, we automatically create a Graph that repesents the items and links in the XML data. Each itemRenderer's 'data' property is set to the Item object whose 'id' is the id of an XML Node, and whose 'data' property is the XML object representing the Node. You can use the xmlNames property to define the names that you have used in your XML data. The default XML names 'Node', 'Edge', 'fromID', and 'toID'.
The default value is null
.
public function get dataProvider():Object
public function set dataProvider(value:Object):void
edgeRenderer | property |
edgeRenderer:IEdgeRenderer
[write-only]
Defines an Edge Renderer object that we will use to render edges. If this is null, we use our built-in edge renderer.
Implementation public function set edgeRenderer(value:IEdgeRenderer):void
itemRenderer | property |
itemRenderer:IFactory
[write-only]
Defines the UIComponent class for rendering an item. One instance of this class will be created for each item contained in the "dataProvider" property. You should specify an itemRenderer if you want every type of Item to have the same kind of view. If you want different types of Items to have different views, use viewFactory instead.
The default value is null
.
public function set itemRenderer(value:IFactory):void
lineColor | property |
lineColor:int
[write-only]
The color we use to draw the lines that represent links between items.
The default value is 0xcccccc
.
public function set lineColor(value:int):void
motionThreshold | property |
public var motionThreshold:Number
[for experimental use]. The layout computations are stopped when the amount of motion falls below this threshold. I don't know what the units are, the range of meaningful values is from 0.001 to 2.0 or so. Low numbers mean that the layout takes longer to settle down, but gives a better result. High numbers means that the layout will stop sooner, but perhaps with not as nice a layout.
removeItemEffect | property |
public var removeItemEffect:Effect
An effect that is applied to all itemRenderer instances when they are removed from the spring graph.
repulsionFactor | property |
repulsionFactor:Number
[read-write]
How strongly do items push each other away.
The default value is 0.75
.
public function get repulsionFactor():Number
public function set repulsionFactor(value:Number):void
viewFactory | property |
viewFactory:IViewFactory
[write-only]
A factory that can create views for specific Items. This is an instance of a class (or component) that implements the IViewFactory interface. You should specify only one of itemRenderer or viewFactory.
Implementation public function set viewFactory(value:IViewFactory):void
xmlNames | property |
xmlNames:Array
[write-only]
The XML element and attribute names to use when parsing an XML dataProvider. The array must have 4 elements:
Implementation
public function set xmlNames(value:Array):void
SpringGraph | () | constructor |
public function SpringGraph()
empty | () | method |
public function empty():void
Throw away the dataProvider, leaving an empty graph.
refresh | () | method |
public function refresh():void
Redraw everything. Call this when you changed something that could affect the size of any of the active itemRenderers. There is no need to call this when the graph data is changed, we update automatically in that case.