com.alee.extended.colorchooser
Class GradientData

java.lang.Object
  extended by com.alee.extended.colorchooser.GradientData
All Implemented Interfaces:
DefaultValue, java.io.Serializable, java.lang.Cloneable

public class GradientData
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, DefaultValue

Data object for WebGradientColorChooser component.

Author:
Mikle Garin
See Also:
Serialized Form

Constructor Summary
GradientData()
          Constructs GradientData object with empty data list.
GradientData(java.util.List<GradientColorData> gradientColorsData)
          Constructs GradientData object with a specified data list.
 
Method Summary
 void addGradientColorData(float location, java.awt.Color color)
          Adds GradientColorData with the specified location and color into data list and sorts the list.
 void addGradientColorData(GradientColorData gradientColorData)
          Adds GradientColorData into data list and sorts the list.
 GradientData clone()
          Returns cloned GradientData.
 boolean containtsLocation(float location)
          Returns whether there is a GradientColorData for specified location or not.
 boolean equals(java.lang.Object obj)
          Returns whether this GradientData is equal to the specified object or not.
 GradientColorData get(int index)
          Returns GradientColorData at the specified index.
 java.awt.Color getColor(int index)
          Returns color for GradientColorData at the specified index.
 java.awt.Color getColorForLocation(float location)
          Returns calculated color for the specified location.
 java.awt.Color[] getColors()
          Returns an array of colors for LinearGradientPaint.
static GradientData getDefaultValue()
          Returns default GradientData value.
 GradientColorData getFirst()
          Returns first GradientColorData.
 float[] getFractions()
          Returns an array of fractions for LinearGradientPaint.
 java.util.List<GradientColorData> getGradientColorsData()
          Returns sorted data list.
 GradientColorData getLast()
          Returns last GradientColorData.
 float getLocation(int index)
          Returns location for GradientColorData at the specified index.
 void removeGradientColorData(GradientColorData gradientColorData)
          Removes GradientColorData from data list and sorts the list.
 void setGradientColorsData(java.util.List<GradientColorData> gradientColorsData)
          Sets data list and sorts it.
 int size()
          Returns data list size.
 void sort()
          Sorts data list.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GradientData

public GradientData()
Constructs GradientData object with empty data list.


GradientData

public GradientData(java.util.List<GradientColorData> gradientColorsData)
Constructs GradientData object with a specified data list.

Method Detail

containtsLocation

public boolean containtsLocation(float location)
Returns whether there is a GradientColorData for specified location or not.

Parameters:
location - location to search for GradientColorData
Returns:
true if there is a GradientColorData for specified location, false otherwise

addGradientColorData

public void addGradientColorData(GradientColorData gradientColorData)
Adds GradientColorData into data list and sorts the list.

Parameters:
gradientColorData - GradientColorData to add

addGradientColorData

public void addGradientColorData(float location,
                                 java.awt.Color color)
Adds GradientColorData with the specified location and color into data list and sorts the list.

Parameters:
location - GradientColorData location
color - GradientColorData color

removeGradientColorData

public void removeGradientColorData(GradientColorData gradientColorData)
Removes GradientColorData from data list and sorts the list.

Parameters:
gradientColorData - GradientColorData to remove

getGradientColorsData

public java.util.List<GradientColorData> getGradientColorsData()
Returns sorted data list.

Returns:
sorted data list

setGradientColorsData

public void setGradientColorsData(java.util.List<GradientColorData> gradientColorsData)
Sets data list and sorts it.

Parameters:
gradientColorsData - new data list

getFractions

public float[] getFractions()
Returns an array of fractions for LinearGradientPaint.

Returns:
an array of fractions for LinearGradientPaint

getColors

public java.awt.Color[] getColors()
Returns an array of colors for LinearGradientPaint.

Returns:
an array of colors for LinearGradientPaint

size

public int size()
Returns data list size.

Returns:
data list size

get

public GradientColorData get(int index)
Returns GradientColorData at the specified index.

Parameters:
index - GradientColorData index
Returns:
GradientColorData at the specified index

getLocation

public float getLocation(int index)
Returns location for GradientColorData at the specified index.

Parameters:
index - GradientColorData index
Returns:
location for GradientColorData at the specified index

getColor

public java.awt.Color getColor(int index)
Returns color for GradientColorData at the specified index.

Parameters:
index - GradientColorData index
Returns:
color for GradientColorData at the specified index

getFirst

public GradientColorData getFirst()
Returns first GradientColorData.

Returns:
first GradientColorData

getLast

public GradientColorData getLast()
Returns last GradientColorData.

Returns:
last GradientColorData

getColorForLocation

public java.awt.Color getColorForLocation(float location)
Returns calculated color for the specified location. This method will return color for any location between 0f and 1f even if there is no data at the specified location.

Parameters:
location - color location
Returns:
calculated color for the specified location

sort

public void sort()
Sorts data list.


equals

public boolean equals(java.lang.Object obj)
Returns whether this GradientData is equal to the specified object or not.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to compare with
Returns:
true if this GradientData is equal to the specified object, false otherwise

clone

public GradientData clone()
Returns cloned GradientData.

Overrides:
clone in class java.lang.Object
Returns:
cloned GradientData

getDefaultValue

public static GradientData getDefaultValue()
Returns default GradientData value.

Returns:
default GradientData value