Class RecordSheetTask

java.lang.Object
javax.swing.SwingWorker<Void,Integer>
megameklab.printing.RecordSheetTask
All Implemented Interfaces:
Runnable, Future<Void>, RunnableFuture<Void>

public abstract class RecordSheetTask extends SwingWorker<Void,Integer>
Renders one or more record sheets as a background task. The task is created using createPrintTask(List, PrinterJob, PrintRequestAttributeSet, PageFormat) for output to a printer and createExportTask(List, PageFormat, String) for export to a PDF file.

Executing the task with execute(boolean) allows showing a popup dialog with a progress bar.

  • Field Details

  • Method Details

    • createPrintTask

      public static RecordSheetTask createPrintTask(List<PrintRecordSheet> sheets, PrinterJob job, PrintRequestAttributeSet printRequestAttributeSet, PageFormat pageFormat)
      Creates a task for rendering a list of record sheets as a print job
      Parameters:
      sheets - The sheets to render The contents are removed as each sheet is processed to avoid running out of memory on large jobs.
      job - The print job
      printRequestAttributeSet - A set of attributes to use for printing
      pageFormat - The page format
      Returns:
      A SwingWorker task
    • createExportTask

      public static RecordSheetTask createExportTask(List<PrintRecordSheet> sheets, PageFormat pageFormat, String pathName)
      Creates a task for rendering a list of record sheets as a print job.
      Parameters:
      sheets - The sheets to render. The contents are removed as each sheet is processed to avoid running out of memory on large jobs.
      pageFormat - The page format
      pathName - The path to the PDF output file
      Returns:
      A SwingWorker task
    • execute

      public void execute(boolean showProgressBar)
      Begins execution with the option to show a progress bar.
      Parameters:
      showProgressBar - Whether to show the progress popup dialog
    • popupLabel

      protected abstract String popupLabel()
    • process

      protected void process(List<Integer> chunks)
      Overrides:
      process in class SwingWorker<Void,Integer>
    • done

      protected void done()
      Overrides:
      done in class SwingWorker<Void,Integer>