|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nih.nlm.util.HTMLDocumentRenderer
public class HTMLDocumentRenderer
Handles printing of HTML documents. Text attributes, including
fonts, color, and small icons, will be rendered to a printed page.
HTMLDocumentRenderer computes line breaks, paginates, and performs
other formatting.
An HTMLDocument is printed by sending it as an argument to the
print(HTMLDocument) method. A PlainDocument is printed the
same way. Other types of Documents must be sent in a JEditorPane as
an argument to the print(JEditorPane) method. Printing documents in
this way will automatically display a print dialog unless the printer name
has been specified.
| Field Summary | |
|---|---|
protected JEditorPane |
jeditor_pane
|
protected PageFormat |
p_format
|
protected PrinterJob |
p_job
|
protected PrintService |
p_service
|
protected int |
pages_per_sheet
|
protected int |
pages_printed
|
protected String |
printer_name
|
protected boolean |
scale_width_to_fit
|
protected double |
scaling_factor
|
protected String |
title
|
| Constructor Summary | |
|---|---|
HTMLDocumentRenderer()
Instantiates an HTMLDocumentRenderer. |
|
| Method Summary | |
|---|---|
Document |
getDocument()
Returns the current Document. |
int |
getPagesPerSheet()
Returns the number of pages per sheet. |
String |
getPrinterName()
Returns the printer name. |
String[] |
getPrinterNames()
Returns the list of available printer names. |
boolean |
getScaleWidthToFit()
Indicates whether or not the document should be scaled to fit the width of the page. |
double |
getScalingFactor()
Returns the scaling factor. |
String |
getTitle()
Returns the title. |
void |
pageDialog()
Displays a page setup dialog. |
int |
print(HTMLDocument html_document)
Prints the specified HTMLDocument. |
int |
print(JEditorPane jed_pane)
Prints the specified JEditorPane. |
int |
print(PlainDocument plain_document)
Prints the specified PlainDocument |
protected int |
printDialog()
Displays the print dialog and initiates printing in response to user input. |
protected void |
setContentType(String type)
Sets the content type the JEditorPane. |
void |
setDocument(HTMLDocument html_doc)
Sets an HTMLDocument as the document to print. |
void |
setDocument(JEditorPane jed_pane)
Sets the document to print as the one contained in a JEditorPane. |
void |
setDocument(PlainDocument plain_document)
Sets a PlainDocument as the Document to print. |
protected void |
setDocument(String type,
Document document)
Sets the content type and document of the JEditorPane. |
void |
setOnePagePerSheet()
Sets the number of pages per sheet to one (1). |
void |
setPrinterName(String printer_name)
Sets the printer name. |
void |
setScaleWidthToFit(boolean scale_width_to_fit)
Set the scale width to fit flag. |
void |
setScalingFactor(double scaling_factor)
Sets the scaling factor. |
void |
setTitle(String title)
Sets the title. |
void |
setTwoPagesPerSheet()
Sets the number of pages per sheet to two (2). |
| 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 PageFormat p_format
protected PrinterJob p_job
protected PrintService p_service
protected String printer_name
protected int pages_per_sheet
protected int pages_printed
protected String title
protected boolean scale_width_to_fit
protected double scaling_factor
| Constructor Detail |
|---|
public HTMLDocumentRenderer()
HTMLDocumentRenderer.
| Method Detail |
|---|
public void setScaleWidthToFit(boolean scale_width_to_fit)
scale_width_to_fit - a flag indiciating whether or not to
scale the content to fit into the allowable widthpublic boolean getScaleWidthToFit()
true if it should, false otherwisepublic void setScalingFactor(double scaling_factor)
scaling_factor - the scaling factor (higher is smaller)public double getScalingFactor()
public void setPrinterName(String printer_name)
printer_name - the printer namepublic String getPrinterName()
public String[] getPrinterNames()
public void setTitle(String title)
title - the titlepublic String getTitle()
public int getPagesPerSheet()
public void setOnePagePerSheet()
public void setTwoPagesPerSheet()
public Document getDocument()
Document.
Documentpublic void pageDialog()
public int print(HTMLDocument html_document)
throws PrinterException
HTMLDocument.
html_document - the HTMLDocument to print
PrinterException - if failed to print document
public int print(JEditorPane jed_pane)
throws PrinterException
JEditorPane.
jed_pane - the JEditorPane to print
PrinterException - if failed to print document
public int print(PlainDocument plain_document)
throws PrinterException
PlainDocument
plain_document - the PlainDocument to print
PrinterException - if failed to print document
protected int printDialog()
throws PrinterException
PrinterException - if failed to print documentprotected void setContentType(String type)
JEditorPane.
type - the content type the JEditorPanepublic void setDocument(HTMLDocument html_doc)
HTMLDocument as the document to print.
html_doc - the specified HTMLDocumentpublic void setDocument(JEditorPane jed_pane)
JEditorPane.
This method is useful when Java does not provide direct access to a
particular Document type, such as a Rich Text Format document. With
this method such a document can be sent to the HTMLDocumentRenderer
class enclosed in a JEditorPane.
jed_pane - An object JEditorPanepublic void setDocument(PlainDocument plain_document)
PlainDocument as the Document to print.
plain_document - the PlainDocument to print
protected void setDocument(String type,
Document document)
JEditorPane.
type - document typedocument - the Document
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||