All Implemented Interfaces:
ICellPainter
Direct Known Subclasses:
CheckBoxPainter, ColumnGroupExpandCollapseImagePainter, ColumnHeaderCheckBoxPainter, ComboBoxFilterIconPainter, FilterIconPainter, RowGroupExpandCollapseImagePainter, SortIconPainter, TreeCheckBoxPainter, TreeImagePainter

public class ImagePainter extends BackgroundPainter
Paints an image. If no image is provided, it will attempt to look up an image from the cell style.
  • Field Details

    • calculateByWidth

      protected boolean calculateByWidth
    • calculateByHeight

      protected boolean calculateByHeight
  • Constructor Details

    • ImagePainter

      public ImagePainter()
      Creates an ImagePainter that retrieves the image to render from the IConfigRegistry.
    • ImagePainter

      public ImagePainter(org.eclipse.swt.graphics.Image image)
      Creates an ImagePainter that renders the provided image.
      Parameters:
      image - The image to render.
    • ImagePainter

      public ImagePainter(boolean paintBg)
      Creates an ImagePainter that retrieves the image to render from the IConfigRegistry.
      Parameters:
      paintBg - true if the cell background should be painted by this painter, false if it should be skipped.
      Since:
      1.4
    • ImagePainter

      public ImagePainter(org.eclipse.swt.graphics.Image image, boolean paintBg)
      Creates an ImagePainter that renders the provided image.
      Parameters:
      image - The image to render.
      paintBg - true if the cell background should be painted by this painter, false if it should be skipped.
  • Method Details

    • getPreferredWidth

      public int getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
      Description copied from interface: ICellPainter
      Get the preferred width of the cell when rendered by this painter. Used for auto-resize.
      Specified by:
      getPreferredWidth in interface ICellPainter
      Overrides:
      getPreferredWidth in class CellPainterWrapper
      Parameters:
      cell - The cell for which the preferred width is requested.
      gc - The GC that is used for rendering.
      configRegistry - The IConfigRegistry that contains the configuration used for rendering.
      Returns:
      The preferred width of the given cell when rendered by this painter.
    • getPreferredHeight

      public int getPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
      Description copied from interface: ICellPainter
      Get the preferred height of the cell when rendered by this painter. Used for auto-resize.
      Specified by:
      getPreferredHeight in interface ICellPainter
      Overrides:
      getPreferredHeight in class CellPainterWrapper
      Parameters:
      cell - The cell for which the preferred height is requested.
      gc - The GC that is used for rendering.
      configRegistry - The IConfigRegistry that contains the configuration used for rendering.
      Returns:
      The preferred height of the given cell when rendered by this painter.
    • getCellPainterAt

      public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
      Specified by:
      getCellPainterAt in interface ICellPainter
      Overrides:
      getCellPainterAt in class CellPainterWrapper
    • 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 BackgroundPainter
    • getImage

      protected org.eclipse.swt.graphics.Image getImage(ILayerCell cell, IConfigRegistry configRegistry)
      Parameters:
      cell - The ILayerCell for which this ImagePainter is called.
      configRegistry - The current IConfigRegistry to retrieve the cell style information from.
      Returns:
      The Image that should be painted by this ImagePainter.
    • isCalculateByWidth

      public boolean isCalculateByWidth()
      Returns:
      true if this ImagePainter is resizing the cell width to show the whole configured image, false if the cell width is not touched by this painter.
    • setCalculateByWidth

      public void setCalculateByWidth(boolean calculateByWidth)
      Configure whether the ImagePainter should calculate the cell dimensions by containing image width. This means the width of the cell is calculated by image width.
      Parameters:
      calculateByWidth - true to calculate and modify the cell dimension according to the image width, false to not modifying the cell dimensions.
    • isCalculateByHeight

      public boolean isCalculateByHeight()
      Returns:
      true if this ImagePainter is resizing the cell height to show the whole configured image, false if the cell height is not touched by this painter.
    • setCalculateByHeight

      public void setCalculateByHeight(boolean calculateByHeight)
      Configure whether the ImagePainter should calculate the cell dimensions by containing image height. This means the height of the cell is calculated by image height.
      Parameters:
      calculateByHeight - true to calculate and modify the cell dimension according to the image height, false to not modifying the cell dimensions.