Class PageNumberPrint

  • All Implemented Interfaces:
    Print

    public class PageNumberPrint
    extends java.lang.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:
    PagePrint, PageDecoration, PageNumber, PageNumberFormat, DefaultPageNumberFormat
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_ALIGN
      The default alignment for a PageNumberPrint.
      static org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATA
      The default font data for a PageNumberPrint.
      static TextStyle DEFAULT_TEXT_STYLE
      The default text style.
    • Constructor Summary

      Constructors 
      Constructor Description
      PageNumberPrint​(PageNumber pageNumber)
      Constructs a PageNumberPrint for the given page number.
      PageNumberPrint​(PageNumber pageNumber, int align)
      Constructs a PageNumberPrint for the given page number and alignment.
      PageNumberPrint​(PageNumber pageNumber, TextStyle textStyle)
      Constructs a PageNumberPrint for the given page number and text style.
      PageNumberPrint​(PageNumber pageNumber, org.eclipse.swt.graphics.FontData fontData)
      Constructs a PageNumberPrint for the given page number and font.
      PageNumberPrint​(PageNumber pageNumber, org.eclipse.swt.graphics.FontData fontData, int align)
      Constructs a PageNumberPrint for the given page number, font and alignment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int getAlign()
      Returns the horizontal text alignment.
      org.eclipse.swt.graphics.FontData getFontData()
      Returns the text font.
      PageNumber getPageNumber()
      Returns the page number of this Print.
      PageNumberFormat getPageNumberFormat()
      Returns the page number format.
      org.eclipse.swt.graphics.RGB getRGB()
      Returns the text color.
      TextStyle getTextStyle()
      Returns the text style that will be used to render the page number
      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 setAlign​(int align)
      Sets the horizontal text alignment to the argument.
      void setFontData​(org.eclipse.swt.graphics.FontData fontData)
      Sets the text font to the argument.
      void setPageNumber​(PageNumber pageNumber)
      Sets the page number to the argument.
      void setPageNumberFormat​(PageNumberFormat format)
      Sets the format that will be used to convert the page number to a text string.
      void setRGB​(org.eclipse.swt.graphics.RGB foreground)
      Sets the text color.
      void setTextStyle​(TextStyle textStyle)
      Sets the text style that will be used to render the page number
      • Methods inherited from class java.lang.Object

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

      • 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:
        Constant Field Values
      • DEFAULT_TEXT_STYLE

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

      • 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 Detail

      • 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
      • 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.