Packagecom.yworks.canvas.model
Classpublic class DefaultCollectionModel
InheritanceDefaultCollectionModel Inheritance com.yworks.support.EventDispatchingProxy
Implements ICollectionModel

A simple default implementation of an ICollectionModel that is backed by an ordinary Collection.

This class also lets you use [ ] array notation to access the getItemAt() method. Writing is not supported.

The for each..in loop is also supported.



Public Methods
 MethodDefined By
  
Creates a new instance using a provided collection as the backing store.
DefaultCollectionModel
  
addAll(iter:Iterable):void
Adds all of the elements in the specified collection to this collection (optional operation).
DefaultCollectionModel
  
addItem(item:Object):Boolean
Adds the specified item to this collection.
DefaultCollectionModel
  
clear():void
Removes all of the elements from this collection.
DefaultCollectionModel
  
contains(item:Object):Boolean
Returns true if this collection contains the specified element.
DefaultCollectionModel
  
getItemAt(index:int):Object
Returns the element at the specified position in this collection.
DefaultCollectionModel
  
isEmpty():Boolean
Returns true if this collection contains no elements.
DefaultCollectionModel
  
Returns an iterator over a set of elements.
DefaultCollectionModel
  
length():uint
Returns the number of elements in this collection.
DefaultCollectionModel
  
onItemAdded(item:Object):void
Callback method that will trigger the collectionChange event.
DefaultCollectionModel
  
onItemChanged(item:Object):void
Callback method that will trigger the collectionChange event.
DefaultCollectionModel
  
onItemRemoved(item:Object):void
Callback method that will trigger the collectionChange event.
DefaultCollectionModel
  
removeItem(item:Object):Boolean
Removes a single instance of the specified element from this collection, if it is present (optional operation).
DefaultCollectionModel
  
toArray():Array
Returns an array containing all of the elements in this collection.
DefaultCollectionModel
Events
 Event Summary Defined By
  Dispatched when an item has been added, removed or changed.DefaultCollectionModel
Constructor Detail
DefaultCollectionModel()Constructor
public function DefaultCollectionModel(items:Collection = null)

Creates a new instance using a provided collection as the backing store.

Creates a new collection if none is provides.

Parameters
items:Collection (default = null) — The collection to use.
Method Detail
addAll()method
public function addAll(iter:Iterable):void

Adds all of the elements in the specified collection to this collection (optional operation).

Parameters

iter:Iterable — the collection containing elements to be added to this collection

addItem()method 
public function addItem(item:Object):Boolean

Adds the specified item to this collection. Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Parameters

item:Object — element whose presence in this collection is to be ensured

Returns
Boolean — true if this collection changed as a result of the call
clear()method 
public function clear():void

Removes all of the elements from this collection. The collection will be empty after this method returns.

contains()method 
public function contains(item:Object):Boolean

Returns true if this collection contains the specified element.

Parameters

item:Object — element whose presence in this collection is to be tested

Returns
Boolean — true if this collection contains the specified element
getItemAt()method 
public function getItemAt(index:int):Object

Returns the element at the specified position in this collection.

Parameters

index:int — the index of the element to return

Returns
Object — the element at the specified position in this list
isEmpty()method 
public function isEmpty():Boolean

Returns true if this collection contains no elements.

Returns
Boolean — true if this collection contains no elements
iterator()method 
public function iterator():Iterator

Returns an iterator over a set of elements.

Returns
Iterator — an Iterator.
length()method 
public function length():uint

Returns the number of elements in this collection.

Returns
uint — the number of elements in this collection
onItemAdded()method 
public function onItemAdded(item:Object):void

Callback method that will trigger the collectionChange event.

Parameters

item:Object — The item that has just been added to the collection.

onItemChanged()method 
public function onItemChanged(item:Object):void

Callback method that will trigger the collectionChange event.

Parameters

item:Object — The item that has just been changed.

onItemRemoved()method 
public function onItemRemoved(item:Object):void

Callback method that will trigger the collectionChange event.

Parameters

item:Object — The item that has just been removed from the collection.

removeItem()method 
public function removeItem(item:Object):Boolean

Removes a single instance of the specified element from this collection, if it is present (optional operation).

Parameters

item:Object — element to be removed from this collection, if present

Returns
Boolean — true if an element was removed as a result of this call
toArray()method 
public function toArray():Array

Returns an array containing all of the elements in this collection.

Returns
Array — an array containing all of the elements in this collection
Event Detail
collectionChange Event
Event Object Type: mx.event.CollectionEvent
CollectionEvent.type property = mx.event.CollectionEvent.COLLECTION_CHANGE

Dispatched when an item has been added, removed or changed.