Package com.projity.job

Examples of com.projity.job.JobQueue


    return container;
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",false); //$NON-NLS-1$
    }
    return jobQueue;
  }
View Full Code Here


//      printerJob.setPageable(printable);
      if (printerJob.printDialog()) {
        //update();


        final JobQueue jobQueue=SessionFactory.getInstance().getJobQueue();
        Job j=new Job(jobQueue,"Printing","Printing...",true,getPrintPreviewFrame());
        j.addRunnable(new JobRunnable("Printing",1.0f){
          public Object run() throws Exception{
            try {
              ViewPrintable vp=getSafePrintable();
              vp.setJr(this);
              vp.setPrinterJob(printerJob);
              vp.setPageFormat(printerJob.validatePage(getSafePageFormat()));
              vp.update();
//              printerJob.setPageable(printable);
              printerJob.setPrintable(vp, vp.getPageFormat());
              vp.setJr(this);
              vp.setPrinterJob(printerJob);
              printerJob.print();
            }catch (PrinterException e) {
              Alert.error(e.getMessage());
            }catch (Exception e) {
              e.printStackTrace();
            }
            return null;
          }
        });
        jobQueue.schedule(j);
      }
    } catch (PrinterException e) {
      Alert.error(e.getMessage());
    }
  }
View Full Code Here

import com.projity.session.SessionFactory;

public class PDFExport {
  public static void export(final GraphPageable pageable,Component parentComponent) throws IOException{
    final File file=chooseFile(pageable.getRenderer().getProject().getName(),parentComponent);
    final JobQueue jobQueue=SessionFactory.getInstance().getJobQueue();
    Job job=new Job(jobQueue,"PDF Export","Exporting PDF...",true,parentComponent);
    job.addRunnable(new JobRunnable("PDF Export",1.0f){
      public Object run() throws Exception{
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        pageable.update();
        int pageCount = pageable.getNumberOfPages();
        if (pageCount>0){
          ViewPrintable printable=pageable.getSafePrintable();
          ExtendedPageFormat pageFormat=pageable.getSafePageFormat();
          double width=pageFormat.getWidth();
          double height=pageFormat.getHeight();
          float startIncrement=0.1f;
          float endIncrement=0.0f;           
          float progressIncrement = (1.0f-startIncrement-endIncrement)/pageCount;
          for (int p=0;p< pageCount;p++) {
            setProgress(startIncrement+p*progressIncrement);
            document.setPageSize(new Rectangle((float)width,(float)height));
            if (p==0) document.open();
            else document.newPage();
           
            Graphics2D g = writer.getDirectContent().createGraphics((float)width, (float)height);
            printable.print(g, p);
            g.dispose();
          }
          document.close();
        }
        setProgress(1.0f);
        return null;
      }
    });
    jobQueue.schedule(job);
  }
View Full Code Here

    return project.getResourceModel();
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",true);
    }
    return jobQueue;
  }
View Full Code Here

    return container;
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",false); //$NON-NLS-1$
    }
    return jobQueue;
  }
View Full Code Here

TOP

Related Classes of com.projity.job.JobQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.