Class PageNumberPrint

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

public class PageNumberPrint extends Object implements Print
Displays the page number and page count within the context of a PagePrint. To properly display page numbers, instances of this class should be created using the PageNumber argument which is passed to the PageDecoration.createPrint(PageNumber) method by PagePrint.

PageNumberPrints 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 page number in a Print which will enforce the same alignment. Usually this is a center:default:grow or right:default:grow column in a GridPrint.

See Also:
  • Field Details

    • DEFAULT_FONT_DATA

      public static final org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATA
      The default font data for a PageNumberPrint. Value is device-dependent.
    • DEFAULT_ALIGN

      public static final int DEFAULT_ALIGN
      The default alignment for a PageNumberPrint. Value is SWT.LEFT.
      See Also:
    • DEFAULT_TEXT_STYLE

      public static final TextStyle DEFAULT_TEXT_STYLE
      The default text style. Value is device-dependent.
  • Constructor Details

    • PageNumberPrint

      public PageNumberPrint(PageNumber pageNumber)
      Constructs a PageNumberPrint for the given page number.
      Parameters:
      pageNumber - the page number of the page this Print will appear on.
    • PageNumberPrint

      public PageNumberPrint(PageNumber pageNumber, org.eclipse.swt.graphics.FontData fontData)
      Constructs a PageNumberPrint for the given page number and font.
      Parameters:
      pageNumber - the page number of the page this Print will appear on.
      fontData - the font that this Print will appear in.
    • PageNumberPrint

      public PageNumberPrint(PageNumber pageNumber, int align)
      Constructs a PageNumberPrint for the given page number and alignment.
      Parameters:
      pageNumber - the page number of the page this Print will appear on.
      align - the horizontal alignment of the text.
    • PageNumberPrint

      public PageNumberPrint(PageNumber pageNumber, org.eclipse.swt.graphics.FontData fontData, int align)
      Constructs a PageNumberPrint for the given page number, font and alignment.
      Parameters:
      pageNumber - the page number of the page this Print will appear on.
      fontData - the font that this Print will appear in.
      align - the horizontal alignment of the text.
    • PageNumberPrint

      public PageNumberPrint(PageNumber pageNumber, TextStyle textStyle)
      Constructs a PageNumberPrint for the given page number and text style.
      Parameters:
      pageNumber - the page number of the page this Print will appear on.
      textStyle - the text style that this Print will appear in.
  • Method Details

    • hashCode

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

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

      public void setPageNumber(PageNumber pageNumber)
      Sets the page number to the argument.
      Parameters:
      pageNumber - the new page number.
    • getPageNumber

      public PageNumber getPageNumber()
      Returns the page number of this Print.
      Returns:
      the page number of this Print.
    • setFontData

      public void setFontData(org.eclipse.swt.graphics.FontData fontData)
      Sets the text font to the argument.
      Parameters:
      fontData - the new text font.
    • getFontData

      public org.eclipse.swt.graphics.FontData getFontData()
      Returns the text font.
      Returns:
      the text font.
    • setAlign

      public void setAlign(int align)
      Sets the horizontal text alignment to the argument.
      Parameters:
      align - the horizontal alignment. Must be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT.
    • getAlign

      public int getAlign()
      Returns the horizontal text alignment.
      Returns:
      the horizontal text alignment.
    • getTextStyle

      public TextStyle getTextStyle()
      Returns the text style that will be used to render the page number
      Returns:
      the text style that will be used to render the page number
    • setTextStyle

      public void setTextStyle(TextStyle textStyle)
      Sets the text style that will be used to render the page number
      Parameters:
      textStyle - the text style
    • setPageNumberFormat

      public void setPageNumberFormat(PageNumberFormat format)
      Sets the format that will be used to convert the page number to a text string.
      Parameters:
      format - the new page number format.
    • getPageNumberFormat

      public PageNumberFormat getPageNumberFormat()
      Returns the page number format. This property determines how the PageNumber will be converted into a String representing the page number. The default value of this property formats page numbers as follows:
       Page 1 of 5
       
      Returns:
      the page number format.
    • setRGB

      public void setRGB(org.eclipse.swt.graphics.RGB foreground)
      Sets the text color.
      Parameters:
      foreground - the new text color.
    • getRGB

      public org.eclipse.swt.graphics.RGB getRGB()
      Returns the text color.
      Returns:
      the text color.
    • 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.