All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.imageprocessing.ColorList

java.lang.Object
   |
   +----com.ibm.imageprocessing.ColorList

public class ColorList
extends Object
implements Serializable, Cloneable
ColorList is a Wrapper class for java.awt.Color[] objects. Colors can be added or deleted by using the addColor and removeColor methods. It prevents duplicating entries of a color in the list.

Note: Normally IDEs cannot generate code for array objects hence this class is required, which will provide a single statement JavaInitialization string for a set of color objects.

See Also:
Cloneable

Variable Index

 o NOTIFY_USER
Variable to be used for either notifying the user about the error messages or not.

Constructor Index

 o ColorList()
Creates a color list with no color in the list.
 o ColorList(Color)
Creates a color list with a single color
 o ColorList(Color[])
Creates a color list with an array of colors.

Method Index

 o addColor(Color)
Adds a color to the list of colors and returns the updated ColorList object.
 o addColorListErrorListener(ColorListErrorListener)
Adds a ColorListErrorListener to the listener list.
 o changeColorAt(Color, int)
Replaces a color with another at a specified location.
 o clone()
Returns a clone of this ColorList.
 o contains(Color)
Checks whether the color exists in the colorlist
 o equals(Object)
Compares this ColorList to a specified object.
 o getColorAt(int)
Returns the color in the colorlist at a specified location.
 o getColors()
Returns the list of colors as an enumeration
 o getColorString(Color)
Returns the Java Initialization String for a color object.
 o hashCode()
Returns a hashcode for this object
 o paramString()
Returns the java initialization String for the ColorList object.
 o removeColor(Color)
Removes a color from the list of colors and returns the updated ColorList object.
 o removeColorListErrorListener(ColorListErrorListener)
Removes a ColorListErrorListener from the listener list.
 o size()
Returns the number of items in the color list.

Variables

 o NOTIFY_USER
 public boolean NOTIFY_USER
Variable to be used for either notifying the user about the error messages or not.

Constructors

 o ColorList
 public ColorList()
Creates a color list with no color in the list.

 o ColorList
 public ColorList(Color listOfColors[])
Creates a color list with an array of colors.

Parameters:
listOfColors - An array of colors to be added to the color list
 o ColorList
 public ColorList(Color color)
Creates a color list with a single color

Parameters:
color - color to be added in the color list

Methods

 o addColor
 public ColorList addColor(Color aColor)
Adds a color to the list of colors and returns the updated ColorList object. If the color already exists in the colorlist, then the colorlist is returned without any modification.

Parameters:
aColor - The color to be added to the list
Returns:
The updated colorlist
Throws: IllegalArgumentException
if the value passed is null
 o removeColor
 public ColorList removeColor(Color aColor)
Removes a color from the list of colors and returns the updated ColorList object. If the specified color does not exist, ColorListErrorEvent is thrown.

Parameters:
aColor - The color to be removed from the list
Returns:
The updated colorlist
Throws: IllegalArgumentException
if the value passed is null
See Also:
ColorListErrorEvent, ColorListErrorListener
 o changeColorAt
 public boolean changeColorAt(Color aColor,
                              int position)
Replaces a color with another at a specified location. The old color will be replaced if the new color is not equal to the old color. If the position is invalid, ColorListErrorEvent is thrown.

Parameters:
aColor - new color to be replaced for the old color
position - specified position
Returns:
true-if the color is changed otherwise false
Throws: IllegalArgumentException
if the value of the passed color is null
See Also:
ColorListErrorEvent, ColorListErrorListener
 o contains
 public boolean contains(Color aColor)
Checks whether the color exists in the colorlist

Parameters:
aColor - specified color
Returns:
true- if the specified color is contained, otherwise false
Throws: IllegalArgumentException
if the passed value is null
 o getColorAt
 public Color getColorAt(int position)
Returns the color in the colorlist at a specified location. If the position is invalid, ColorListErrorEvent is thrown.

Parameters:
position - specified position
Returns:
color at a specified position
See Also:
ColorListErrorEvent, ColorListErrorListener
 o getColors
 public Enumeration getColors()
Returns the list of colors as an enumeration

Returns:
enumeration of colors
See Also:
Enumeration
 o size
 public int size()
Returns the number of items in the color list.

Returns:
size of the color list
 o addColorListErrorListener
 public synchronized void addColorListErrorListener(ColorListErrorListener listener)
Adds a ColorListErrorListener to the listener list.

Parameters:
listener - ColorListErrorListener to be added
See Also:
ColorListErrorListener, removeColorListErrorListener
 o removeColorListErrorListener
 public synchronized void removeColorListErrorListener(ColorListErrorListener listener)
Removes a ColorListErrorListener from the listener list.

Parameters:
listener - ColorListErrorListener to be removed
See Also:
ColorListErrorListener, addColorListErrorListener
 o equals
 public boolean equals(Object obj)
Compares this ColorList to a specified object. The result is true if and only if the argument is not null and is a ColorList object that has the same list of colors as this object.

Parameters:
the - object to compare this ColorList with.
Returns:
true if the ColorList objects are equal, false otherwise.
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Returns a hashcode for this object

Returns:
A hashcode value for this object
Overrides:
hashCode in class Object
 o clone
 public Object clone()
Returns a clone of this ColorList.

Returns:
A clone of this ColorList
Overrides:
clone in class Object
 o paramString
 public String paramString()
Returns the java initialization String for the ColorList object.

Returns:
the java initialization String
 o getColorString
 protected String getColorString(Color aColor)
Returns the Java Initialization String for a color object.

Parameters:
aColor - specified color
Returns:
the JavaInitialization string for color

All Packages  Class Hierarchy  This Package  Previous  Next  Index