Class ColorMap


  • public class ColorMap
    extends Object
    Author:
    Will Braynen
    • Field Detail

      • DARK_RED

        public static final Color DARK_RED
      • BLACKBODY_COLORMAP

        public static final Color[] BLACKBODY_COLORMAP
      • GREENRED_COLORMAP

        public static final Color[] GREENRED_COLORMAP
      • m_defaultSuggestedNumberOfColors

        public static final int m_defaultSuggestedNumberOfColors
        See Also:
        Constant Field Values
      • REDGREEN_COLORMAP

        public static final Color[] REDGREEN_COLORMAP
      • m_colorPalette

        protected Color[] m_colorPalette
      • m_currentColorMap

        protected Color[] m_currentColorMap
      • m_customColorMap

        protected Color[] m_customColorMap
      • m_maxColor

        protected Color m_maxColor
        last color in the current color map
      • m_minColor

        protected Color m_minColor
        first color in the current color map
    • Constructor Detail

      • ColorMap

        public ColorMap()
      • ColorMap

        public ColorMap​(Color[] colorMap)
      • ColorMap

        public ColorMap​(int suggestedNumberOfColors)
      • ColorMap

        public ColorMap​(int suggestedNumberOfColors,
                        Color[] colorMap)
        Pre-condition: suggestedNumberOfColors > colorMap.length
        Parameters:
        suggestedNumberOfColors - int
        colorMap - Color[]
    • Method Detail

      • getColor

        public Color getColor​(int i)
      • getPalette

        public Color[] getPalette()
      • getPaletteSize

        public int getPaletteSize()
        Returns:
        the number of colors in the palette
      • createColorPalette

        protected Color[] createColorPalette​(int suggestedNumberOfColors,
                                             Color[] colorMap)
        Allocates colors across a range.
        Parameters:
        suggestedNumberOfColors - palette resolution; if colorPalette.length does not evenly divide into this number, the actual number of colors in the palette will be rounded down.
        colorMap - the simplest color map is { minColor, maxColor }; you might, however, want to go through intermediate colors instead of following a straight-line route through the color space.
        Returns:
        Color[] the color palette
      • getStepSize

        protected int getStepSize​(int minColor,
                                  int maxColor,
                                  int totalColors)
        Calculate how fast we have to change color components. Assume min and max colors are different!
        Parameters:
        minColor - red, green, or blue component of the RGB color
        maxColor - red, green, or blue component of the RGB color
        totalColors - int
        Returns:
        positive or negative step size