Package net.sf.paperclips
Class TextPrint
java.lang.Object
net.sf.paperclips.TextPrint
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final int
The default alignment for TextPrint.static final org.eclipse.swt.graphics.FontData
The default font data for a TextPrint.static final String
The default text for a TextPrint. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a TextPrint with the default properties.Constructs a TextPrint with the given text.Constructs a TextPrint with the give text and alignment.Constructs a TextPrint with the given text and style.Constructs a TextPrint with the given text and font data.Constructs a TextPrint with the given text, font data, and alignment. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
getAlign()
Deprecated.int
Returns the horizontal text alignment.org.eclipse.swt.graphics.RGB
Returns the background color.org.eclipse.swt.graphics.FontData
Returns the font that will be used to print the text.org.eclipse.swt.graphics.RGB
Returns the foreground color.org.eclipse.swt.graphics.RGB
getRGB()
Deprecated.UsegetForeground()
instead.boolean
Returns the strikout flag.getStyle()
Returns the text style.getText()
Returns the text that will be printed.boolean
Returns the underline flag.boolean
Returns whether word splitting is enabled.int
hashCode()
iterator
(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc) Returns a PrintIterator for laying out the contents of this Print.void
setAlign
(int alignment) Deprecated.UsesetAlignment(int)
instead.void
setAlignment
(int alignment) Sets the horizontal text alignment.void
setBackground
(org.eclipse.swt.graphics.RGB background) Sets the background color to the argument.void
setFontData
(org.eclipse.swt.graphics.FontData fontData) Sets the font that will be used to print the text.void
setForeground
(org.eclipse.swt.graphics.RGB foreground) Sets the foreground color to the argument.void
setRGB
(org.eclipse.swt.graphics.RGB foreground) Deprecated.UsesetForeground(RGB)
instead.void
setStrikeout
(boolean strikeout) Sets the strikeout flag to the argument.void
Sets the text style to the argument.void
Sets the text that will be printed.void
setUnderline
(boolean underline) Sets the underline flag to the argument.void
setWordSplitting
(boolean wordBreaking) Sets whether word splitting is enabled.
-
Field Details
-
DEFAULT_TEXT
The default text for a TextPrint. Value is "".- See Also:
-
DEFAULT_FONT_DATA
public static final org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATAThe default font data for a TextPrint. Value is device-dependent. -
DEFAULT_ALIGN
public static final int DEFAULT_ALIGNThe default alignment for TextPrint. Value is SWT.LEFT.- See Also:
-
-
Constructor Details
-
TextPrint
public TextPrint()Constructs a TextPrint with the default properties. -
TextPrint
Constructs a TextPrint with the given text.- Parameters:
text
- the text to print.
-
TextPrint
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
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.CENTER
orSWT.RIGHT
.
-
TextPrint
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.CENTER
orSWT.RIGHT
.
-
TextPrint
Constructs a TextPrint with the given text and style.- Parameters:
text
- the text to print.style
- the style to apply to the text.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getText
Returns the text that will be printed.- Returns:
- the text that will be printed.
-
setText
Sets the text that will be printed.- Parameters:
text
- the text to print.
-
getStyle
Returns the text style.- Returns:
- the text style.
-
setStyle
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.
-
getAlign
public int getAlign()Deprecated.UsegetAlignment()
instead.Returns the horizontal text alignment. Possible values includeSWT.LEFT
,SWT.CENTER
orSWT.RIGHT
.- Returns:
- the horizontal text alignment.
-
setAlign
public void setAlign(int alignment) Deprecated.UsesetAlignment(int)
instead.Sets the horizontal text alignment.- Parameters:
alignment
- the horizontal text alignment. Must be one ofSWT.LEFT
,SWT.CENTER
orSWT.RIGHT
.
-
getAlignment
public int getAlignment()Returns the horizontal text alignment. Possible values includeSWT.LEFT
,SWT.CENTER
orSWT.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.CENTER
orSWT.RIGHT
.
-
getRGB
public org.eclipse.swt.graphics.RGB getRGB()Deprecated.UsegetForeground()
instead.Returns the foreground color.- Returns:
- the foreground color.
-
setRGB
public void setRGB(org.eclipse.swt.graphics.RGB foreground) Deprecated.UsesetForeground(RGB)
instead.Sets the foreground color to the argument.- Parameters:
foreground
- the new foreground color.
-
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:Print
Returns 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.
-
getAlignment()
instead.