|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nih.nlm.util.OnePagePrintable
Handles printing of the contents of a JEditorPane
,
JTree
, and JTable
using one page 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 int |
current_page
|
protected JEditorPane |
jeditor_pane
|
protected JTable |
jtable
|
protected JTree |
jtree
|
protected double |
page_end_y
|
protected double |
page_start_y
|
protected int |
pages_printed
|
protected String |
title
|
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
OnePagePrintable(JEditorPane jp,
String title)
Instantiates OnePagePrintable using the
specified JEditorPane and String title. |
|
OnePagePrintable(JTable jt,
String title)
Instantiates OnePagePrintable using the
specified JTable and String title. |
|
OnePagePrintable(JTree jt,
String title)
Instantiates OnePagePrintable using the
specified JTree and String title. |
Method Summary | |
int |
getPagesPrinted()
Returns the number of pages printed. |
boolean |
getScaleWidthToFit()
Indicates whether or not the content should be scaled to fit the 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 indicating whether or not to scale the content. |
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 int current_page
protected JEditorPane jeditor_pane
protected JTable jtable
protected JTree jtree
protected double page_end_y
protected double page_start_y
protected int pages_printed
protected String title
Constructor Detail |
public OnePagePrintable(JEditorPane jp, String title)
OnePagePrintable
using the
specified JEditorPane
and String
title.
jp
- the JEditorPane
to printtitle
- the titlepublic OnePagePrintable(JTable jt, String title)
OnePagePrintable
using the
specified JTable
and String
title.
jt
- the JTable
to printtitle
- the titlepublic OnePagePrintable(JTree jt, String title)
OnePagePrintable
using the
specified JTree
and String
title.
jt
- the JTree
to printtitle
- the titleMethod Detail |
public int getPagesPrinted()
public int print(Graphics graphics, PageFormat page_format, int page_index)
Printable
interface. The code
prints one logical page per sheet of paper with a title
bar.
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 it should, false
otherwisepublic void setScaleWidthToFit(boolean scale_width)
scale_width
- A boolean
flag indiciating whether
or not to scale the content to fit the width of the pagepublic void setScalingFactor(double scaling_factor)
scaling_factor
- the scaling factorpublic double getScalingFactor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |