discovery.gui
Class PrintManager

java.lang.Object
  extended by discovery.gui.PrintManager
All Implemented Interfaces:
java.awt.print.Printable

public class PrintManager
extends java.lang.Object
implements java.awt.print.Printable

This class is responsible for printing out task structure, task flow and narrative diagrams. It implements the Printable interface, and provides a static method called 'printComponent' which takes the component to print. It then brings up the standard print dialog to allow the user to setup printing as they would like. Methods are also provided to disable and enable double buffering. Double buffering is disabled before printing to give a much higher quality print with quicker spooling times. This class is based on the PrintUtilities.java class by Marty Hall, which is freely available to use and can be found at: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html


Field Summary
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PrintManager(java.awt.Component comp)
          Constructor which creates a new PrintManager instance with the supplied component.
 
Method Summary
static void disableDoubleBuffering(java.awt.Component c)
          This method disables double buffering when the specified component is repainted.
static void enableDoubleBuffering(java.awt.Component c)
          This method enables double buffering when the specified component is repainted.
 void print()
          This method is called by the printComponent method.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
          This method is required by the Printable interface.
static void printComponent(java.awt.Component c)
          Static method which prints the supplied Swing component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintManager

public PrintManager(java.awt.Component comp)
Constructor which creates a new PrintManager instance with the supplied component.

Parameters:
comp - the component associated with this PrintManager instance
Method Detail

printComponent

public static void printComponent(java.awt.Component c)
Static method which prints the supplied Swing component. This method is called when the print button is clicked on the GUI, and is supplied with either the structure panel, flow panel or narrative panel.

Parameters:
c - the component to print

print

public void print()
This method is called by the printComponent method. It sets up the print job and displays the Print Dialog window.


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
This method is required by the Printable interface.

Specified by:
print in interface java.awt.print.Printable

disableDoubleBuffering

public static void disableDoubleBuffering(java.awt.Component c)
This method disables double buffering when the specified component is repainted. It is called before printing to ensure a higher quality print and quicker spooling time.

Parameters:
c - the component to disable double buffering of

enableDoubleBuffering

public static void enableDoubleBuffering(java.awt.Component c)
This method enables double buffering when the specified component is repainted. It is called after printing to allow quicker drawing speeds on screen.

Parameters:
c - the component to enable double buffering of