- java.lang.Object
-
- com.iamsoft.util.ui.swing.DocumentRenderer
-
- All Implemented Interfaces:
Printable
public class DocumentRenderer extends Object implements Printable
DocumentRenderer prints objects of type Document. Text attributes, including fonts, color, and small icons, will be rendered to a printed page. DocumentRenderer 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. As objects which implement the Printable Interface, instances of the DocumentRenderer class can also be used as the argument in the setPrintable method of the PrinterJob class. Instead of using the print() methods detailed above, a programmer may gain access to the formatting capabilities of this class without using its print dialog by creating an instance of DocumentRenderer and setting the document to be printed with the setDocument() or setJEditorPane(). The Document may then be printed by setting the instance of DocumentRenderer in any PrinterJob.
-
-
Field Summary
-
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
-
Constructor Summary
Constructors Constructor Description DocumentRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentgetDocument()booleangetScaleWidthToFit()voidpageDialog()intprint(Graphics pGraphics, PageFormat pPageFormat, int pPageIndex)voidprint(JEditorPane pJedPane)voidprint(HTMLDocument pHtmlDocument)voidprint(PlainDocument pPlainDocument)protected voidprintDialog()protected booleanprintView(Graphics2D pGraphics2D, Shape pAllocation, View pView)protected voidsetContentType(String pType)protected voidsetDocument(String pType, Document pDocument)voidsetDocument(JEditorPane pJedPane)voidsetDocument(HTMLDocument pHtmlDocument)voidsetDocument(PlainDocument pPlainDocument)voidsetScaleWidthToFit(boolean pScaleWidth)
-
-
-
Method Detail
-
getDocument
public Document getDocument()
-
getScaleWidthToFit
public boolean getScaleWidthToFit()
-
pageDialog
public void pageDialog()
-
print
public int print(Graphics pGraphics, PageFormat pPageFormat, int pPageIndex)
-
print
public void print(HTMLDocument pHtmlDocument)
-
print
public void print(JEditorPane pJedPane)
-
print
public void print(PlainDocument pPlainDocument)
-
printDialog
protected void printDialog()
-
printView
protected boolean printView(Graphics2D pGraphics2D, Shape pAllocation, View pView)
-
setContentType
protected void setContentType(String pType)
-
setDocument
public void setDocument(HTMLDocument pHtmlDocument)
-
setDocument
public void setDocument(JEditorPane pJedPane)
-
setDocument
public void setDocument(PlainDocument pPlainDocument)
-
setScaleWidthToFit
public void setScaleWidthToFit(boolean pScaleWidth)
-
-