|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.fx.print.PrintableObject
A very useful base class for implementing a Printable object, which uses PrintPage objects to paint to each page.
| Field Summary | |
protected PageFormat |
currentPageFormat
This is the PageFormat for the page being printed now. |
protected PageRect |
currentPageRect
This is the PageRect that is currently being drawn on. |
protected PrintPage |
currentPrintPage
This is the PrintPage being used for the current page. |
protected double |
defaultBlockSize
|
protected double |
drawDPI
This is 360 by default, but you can change it to any value you want. |
protected boolean |
useImageableAreaOnly
By default whenever a new page is started a PrintPage is created that covers the entire area. |
| Fields inherited from interface ewe.fx.print.Printable |
UNKNOWN_NUMBER_OF_PAGES |
| Constructor Summary | |
PrintableObject()
|
|
| Method Summary | |
protected void |
adjustForPen(double penSize,
Rect source)
|
protected Rect |
adjustForPen(double penSize,
Rect source,
Rect destination)
A Pen size that is greater than 1 will result in lines that extend to either side of the actual line. |
int |
countPages(PageFormat pf)
By default this returns UNKNOWN_NUMBER_OF_PAGES. |
protected PointRect |
getAreaFor(int pageIndex)
This should return the area on the specified page that you want to draw on. |
protected PointRect |
getCurrentArea()
Get the current area within the current PrintPage (not within the current page). |
protected PointRect |
getCurrentFullPage()
Return the full size of the current page in points. |
protected PointRect |
getCurrentImageableArea()
Return the current page imageable area in points. |
protected int |
getHintsFor(int pageIndex)
By default this returns 0. |
protected PrintPage |
getPrintPageFor(PrintSurface printSurface,
int pageIndex)
This is done at the start of each page. |
protected double |
getXdpiFor(int pageIndex)
|
protected double |
getYdpiFor(int pageIndex)
|
protected boolean |
isWithinCurrentArea(PointRect pr)
Return if the specified area given in Points, relative to the top-left point of the current print area (as selected by getAreaFor) is within the current PageRect buffer. |
protected boolean |
print(Handle h,
Graphics g,
int pageIndex)
This is the main method you must override. |
boolean |
print(Handle handle,
PrintSurface printSurface,
PageFormat page,
int pageIndex)
Prints the page at the specified index into the specified Graphics context in the specified format. |
protected int |
scaleDimension(double pointSize)
Scale a dimension, width or height value from point size to pixels for the current PrintPage. |
protected Rect |
scaleToPixels(PointRect pr,
Rect dest)
Scale the specified PointRect to integer pixel co-ordinates for the current PageRect area. |
abstract boolean |
validatePage(PageFormat pf,
int pageIndex)
You must override to indicate whether a page is valid or not. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected double drawDPI
protected double defaultBlockSize
protected boolean useImageableAreaOnly
protected PageFormat currentPageFormat
protected PageRect currentPageRect
protected PrintPage currentPrintPage
| Constructor Detail |
public PrintableObject()
| Method Detail |
protected PointRect getCurrentImageableArea()
protected PointRect getCurrentFullPage()
protected double getXdpiFor(int pageIndex)
protected double getYdpiFor(int pageIndex)
protected PointRect getAreaFor(int pageIndex)
protected int getHintsFor(int pageIndex)
protected PrintPage getPrintPageFor(PrintSurface printSurface,
int pageIndex)
protected Rect scaleToPixels(PointRect pr,
Rect dest)
protected boolean isWithinCurrentArea(PointRect pr)
protected PointRect getCurrentArea()
protected int scaleDimension(double pointSize)
protected Rect adjustForPen(double penSize,
Rect source,
Rect destination)
protected void adjustForPen(double penSize,
Rect source)
protected boolean print(Handle h,
Graphics g,
int pageIndex)
public final boolean print(Handle handle,
PrintSurface printSurface,
PageFormat page,
int pageIndex)
PrintableWithin this method you should call printSurface.getPageRect() to get a Rectangular window onto the virtual printer page. You can then draw into the image provided by that PageRect and then afterwards, transfer the PageRect to the printer using printSurface.putPageRect().
The PageMosaic class is an excellent class for allowing you to draw onto an arbitrary section on the output page.
print in interface Printablehandle - a Handle that an outside thread can use to monitor the printing. During the printing
you should check the shouldStop value of the Handle, and if it is true, then you should abort printing
and return false.printSurface - A printSurface that you should call getPageRect() on in order to get buffers to
draw on.page - the format for the page you are printing on.pageIndex - the index of the page you are printing on, starting from index 0.
public int countPages(PageFormat pf)
countPages in interface Printable
public abstract boolean validatePage(PageFormat pf,
int pageIndex)
validatePage in interface Printable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||