Class RichTextCellPainter
- 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 NebulaRichTextPainter
.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
calculateByTextHeight
protected boolean
calculateByTextLength
protected org.eclipse.nebula.widgets.richtext.RichTextPainter
richTextPainter
-
Constructor Summary
Constructors Constructor Description RichTextCellPainter()
Creates a newRichTextCellPainter
with text wrapping enabled and auto-resizing disabled.RichTextCellPainter(boolean wrapText)
Creates a newRichTextCellPainter
with auto-resizing disabled.RichTextCellPainter(boolean wrapText, boolean calculate)
Creates a newRichTextCellPainter
.RichTextCellPainter(boolean wrapText, boolean calculateByTextLength, boolean calculateByTextHeight)
Creates a newRichTextCellPainter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.boolean
isCalculateByTextHeight()
boolean
isCalculateByTextLength()
void
paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
protected boolean
performColumnResize(int contentWidth, org.eclipse.swt.graphics.Rectangle rectangle)
Checks if a column resize needs to be triggered.protected boolean
performRowResize(int contentHeight, org.eclipse.swt.graphics.Rectangle rectangle)
Checks if a row resize needs to be triggered.void
setCalculateByTextHeight(boolean calculateByTextHeight)
Configure whether the text painter should calculate the cell dimensions by containing text height.void
setCalculateByTextLength(boolean calculateByTextLength)
Configure whether the text painter should calculate the cell dimensions by containing text length.void
setupGCFromConfig(org.eclipse.swt.graphics.GC gc, IStyle cellStyle)
Setup theGC
by the values defined in the given cell style.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
getCellPainterAt
-
-
-
-
Constructor Detail
-
RichTextCellPainter
public RichTextCellPainter()
Creates a newRichTextCellPainter
with text wrapping enabled and auto-resizing disabled.
-
RichTextCellPainter
public RichTextCellPainter(boolean wrapText)
Creates a newRichTextCellPainter
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 newRichTextCellPainter
.- 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 newRichTextCellPainter
.- 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 Detail
-
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 theGC
by the values defined in the given cell style.- Parameters:
gc
- TheGC
that is used for rendering.cellStyle
- TheIStyle
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 completelyrectangle
- 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 completelyrectangle
- 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
-
-