Class WStandardColorMap
The WStandardColorMap is defined by a list of value-to-color pairs. The WStandardColorMap has two modes: a continuous mode, in which the colors are linearly interpolated in between the pair values, and a non-continuous mode, where the values are not interpolated, so that the colormap has a banded effect. In non-continuous mode, the color of a given point P is the color of the pair with the largest value smaller than P.
Numerical values above the maximum value in the list map to the maximum value's color,
all values below the minimum value in the list map to the minimum value's color. The range
indicated by the minimum and maximum passed to the constructor determines which part of the
colormap is drawn by createStrip()
or paintLegend()
.
The figure below illustrates the possible colormaps that can be constructed from the list
{"0.0 - StandardColor::DarkRed", "1.0 - StandardColor::Red", "2.0 -
StandardColor::Gray"}. The discrete map (on the left) has the range [0, 3], the continuous
map (on the right) has the range [0, 2]. The utility method discretise()
is also applied to the continuous
colormap to obtain a colormap with 5 bands in the same range.

Different uses of WStandardColorMap
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.chart.WAbstractColorMap
format_, labelFont_, max_, min_, tickSpacing_
-
Constructor Summary
ConstructorsConstructorDescriptionWStandardColorMap
(double min, double max, boolean continuous) Construct a default colormap.WStandardColorMap
(double min, double max, List<WStandardColorMap.Pair> colors, boolean continuous) Construct a custom colormap. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createStrip
(WPainter painter, WRectF area) Paints the colormap as a colored strip.void
discretise
(int numberOfBands) Utility method to discretise a continuous colormap in a number of equally sized bands.boolean
void
paintLegend
(WPainter painter, WRectF area) Paints the colormap as a legend.toColor
(double value) Converts a numerical value to aWColor
.Methods inherited from class eu.webtoolkit.jwt.chart.WAbstractColorMap
createStrip, getFormatString, getLabelFont, getMaximum, getMinimum, getTickSpacing, paintLegend, setFormatString, setLabelFont, setTickSpacing
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Constructor Details
-
WStandardColorMap
public WStandardColorMap(double min, double max, boolean continuous) Construct a default colormap.The default colormap is a transition from yellow to red. The color-scheme was taken from ColorBrewer, which contains lots of useful info and example schemes you might want to use for your custom colormaps.
-
WStandardColorMap
public WStandardColorMap(double min, double max, List<WStandardColorMap.Pair> colors, boolean continuous) Construct a custom colormap.This constructor allows you to pass a list of value-to-color pairs that define a colormap as described in the class description.
-
-
Method Details
-
discretise
public void discretise(int numberOfBands) Utility method to discretise a continuous colormap in a number of equally sized bands.This method makes a new list of value-to-color pairs by discretising the linear interpolation of the previous one into numberOfBands equally sized colorbands. This method only has effect if the colormap is continuous.
-
isContinuous
public boolean isContinuous() -
getColorValuePairs
-
toColor
Description copied from class:WAbstractColorMap
Converts a numerical value to aWColor
.- Specified by:
toColor
in classWAbstractColorMap
-
createStrip
Description copied from class:WAbstractColorMap
Paints the colormap as a colored strip.This paints the colormap from the minimum to the maximum value in the provided area (default = fill the entire paintdevice). This is no legend with ticks and labels, only the colors are painted.
- Specified by:
createStrip
in classWAbstractColorMap
- See Also:
-
paintLegend
Description copied from class:WAbstractColorMap
Paints the colormap as a legend.The colormap is painted as a legend with ticks and value-labels. The parameter area can be used to specify a part of the paintdevice where the legend should be drawn. When drawing the legend, the tickspacing, labelformat and labelfont are taken into account.
-