Class ColorMapCSS

Object
ColorMap<String>
ColorMapCSS

public abstract class ColorMapCSS extends ColorMap<String>
Coloring is a wrapper class for different schemes to map data onto colors for 2D visualizations using the HTML5 canvas element. Each inner class implements the ColorMap interface to provide an implementation agnostic manner to translate data into colors.

The following color mappings are currently available:

Index
Associates integer indices with colors.
Gradient1D
One dimensional color gradient spanning two or more colors.
Hue
Special case of Gradient1D where the gradient follows the color hue.
Gradient2D
Two dimensional gradient with each dimension represented by one color.
GradientND
Multi-dimensional gradient spanned by an identical number of colors
Author:
Christoph Hauert
  • Constructor Details

    • ColorMapCSS

      public ColorMapCSS()
      Constructs a new color map.
  • Method Details

    • Color2Css

      public static String Color2Css(Color color)
      Convert Color to CSS style string. For colors with transparency, the output is of the form rgba(r, g, b, a), where r, g, b, and a refer to the red, green, blue and alpha (transparency) components. Without transparency the output is of the form #rrggbb, where rr, gg, and bb are the hexadecimal representation of the red, green and blue components, respectively.
      Parameters:
      color - the color to convert
      Returns:
      CSS color string
      See Also:
    • Color2Css

      public static String[] Color2Css(Color[] colors)
      Convert an array of Color's to an array of CSS style strings.
      Parameters:
      colors - the array of Color's to convert
      Returns:
      array of CSS color strings
      See Also:
    • RGBA2Css

      public static String RGBA2Css(int r, int g, int b, int a)
      Convert the four components of a 32bit color, r, g, b, and a to a CSS color style.
      Parameters:
      r - the red component 0-255
      g - the green component 0-255
      b - the blue component 0-255
      a - the alpha (transparency) component [0,1]
      Returns:
      CSS color string rgba(r, g, b, a)
    • RGB2Css

      public static String RGB2Css(int r, int g, int b)
      Convert the three components of a 24bit color, r, g, and b to a CSS color style.
      Parameters:
      r - the red component 0-255
      g - the green component 0-255
      b - the blue component 0-255
      Returns:
      CSS color string #rrggbb
    • pad

      private static String pad(String in)
      Utility function to add padding (if needed) of leading zero'es to ensure that each color component is encoded by a two digit hexadecimal.
      Parameters:
      in - the input string
      Returns:
      leading zero'es added as needed to ensure two digit string