public final class ColorScale extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.awt.Color |
aboveMaxColor |
private java.awt.Color |
belowMinColor |
private java.awt.Color[] |
colors |
private int |
intervalCount |
private double |
max |
private double |
min |
private java.awt.Color |
noDataColor |
private java.lang.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 |
addTitle(java.lang.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 |
createHSBScale(int count)
Gets a HSB color range.
|
void |
drawColorBar(java.awt.Graphics2D g,
int x,
int y,
int w,
int h,
double valueScale)
Draws a color bar representing this scale on the given graphics
|
java.awt.Color |
getColor(double value)
Gets a color for the given value.
|
java.awt.Color |
getColor(java.lang.Number value)
Gets a color for the given value.
|
java.awt.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(java.awt.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 java.awt.Color noDataColor
private java.awt.Color belowMinColor
private java.awt.Color aboveMaxColor
private java.awt.Color[] colors
private java.lang.String title
private int intervalCount
private ColorScale()
public 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 java.awt.Color getColor(double value)
value
- The valuepublic java.awt.Color getColor(java.lang.Number value)
value
- The value, may be null
public java.awt.Color getNoDataColor()
public void setNoDataColor(java.awt.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(java.lang.String title)
title
- The new titlepublic ColorScale setIntervalCount(int intervalCount)
intervalCount
- The interval count hintpublic ColorScale makeReversed()
public void drawColorBar(java.awt.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