Package ubic.basecode.graphics
Class ColorMap
- java.lang.Object
-
- ubic.basecode.graphics.ColorMap
-
public class ColorMap extends Object
- Author:
- Will Braynen
-
-
Field Summary
Fields Modifier and Type Field Description static Color[]
BLACKBODY_COLORMAP
static Color
DARK_RED
static Color[]
GREENRED_COLORMAP
protected Color[]
m_colorPalette
protected Color[]
m_currentColorMap
protected Color[]
m_customColorMap
static int
m_defaultSuggestedNumberOfColors
protected Color
m_maxColor
last color in the current color mapprotected Color
m_minColor
first color in the current color mapstatic Color[]
REDGREEN_COLORMAP
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Color[]
createColorPalette(int suggestedNumberOfColors, Color[] colorMap)
Allocates colors across a range.Color
getColor(int i)
Color[]
getPalette()
int
getPaletteSize()
protected int
getStepSize(int minColor, int maxColor, int totalColors)
Calculate how fast we have to change color components.
-
-
-
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
- intcolorMap
- 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 colormaxColor
- red, green, or blue component of the RGB colortotalColors
- int- Returns:
- positive or negative step size
-
-