Packageflare.vis.data
Classpublic class DataList
InheritanceDataList Inheritance flash.utils.Proxy
Implementsflash.events.IEventDispatcher

Data structure for a collection of DataSprite instances. Items contained in this list can be accessed using array notation ([]), iterated over using the for each construct, or can be processed by passing a visitor function to the visit method.

Data lists provide methods for sorting elements both in a one-time and persistent fashion, for setting the properties of contained items in a batch-processing style (see the setProperty and setProperties methods), and for computing and caching summary statistics of data variables (see the stats method.

Data lists also support listeners for add and remove events. These events are fired before the add or remove is executed. These data events can be canceled by calling preventDefault() on the DataEvent object, thereby preventing the add or remove from being performed. Using this mechanism, clients can add custom constraints on the contents of a data list by adding new listeners that monitor add and remove events and cancel them when desired.



Public Properties
 PropertyDefined by
  length : int
[read-only] The number of items contained in this list.
DataList
  list : Array
[read-only] The underlying array storing the list.
DataList
  name : String
[read-only] The name of this data list.
DataList
  sort : Sort
A standing sort criteria for items in the list.
DataList
Public Methods
 MethodDefined by
  
DataList(name:String)
Creates a new DataList instance.
DataList
  
Add a DataSprite to the list.
DataList
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
DataList
  
adjacencyMatrix(w:Function = null, mat:IMatrix = null):IMatrix
Creates a new adjacency matrix representing the connections between items in this DataList.
DataList
  
applyDefaults(o:Object):void
Applies the default values to an object.
DataList
  
clear():Boolean
Remove all DataSprites from this list.
DataList
  
Clears all default value settings for this list.
DataList
  
clearStats(field:String):void
Clears any cached stats for the given field.
DataList
  
contains(d:DataSprite):Boolean
Indicates if the given object is contained in this list.
DataList
  
dispatchEvent(event:Event):Boolean
DataList
  
distanceMatrix(d:Function, mat:IMatrix = null):IMatrix
Creates a new distance matrix based on a distance function.
DataList
  
hasEventListener(type:String):Boolean
DataList
  
remove(d:DataSprite):Boolean
Remove a data sprite from the list.
DataList
  
removeAt(idx:int):DataSprite
Remove a DataSprite from the list.
DataList
  
removeDefault(name:String):void
Removes a default value for newly created items.
DataList
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
DataList
  
setDefault(name:String, value:*):void
Sets a default property value for newly created items.
DataList
  
setDefaults(values:Object):void
Sets default values for newly created items.
DataList
  
setLater(vals:Object, filter:* = null):Function
A function generator that can be used to set properties at a later time.
DataList
  
setProperties(vals:Object, t:* = null, filter:* = null):Transitioner
Sets property values on all sprites in a given group.
DataList
  
setProperty(name:String, value:*, t:* = null, filter:* = null):Transitioner
Sets a property value on all items in the list.
DataList
  
sortBy(... args):void
Sort DataSprites according to their properties.
DataList
  
stats(field:String):Stats
Computes and caches statistics for a data field.
DataList
  
toDataArray():Array
Returns an array of data objects for each item in this data list.
DataList
  
visit(visitor:Function, filter:Boolean = null, reverse:* = false):Boolean
Iterates over the contents of the list, invoking a visitor function on each element of the list.
DataList
  
willTrigger(type:String):Boolean
DataList
Events
 EventSummaryDefined by
  
add
 DataList
    DataList
Property detail
lengthproperty
length:int  [read-only]

The number of items contained in this list.

Implementation
    public function get length():int
listproperty 
list:Array  [read-only]

The underlying array storing the list.

Implementation
    public function get list():Array
nameproperty 
name:String  [read-only]

The name of this data list.

Implementation
    public function get name():String
sortproperty 
sort:Sort  [read-write]

A standing sort criteria for items in the list.

Implementation
    public function get sort():Sort
    public function set sort(value:Sort):void
Constructor detail
DataList()constructor
public function DataList(name:String)

Creates a new DataList instance.

Parameters
name:String — indicates if this list should be publicly editable.
Method detail
add()method
public function add(d:DataSprite):DataSprite

Add a DataSprite to the list.

Parameters
d:DataSprite — the DataSprite to add

Returns
DataSprite — the added DataSprite, or null if the add failed
addEventListener()method 
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
adjacencyMatrix()method 
public function adjacencyMatrix(w:Function = null, mat:IMatrix = null):IMatrix

Creates a new adjacency matrix representing the connections between items in this DataList. This method should only be applied when the items contained in this list are NodeSprite instances. The method takes an optional function to compute edge weights.

Parameters
w:Function (default = null) — the edge weight function. This function should take an EdgeSprite as input and return a Number.
 
mat:IMatrix (default = null) — a matrix instance in which to store the adjacency matrix values. If this value is null, a new DenseMatrix will be constructed.

Returns
IMatrix — the adjacency matrix
applyDefaults()method 
public function applyDefaults(o:Object):void

Applies the default values to an object.

Parameters
o:Object — the object on which to set the default values
clear()method 
public function clear():Boolean

Remove all DataSprites from this list.

Returns
Boolean
clearDefaults()method 
public function clearDefaults():void

Clears all default value settings for this list.

clearStats()method 
public function clearStats(field:String):void

Clears any cached stats for the given field.

Parameters
field:String — the data field to clear the stats for.
contains()method 
public function contains(d:DataSprite):Boolean

Indicates if the given object is contained in this list.

Parameters
d:DataSprite — the object to check for containment

Returns
Boolean — true if the list contains the object, false otherwise.
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Parameters
event:Event

Returns
Boolean
distanceMatrix()method 
public function distanceMatrix(d:Function, mat:IMatrix = null):IMatrix

Creates a new distance matrix based on a distance function.

Parameters
d:Function — the distance function. This should take two DataSprite instances and return a Number
 
mat:IMatrix (default = null) — a matrix instance in which to store the adjacency matrix values. If this value is null, a new DenseMatrix will be constructed.

Returns
IMatrix — the distance matrix
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Parameters
type:String

Returns
Boolean
remove()method 
public function remove(d:DataSprite):Boolean

Remove a data sprite from the list.

Parameters
d:DataSprite — the DataSprite to remove

Returns
Boolean — true if the object was found and removed, false otherwise
removeAt()method 
public function removeAt(idx:int):DataSprite

Remove a DataSprite from the list.

Parameters
idx:int — the index of the DataSprite to remove

Returns
DataSprite — the removed DataSprite
removeDefault()method 
public function removeDefault(name:String):void

Removes a default value for newly created items.

Parameters
name:String — the name of the property
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
setDefault()method 
public function setDefault(name:String, value:*):void

Sets a default property value for newly created items.

Parameters
name:String — the name of the property
 
value:* — the value of the property
setDefaults()method 
public function setDefaults(values:Object):void

Sets default values for newly created items.

Parameters
values:Object — the default properties to set
setLater()method 
public function setLater(vals:Object, filter:* = null):Function

A function generator that can be used to set properties at a later time. This method returns a function that can accept a Transitioner as its sole argument and then executes the setProperties method.

Parameters
vals:Object — an object containing the properties and values to set. This is treated the same as the setProperties method.
 
filter:* (default = null) — an optional Boolean-valued filter function for limiting which items are visited

Returns
Function — a function that accepts a Transitioner argument and runs setProperties.
setProperties()method 
public function setProperties(vals:Object, t:* = null, filter:* = null):Transitioner

Sets property values on all sprites in a given group. The values within the vals argument can take a number of forms:

Parameters
vals:Object — an object containing the properties and values to set.
 
t:* (default = null) — a transitioner or time span for updating object values. If the input is a transitioner, it will be used to store the updated values. If the input is a number, a new Transitioner with duration set to the input value will be used. The input is null by default, in which case object values are updated immediately.
 
filter:* (default = null) — an optional Boolean-valued filter function for limiting which items are visited

Returns
Transitioner — the transitioner used to update the values
setProperty()method 
public function setProperty(name:String, value:*, t:* = null, filter:* = null):Transitioner

Sets a property value on all items in the list. The value can take a number of forms:

Parameters
name:String — the name of the property
 
value:* — the value of the property
 
t:* (default = null) — a transitioner or time span for updating object values. If the input is a transitioner, it will be used to store the updated values. If the input is a number, a new Transitioner with duration set to the input value will be used. The input is null by default, in which case object values are updated immediately.
 
filter:* (default = null) — an optional Boolean-valued filter function for limiting which items are visited

Returns
Transitioner — the transitioner used to update the values
sortBy()method 
public function sortBy(... args):void

Sort DataSprites according to their properties. This method performs a one-time sorting. To establish a consistent sort order robust over the addition of new items, use the sort property.

Parameters
... args — the sort arguments. If a String is provided, the data will be sorted in ascending order according to the data field named by the string. If an Array is provided, the data will be sorted according to the fields in the array. In addition, field names can optionally be followed by a boolean value. If true, the data is sorted in ascending order (the default). If false, the data is sorted in descending order.
stats()method 
public function stats(field:String):Stats

Computes and caches statistics for a data field. The resulting Stats object is cached, so that later access does not require any re-calculation. The cache of statistics objects may be cleared, however, if changes to the data set are made.

Parameters
field:String — the property name

Returns
Stats — a Stats object with the computed statistics
toDataArray()method 
public function toDataArray():Array

Returns an array of data objects for each item in this data list. Data objects are retrieved from the "data" property for each item.

Returns
Array — an array of data objects for items in this data list
visit()method 
public function visit(visitor:Function, filter:Boolean = null, reverse:* = false):Boolean

Iterates over the contents of the list, invoking a visitor function on each element of the list. If the visitor function returns a Boolean true value, the iteration will stop with an early exit.

Parameters
visitor:Function — the visitor function to be invoked on each item
 
filter:Boolean (default = null) — an optional boolean-valued function indicating which items should be visited
 
reverse:* (default = false) — optional flag indicating if the list should be visited in reverse order

Returns
Boolean — true if the visitation was interrupted with an early exit
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters
type:String

Returns
Boolean
Event detail
addevent 
Event object type: flare.vis.events.DataEvent

removeevent  
Event object type: flare.vis.events.DataEvent