Class ColorSpectrum
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] invalid input: '<' value[1] invalid input: '<' .... invalid input: '<' value[n-1] invalid input: '<' 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]
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionColorSpectrum(Color[] color, double[] value) Creates a color spectrum object. -
Method Summary
Modifier and TypeMethodDescriptionColor[]getColor()This function returns the color arraygetColor(double target) This function returns the color corresponding to a target valuedouble[]getValue()This function returns the value arrayintThis function returns the number of value in the value array
-
Constructor Details
-
ColorSpectrum
Creates a color spectrum object. Generally speaking, if there are n values in the color spectrum,
value[0] invalid input: '<' value[1] invalid input: '<' .... invalid input: '<' value[n-1] invalid input: '<' 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]- Parameters:
color- The color arrayvalue- The value array- Throws:
IllegalArgumentException
-
-
Method Details
-
getColor
This function returns the color array- Returns:
- The color array
-
getValue
public double[] getValue()This function returns the value array- Returns:
- The value array
-
getValueCount
public int getValueCount()This function returns the number of value in the value array- Returns:
- The count
-
getColor
This function returns the color corresponding to a target value- Returns:
- The color
-