com.sas.awt
Class Color

com.sas.awt.Color
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.models.NodeIconInterface, com.sas.models.NodeInterface, com.sas.models.SimpleNodeInterface, com.sas.PublicClonable, com.sas.ViewInterface, com.sas.visuals.IconInterface, com.sas.visuals.PainterInterface, java.awt.Paint, java.awt.Transparency, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class Color
implements com.sas.PublicClonable, com.sas.models.NodeIconInterface, com.sas.visuals.IconInterface

A class representing Color. It has a default colorList that stores the name and RGB value pairs for the java defined colors. User can create a color object by specifying a name and its RGB value - this will be stored in the colorList for lookup at later time. eg. new Color("myColor", 0x808000)

See Also:
RGBList, Serialized Form

Field Summary
static Color control
           
static Color controlHighlight
           
static Color controlShadow
           
static Color controlText
           
protected  java.lang.String name
          name of this color
protected static java.lang.String NODETYPE
          Node type color
static Color windowBorder
           
 
Constructor Summary
Color()
          Default constructor
Color(java.awt.Color jc)
          Deprecated. use newColor(java.awt.Color)
Color(int hexValue)
          A constructor that takes a RGB value and creates a color object.
Color(int r, int g, int b)
          A constructor that takes three integers and creates a com.sas.awt.Color object.
Color(java.lang.String name)
          A constructor that takes a String and creates a new color object.
Color(java.lang.String name, int hexValue)
          A constructor that takes a String and a RGB value and puts it in the list and creates a color object.
 
Method Summary
static void addColor(java.lang.String name, int hexValue)
          Add a color and corresponding RGB value to the list.
 java.lang.Object clone()
          Clones the component
 int countNodeChildren(int maximumChildCount)
          Always returns 0
 boolean equals(java.lang.Object color)
          Compares this object against the specified object.
 com.sas.visuals.IconInterface getDefaultIcon()
          Returns the default icon for the current node.
 com.sas.visuals.IconInterface getExpandedIcon()
          Returns the expanded icon for the current node.
 com.sas.visuals.IconInterface getExpandedSelectedIcon()
          Sets the expandedSelected icon for the current node.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns the ExtendedBeanInfo for this class.
 java.awt.Insets getInsets()
          Get the insets of the current color.
 java.lang.String getName()
          Gets the name of this color object
 com.sas.models.SimpleNodeInterface getNodeChild(int index)
          Returns the child node at the specified index.
 int getNodeChildCount()
          Returns the number of children available.
 com.sas.models.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.
 java.awt.Dimension getPreferredSize()
          Return the preferredSize of the area to be painted.
 int getRGB()
          Gets the RGB value of this color component.
 com.sas.visuals.IconInterface getSelectedIcon()
          Returns the selected icon for the current node.
 boolean isHexString()
          Returns true if the name of this color object is a hexString
 boolean isLeafNode()
          Indicates whether the current node is a leaf.
static void merge(com.sas.models.RGBList rgbList)
          Merge the new list with the current list.
static Color newColor(java.awt.Color jcolor)
          Return the com.sas.awt.Color Object corresponding to the java.awt.color object passed in.
static Color newColor(int rgb)
          Return the Color Object corresponding to the rgb value from the list.
static Color newColor(java.lang.String colorName)
          Return the com.sas.awt.Color Object corresponding to the name provided.
 void paint(java.awt.Component component, java.awt.Graphics g, int x, int y, int width, int height)
          Paint the current color in the specified bounds.
static void removeAll()
          Removes all the items from the colorlist
 java.lang.String toString()
          Gets the string representation of this color object.
 
Methods inherited from class com.sas.awt.ColorComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, 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
 

Field Detail

windowBorder

public static Color windowBorder

controlHighlight

public static Color controlHighlight

controlShadow

public static Color controlShadow

control

public static Color control

controlText

public static Color controlText

name

protected java.lang.String name
name of this color


NODETYPE

protected static java.lang.String NODETYPE
Node type color

Constructor Detail

Color

public Color()
Default constructor


Color

public Color(java.lang.String name)
A constructor that takes a String and creates a new color object. If the String is a valid name, a color Object is created, otherwise an illegalArgumentException is thrown A valid name is -any name defined by java.awt.color object as constants -a color name added using Color.addColor(name, int) -valid hex number

Parameters:
color - name

Color

public Color(int hexValue)
A constructor that takes a RGB value and creates a color object.

Parameters:
hexValue - RGB in hexadecimal form.

Color

public Color(java.lang.String name,
             int hexValue)
A constructor that takes a String and a RGB value and puts it in the list and creates a color object.

Parameters:
name - of the color
RGB - value corresponding to the name of the color.

Color

public Color(int r,
             int g,
             int b)
A constructor that takes three integers and creates a com.sas.awt.Color object. The parameters should be in the range 0-255.

Parameters:
r - red component of the color
g - green component of the color
b - blue component of the color

Color

public Color(java.awt.Color jc)
Deprecated. use newColor(java.awt.Color)

A constructor that takes three integers and creates a com.sas.awt.Color object. The parameters should be in the range 0-255.

Parameters:
r - red component of the color
g - green component of the color
b - blue component of the color
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns the ExtendedBeanInfo for this class.

Returns:
ExtendedBeanInfo for this class

addColor

public static void addColor(java.lang.String name,
                            int hexValue)
Add a color and corresponding RGB value to the list.

Parameters:
name - Name of the color to be added.
hexValue - int referring to RGB value of the color

newColor

public static Color newColor(java.awt.Color jcolor)
Return the com.sas.awt.Color Object corresponding to the java.awt.color object passed in.

Parameters:
jcolor - a java.awt.Color object.
Returns:
com.sas.awt.Color object for the java.awt.Color passed.

newColor

public static Color newColor(java.lang.String colorName)
Return the com.sas.awt.Color Object corresponding to the name provided.

Parameters:
colorName - a String specifying the color name.
Returns:
the Color associated with colorName

newColor

public static Color newColor(int rgb)
Return the Color Object corresponding to the rgb value from the list.

Parameters:
rgb - an integer representing the hex value of a color
Returns:
com.sas.awt.Color corresponding to the rgb value passed in. Creates a new Color if not in the list.

merge

public static void merge(com.sas.models.RGBList rgbList)
Merge the new list with the current list.

Parameters:
rgbList - to merge with this list

removeAll

public static void removeAll()
Removes all the items from the colorlist


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the component

Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class ColorComponent
Returns:
new instance of the Color
Throws:
java.lang.CloneNotSupportedException - if the model attached to the component being cloned will not allow the clone to attach.

equals

public boolean equals(java.lang.Object color)
Compares this object against the specified object. In order to compare the "current" RGB value of this com.sas.awt.Color object with a java.awt.Color object, getRGB() should be used rather than equals().

Overrides:
equals in class java.awt.Color
Parameters:
obj - the object to compare with.
Returns:
true if the objects are the same; false otherwise.

getName

public java.lang.String getName()
Gets the name of this color object

Returns:
string specifying the name of this color object.

getRGB

public int getRGB()
Gets the RGB value of this color component.

Overrides:
getRGB in class java.awt.Color
Returns:
int rgb value

isHexString

public boolean isHexString()
Returns true if the name of this color object is a hexString

Returns:
true if the name is a hex string.

toString

public java.lang.String toString()
Gets the string representation of this color object. It is an alias to method getName()

Overrides:
toString in class java.awt.Color
Returns:
String representation of this color 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. For example, a node that represents a file can return the file name for the nodeText property and the full path name for the nodeExpandedText property.

Specified by:
getNodeExpandedText in interface com.sas.models.NodeInterface
Returns:
the name of this Color object.

getNodeText

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

Specified by:
getNodeText in interface com.sas.models.NodeInterface
Returns:
the name of this Color object

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 com.sas.models.NodeInterface
Returns:
the type 'color'

countNodeChildren

public int countNodeChildren(int maximumChildCount)
Always returns 0

Specified by:
countNodeChildren in interface com.sas.models.SimpleNodeInterface
Returns:
The number of children known to be available.
See Also:
NodeIconInterface

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 com.sas.models.SimpleNodeInterface
Returns:
always zero

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 com.sas.models.SimpleNodeInterface
Returns:
always true

getNodeChild

public com.sas.models.SimpleNodeInterface getNodeChild(int index)
Returns the child node at the specified index.

Specified by:
getNodeChild in interface com.sas.models.SimpleNodeInterface
Parameters:
index - the 0-based index of the child node to retrieve
Returns:
null

getNodeChildren

public com.sas.models.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 com.sas.models.SimpleNodeInterface
Parameters:
startIndex - 0-based index which identifies the start of the range
count - the amount of children to get
Returns:
null always

getDefaultIcon

public com.sas.visuals.IconInterface getDefaultIcon()
Returns the default icon for the current node.

Specified by:
getDefaultIcon in interface com.sas.models.NodeIconInterface
Returns:
Current color

getExpandedIcon

public com.sas.visuals.IconInterface getExpandedIcon()
Returns the expanded icon for the current node. If the expanded icon is null then the result of getDefaultIcon should be returned.

Specified by:
getExpandedIcon in interface com.sas.models.NodeIconInterface
Returns:
current Color

getSelectedIcon

public com.sas.visuals.IconInterface getSelectedIcon()
Returns the selected icon for the current node. If the selected icon is null then the result of getDefaultIcon should be returned.

Specified by:
getSelectedIcon in interface com.sas.models.NodeIconInterface
Returns:
the selected icon for the current node

getExpandedSelectedIcon

public com.sas.visuals.IconInterface getExpandedSelectedIcon()
Sets the expandedSelected icon for the current node. If the expandedSelected icon is null then the result of getExpandedIcon should be returned.

Specified by:
getExpandedSelectedIcon in interface com.sas.models.NodeIconInterface
Returns:
Current Color

getPreferredSize

public java.awt.Dimension getPreferredSize()
Return the preferredSize of the area to be painted.

Specified by:
getPreferredSize in interface com.sas.visuals.IconInterface
Returns:
a default dimension(4,4)

paint

public void paint(java.awt.Component component,
                  java.awt.Graphics g,
                  int x,
                  int y,
                  int width,
                  int height)
Paint the current color in the specified bounds.

Specified by:
paint in interface com.sas.visuals.PainterInterface
Parameters:
comp - the component used to determine the color used to paint
g - the Graphics context
x - the x position of the bounds to paint the color in
y - the y position of the bounds to paint the color in
width - the width of the bounds to paint the color in
height - the height of the bounds to paint the color in

getInsets

public java.awt.Insets getInsets()
Get the insets of the current color.

Specified by:
getInsets in interface com.sas.visuals.PainterInterface
Returns:
Insets( 0,0,0,0 )



Copyright © 2009 SAS Institute Inc. All Rights Reserved.