|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.spark.ui.ChatPrinter
public class ChatPrinter
Used to print any item contained with a TextArea, such as a Chat.
Field Summary |
---|
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
ChatPrinter()
The constructor initializes the pFormat and PJob variables. |
Method Summary | |
---|---|
javax.swing.text.Document |
getDocument()
Method to get the current Document. |
boolean |
getScaleWidthToFit()
Method to get the current choice the width scaling option. |
void |
pageDialog()
pageDialog() displays a page setup dialog. |
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
may be called to render a page more than once, each page is painted in order. |
void |
print(javax.swing.text.html.HTMLDocument htmlDocument)
print(HTMLDocument) is called to set an HTMLDocument for printing. |
void |
print(javax.swing.JEditorPane jedPane)
print(JEditorPane) prints a Document contained within a JEditorPane. |
void |
print(javax.swing.text.PlainDocument plainDocument)
print(PlainDocument) is called to set a PlainDocument for printing. |
void |
setDocument(javax.swing.text.html.HTMLDocument htmlDocument)
Method to set an HTMLDocument as the Document to print. |
void |
setDocument(javax.swing.JEditorPane jedPane)
Method to set the Document to print as the one contained in a JEditorPane. |
void |
setDocument(javax.swing.text.PlainDocument plainDocument)
Method to set a PlainDocument as the Document to print. |
void |
setScaleWidthToFit(boolean scaleWidth)
Method to set the current choice of the width scaling option. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChatPrinter()
Method Detail |
---|
public javax.swing.text.Document getDocument()
public boolean getScaleWidthToFit()
public void pageDialog()
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
The highlights of the process used print a page are as follows:
I. The Graphics object is cast to a Graphics2D object to allow for scaling. II. The JEditorPane is laid out using the width of a printable page. This will handle line breaks. If the JEditorPane cannot be sized at the width of the graphics clip, scaling will be allowed. III. The root view of the JEditorPane is obtained. By examining this root view and all of its children, printView will be able to determine the location of each printable element of the document. IV. If the scaleWidthToFit option is chosen, a scaling ratio is determined, and the graphics2D object is scaled. V. The Graphics2D object is clipped to the size of the printable page. VI. currentPage is checked to see if this is a new page to render. If so, pageStartY and pageEndY are reset. VII. To match the coordinates of the printable clip of graphics2D and the allocation rectangle which will be used to lay out the views, graphics2D is translated to begin at the printable X and Y coordinates of the graphics clip. VIII. An allocation Rectangle is created to represent the layout of the Views.
The Printable Interface always prints the area indexed by reference to the Graphics object. For instance, with a standard 8.5 x 11 inch page with 1 inch margins the rectangle X = 72, Y = 72, Width = 468, and Height = 648, the area 72, 72, 468, 648 will be painted regardless of which page is actually being printed.
To align the allocation Rectangle with the graphics2D object two things are done. The first step is to translate the X and Y coordinates of the graphics2D object to begin at the X and Y coordinates of the printable clip, see step VII. Next, when printing other than the first page, the allocation rectangle must start laying out in coordinates represented by negative numbers. After page one, the beginning of the allocation is started at minus the page end of the prior page. This moves the part which has already been rendered to before the printable clip of the graphics2D object.
X. The printView method is called to paint the page. Its return value will indicate if a page has been rendered.
Although public, print should not ordinarily be called by programs other than PrinterJob.
print
in interface java.awt.print.Printable
graphics
- the Graphic Object used to print.pageFormat
- the page formatter.pageIndex
- the page to print.
public void print(javax.swing.text.html.HTMLDocument htmlDocument)
htmlDocument
- the HtmlDocument to print.public void print(javax.swing.JEditorPane jedPane)
jedPane
- the JEditorPane to print.public void print(javax.swing.text.PlainDocument plainDocument)
plainDocument
- the PlainDocument to print.public void setDocument(javax.swing.text.html.HTMLDocument htmlDocument)
htmlDocument
- sets the html document.public void setDocument(javax.swing.JEditorPane jedPane)
jedPane
- the JEditorPane document container.public void setDocument(javax.swing.text.PlainDocument plainDocument)
plainDocument
- the PlainDocument to use.public void setScaleWidthToFit(boolean scaleWidth)
scaleWidth
- the width to scale to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |