Class PageIterator
- java.lang.Object
-
- org.eclipse.nebula.paperclips.core.page.PageIterator
-
- All Implemented Interfaces:
PrintIterator
class PageIterator extends java.lang.Object implements PrintIterator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
PageIterator.PageNumberer
-
Field Summary
Fields Modifier and Type Field Description (package private) PrintIterator
body
(package private) org.eclipse.swt.graphics.Device
device
(package private) PageDecoration
footer
(package private) int
footerGap
(package private) org.eclipse.swt.graphics.GC
gc
(package private) PageDecoration
header
(package private) int
headerGap
(package private) org.eclipse.swt.graphics.Point
minimumSize
(package private) PageIterator.PageNumberer
numberer
(package private) PageNumber
pageNumber
(package private) org.eclipse.swt.graphics.Point
preferredSize
-
Constructor Summary
Constructors Constructor Description PageIterator(PageIterator that)
PageIterator(PagePrint print, org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
advancePageNumber()
private org.eclipse.swt.graphics.Point
computeSize(PrintSizeStrategy strategy)
PrintIterator
copy()
Returns a copy of this PrintIterator, with all relevant internal states.private CompositeEntry
createEntry(PrintPiece piece, int y)
private PrintPiece
createResult(int height, PrintPiece headerPiece, PrintPiece bodyPiece, PrintPiece footerPiece)
private PageNumber
getCurrentPageNumber()
private PrintPiece
getDecorationPrintPiece(Print decoration, int width, int height)
boolean
hasNext()
Identifies whether any PrintPieces remain.private int
heightOf(PrintPiece piece)
org.eclipse.swt.graphics.Point
minimumSize()
Returns the minimum size PrintPiece that this Print should be broken into.PrintPiece
next(int width, int height)
Returns the next PrintPiece for the Print.org.eclipse.swt.graphics.Point
preferredSize()
Returns the smallest size PrintPiece that this Print would be broken into if print space was unlimited.
-
-
-
Field Detail
-
device
final org.eclipse.swt.graphics.Device device
-
gc
final org.eclipse.swt.graphics.GC gc
-
header
final PageDecoration header
-
headerGap
final int headerGap
-
body
final PrintIterator body
-
footerGap
final int footerGap
-
footer
final PageDecoration footer
-
numberer
final PageIterator.PageNumberer numberer
-
minimumSize
final org.eclipse.swt.graphics.Point minimumSize
-
preferredSize
final org.eclipse.swt.graphics.Point preferredSize
-
pageNumber
PageNumber pageNumber
-
-
Constructor Detail
-
PageIterator
PageIterator(PagePrint print, org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
-
PageIterator
PageIterator(PageIterator that)
-
-
Method Detail
-
computeSize
private org.eclipse.swt.graphics.Point computeSize(PrintSizeStrategy strategy)
-
hasNext
public boolean hasNext()
Description copied from interface:PrintIterator
Identifies whether any PrintPieces remain.- Specified by:
hasNext
in interfacePrintIterator
- Returns:
- whether any PrintPieces remain.
-
minimumSize
public org.eclipse.swt.graphics.Point minimumSize()
Description copied from interface:PrintIterator
Returns the minimum size PrintPiece that this Print should be broken into.Note that the size calculated by this method is a "preferred minimum," or the smallest size that the Print should normally be broken into. For a TextPrint, this is the size of the widest individual word, in pixels.
This is distinct from the "absolute minimum," which is the smallest size that a Print could possibly be broken into. For a TextPrint, this is the size of the widest individual letter, in pixels.
- Specified by:
minimumSize
in interfacePrintIterator
- Returns:
- a Point indicating the minimum size PrintPiece this PrintIterator should be broken into.
-
preferredSize
public org.eclipse.swt.graphics.Point preferredSize()
Description copied from interface:PrintIterator
Returns the smallest size PrintPiece that this Print would be broken into if print space was unlimited.For a TextPrint, this is the size of the widest line (or the whole TextPrint, if there are no line breaks), in pixels.
- Specified by:
preferredSize
in interfacePrintIterator
- Returns:
- a Point indicating the smallest size PrintPiece that this Print would be broken into if print space was unlimited.
-
next
public PrintPiece next(int width, int height)
Description copied from interface:PrintIterator
Returns the next PrintPiece for the Print.If all of the remaining contents of the Print will fit in the given space, the returned PrintPiece will include all remaining contents, and subsequent calls to
PrintIterator.hasNext()
will returnfalse
.If some, but not all of the remaining contents will fit in the given space, the returned PrintPiece will contain as much of the contents as possible, and subsequent calls to
PrintIterator.hasNext()
will returntrue
.If there is insufficient space for any of the remaining contents in the given space,
null
is returned, and subsequent calls toPrintIterator.hasNext()
will returntrue
.If subsequent calls to PrintIterator#hasNext() return
true
, this PrintIterator cannot fit any more in the given print area. Future calls to this method should provide a fresh print area. At the top level, each returned PrintPiece contains an entire page.Note: PrintIterator classes should call
PaperClips.next(PrintIterator, int, int)
instead of calling this method directly, to gain automatic results checking to ensure all Print classes are well-behaved.- Specified by:
next
in interfacePrintIterator
- Parameters:
width
- the width available on the graphics device for this iteration.height
- the height available on the graphics device for this iteration.- Returns:
- a PrintPiece that paints the next part of the Print, or null if the print area is too small. The size of the returned PrintPiece must NOT exceed the width and height indicated.
-
heightOf
private int heightOf(PrintPiece piece)
-
advancePageNumber
private void advancePageNumber()
-
getCurrentPageNumber
private PageNumber getCurrentPageNumber()
-
createResult
private PrintPiece createResult(int height, PrintPiece headerPiece, PrintPiece bodyPiece, PrintPiece footerPiece)
-
createEntry
private CompositeEntry createEntry(PrintPiece piece, int y)
-
getDecorationPrintPiece
private PrintPiece getDecorationPrintPiece(Print decoration, int width, int height)
-
copy
public PrintIterator copy()
Description copied from interface:PrintIterator
Returns a copy of this PrintIterator, with all relevant internal states. This method allows a containing iterator to "back up" the current state of its child iterators before invokingnext(int, int)
on them. The containing iterator can then safely attempt iterating its child(ren) in a variety of ways before selecting which way is the most appropriate.- Specified by:
copy
in interfacePrintIterator
- Returns:
- a deep clone of the target with all relevant internal states.
-
-