Package ca.cgjennings.apps.arkham.deck
Class PaperSplitter
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.PaperSplitter
-
public final class PaperSplitter extends java.lang.Object
Prints large virtual pages by tiling them over multiple physical pages.- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description PaperSplitter(PaperProperties virtualPaper, PaperProperties physicalPaper)
Create a layout for splitting a virtual page over one or more physical ones.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.print.Printable
createPrintable(java.awt.print.Printable virtualPrintable)
Returns a printable capable of printing physical pages by delegating to a printable that prints virtual pages.int
getPhysicalColumn(int physicalPage)
Given a physical page number in the final printed document, returns its tile column.int
getPhysicalColumns()
Returns the number of columns of physical pages required for each virtual page.int
getPhysicalPageBeingPrinted()
Returns the index of the last physical page that was printed using a Printable instance created withcreatePrintable(java.awt.print.Printable)
.int
getPhysicalPagesPerPage()
Returns the number of physical pages required for each virtual page.int
getPhysicalRow(int physicalPage)
Given a physical page number in the final printed document, returns its tile row.int
getPhysicalRows()
Returns the number of rows of physical pages required for each virtual page.java.awt.Color
getPrintableFrameColor()
float
getPrintableFrameWidth()
java.awt.geom.Point2D
getPrintOffsetForPage(int physicalPage)
Returns the offset to translate the virtual graphics context by to map it to a physical page.int
getTotalPhysicalPagesRequired(int virtualPageCount)
Returns the total number of physical pages needed to print a document.int
getVirtualPageForPage(int physicalPage)
Given a physical page number, determine the number of the virtual page being printed (assuming that they are all the same size).boolean
isPrintableBounded()
void
setPrintableBounded(boolean printableBounded)
void
setPrintableFrameColor(java.awt.Color printableFrameColor)
void
setPrintableFrameWidth(float printableFrameWidth)
-
-
-
Constructor Detail
-
PaperSplitter
public PaperSplitter(PaperProperties virtualPaper, PaperProperties physicalPaper)
Create a layout for splitting a virtual page over one or more physical ones. If the two paper types are the same, returns a special configuration that maps the two pages to each other exactly. Otherwise, a layout is created as follows:The printable area of each page is taken to be its margin. The upper-left corner of the document is mapped to the upper-left margin of the first page. The following pages assume that only the area within the margins was printed, and adjust the page to line up that edge with the margin of the next page.
- Parameters:
virtualPaper
-physicalPaper
-
-
-
Method Detail
-
getPrintOffsetForPage
public java.awt.geom.Point2D getPrintOffsetForPage(int physicalPage)
Returns the offset to translate the virtual graphics context by to map it to a physical page.- Parameters:
physicalPage
- the physical page being printed- Returns:
- the amount by which to translate the virtual page before printing
-
getVirtualPageForPage
public int getVirtualPageForPage(int physicalPage)
Given a physical page number, determine the number of the virtual page being printed (assuming that they are all the same size). Essentially, this isfloor(physicalPage/getPhysicalPagesPerPage())
.- Returns:
- the virtual page number
-
getPhysicalColumn
public int getPhysicalColumn(int physicalPage)
Given a physical page number in the final printed document, returns its tile column.- Parameters:
physicalPage
- the physical page number- Returns:
- the tile column of the page
-
getPhysicalRow
public int getPhysicalRow(int physicalPage)
Given a physical page number in the final printed document, returns its tile row.- Parameters:
physicalPage
- the physical page number- Returns:
- the tile row of the page
-
getPhysicalColumns
public int getPhysicalColumns()
Returns the number of columns of physical pages required for each virtual page.- Returns:
- the number of columns of tiled pages
-
getPhysicalRows
public int getPhysicalRows()
Returns the number of rows of physical pages required for each virtual page.- Returns:
- the number of rows of tiled pages
-
getPhysicalPagesPerPage
public int getPhysicalPagesPerPage()
Returns the number of physical pages required for each virtual page.- Returns:
- the number of printed pages required to tile a single virtual page
-
getTotalPhysicalPagesRequired
public int getTotalPhysicalPagesRequired(int virtualPageCount)
Returns the total number of physical pages needed to print a document.- Returns:
- the number of pages required to print
virtualPageCount
virtual pages
-
createPrintable
public java.awt.print.Printable createPrintable(java.awt.print.Printable virtualPrintable)
Returns a printable capable of printing physical pages by delegating to a printable that prints virtual pages. If the virtual printable takes up more than one physical page, then it will be printed multiple times using different translation and clip settings to cover the matching physical pages.
-
getPhysicalPageBeingPrinted
public int getPhysicalPageBeingPrinted()
Returns the index of the last physical page that was printed using a Printable instance created withcreatePrintable(java.awt.print.Printable)
. This is provided mainly for debugging from within the virtual printable'sprint
method.- Returns:
- the physical page last printed by a printable created from this splitter
-
isPrintableBounded
public boolean isPrintableBounded()
-
setPrintableBounded
public void setPrintableBounded(boolean printableBounded)
-
getPrintableFrameWidth
public float getPrintableFrameWidth()
-
setPrintableFrameWidth
public void setPrintableFrameWidth(float printableFrameWidth)
-
getPrintableFrameColor
public java.awt.Color getPrintableFrameColor()
-
setPrintableFrameColor
public void setPrintableFrameColor(java.awt.Color printableFrameColor)
-
-