com.sas.models
Class ColorList

com.sas.models.ColorList
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, CollectionInterface, com.sas.collection.ContentsChangedSource, OrderedCollectionInterface, Sortable, StaticCollectionInterface, StaticOrderedCollectionInterface, ComponentInterface, com.sas.DeepClonable, LinkPropertiesInterface, ModelInterface, NodeInterface, SimpleNodeInterface, TreeInterface, com.sas.PublicClonable, com.sas.util.Countable, com.sas.util.Enumerable, com.sas.util.EventGateInterface, IndexedGetInterface, IndexedSetInterface, ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
DefaultColorList

public class ColorList
implements TreeInterface, NodeInterface, com.sas.PublicClonable

A base class that creates an empty ordered collection. A java.awt.color objects can be added to this collection. This Collection has an association list which maintains a key value pair. The keys are java.awt.SystemColor or com.sas.awt.Color objects and values are its name.

Creating a ColorList Component

ColorList = new ColorList();

Usage

The ColorList is an empty list which can be dropped on any visual component that supports OrderedCollection Interface like ListBox, ComboBox

See Also:
ColorNameList, Serialized Form

Field Summary
protected static java.lang.String COLORNOTFOUNDERROR
           
protected  java.lang.String NodeName
           
protected  java.lang.String NodeType
           
 
Fields inherited from class com.sas.collection.BaseCollection
allContentsChangedListeners, mappingObject
 
Constructor Summary
ColorList()
          The default constructor which creates an empty list.
ColorList(ColorNameList cnl)
          A constructor that takes the ColorNameList and initializes this list with it.
ColorList(java.util.Enumeration e)
          A constructor that takes enumeration of java.awt.SystemColor or com.sas.awt.Color objects and creates a list.
 
Method Summary
 void add(java.lang.Object c, int index)
          Overridden to call convertObject(Object) first on the item to add to the ColorList.
 void addItems(java.util.Enumeration items, int index)
          Overridden to call convertObject(Object) first on all items in the Enumeration.
 void append(int index, java.lang.Object item)
          Overridden to call convertObject(Object) first on the item to append to the ColorList.
 java.lang.Object clone()
          Create a copy of the current model
protected  java.lang.Object convertObject(java.lang.Object c)
          Convert the specified object to a valid object to add to the ColorList.
 int countNodeChildren(int maximumChildCount)
          Counts the children of the current node. countNodeChildren differs from getNodeChildCount when the number of children is not readily known.
 java.awt.Color getColor(int rgb)
          Return the Color corresponding to the rgb value provided.
 java.awt.Color getColor(java.lang.String colorName)
          Return the Color corresponding to the name provided.
 java.util.Enumeration getColors()
          Returns an enumeration of com.sas.awt.Color or java.awt.SystemColor objects.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 SimpleNodeInterface getNodeChild(int index)
          Returns the child node at the specified index.
 int getNodeChildCount()
          Returns the number of children available.
 SimpleNodeInterface[] getNodeChildren(int startIndex, int count)
          Returns the specified range of children for the current node.
 java.lang.String getNodeExpandedText()
          Returns the value of the nodeExpandedText property.
 java.lang.String getNodeText()
          Returns the value of the nodeText property.
 java.lang.String getNodeType()
          Returns the value of the nodeType property.
 NodeInterface getRoot()
          Gets the root for the tree implementation of the list
 boolean isLeafNode()
          Indicates whether the current node is a leaf.
 void set(int index, java.lang.Object item)
          Overridden to call convertObject(Object) first on the item to set on the ColorList.
protected  void setList(ColorNameList cnl)
          Gets the color objects from the colorNameList(associationlist with keys as com.sas.awt.Color or java.awt.SystemColor objects and names as values) and adds it to the collection
 
Methods inherited from class com.sas.collection.OrderedCollection
add, addItems, apply, clone, computeNewCapacity, contains, count, dumpComponent, equals, equals, get, getIndex, getItems, getItems, getLastIndex, moveHole, moveHoleEnsureCapacity, remove, removeAll, removeAll, removeAt, setSize, sort, sort, sort, sort, toArray, toArray, toString
 
Methods inherited from class com.sas.collection.BaseCollection
addContentsChangedListener, anyContentsChangedListeners, disableEvents, enableEvents, enableEvents, fireContentsChanged, map, removeContentsChangedListener, unmap
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, detachModel, detachView, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from interface com.sas.collection.ContentsChangedSource
addContentsChangedListener, removeContentsChangedListener
 
Methods inherited from interface com.sas.beans.PropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

NodeName

protected java.lang.String NodeName

NodeType

protected java.lang.String NodeType

COLORNOTFOUNDERROR

protected static java.lang.String COLORNOTFOUNDERROR
Constructor Detail

ColorList

public ColorList(ColorNameList cnl)
A constructor that takes the ColorNameList and initializes this list with it.

Parameters:
cnl - an associationlist with com.sas.awt.Color and java.awt.SystemColor objects as keys and names as values

ColorList

public ColorList()
The default constructor which creates an empty list.


ColorList

public ColorList(java.util.Enumeration e)
A constructor that takes enumeration of java.awt.SystemColor or com.sas.awt.Color objects and creates a list. A com.sas.awt.Color object is created for each java.awt.Color object. If the enumeration is empty, an empty list is created. If the enumeration does not contain java.awt.Colors or com.sas.awt.Colors then creates an empty list.

Parameters:
Enumeration - of java.awt.Color objects
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

setList

protected void setList(ColorNameList cnl)
Gets the color objects from the colorNameList(associationlist with keys as com.sas.awt.Color or java.awt.SystemColor objects and names as values) and adds it to the collection


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a copy of the current model

Specified by:
clone in interface CollectionInterface
Specified by:
clone in interface OrderedCollectionInterface
Specified by:
clone in interface StaticCollectionInterface
Specified by:
clone in interface StaticOrderedCollectionInterface
Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class OrderedCollection
Returns:
a clone of this collection.
Throws:
java.lang.CloneNotSupportedException - if the clone fails.

getRoot

public NodeInterface getRoot()
Gets the root for the tree implementation of the list

Specified by:
getRoot in interface TreeInterface
Returns:
this object as a root

getColor

public java.awt.Color getColor(java.lang.String colorName)
Return the Color corresponding to the name provided.

Parameters:
colorName - a String corresponding to a key in the hashtable. The String must be one of the keys in this list.
Returns:
Color The java.awt.Color associated with colorName.
Throws:
java.util.NoSuchElementException - when there is no matching name in this list.

getColor

public java.awt.Color getColor(int rgb)
Return the Color corresponding to the rgb value provided.

Parameters:
rgb - an integer corresponding to an item in the hashtable. If more than one item exists, the first one is returned. The rgb value must be one of the items in the hashtable.
Returns:
Color The java.awt.Color associated with colorName.
Throws:
java.util.NoSuchElementException - when there is no matching color object in this list.

getColors

public java.util.Enumeration getColors()
Returns an enumeration of com.sas.awt.Color or java.awt.SystemColor objects.

Returns:
enumeration of com.sas.awt.Color or java.awt.SystemColor objects (subclasses of java.awt.Color).

convertObject

protected java.lang.Object convertObject(java.lang.Object c)
Convert the specified object to a valid object to add to the ColorList. If the object cannot be converted a ClassCastException is thrown.

Parameters:
c - the object to convert to a com.sas.awt.Color
Returns:
the converted com.sas.awt.Color object

add

public void add(java.lang.Object c,
                int index)
Overridden to call convertObject(Object) first on the item to add to the ColorList.

Specified by:
add in interface OrderedCollectionInterface
Overrides:
add in class OrderedCollection
Parameters:
c - the item to add to this collection. The item may exist multiple times in this collection.
index - insert the object before the indexed item. The newly inserted item can be accessed by get(index) afterwards.
See Also:
convertObject(java.lang.Object)

addItems

public void addItems(java.util.Enumeration items,
                     int index)
Overridden to call convertObject(Object) first on all items in the Enumeration.

Specified by:
addItems in interface OrderedCollectionInterface
Overrides:
addItems in class OrderedCollection
Parameters:
items - an Enumeration of items to add to this collection
index - insert the objects starting before the indexed item. The first of the newly inserted item can be accessed by get(index) afterwards.
See Also:
convertObject(java.lang.Object)

set

public void set(int index,
                java.lang.Object item)
Overridden to call convertObject(Object) first on the item to set on the ColorList.

Specified by:
set in interface OrderedCollectionInterface
Specified by:
set in interface IndexedSetInterface
Overrides:
set in class OrderedCollection
Parameters:
index - The position where the Object will be placed.
item - The Object to be added to this ordered collection.
See Also:
convertObject(java.lang.Object)

append

public void append(int index,
                   java.lang.Object item)
Overridden to call convertObject(Object) first on the item to append to the ColorList.

Overrides:
append in class OrderedCollection
Parameters:
index - The position where the object will be placed. If necessary, this collection is extended to accommodate the item.
item - the object to be added to this ordered collection.
See Also:
convertObject(java.lang.Object)

getNodeExpandedText

public java.lang.String getNodeExpandedText()
Returns the value of the nodeExpandedText property. The expanded text is usually a more descriptive version of the nodeText property. In this case it is the same as the nodeText property

Specified by:
getNodeExpandedText in interface NodeInterface
Returns:
the name of this node

getNodeText

public java.lang.String getNodeText()
Returns the value of the nodeText property.

Specified by:
getNodeText in interface NodeInterface
Returns:
the name of this node

getNodeType

public java.lang.String getNodeType()
Returns the value of the nodeType property. The type can be used for categorizing nodes.

Specified by:
getNodeType in interface NodeInterface
Returns:
the nodeType property

countNodeChildren

public int countNodeChildren(int maximumChildCount)
Counts the children of the current node. countNodeChildren differs from getNodeChildCount when the number of children is not readily known. In such a case, getNodeChildCount will simply return -1 to indicate that the count is unknown, while countNodeChildren will actually compute the answer; thus countNodeChildren is a potentially expensive operation. To limit this potential overhead, a maximum child count may be passed to this method, such that the implementation will not read more than that many children. If exactly the number of children specified as the maximum count to read exists under the current node then a value equal in magnitude but opposite in sign (-maximumChildCount) should be returned.

Specified by:
countNodeChildren in interface SimpleNodeInterface
Parameters:
maximumChildCount - the maximum number of children to read, or 0 to read indefinitely
Returns:
The number of children known to be available.

getNodeChildCount

public int getNodeChildCount()
Returns the number of children available. If the number of children is unknown, -1 should be returned.

Specified by:
getNodeChildCount in interface SimpleNodeInterface
Returns:
the number of children or -1 if unknown

isLeafNode

public boolean isLeafNode()
Indicates whether the current node is a leaf. A true value indicates that the current node is a leaf and hence will not have any children.

Specified by:
isLeafNode in interface SimpleNodeInterface
Returns:
true if the current node is a leaf, otherwise false

getNodeChild

public SimpleNodeInterface getNodeChild(int index)
Returns the child node at the specified index. This method converts java.awt.Systemcolor to com.sas.awt.Color object.

Specified by:
getNodeChild in interface SimpleNodeInterface
Parameters:
index - the 0-based index of the child node to retrieve
Returns:
the child at index or null if the leafNode property value is true.

getNodeChildren

public SimpleNodeInterface[] getNodeChildren(int startIndex,
                                             int count)
Returns the specified range of children for the current node. If there are less children than are queried for, an implementation can return an array whose size if representative of the actual number of children being returned or an array whose size is the same as the number of children asked for. If the resulting array's size is the same as the number asked for and there are fewer children returned than asked for the implementation should assign the unused values in the array to null.

Specified by:
getNodeChildren in interface SimpleNodeInterface
Parameters:
startIndex - 0-based index which identifies the start of the range
count - the amount of children to get
Returns:
an array containing the specified range of children or null if the leafNode property value is true.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.