Class TextPrint
- java.lang.Object
-
- org.eclipse.nebula.paperclips.core.text.TextPrint
-
- All Implemented Interfaces:
Print
public class TextPrint extends java.lang.Object implements Print
A Print for displaying text.TextPrints are never greedy with layout space, even with center- or right-alignment. (Greedy prints take up all the available space on the page.) Therefore, when center- or right-alignment is required, it is necessary to wrap the text in a Print which will enforce the same alignment. Usually this is a center:default:grow or right:default:grow column in a GridPrint.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ALIGNThe default alignment for TextPrint.static org.eclipse.swt.graphics.FontDataDEFAULT_FONT_DATAThe default font data for a TextPrint.private static TextStyleDEFAULT_STYLEstatic java.lang.StringDEFAULT_TEXTThe default text for a TextPrint.(package private) TextStylestyle(package private) java.lang.Stringtext(package private) booleanwordSplitting
-
Constructor Summary
Constructors Constructor Description TextPrint()Constructs a TextPrint with the default properties.TextPrint(java.lang.String text)Constructs a TextPrint with the given text.TextPrint(java.lang.String text, int align)Constructs a TextPrint with the give text and alignment.TextPrint(java.lang.String text, TextStyle style)Constructs a TextPrint with the given text and style.TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData)Constructs a TextPrint with the given text and font data.TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData, int align)Constructs a TextPrint with the given text, font data, and alignment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)intgetAlignment()Returns the horizontal text alignment.org.eclipse.swt.graphics.RGBgetBackground()Returns the background color.org.eclipse.swt.graphics.FontDatagetFontData()Returns the font that will be used to print the text.org.eclipse.swt.graphics.RGBgetForeground()Returns the foreground color.booleangetStrikeout()Returns the strikout flag.TextStylegetStyle()Returns the text style.java.lang.StringgetText()Returns the text that will be printed.booleangetUnderline()Returns the underline flag.booleangetWordSplitting()Returns whether word splitting is enabled.inthashCode()PrintIteratoriterator(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)Returns a PrintIterator for laying out the contents of this Print.voidsetAlignment(int alignment)Sets the horizontal text alignment.voidsetBackground(org.eclipse.swt.graphics.RGB background)Sets the background color to the argument.voidsetFontData(org.eclipse.swt.graphics.FontData fontData)Sets the font that will be used to print the text.voidsetForeground(org.eclipse.swt.graphics.RGB foreground)Sets the foreground color to the argument.voidsetStrikeout(boolean strikeout)Sets the strikeout flag to the argument.voidsetStyle(TextStyle style)Sets the text style to the argument.voidsetText(java.lang.String text)Sets the text that will be printed.voidsetUnderline(boolean underline)Sets the underline flag to the argument.voidsetWordSplitting(boolean wordBreaking)Sets whether word splitting is enabled.
-
-
-
Field Detail
-
DEFAULT_TEXT
public static final java.lang.String DEFAULT_TEXT
The default text for a TextPrint. Value is "".- See Also:
- Constant Field Values
-
DEFAULT_FONT_DATA
public static final org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATA
The default font data for a TextPrint. Value is device-dependent.
-
DEFAULT_ALIGN
public static final int DEFAULT_ALIGN
The default alignment for TextPrint. Value is SWT.LEFT.- See Also:
- Constant Field Values
-
DEFAULT_STYLE
private static final TextStyle DEFAULT_STYLE
-
text
java.lang.String text
-
style
TextStyle style
-
wordSplitting
boolean wordSplitting
-
-
Constructor Detail
-
TextPrint
public TextPrint()
Constructs a TextPrint with the default properties.
-
TextPrint
public TextPrint(java.lang.String text)
Constructs a TextPrint with the given text.- Parameters:
text- the text to print.
-
TextPrint
public TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData)Constructs a TextPrint with the given text and font data.- Parameters:
text- the text to print.fontData- the font that will be used to print the text.
-
TextPrint
public TextPrint(java.lang.String text, int align)Constructs a TextPrint with the give text and alignment.- Parameters:
text- the text to print.align- the horizontal text alignment. Must be one ofSWT.LEFT,SWT.CENTERorSWT.RIGHT.
-
TextPrint
public TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData, int align)Constructs a TextPrint with the given text, font data, and alignment.- Parameters:
text- the text to print.fontData- the font that will be used to print the text.align- the horizontal text alignment. Must be one ofSWT.LEFT,SWT.CENTERorSWT.RIGHT.
-
TextPrint
public TextPrint(java.lang.String text, TextStyle style)Constructs a TextPrint with the given text and style.- Parameters:
text- the text to print.style- the style to apply to the text.
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getText
public java.lang.String getText()
Returns the text that will be printed.- Returns:
- the text that will be printed.
-
setText
public void setText(java.lang.String text)
Sets the text that will be printed.- Parameters:
text- the text to print.
-
getStyle
public TextStyle getStyle()
Returns the text style.- Returns:
- the text style.
-
setStyle
public void setStyle(TextStyle style)
Sets the text style to the argument.- Parameters:
style- the new text style.
-
getFontData
public org.eclipse.swt.graphics.FontData getFontData()
Returns the font that will be used to print the text.- Returns:
- the font that will be used to print the text.
-
setFontData
public void setFontData(org.eclipse.swt.graphics.FontData fontData)
Sets the font that will be used to print the text.- Parameters:
fontData- the font that will be used to print the text.
-
getAlignment
public int getAlignment()
Returns the horizontal text alignment. Possible values includeSWT.LEFT,SWT.CENTERorSWT.RIGHT.- Returns:
- the horizontal text alignment.
-
setAlignment
public void setAlignment(int alignment)
Sets the horizontal text alignment.- Parameters:
alignment- the horizontal text alignment. Must be one ofSWT.LEFT,SWT.CENTERorSWT.RIGHT.
-
getForeground
public org.eclipse.swt.graphics.RGB getForeground()
Returns the foreground color. A null value indicates that the foreground color is inherited.- Returns:
- the foreground color.
-
setForeground
public void setForeground(org.eclipse.swt.graphics.RGB foreground)
Sets the foreground color to the argument.- Parameters:
foreground- the new foreground color. A null value causes the foreground color to be inherited.
-
getBackground
public org.eclipse.swt.graphics.RGB getBackground()
Returns the background color. A null value indicates that the background is transparent.- Returns:
- the background color.
-
setBackground
public void setBackground(org.eclipse.swt.graphics.RGB background)
Sets the background color to the argument.- Parameters:
background- the new background color. A null value causes the background to be transparent.
-
getUnderline
public boolean getUnderline()
Returns the underline flag.- Returns:
- the underline flag.
-
setUnderline
public void setUnderline(boolean underline)
Sets the underline flag to the argument.- Parameters:
underline- the underline flag.
-
getStrikeout
public boolean getStrikeout()
Returns the strikout flag.- Returns:
- the strikout flag.
-
setStrikeout
public void setStrikeout(boolean strikeout)
Sets the strikeout flag to the argument.- Parameters:
strikeout- the strikeout flag.
-
getWordSplitting
public boolean getWordSplitting()
Returns whether word splitting is enabled. Default is true.- Returns:
- whether word splitting is enabled.
-
setWordSplitting
public void setWordSplitting(boolean wordBreaking)
Sets whether word splitting is enabled.- Parameters:
wordBreaking- whether to allow word splitting.
-
iterator
public PrintIterator iterator(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
Description copied from interface:PrintReturns a PrintIterator for laying out the contents of this Print. The iterator uses a snapshot of the print at the time this method is invoked, so subsequent changes to the Print will not affect the output of the iterator.
-
-