|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nih.nlm.util.TwoPagePrintable
Handles printing of the contents of a JEditorPane
using two pages
per sheet of paper.
This class implements the Printable
interface, instances of this
class can also be used as the argument in the setPrintable
method of the PrinterJob class.
HTMLDocumentRenderer
Field Summary | |
protected double |
current_page
|
protected JEditorPane |
jeditor_pane
|
protected double |
page_end_y
|
protected double |
page_start_y
|
protected int[] |
page_starts
|
protected int |
pages_printed
|
protected String |
title
|
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
TwoPagePrintable(JEditorPane jp,
String title)
Instantiates the TwoPagePrintable using the
specified JEditorPane and String title. |
Method Summary | |
int |
getPagesPrinted()
Returns the number of pages printed. |
boolean |
getScaleWidthToFit()
Indicates whether or not to scale content to fit width of the page. |
double |
getScalingFactor()
Returns the scaling factor. |
int |
print(Graphics graphics,
PageFormat page_format,
int page_index)
The print method implements the Printable interface. |
protected boolean |
printView(Graphics2D graphics_2D,
Shape allocation,
View view)
printView is a recursive method which iterates through the tree structure of the view sent to it. |
void |
setScaleWidthToFit(boolean scale_width)
Sets the flag indiciating whether or not to scale content to fit the width of the page |
void |
setScalingFactor(double scaling_factor)
Set the scaling factor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected JEditorPane jeditor_pane
protected double page_end_y
protected double current_page
protected double page_start_y
protected int[] page_starts
protected int pages_printed
protected String title
Constructor Detail |
public TwoPagePrintable(JEditorPane jp, String title)
TwoPagePrintable
using the
specified JEditorPane
and String
title.
jp
- the JEditorPane
to printtitle
- the titleMethod Detail |
public int getPagesPrinted()
public int print(Graphics graphics, PageFormat page_format, int page_index)
Printable
interface. The code
prints two logical pages to the same sheet of paper with a title
bar and a vertical line separating the two pages.
print
in interface Printable
graphics
- the Graphics
representing the printerpage_format
- the PageFormat
page_index
- the page index
int
representation of printable statusprotected boolean printView(Graphics2D graphics_2D, Shape allocation, View view)
Graphics2D
object.
I. When any view starts after the beginning of the current printable
page, this means that there are pages to print and the method sets
page_exists to true.
II. When a leaf view is taller than the printable area of a page, it
cannot, of course, be broken down to fit a single page. Such a View
will be printed whenever it intersects with the Graphics2D
clip.
III. If a leaf view intersects the printable area of the graphics clip and
fits vertically within the printable area, it will be rendered.
graphics_2D
- An object Graphics2D
allocation
- An object Shape
view
- An object View
boolean
representation of page statuspublic boolean getScaleWidthToFit()
true
if the content should be scaled,
false
otherwisepublic void setScaleWidthToFit(boolean scale_width)
scale_width
- a boolean
flag indicating whether or not to scale the contentpublic void setScalingFactor(double scaling_factor)
scaling_factor
- double
public double getScalingFactor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |