public class ColorSpectrum
extends java.lang.Object
Color Spectrum:
+-------+ highest value
| |
| red | color[2] = red
| |
+-------+ value[1] = 60.0
| |
| |
| yellow| color[1] = yellow
| |
| |
+-------+ value[0] = 30.0
| |
| green | color[0] = green
| |
+-------+ lowest value
If the color spectrum only has one value, the value array is null and the color array always has
one element. Otherwise, the color array always has one more element than the value array. Since a
color spectrum object is not mutable, another object has to be created when it need to be
changed.
Generally speaking, if there are n values in the color spectrum,
value[0] < value[1] < .... < value[n-1] < value[n]
then the order of the array elements is as follows:
color[0], value[0], color[1], value[1], ... , color[n], value[n], color[n+1]
Constructor and Description |
---|
ColorSpectrum(java.awt.Color[] color,
double[] value)
Creates a color spectrum object.
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color[] |
getColor()
This function returns the color array
|
java.awt.Color |
getColor(double target)
This function returns the color corresponding to a target value
|
double[] |
getValue()
This function returns the value array
|
int |
getValueCount()
This function returns the number of value in the value array
|
public ColorSpectrum(java.awt.Color[] color, double[] value) throws java.lang.IllegalArgumentException
then the order of the array elements is as follows:
color[0], value[0], color[1], value[1], ... , color[n], value[n], color[n+1]
color
- The color arrayvalue
- The value arrayjava.lang.IllegalArgumentException
public java.awt.Color[] getColor()
public double[] getValue()
public int getValueCount()
public java.awt.Color getColor(double target)