Class TextPrint

java.lang.Object
net.sf.paperclips.TextPrint
All Implemented Interfaces:
Print

public class TextPrint extends 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.

Author:
Matthew Hall
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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

    Constructors
    Constructor
    Description
    Constructs a TextPrint with the default properties.
    Constructs a TextPrint with the given text.
    TextPrint(String text, int align)
    Constructs a TextPrint with the give text and alignment.
    TextPrint(String text, TextStyle style)
    Constructs a TextPrint with the given text and style.
    TextPrint(String text, org.eclipse.swt.graphics.FontData fontData)
    Constructs a TextPrint with the given text and font data.
    TextPrint(String text, org.eclipse.swt.graphics.FontData fontData, int align)
    Constructs a TextPrint with the given text, font data, and alignment.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
    Deprecated.
    Use getAlignment() instead.
    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
    Deprecated.
    Use getForeground() instead.
    boolean
    Returns the strikout flag.
    Returns the text style.
    Returns the text that will be printed.
    boolean
    Returns the underline flag.
    boolean
    Returns whether word splitting is enabled.
    int
     
    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.
    Use setAlignment(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.
    Use setForeground(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.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_TEXT

      public static final String 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_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:
  • Constructor Details

    • TextPrint

      public TextPrint()
      Constructs a TextPrint with the default properties.
    • TextPrint

      public TextPrint(String text)
      Constructs a TextPrint with the given text.
      Parameters:
      text - the text to print.
    • TextPrint

      public TextPrint(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(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 of SWT.LEFT , SWT.CENTER or SWT.RIGHT.
    • TextPrint

      public TextPrint(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 of SWT.LEFT , SWT.CENTER or SWT.RIGHT.
    • TextPrint

      public TextPrint(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 Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getText

      public String getText()
      Returns the text that will be printed.
      Returns:
      the text that will be printed.
    • setText

      public void setText(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.
    • getAlign

      public int getAlign()
      Deprecated.
      Use getAlignment() instead.
      Returns the horizontal text alignment. Possible values include SWT.LEFT, SWT.CENTER or SWT.RIGHT.
      Returns:
      the horizontal text alignment.
    • setAlign

      public void setAlign(int alignment)
      Deprecated.
      Use setAlignment(int) instead.
      Sets the horizontal text alignment.
      Parameters:
      alignment - the horizontal text alignment. Must be one of SWT.LEFT , SWT.CENTER or SWT.RIGHT.
    • getAlignment

      public int getAlignment()
      Returns the horizontal text alignment. Possible values include SWT.LEFT, SWT.CENTER or SWT.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 of SWT.LEFT , SWT.CENTER or SWT.RIGHT.
    • getRGB

      public org.eclipse.swt.graphics.RGB getRGB()
      Deprecated.
      Use getForeground() instead.
      Returns the foreground color.
      Returns:
      the foreground color.
    • setRGB

      public void setRGB(org.eclipse.swt.graphics.RGB foreground)
      Deprecated.
      Use setForeground(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.
      Specified by:
      iterator in interface Print
      Parameters:
      device - the graphics device this Print will be drawn onto.
      gc - the graphics context to be used for calculating layout and drawing the Print's contents.
      Returns:
      a PrintIterator for laying out the contents of this Print.