Package quadbase.util

Class ColorSpectrum

java.lang.Object
quadbase.util.ColorSpectrum

public class ColorSpectrum extends Object
This class is used for defining the color of data based on the vertical value. Currently only 3D surface chart can support this feature. The following diagram shows the meaning of the color array and the value array.

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 Details

    • ColorSpectrum

      public ColorSpectrum(Color[] color, double[] value) throws IllegalArgumentException
      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 array
      value - The value array
      Throws:
      IllegalArgumentException
  • Method Details

    • getColor

      public Color[] 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

      public Color getColor(double target)
      This function returns the color corresponding to a target value
      Returns:
      The color