Package org.evoludo.simulator
Class ColorMapCSS
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
One dimensional color gradient spanning two or more colorsstatic class
Two dimensional color gradient with one color for each dimension.static class
N
dimensional color gradient with one color for each dimension.static class
Color gradient following the hue.static class
Associates integer indices with colors.Nested classes/interfaces inherited from class ColorMap
ColorMap.Gradient<T>
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Convert Color to CSS style string.static String[]
Convert an array of Color's to an array of CSS style strings.private static String
Utility function to add padding (if needed) of leading zero'es to ensure that each color component is encoded by a two digit hexadecimal.static String
RGB2Css
(int r, int g, int b) Convert the three components of a 24bit color,r, g
, andb
to a CSS color style.static String
RGBA2Css
(int r, int g, int b, int a) Convert the four components of a 32bit color,r, g, b
, anda
to a CSS color style.Methods inherited from class ColorMap
addAlpha, addAlpha, addColors, blendColors, blendColors, color2Color, translate, translate, translate, translate, translate, translate
-
Constructor Details
-
ColorMapCSS
public ColorMapCSS()Constructs a new color map.
-
-
Method Details
-
Color2Css
Convert Color to CSS style string. For colors with transparency, the output is of the formrgba(r, g, b, a)
, wherer, g, b
, anda
refer to the red, green, blue and alpha (transparency) components. Without transparency the output is of the form#rrggbb
, whererr, gg
, andbb
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
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
Convert the four components of a 32bit color,r, g, b
, anda
to a CSS color style.- Parameters:
r
- the red component0-255
g
- the green component0-255
b
- the blue component0-255
a
- the alpha (transparency) component[0,1]
- Returns:
- CSS color string
rgba(r, g, b, a)
-
RGB2Css
Convert the three components of a 24bit color,r, g
, andb
to a CSS color style.- Parameters:
r
- the red component0-255
g
- the green component0-255
b
- the blue component0-255
- Returns:
- CSS color string
#rrggbb
-
pad
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
-