Class ColorScaleModel

java.lang.Object
cnuphys.splot.plot.ColorScaleModel

public class ColorScaleModel extends Object
Used for color scales, such as on magnetic field plots
Author:
heddle
  • Field Details

    • _colors

      protected Color[] _colors
      The array of colors
  • Constructor Details

    • ColorScaleModel

      public ColorScaleModel(double minVal, double maxVal, Color[] colors)
      This creates a ColorScaleModel for converting a value into a color.
      Parameters:
      minVal - the minimum value;
      maxVal - the maximum value the array of colors.
  • Method Details

    • blueToRed

      public static ColorScaleModel blueToRed()
      Get a standard blue to red colors scale
      Returns:
      a standard blue to red color scale
    • getAlphaColor

      public Color getAlphaColor(double value, int alpha)
      Get a color via getColor but add an alpha value
      Parameters:
      value - the value
      alpha - the alpha value [0..255]
      Returns:
      the color corresponding to the value.
    • getColor

      public Color getColor(double value)
      Given a value, returns the corresponding color. Example:

      values: {0, 2, 4, 6, 8}

      colors: {R, G, B, Y}

      then

      value = 1.77 -> R

      value = -1 -> tooSmallColor

      value = 8.01 -> tooBigColor

      value = 4 (exactly) -> G

      Parameters:
      value - the for which we want the color.
      Returns:
      the color corresponding to the value.
    • getColors

      public Color[] getColors()
      Get the color array.
      Returns:
      the color array.
    • getTooBigColor

      public Color getTooBigColor()
      Get the too-big color.
      Returns:
      the color used for a "too big" value.
    • getTooSmallColor

      public Color getTooSmallColor()
      Get the too-small color.
      Returns:
      the color used for a "too small" value.
    • setTooSmallColor

      public void setTooSmallColor(Color tooSmallColor)
      Parameters:
      tooSmallColor - the tooSmallColor to set
    • setTooBigColor

      public void setTooBigColor(Color tooBigColor)
      Parameters:
      tooBigColor - the tooBigColor to set