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
ICellPainter that is able to render HTML formatted text by using the
Nebula RichTextPainter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected org.eclipse.nebula.widgets.richtext.RichTextPainter -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newRichTextCellPainterwith text wrapping enabled and auto-resizing disabled.RichTextCellPainter(boolean wrapText) Creates a newRichTextCellPainterwith auto-resizing disabled.RichTextCellPainter(boolean wrapText, boolean calculate) Creates a newRichTextCellPainter.RichTextCellPainter(boolean wrapText, boolean calculateByTextLength, boolean calculateByTextHeight) Creates a newRichTextCellPainter. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetHtmlText(ILayerCell cell, IConfigRegistry configRegistry) Returns the HTML text for the data that should be shown in the givenILayerCell.intgetPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred height of the cell when rendered by this painter.intgetPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred width of the cell when rendered by this painter.booleanbooleanvoidpaintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) protected booleanperformColumnResize(int contentWidth, org.eclipse.swt.graphics.Rectangle rectangle) Checks if a column resize needs to be triggered.protected booleanperformRowResize(int contentHeight, org.eclipse.swt.graphics.Rectangle rectangle) Checks if a row resize needs to be triggered.voidsetCalculateByTextHeight(boolean calculateByTextHeight) Configure whether the text painter should calculate the cell dimensions by containing text height.voidsetCalculateByTextLength(boolean calculateByTextLength) Configure whether the text painter should calculate the cell dimensions by containing text length.voidsetupGCFromConfig(org.eclipse.swt.graphics.GC gc, IStyle cellStyle) Setup theGCby the values defined in the given cell style.Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
getCellPainterAt
-
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 newRichTextCellPainterwith text wrapping enabled and auto-resizing disabled. -
RichTextCellPainter
public RichTextCellPainter(boolean wrapText) Creates a newRichTextCellPainterwith auto-resizing disabled.- Parameters:
wrapText-trueto 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-trueto enable text wrapping, which means that text is wrapped for whole words. Words itself are not wrapped.calculate-trueto 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-trueto enable text wrapping, which means that text is wrapped for whole words. Words itself are not wrapped.calculateByTextLength-trueto 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-trueto 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:ICellPainterGet 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:ICellPainterGet 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
Setup theGCby the values defined in the given cell style.- Parameters:
gc- TheGCthat is used for rendering.cellStyle- TheIStylethat 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:
trueif a row resize needs to be performed,falseif 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:
trueif a column resize needs to be performed,falseif not- Since:
- 1.1
-
isCalculateByTextLength
public boolean isCalculateByTextLength()- Returns:
trueif 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-trueto calculate and modify the cell dimension according to the text length,falseto not modifying the cell dimensions.- Since:
- 1.1
-
isCalculateByTextHeight
public boolean isCalculateByTextHeight()- Returns:
trueif 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-trueto calculate and modify the cell dimension according to the text height,falseto not modifying the cell dimensions.- Since:
- 1.1
-
getHtmlText
Returns the HTML text for the data that should be shown in the givenILayerCell.- Parameters:
cell- The cell for which the data should be shown.configRegistry- TheIConfigRegistryto retrieve the configurations like e.g. theIDisplayConverter.- Returns:
- The data to be shown in the cell as HTML text.
- Since:
- 2.1
-