Package weka.gui

# Class DocumentPrinting

java.lang.Object
weka.gui.DocumentPrinting

All Implemented Interfaces:
  `Printable`

public class DocumentPrinting extends Object implements Printable
DocumentPrinting is a class that lets you print documents on the fly for free ;) Printing in JDK 1.2 - 1.5 is hard. With this, you just simply call it in your application and add your text component like JTextPane:

     new DocumentPrinting().print(YourJTextComponent);

Reminder: Just make sure there is a text on your component ;P

     Author : Jan Michael Soan
     WebSite: http://www.jmsoan.com
     Date   : 04/17/2004
     Time   : 2:20 PM

Found on Toolbox (Terms of Use).

Author:
  Jan Michael Soan (original code), FracPete (fracpete at waikato dot ac dot nz)

- ## Field Summary

  ### Fields inherited from interface java.awt.print.Printable

  `NO_SUCH_PAGE, PAGE_EXISTS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DocumentPrinting()`
  Initializes the printing.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Document`
  `getDocument()`
  Returns the document to print.
  `boolean`
  `getScaleWidthToFit()`
  Returns whether the width is to be scaled.
  `int`
  `print(Graphics graphics, PageFormat pageFormat, int pageIndex)`
  Prints the page.
  `void`
  `print(JTextPane pane)`
  Prints the document in the JTextPane.
  `void`
  `printDialog()`
  Shows the print dialog.
  `void`
  `setContentType(String type)`
  Sets the content type.
  `void`
  `setDocument(String type, Document document)`
  Sets the document and the according content type.
  `void`
  `setDocument(JTextPane pane)`
  Sets the document from the given JTextPane.
  `void`
  `setScaleWidthToFit(boolean scaleWidth)`
  Sets whether to scale the width to fit.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DocumentPrinting

    public DocumentPrinting()
    Initializes the printing.

- ## Method Details

  - ### print

    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
    Prints the page.
    Specified by:
      `print` in interface `Printable`
    Parameters:
      `graphics` - the graphics context
      `pageFormat` - the format of the page
      `pageIndex` - the page index
    Returns:
      either NO_SUCH_PAGE or PAGE_EXISTS
    See Also:
      - `Printable.NO_SUCH_PAGE`
      - `Printable.PAGE_EXISTS`

  - ### print

    public void print(JTextPane pane)
    Prints the document in the JTextPane.
    Parameters:
      `pane` - the document to print

  - ### printDialog

    public void printDialog()
    Shows the print dialog.

  - ### setContentType

    public void setContentType(String type)
    Sets the content type.
    Parameters:
      `type` - the content type

  - ### getDocument

    public Document getDocument()
    Returns the document to print.
    Returns:
      the document or null

  - ### setDocument

    public void setDocument(JTextPane pane)
    Sets the document from the given JTextPane.
    Parameters:
      `pane` - the JTextPane to get the document from

  - ### setDocument

    public void setDocument(String type, Document document)
    Sets the document and the according content type.
    Parameters:
      `type` - the content type
      `document` - the document to print

  - ### setScaleWidthToFit

    public void setScaleWidthToFit(boolean scaleWidth)
    Sets whether to scale the width to fit.
    Parameters:
      `scaleWidth` - if true then the width will be scaled

  - ### getScaleWidthToFit

    public boolean getScaleWidthToFit()
    Returns whether the width is to be scaled.
    Returns:
      true if scaled