Class WStandardColorMap
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.chart.WAbstractColorMap
-
- eu.webtoolkit.jwt.chart.WStandardColorMap
-
public class WStandardColorMap extends WAbstractColorMap
Standard colorMap.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()orpaintLegend().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 Classes Modifier and Type Class Description static classWStandardColorMap.PairContains a pair of a numerical value and aWColor.-
Nested 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
Constructors Constructor Description WStandardColorMap(double min, double max, boolean continuous)Construct a default colormap.WStandardColorMap(double min, double max, java.util.List<WStandardColorMap.Pair> colors, boolean continuous)Construct a custom colormap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateStrip(WPainter painter, WRectF area)Paints the colormap as a colored strip.voiddiscretise(int numberOfBands)Utility method to discretise a continuous colormap in a number of equally sized bands.java.util.List<WStandardColorMap.Pair>getColorValuePairs()booleanisContinuous()voidpaintLegend(WPainter painter, WRectF area)Paints the colormap as a legend.WColortoColor(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 Detail
-
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, java.util.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 Detail
-
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
public java.util.List<WStandardColorMap.Pair> getColorValuePairs()
-
toColor
public WColor toColor(double value)
Description copied from class:WAbstractColorMapConverts a numerical value to aWColor.- Specified by:
toColorin classWAbstractColorMap
-
createStrip
public void createStrip(WPainter painter, WRectF area)
Description copied from class:WAbstractColorMapPaints 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:
createStripin classWAbstractColorMap- See Also:
WAbstractColorMap.paintLegend(WPainter painter, WRectF area)
-
paintLegend
public void paintLegend(WPainter painter, WRectF area)
Description copied from class:WAbstractColorMapPaints 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.
-
-