public final class ColorScale extends Object
Modifier and Type | Field and Description |
---|---|
private Color |
aboveMaxColor |
private Color |
belowMinColor |
private String[] |
colorBarTitles |
private Color[] |
colors |
private int |
intervalCount |
private double |
max |
private double |
min |
private Color |
noDataColor |
private String |
title |
Modifier | Constructor and Description |
---|---|
private |
ColorScale() |
Modifier and Type | Method and Description |
---|---|
void |
addBounds()
Add standard colors for values below min or above max value
|
ColorScale |
addColorBarTitles(String[] titles)
Adds titles to the color bar for a fixed scale
|
ColorScale |
addTitle(String title)
Adds a title to this scale
|
static ColorScale |
createCyclicScale(int count)
Creates a cyclic color scale (red yellow green blue red)
|
static ColorScale |
createFixedScale(Color[] colors)
Gets a fixed color range.
|
static ColorScale |
createHSBScale(int count)
Gets a HSB color range.
|
void |
drawColorBar(Graphics2D g,
int x,
int y,
int w,
int h,
double valueScale)
Draws a color bar representing this scale on the given graphics
|
Color |
getColor(double value)
Gets a color for the given value.
|
Color |
getColor(Number value)
Gets a color for the given value.
|
Color |
getNoDataColor()
Get the color to use if there is no data
|
ColorScale |
makeReversed()
Reverses this scale
|
ColorScale |
makeTransparent(int alpha)
Make all colors transparent
|
ColorScale |
setIntervalCount(int intervalCount)
Sets the interval count for this scale
|
void |
setNoDataColor(Color noDataColor)
Sets the color to use if there is no data
|
void |
setRange(double min,
double max)
Sets the hint on the range this scale is for
|
private static float |
weighted(float x)
transition function:
w(0)=1, w(1)=0, 0<=w(x)<=1
|
private double min
private double max
private Color noDataColor
private Color belowMinColor
private Color aboveMaxColor
private String[] colorBarTitles
private int intervalCount
private ColorScale()
public static ColorScale createFixedScale(Color[] colors)
colors
- the fixed colors listpublic static ColorScale createHSBScale(int count)
count
- The number of colors the scale should havepublic static ColorScale createCyclicScale(int count)
count
- The number of colors the scale should haveprivate static float weighted(float x)
x
- number: 0<=x<=1public void setRange(double min, double max)
min
- The minimum valuemax
- The maximum valuepublic void addBounds()
public Color getColor(double value)
value
- The valuepublic Color getColor(Number value)
value
- The value, may be null
public Color getNoDataColor()
public void setNoDataColor(Color noDataColor)
noDataColor
- The colorpublic ColorScale makeTransparent(int alpha)
alpha
- The alpha value all colors in the range should have, range 0..255public ColorScale addTitle(String title)
title
- The new titlepublic ColorScale addColorBarTitles(String[] titles)
titles
- Array of String, same length as the colors arraypublic ColorScale setIntervalCount(int intervalCount)
intervalCount
- The interval count hintpublic ColorScale makeReversed()
public void drawColorBar(Graphics2D g, int x, int y, int w, int h, double valueScale)
g
- The graphics to draw onx
- Rect xy
- Rect yw
- Rect widthh
- Rect heightvalueScale
- The scale factor of the values