Class PageNumberPrint
- java.lang.Object
-
- org.eclipse.nebula.paperclips.core.page.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 aPagePrint. To properly display page numbers, instances of this class should be created using thePageNumberargument which is passed to thePageDecoration.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 intDEFAULT_ALIGNThe default alignment for a PageNumberPrint.static org.eclipse.swt.graphics.FontDataDEFAULT_FONT_DATAThe default font data for a PageNumberPrint.static TextStyleDEFAULT_TEXT_STYLEThe default text style.(package private) PageNumberFormatformat(package private) PageNumberpageNumber(package private) TextStyletextStyle
-
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 private intcheckAlign(int align)booleanequals(java.lang.Object obj)intgetAlign()Returns the horizontal text alignment.org.eclipse.swt.graphics.FontDatagetFontData()Returns the text font.PageNumbergetPageNumber()Returns the page number of this Print.PageNumberFormatgetPageNumberFormat()Returns the page number format.org.eclipse.swt.graphics.RGBgetRGB()Returns the text color.TextStylegetTextStyle()Returns the text style that will be used to render the page numberinthashCode()PrintIteratoriterator(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)Returns a PrintIterator for laying out the contents of this Print.voidsetAlign(int align)Sets the horizontal text alignment to the argument.voidsetFontData(org.eclipse.swt.graphics.FontData fontData)Sets the text font to the argument.voidsetPageNumber(PageNumber pageNumber)Sets the page number to the argument.voidsetPageNumberFormat(PageNumberFormat format)Sets the format that will be used to convert the page number to a text string.voidsetRGB(org.eclipse.swt.graphics.RGB foreground)Sets the text color.voidsetTextStyle(TextStyle textStyle)Sets the text style that will be used to render the page number
-
-
-
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.
-
pageNumber
PageNumber pageNumber
-
textStyle
TextStyle textStyle
-
format
PageNumberFormat format
-
-
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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.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 ofSWT.LEFT,SWT.CENTERorSWT.RIGHT.
-
getAlign
public int getAlign()
Returns the horizontal text alignment.- Returns:
- the horizontal text alignment.
-
checkAlign
private int checkAlign(int align)
-
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:PrintReturns 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.
-
-