com.orsoncharts.renderer

## Class RainbowScale

- java.lang.Object
- - com.orsoncharts.renderer.AbstractColorScale
  - - com.orsoncharts.renderer.RainbowScale

- All Implemented Interfaces:
    ColorScale, java.io.Serializable

      public class RainbowScale
      extends AbstractColorScale
      implements ColorScale

  A color scale that returns all the colors of the rainbow. Instances of this class are immutable and serializable.
  NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
  Since:
    1.1
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Range` | `ALL_HUES` A range to include all hues.
    `static Range` | `BLUE_TO_RED_RANGE` A hue subrange that restricts colors to the blue to red range.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RainbowScale(Range range)` Creates a new rainbow scale for the specified value range, with 256 color samples in the blue to red range.
    `RainbowScale(Range range, int samples, Range hueSubrange)` Creates a new rainbow scale for the specified value range, with the given number of samples and hues restricted to the specified range.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)` Tests this color scale for equality with an arbitrary object.
    `Range` | `getHueSubrange()` Returns the sub-range of hues used in this scale.
    `int` | `getSampleCount()` Returns the number of samples used by this color scale.
    `java.awt.Color` | `valueToColor(double value)` Converts a value to a color on the scale.

    - ### Methods inherited from class com.orsoncharts.renderer.AbstractColorScale

      `getRange`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.orsoncharts.renderer.ColorScale

      `getRange`

- - ### Field Detail

    - #### ALL_HUES

          public static final Range ALL_HUES

      A range to include all hues. This can be used for the `hueSubrange` argument in the constructor.

    - #### BLUE_TO_RED_RANGE

          public static final Range BLUE_TO_RED_RANGE

      A hue subrange that restricts colors to the blue to red range. This can be used for the `hueSubrange` argument in the constructor.

  - ### Constructor Detail

    - #### RainbowScale

          public RainbowScale(Range range)

      Creates a new rainbow scale for the specified value range, with 256 color samples in the blue to red range.
      Parameters:
        `range` - the range (`null` not permitted).

    - #### RainbowScale

          public RainbowScale(Range range,
                              int samples,
                              Range hueSubrange)

      Creates a new rainbow scale for the specified value range, with the given number of samples and hues restricted to the specified range.
      Parameters:
        `range` - the range (`null` not permitted).
        `samples` - the number of samples.
        `hueSubrange` - the hue sub-range.

  - ### Method Detail

    - #### getSampleCount

          public int getSampleCount()

      Returns the number of samples used by this color scale.
      Returns:
        The number of samples.

    - #### getHueSubrange

          public Range getHueSubrange()

      Returns the sub-range of hues used in this scale.
      Returns:
        The sub-range of hues.

    - #### valueToColor

          public java.awt.Color valueToColor(double value)

      Converts a value to a color on the scale.
      Specified by:
        `valueToColor` in interface `ColorScale`
      Parameters:
        `value` - the value.
      Returns:
        A color (never `null`).

    - #### equals

          public boolean equals(java.lang.Object obj)

      Tests this color scale for equality with an arbitrary object.
      Overrides:
        `equals` in class `AbstractColorScale`
      Parameters:
        `obj` - the object (`null` permitted).
      Returns:
        A boolean.