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 int DEFAULT_ALIGN
    The default alignment for TextPrint.
    static org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATA
    The default font data for a TextPrint.
    static java.lang.String DEFAULT_TEXT
    The default text for a TextPrint.
    (package private) TextStyle style  
    (package private) java.lang.String text  
    (package private) boolean wordSplitting  
  • 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

    Modifier and Type Method Description
    boolean equals​(java.lang.Object obj)  
    int getAlignment()
    Returns the horizontal text alignment.
    org.eclipse.swt.graphics.RGB getBackground()
    Returns the background color.
    org.eclipse.swt.graphics.FontData getFontData()
    Returns the font that will be used to print the text.
    org.eclipse.swt.graphics.RGB getForeground()
    Returns the foreground color.
    boolean getStrikeout()
    Returns the strikout flag.
    TextStyle getStyle()
    Returns the text style.
    java.lang.String getText()
    Returns the text that will be printed.
    boolean getUnderline()
    Returns the underline flag.
    boolean getWordSplitting()
    Returns whether word splitting is enabled.
    int hashCode()  
    PrintIterator 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 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 setStrikeout​(boolean strikeout)
    Sets the strikeout flag to the argument.
    void setStyle​(TextStyle style)
    Sets the text style to the argument.
    void setText​(java.lang.String text)
    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

  • Constructor Details

    • 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 of SWT.LEFT , SWT.CENTER or SWT.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 of SWT.LEFT , SWT.CENTER or SWT.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 Details

    • hashCode

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

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.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 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.
    • 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.