java.lang.Object
org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
org.eclipse.nebula.widgets.nattable.extension.nebula.richtext.RichTextCellPainter
All Implemented Interfaces:
ICellPainter

public class RichTextCellPainter extends AbstractCellPainter
ICellPainter that is able to render HTML formatted text by using the Nebula RichTextPainter.
  • Field Details

    • richTextPainter

      protected org.eclipse.nebula.widgets.richtext.RichTextPainter richTextPainter
    • calculateByTextLength

      protected boolean calculateByTextLength
      Since:
      1.1
    • calculateByTextHeight

      protected boolean calculateByTextHeight
      Since:
      1.1
  • Constructor Details

    • RichTextCellPainter

      public RichTextCellPainter()
      Creates a new RichTextCellPainter with text wrapping enabled and auto-resizing disabled.
    • RichTextCellPainter

      public RichTextCellPainter(boolean wrapText)
      Creates a new RichTextCellPainter with auto-resizing disabled.
      Parameters:
      wrapText - true to enable text wrapping, which means that text is wrapped for whole words. Words itself are not wrapped.
    • RichTextCellPainter

      public RichTextCellPainter(boolean wrapText, boolean calculate)
      Creates a new RichTextCellPainter.
      Parameters:
      wrapText - true to enable text wrapping, which means that text is wrapped for whole words. Words itself are not wrapped.
      calculate - true to configure the text painter for auto-resizing which means to calculate the cell borders regarding the content
      Since:
      1.1
    • RichTextCellPainter

      public RichTextCellPainter(boolean wrapText, boolean calculateByTextLength, boolean calculateByTextHeight)
      Creates a new RichTextCellPainter.
      Parameters:
      wrapText - true to enable text wrapping, which means that text is wrapped for whole words. Words itself are not wrapped.
      calculateByTextLength - true to configure the text painter to calculate the cell border by containing text length. This means the width of the cell is calculated by content.
      calculateByTextHeight - true to configure the text painter to calculate the cell border by containing text height. This means the height of the cell is calculated by content.
      Since:
      1.1
  • Method Details

    • paintCell

      public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
    • 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.
      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.
      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.
    • setupGCFromConfig

      public void setupGCFromConfig(org.eclipse.swt.graphics.GC gc, IStyle cellStyle)
      Setup the GC by the values defined in the given cell style.
      Parameters:
      gc - The GC that is used for rendering.
      cellStyle - The IStyle that contains the styles to apply.
    • performRowResize

      protected boolean performRowResize(int contentHeight, org.eclipse.swt.graphics.Rectangle rectangle)
      Checks if a row resize needs to be triggered.
      Parameters:
      contentHeight - The necessary height to show the content completely
      rectangle - The available rectangle to render to
      Returns:
      true if a row resize needs to be performed, false if not
      Since:
      1.1
    • performColumnResize

      protected boolean performColumnResize(int contentWidth, org.eclipse.swt.graphics.Rectangle rectangle)
      Checks if a column resize needs to be triggered.
      Parameters:
      contentWidth - The necessary width to show the content completely
      rectangle - The available rectangle to render to
      Returns:
      true if a column resize needs to be performed, false if not
      Since:
      1.1
    • isCalculateByTextLength

      public boolean isCalculateByTextLength()
      Returns:
      true if this text painter is calculating the cell dimensions by containing text length. This means the width of the cell is calculated by content.
      Since:
      1.1
    • setCalculateByTextLength

      public void setCalculateByTextLength(boolean calculateByTextLength)
      Configure whether the text painter should calculate the cell dimensions by containing text length. This means the width of the cell is calculated by content.
      Parameters:
      calculateByTextLength - true to calculate and modify the cell dimension according to the text length, false to not modifying the cell dimensions.
      Since:
      1.1
    • isCalculateByTextHeight

      public boolean isCalculateByTextHeight()
      Returns:
      true if this text painter is calculating the cell dimensions by containing text height. This means the height of the cell is calculated by content.
      Since:
      1.1
    • setCalculateByTextHeight

      public void setCalculateByTextHeight(boolean calculateByTextHeight)
      Configure whether the text painter should calculate the cell dimensions by containing text height. This means the height of the cell is calculated by content.
      Parameters:
      calculateByTextHeight - true to calculate and modify the cell dimension according to the text height, false to not modifying the cell dimensions.
      Since:
      1.1
    • getHtmlText

      protected String getHtmlText(ILayerCell cell, IConfigRegistry configRegistry)
      Returns the HTML text for the data that should be shown in the given ILayerCell.
      Parameters:
      cell - The cell for which the data should be shown.
      configRegistry - The IConfigRegistry to retrieve the configurations like e.g. the IDisplayConverter.
      Returns:
      The data to be shown in the cell as HTML text.
      Since:
      2.1