Class PrintHelper

java.lang.Object
net.simplace.ui.service.PrintHelper
All Implemented Interfaces:
Printable, Runnable

public class PrintHelper extends Object implements Runnable, Printable
This helper class provides methods used for printing stuff on a printing device.
Author:
Martin Uhlir
  • Field Details

    • TYPE_PDF

      public static final int TYPE_PDF
      Document type PDF (currently unused)
      See Also:
    • TYPE_RTF

      public static final int TYPE_RTF
      Document type RTF (currently unused)
      See Also:
    • TYPE_HTML

      public static final int TYPE_HTML
      Document type HTML (currently unused)
      See Also:
  • Method Details

    • print

      public static void print(Component aComponent, net.simplace.core.FWObservable aObservable) throws PrinterException
      Prints a GUI component on a printer. Before printing is started, a cross-platform dialog appears to the user who can select the desired printer and customise the print properties. If the print dialog is canceled, no print job will start.
      Parameters:
      aComponent - a GUI component to be printed
      aObservable - not used
      Throws:
      PrinterException - if the print thread could not be started
      See Also:
    • print

      public static void print(Component aComponent) throws PrinterException
      Prints a GUI component on a printer. Printing runs in a separate thread. Before printing is started, a cross-platform dialog appears to the user who can select the desired printer and customise the print properties. If the print dialog is canceled, no print job will start. The component is scaled to the page width and split over as many pages as needed.

      Errors in the print thread (no print service available, print job aborted) are thrown as RuntimeException in that thread and do not reach the caller.

      Parameters:
      aComponent - a GUI component to be printed
      Throws:
      PrinterException - if the print thread could not be started (e.g. aComponent is null)
    • run

      public void run()
      Handles the whole printing process.
      Note: it's implemented in a new thread because looking up the printing device takes a lot of time
      Specified by:
      run in interface Runnable
      Throws:
      RuntimeException - if no print service is available or the print job fails
    • print

      public int print(Graphics g, PageFormat pf, int pageIndex)
      Renders one page of the component. The component is scaled to the imageable page width and split vertically into pages.
      Specified by:
      print in interface Printable