All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.simulationconstructionset.gui.dialogConstructors.PrintGraphsDialogGenerator Maven / Gradle / Ivy

There is a newer version: 0.25.2
Show newest version
package us.ihmc.simulationconstructionset.gui.dialogConstructors;

import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

import us.ihmc.simulationconstructionset.gui.GraphArrayPanel;

public class PrintGraphsDialogGenerator implements PrintGraphsDialogConstructor
{
   private GraphArrayPanel myGraphArrayPanel;

   public PrintGraphsDialogGenerator(GraphArrayPanel graphArrayPanel)
   {
      myGraphArrayPanel = graphArrayPanel;
   }

   @Override
   public void closeAndDispose()
   {
      myGraphArrayPanel = null;
   }

   @Override
   public void constructDialog()
   {
      // System.out.println("Printing..");
      // Paper paper = new Paper();
      // paper.setImageableArea(1*72, 1.5*72, 6.5*72, 8*72);

      // format.setPaper(paper);
      Thread t = new Thread(new Runnable()
      {
         @Override
         public void run()
         {
            PrinterJob printerJob = PrinterJob.getPrinterJob();

            PageFormat format = new PageFormat();
            format = printerJob.pageDialog(format);

            printerJob.setPrintable(myGraphArrayPanel, format);
            printerJob.setJobName("Simulation Construction Set");

            if (printerJob.printDialog())
            {
               try
               {
                  printerJob.print();
               }
               catch (PrinterException pe)
               {
                  System.err.println("printing failed: " + pe.getMessage());
               }
            }
         }
      }, "PrintGraphs");
      t.start();
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy