Class WAbstractColorMap

java.lang.Object
eu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.chart.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 Details

    • min_

      protected double min_
    • max_

      protected double max_
    • tickSpacing_

      protected int tickSpacing_
    • format_

      protected WString format_
    • labelFont_

      protected WFont labelFont_
  • Constructor Details

    • 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 Details

    • 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:
    • createStrip

      public final void createStrip(WPainter painter)
      Paints the colormap as a colored strip.

      Calls createStrip(painter, null)

    • paintLegend

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

      See Also:
    • paintLegend

      public final void paintLegend(WPainter painter)
      Paints the colormap as a legend.

      Calls paintLegend(painter, null)

    • 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:
    • getTickSpacing

      public int getTickSpacing()
      Returns the tickspacing for the legend.

      See Also:
    • setFormatString

      public void setFormatString(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:
    • getFormatString

      public WString getFormatString()
      Returns the format string.

      See Also:
    • setLabelFont

      public void setLabelFont(WFont font)
      Sets the font to be used when drawing the labels in the legend.

      The default is a default constructed WFont.

      See Also:
    • getLabelFont

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

      See Also: