All Implemented Interfaces:
ICellPainter

public class PaddingDecorator extends CellPainterWrapper
CellPainterWrapper that adds a padding between the cell border and the interior painter.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PaddingDecorator(ICellPainter interiorPainter)
    Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
    If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.
    PaddingDecorator(ICellPainter interiorPainter, boolean paintBg)
    Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
    This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.
    PaddingDecorator(ICellPainter interiorPainter, int padding)
    Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
    If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.
    PaddingDecorator(ICellPainter interiorPainter, int padding, boolean paintBg)
    Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
    This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.
    PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding)
    Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
    If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.
    PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding, boolean paintBg)
    Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
    This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.eclipse.swt.graphics.Color
    Extract the background color that is registered for the given ILayerCell.
    int
     
    getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
     
    org.eclipse.swt.graphics.Rectangle
    getInteriorBounds(org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
    Calculates the cell bounds that should be used for the internal painter out of the available bounds for this PaddingDecorator and the configured padding.
    int
     
    int
    getPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
    Get the preferred height of the cell when rendered by this painter.
    int
    getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
    Get the preferred width of the cell when rendered by this painter.
    int
     
    int
     
    void
    paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
     

    Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper

    getWrappedPainter, getWrappedPainterBounds, setWrappedPainter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter)
      Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
      If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.
      Parameters:
      interiorPainter - The painter that should be wrapped.
    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter, boolean paintBg)
      Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
      This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to be false to avoid rendering issues.
      Parameters:
      interiorPainter - The painter that should be wrapped.
      paintBg - true if the PaddingDecorator should paint the background, false if not.
    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter, int padding)
      Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
      If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.
      Parameters:
      interiorPainter - The painter that should be wrapped.
      padding - The number of pixels that should be used as padding on every side.
    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter, int padding, boolean paintBg)
      Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
      This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to be false to avoid rendering issues.
      Parameters:
      interiorPainter - The painter that should be wrapped.
      padding - The number of pixels that should be used as padding on every side.
      paintBg - true if the PaddingDecorator should paint the background, false if not.
    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding)
      Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
      If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.
      Parameters:
      interiorPainter - The painter that should be wrapped.
      topPadding - The number of pixels that should be used as padding on top.
      rightPadding - The number of pixels that should be used as padding to the right.
      bottomPadding - The number of pixels that should be used as padding at the bottom.
      leftPadding - The number of pixels that should be used as padding to the left.
    • PaddingDecorator

      public PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding, boolean paintBg)
      Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
      This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to be false to avoid rendering issues.
      Parameters:
      interiorPainter - The painter that should be wrapped.
      topPadding - The number of pixels that should be used as padding on top.
      rightPadding - The number of pixels that should be used as padding to the right.
      bottomPadding - The number of pixels that should be used as padding at the bottom.
      leftPadding - The number of pixels that should be used as padding to the left.
      paintBg - true if the PaddingDecorator should paint the background, false if not.
  • 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.
    • paintCell

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

      public org.eclipse.swt.graphics.Rectangle getInteriorBounds(org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Calculates the cell bounds that should be used for the internal painter out of the available bounds for this PaddingDecorator and the configured padding.
      Parameters:
      adjustedCellBounds - The cell bounds of the cell to render.
      configRegistry - The IConfigRegistry needed for accessing the dpi converter.
      Returns:
      The cell bounds that are available for the interior painter.
      Since:
      2.0
    • getBackgroundColor

      protected org.eclipse.swt.graphics.Color getBackgroundColor(ILayerCell cell, IConfigRegistry configRegistry)
      Extract the background color that is registered for the given ILayerCell.
      Parameters:
      cell - The cell for which the background color is requested.
      configRegistry - The IConfigRegistry which contains the style configurations.
      Returns:
      The background color that should be used to render the background of the given cell.
    • getCellPainterAt

      public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Specified by:
      getCellPainterAt in interface ICellPainter
      Overrides:
      getCellPainterAt in class CellPainterWrapper
    • getTopPadding

      public int getTopPadding()
      Returns:
      The top padding added by this PaddingDecorator.
      Since:
      1.4
    • getRightPadding

      public int getRightPadding()
      Returns:
      The right padding added by this PaddingDecorator.
      Since:
      1.4
    • getBottomPadding

      public int getBottomPadding()
      Returns:
      The bottom padding added by this PaddingDecorator.
      Since:
      1.4
    • getLeftPadding

      public int getLeftPadding()
      Returns:
      The left padding added by this PaddingDecorator.
      Since:
      1.4