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
-
NOTIFY_USER
- Variable to be used for either notifying the user
about the error messages or not.
-
ColorList()
- Creates a color list with no color in the list.
-
ColorList(Color)
- Creates a color list with a single color
-
ColorList(Color[])
- Creates a color list with an array of colors.
-
addColor(Color)
- Adds a color to the list of colors and returns the
updated ColorList object.
-
addColorListErrorListener(ColorListErrorListener)
- Adds a ColorListErrorListener to the listener list.
-
changeColorAt(Color, int)
- Replaces a color with another at a specified location.
-
clone()
- Returns a clone of this
ColorList
.
-
contains(Color)
- Checks whether the color exists in the colorlist
-
equals(Object)
- Compares this
ColorList
to a specified object.
-
getColorAt(int)
- Returns the color in the colorlist at a specified location.
-
getColors()
- Returns the list of colors as an enumeration
-
getColorString(Color)
- Returns the Java Initialization String for a color object.
-
hashCode()
- Returns a hashcode for this object
-
paramString()
- Returns the java initialization String for the ColorList object.
-
removeColor(Color)
- Removes a color from the list of colors and returns
the updated ColorList object.
-
removeColorListErrorListener(ColorListErrorListener)
- Removes a ColorListErrorListener from the listener list.
-
size()
- Returns the number of items in the color list.
NOTIFY_USER
public boolean NOTIFY_USER
- Variable to be used for either notifying the user
about the error messages or not.
ColorList
public ColorList()
- Creates a color list with no color in the list.
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
ColorList
public ColorList(Color color)
- Creates a color list with a single color
- Parameters:
- color - color to be added in the color list
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
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
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
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
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
getColors
public Enumeration getColors()
- Returns the list of colors as an enumeration
- Returns:
- enumeration of colors
- See Also:
- Enumeration
size
public int size()
- Returns the number of items in the color list.
- Returns:
- size of the color list
addColorListErrorListener
public synchronized void addColorListErrorListener(ColorListErrorListener listener)
- Adds a ColorListErrorListener to the listener list.
- Parameters:
- listener - ColorListErrorListener to be added
- See Also:
- ColorListErrorListener, removeColorListErrorListener
removeColorListErrorListener
public synchronized void removeColorListErrorListener(ColorListErrorListener listener)
- Removes a ColorListErrorListener from the listener list.
- Parameters:
- listener - ColorListErrorListener to be removed
- See Also:
- ColorListErrorListener, addColorListErrorListener
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
hashCode
public int hashCode()
- Returns a hashcode for this object
- Returns:
- A hashcode value for this object
- Overrides:
- hashCode in class Object
clone
public Object clone()
- Returns a clone of this
ColorList
.
- Returns:
- A clone of this
ColorList
- Overrides:
- clone in class Object
paramString
public String paramString()
- Returns the java initialization String for the ColorList object.
- Returns:
- the java initialization String
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