org.jivesoftware.spark.ui
Class ChatPrinter
java.lang.Object
  
org.jivesoftware.spark.ui.ChatPrinter
- All Implemented Interfaces: 
 - java.awt.print.Printable
 
public class ChatPrinter
- extends java.lang.Object
- implements java.awt.print.Printable
  
Used to print any item contained with a TextArea, such as a Chat.
 
| 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 | 
 
ChatPrinter
public ChatPrinter()
- The constructor initializes the pFormat and PJob variables.
 
getDocument
public javax.swing.text.Document getDocument()
- Method to get the current Document.
 
- Returns:
 - the Chat document object.
 
 
 
getScaleWidthToFit
public boolean getScaleWidthToFit()
- Method to get the current choice the width scaling option.
 
- Returns:
 - true if it should scale the width.
 
 
 
pageDialog
public void pageDialog()
- pageDialog() displays a page setup dialog.
 
 
 
print
public 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. We may, therefore, keep track of changes in the page being rendered
 by setting the currentPage variable to equal the pageIndex, and then
 comparing these variables on subsequent calls to this method. When the two
 variables match, it means that the page is being rendered for the second or
 third time. When the currentPage differs from the pageIndex, a new page is
 being requested.
 
 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.
- Specified by:
 print in interface java.awt.print.Printable
 
- Parameters:
 graphics - the Graphic Object used to print.pageFormat - the page formatter.pageIndex - the page to print.
- Returns:
 - the page number printed.
 
 
 
print
public void print(javax.swing.text.html.HTMLDocument htmlDocument)
- print(HTMLDocument) is called to set an HTMLDocument for printing.
 
- Parameters:
 htmlDocument - the HtmlDocument to print.
 
 
print
public void print(javax.swing.JEditorPane jedPane)
- print(JEditorPane) prints a Document contained within a JEditorPane.
 
- Parameters:
 jedPane - the JEditorPane to print.
 
 
print
public void print(javax.swing.text.PlainDocument plainDocument)
- print(PlainDocument) is called to set a PlainDocument for printing.
 
- Parameters:
 plainDocument - the PlainDocument to print.
 
 
setDocument
public void setDocument(javax.swing.text.html.HTMLDocument htmlDocument)
- Method to set an HTMLDocument as the Document to print.
 
- Parameters:
 htmlDocument - sets the html document.
 
 
setDocument
public void setDocument(javax.swing.JEditorPane jedPane)
- Method to set the Document to print as the one contained in a 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 DocumentRenderer class enclosed
 in a JEditorPane.
 
- Parameters:
 jedPane - the JEditorPane document container.
 
 
setDocument
public void setDocument(javax.swing.text.PlainDocument plainDocument)
- Method to set a PlainDocument as the Document to print.
 
- Parameters:
 plainDocument - the PlainDocument to use.
 
 
setScaleWidthToFit
public void setScaleWidthToFit(boolean scaleWidth)
- Method to set the current choice of the width scaling option.
 
- Parameters:
 scaleWidth - the width to scale to.