Class GradientBackgroundPainter

All Implemented Interfaces:
ICellPainter

public class GradientBackgroundPainter extends CellPainterWrapper
Paints the background of the cell with a gradient sweeping using the style configuration. To configure the gradient sweeping the following style attributes need to be configured in the ConfigRegistry: If none of these values are registered in the ConfigRegistry the painting is skipped.

Can be used as a cell painter or a decorator.

  • Constructor Details

    • GradientBackgroundPainter

      public GradientBackgroundPainter()
      Creates a GradientBackgroundPainter with a gradient sweeping from left to right.
    • GradientBackgroundPainter

      public GradientBackgroundPainter(boolean vertical)
      Creates a GradientBackgroundPainter where the sweeping direction can be set.
      Parameters:
      vertical - if true sweeps from top to bottom, else sweeps from left to right. false is default
    • GradientBackgroundPainter

      public GradientBackgroundPainter(ICellPainter painter)
      Creates a GradientBackgroundPainter as wrapper for the given painter with a gradient sweeping from left to right.
      Parameters:
      painter - The ICellPainter that is wrapped by this GradientBackgroundPainter
    • GradientBackgroundPainter

      public GradientBackgroundPainter(ICellPainter painter, boolean vertical)
      Creates a GradientBackgroundPainter as wrapper for the given painter where the sweeping direction can be set.
      Parameters:
      painter - The ICellPainter that is wrapped by this GradientBackgroundPainter
      vertical - if true sweeps from top to bottom, else sweeps from left to right. false is default
  • Method Details

    • paintCell

      public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
      Specified by:
      paintCell in interface ICellPainter
      Overrides:
      paintCell in class CellPainterWrapper
    • getForeGroundColour

      protected org.eclipse.swt.graphics.Color getForeGroundColour(ILayerCell cell, IConfigRegistry configRegistry)
      Searches the foreground color to be used for gradient sweeping. First checks the ConfigRegistry if there is a value for the attribute CellStyleAttributes.GRADIENT_FOREGROUND_COLOR is registered. If there is one this value will be returned, if not it is checked if there is a value registered for CellStyleAttributes.FOREGROUND_COLOR and returned. If there is no value registered for any of these attributes, null will be returned which will skip the painting.
      Parameters:
      cell - The LayerCell for which the style attributes should be retrieved out of the ConfigRegistry
      configRegistry - The ConfigRegistry to retrieve the attribute values from.
      Returns:
      The Color to use as foreground color of the gradient sweeping or null if none was configured.
    • getBackgroundColour

      protected org.eclipse.swt.graphics.Color getBackgroundColour(ILayerCell cell, IConfigRegistry configRegistry)
      Searches the background color to be used for gradient sweeping. First checks the ConfigRegistry if there is a value for the attribute CellStyleAttributes.GRADIENT_BACKGROUND_COLOR is registered. If there is one this value will be returned, if not it is checked if there is a value registered for CellStyleAttributes.BACKGROUND_COLOR and returned. If there is no value registered for any of these attributes, null will be returned which will skip the painting.
      Parameters:
      cell - The LayerCell for which the style attributes should be retrieved out of the ConfigRegistry
      configRegistry - The ConfigRegistry to retrieve the attribute values from.
      Returns:
      The Color to use as background color of the gradient sweeping or null if none was configured.
    • isVertical

      public boolean isVertical()
      Returns:
      true if sweeps from top to bottom, else sweeps from left to right. Default is false
      Since:
      1.4
    • setVertical

      public void setVertical(boolean vertical)
      Parameters:
      vertical - true if should sweep from top to bottom, false if it should sweep from left to right. Default is false
      Since:
      1.4