Class WAbstractColorMap

  • Direct Known Subclasses:
    WStandardColorMap

    public abstract class WAbstractColorMap
    extends WObject
    Maps numerical values to colors.

    The colormap has functionality to convert a numerical value to a WColor. For details on how, see the documentation of the implementations.

    A colormap has a certain numerical range. When a colormap is painted as a colored strip or as a legend, this range is what will be presented, even if the colormap has the ability to convert values outside this range.

    • Field Detail

      • min_

        protected double min_
      • max_

        protected double max_
      • tickSpacing_

        protected int tickSpacing_
      • format_

        protected WString format_
      • labelFont_

        protected WFont labelFont_
    • Constructor Detail

      • WAbstractColorMap

        public WAbstractColorMap​(double min,
                                 double max)
        Constructor.

        Constructor taking a minimum and maximum value, determining the active range of the colormap. The default value for tickSpacing is 2 and the default label format is 2 decimal points.

    • Method Detail

      • toColor

        public abstract WColor toColor​(double value)
        Converts a numerical value to a WColor.
      • createStrip

        public abstract void createStrip​(WPainter painter,
                                         WRectF area)
        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.

        See Also:
        paintLegend(WPainter painter, WRectF area)
      • getMinimum

        public double getMinimum()
        Returns the minimum of the colormap range.
      • getMaximum

        public double getMaximum()
        Returns the maximum of the colormap range.
      • setTickSpacing

        public void setTickSpacing​(int spacing)
        Sets the tickspacing for the legend as a number of line-heights.

        The tickspacing must be specified as an integer number of line-heigths. For example, the default value of 2 will leave two line-heights between the labels of the ticks.

        See Also:
        paintLegend(WPainter painter, WRectF area)
      • setFormatString

        public void setFormatString​(java.lang.CharSequence format)
        Sets the format for the labels on the colormap-legend.

        The format string is interpreted by snprintf(). The default is a float with two decimal places.

        See Also:
        paintLegend(WPainter painter, WRectF area)
      • getLabelFont

        public WFont getLabelFont()
        Returns the font to be used when drawing the labels in the legend.

        See Also:
        setLabelFont(WFont font)