public abstract class AbstractTextPainter extends BackgroundPainter
Modifier and Type | Field and Description |
---|---|
protected boolean |
calculateByTextHeight |
protected boolean |
calculateByTextLength |
static String |
DOT |
static String |
EMPTY |
static String |
LINE_SEPARATOR |
static String |
NEW_LINE_REGEX
The regular expression to find predefined new lines in the text to show.
|
protected boolean |
paintBg |
protected boolean |
paintFg |
protected int |
spacing |
protected boolean |
wrapText |
Constructor and Description |
---|
AbstractTextPainter() |
AbstractTextPainter(boolean wrapText,
boolean paintBg) |
AbstractTextPainter(boolean wrapText,
boolean paintBg,
boolean calculate) |
AbstractTextPainter(boolean wrapText,
boolean paintBg,
boolean calculateByTextLength,
boolean calculateByTextHeight) |
AbstractTextPainter(boolean wrapText,
boolean paintBg,
int spacing) |
AbstractTextPainter(boolean wrapText,
boolean paintBg,
int spacing,
boolean calculate) |
AbstractTextPainter(boolean wrapText,
boolean paintBg,
int spacing,
boolean calculateByTextLength,
boolean calculateByTextHeight) |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
calculatePadding(ILayerCell cell,
int availableLength)
This method is used to determine the padding from the cell to the available length.
|
protected String |
convertDataType(ILayerCell cell,
IConfigRegistry configRegistry)
Convert the data value of the cell using the
IDisplayConverter from the IConfigRegistry |
protected int |
getLengthFromCache(org.eclipse.swt.graphics.GC gc,
String text)
Calculates the length of a given text by using the GC.
|
protected int |
getNumberOfNewLines(String text)
Scans for new line characters and counts the number of lines
for the given text.
|
protected String |
getTextToDisplay(ILayerCell cell,
org.eclipse.swt.graphics.GC gc,
int availableLength,
String text)
Computes dependent on the configuration of the TextPainter the text to display.
|
protected boolean |
renderStrikethrough(IStyle cellStyle)
Checks if there is a strikethrough text decoration configured within the given cell style.
|
protected boolean |
renderUnderlined(IStyle cellStyle)
Checks if there is a underline text decoration configured within the given cell style.
|
protected abstract void |
setNewMinLength(ILayerCell cell,
int contentLength)
This method gets only called if automatic length calculation is enabled.
|
void |
setStrikethrough(boolean strikethrough)
Set if the text should be rendered strikethrough or not.
|
void |
setUnderline(boolean underline)
Set if the text should be rendered underlined or not.
|
void |
setupGCFromConfig(org.eclipse.swt.graphics.GC gc,
IStyle cellStyle)
Setup the GC by the values defined in the given cell style.
|
getBackgroundColour, paintCell
getCellPainterAt, getPreferredHeight, getPreferredWidth, getWrappedPainter, getWrappedPainterBounds, setWrappedPainter
public static final String EMPTY
public static final String DOT
public static final String NEW_LINE_REGEX
public static final String LINE_SEPARATOR
protected final boolean wrapText
protected final boolean paintBg
protected boolean paintFg
protected int spacing
protected final boolean calculateByTextLength
protected final boolean calculateByTextHeight
public AbstractTextPainter()
public AbstractTextPainter(boolean wrapText, boolean paintBg)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEpublic AbstractTextPainter(boolean wrapText, boolean paintBg, int spacing)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEspacing
- The space between text and cell borderpublic AbstractTextPainter(boolean wrapText, boolean paintBg, boolean calculate)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEcalculate
- tells the text painter to calculate the cell borders regarding the contentpublic AbstractTextPainter(boolean wrapText, boolean paintBg, boolean calculateByTextLength, boolean calculateByTextHeight)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEcalculateByTextLength
- tells the text painter to calculate the cell border by containing
text length. For horizontal text rendering, this means the width of the cell is calculated
by content, for vertical text rendering the height is calculatedcalculateByTextHeight
- tells the text painter to calculate the cell border by containing
text height. For horizontal text rendering, this means the height of the cell is calculated
by content, for vertical text rendering the width is calculatedpublic AbstractTextPainter(boolean wrapText, boolean paintBg, int spacing, boolean calculate)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEspacing
- The space between text and cell bordercalculate
- tells the text painter to calculate the cell borders regarding the contentpublic AbstractTextPainter(boolean wrapText, boolean paintBg, int spacing, boolean calculateByTextLength, boolean calculateByTextHeight)
wrapText
- split text over multiple linespaintBg
- skips painting the background if is FALSEspacing
- The space between text and cell bordercalculateByTextLength
- tells the text painter to calculate the cell border by containing
text length. For horizontal text rendering, this means the width of the cell is calculated
by content, for vertical text rendering the height is calculatedcalculateByTextHeight
- tells the text painter to calculate the cell border by containing
text height. For horizontal text rendering, this means the height of the cell is calculated
by content, for vertical text rendering the width is calculatedprotected String convertDataType(ILayerCell cell, IConfigRegistry configRegistry)
IDisplayConverter
from the IConfigRegistry
public void setupGCFromConfig(org.eclipse.swt.graphics.GC gc, IStyle cellStyle)
gc
- cellStyle
- protected boolean renderUnderlined(IStyle cellStyle)
cellStyle
- The cell style of the current cell to check for the text decoration.true
if there is a underline text decoration configured,
false
otherwise.protected boolean renderStrikethrough(IStyle cellStyle)
cellStyle
- The cell style of the current cell to check for the text decoration.true
if there is a strikethrough text decoration configured,
false
otherwise.protected int getNumberOfNewLines(String text)
text
- the text to scanprotected int getLengthFromCache(org.eclipse.swt.graphics.GC gc, String text)
gc
- the current GCtext
- the text to get the length forprotected String getTextToDisplay(ILayerCell cell, org.eclipse.swt.graphics.GC gc, int availableLength, String text)
cell
- the current cell to paintgc
- the current GCavailableLength
- the available space for the text to displaytext
- the text that should be modified for displayprotected abstract void setNewMinLength(ILayerCell cell, int contentLength)
cell
- the current cell that is paintedcontentLength
- the length of the contentprotected abstract int calculatePadding(ILayerCell cell, int availableLength)
cell
- the current cell which should be resizedavailableLength
- the length value that is available and was given into paintCell()
as Rectangle argumentpublic void setUnderline(boolean underline)
underline
- true
if the text should be printed underlined,
false
if notpublic void setStrikethrough(boolean strikethrough)
strikethrough
- true
if the text should be printed strikethrough,
false
if notCopyright © 2013. All Rights Reserved.