Package org.eclipse.swt.printing

Examples of org.eclipse.swt.printing.Printer


  public Object execute(ExecutionEvent event) throws ExecutionException {
    PrintDialog printDialog = new PrintDialog(HandlerUtil.getActiveShell(event));
    PrinterData printerData = printDialog.open();
   
    if(printerData != null ) {
      Printer printer = new Printer(printerData);
      if(printer.startJob("Text")) {
        GC gc = new GC(printer);
        View view = (View) HandlerUtil.getActivePart(event);
        SieveResult sr = view.getSieveData().getSeiveResult();
        SingleSieve[] s = sr.getSieves();
       
        if(printer.startPage()) {
          gc.drawString("Total mass  = " + Double.toString(sr.getTotal()) + " gr", 100, 100 );
         
          gc.drawLine(85, 135, 600, 135);
          gc.drawLine(85, 185, 600, 185);
          gc.drawLine(85, s.length * 50 + 185, 600, s.length * 50 + 185);
         
          gc.drawString("Sieve NO.", 100, 150 );
          gc.drawString("Size( mm )", 200, 150 );
          gc.drawString("Remind", 300, 150 );
          gc.drawString("% Reminded", 400, 150 );
          gc.drawString("% Finer", 500, 150);
         
          for( int i = 0; i < s.length; i++ ) {
            gc.drawString(s[i].getNo(), 100, 150 + ( i + 1 ) * 50);
            gc.drawString("" + s[i].getSize(), 200, 150 + ( i + 1 ) * 50);
            gc.drawString("" + s[i].getReminded(), 300, 150 + ( i + 1 ) * 50);
            gc.drawString("" + s[i].getPercentReminded(), 400, 150 + ( i + 1 ) * 50);
            gc.drawString("" + s[i].getPercentFiner(), 500, 150 + ( i + 1 ) * 50);
          }
         
          printer.endPage();
        }
       
        gc.dispose();
       
        printer.endJob();
      }
     
      printer.dispose();
    }
    return null;
  }
View Full Code Here


  public void print(StyledTextPrintOptions options) {
    final PrintDialog dialog= new PrintDialog(fTextWidget.getShell(), SWT.PRIMARY_MODAL);
    final PrinterData data= dialog.open();

    if (data != null) {
      final Printer printer= new Printer(data);
      final Runnable styledTextPrinter= fTextWidget.print(printer, options);

      Thread printingThread= new Thread("Printing") { //$NON-NLS-1$
        public void run() {
          styledTextPrinter.run();
          printer.dispose();
        }
      };
      printingThread.start();
    }
  }
View Full Code Here

        startPrintJob(elementToPrint, printerData);
    }

    protected void startPrintJob(Composite elementToPrint,
            PrinterData printerData) {
        Printer printer = new Printer(printerData);
        try {
            printer.startJob(jobName);

            GC gc = new GC(printer);
            try {
                Rectangle printArea = getPrintableArea(printer, BORDER);
                printer.startPage();
                printComposite(elementToPrint, gc, printArea);
                printer.endPage();
            } finally {
                gc.dispose();
            }
            printer.endJob();

        } finally {
            printer.dispose();
        }
    }
View Full Code Here

        if (data == null) {
          System.out.println("Warning: No default printer.");
          return;
        }
       
        Printer printer = new Printer(data);

        printer.startJob("Validation Result");
        GC gc = new GC(printer);
        if (printer.startPage()) {
          ImageData id = mCanvas.getSourceImage().getImageData();
          Image printImage = new Image(printer, id);
         
          //Try to scale it
          int origWidth = printImage.getBounds().width;
          int origHeight = printImage.getBounds().height;
          int maxWidth = printer.getClientArea().width;
          int maxHeight = printer.getClientArea().height;
         
          double scalex = maxWidth/origWidth;
          double scaley = maxHeight/origHeight;
          int nheight, nwidth;
          if (scalex > scaley) {
            nheight = maxHeight;
            nwidth = (int) (origWidth * scaley);
          } else {
            nheight = (int) (origHeight * scalex);
            nwidth = maxWidth;
          }
         
          gc.drawImage(printImage, 0, 0,
              origWidth, origHeight,
              0, 0, nwidth, nheight);
       
          printer.endPage();
          printImage.dispose();
        }
        printer.endJob();
        printer.dispose();
        gc.dispose();
      }
    };
   
    printAction.setActionDefinitionId("Print");
View Full Code Here

  private final int BOILERPLATE_SIZE = 2 * PAPER_MARGIN + 2 * PAPER_BORDER_WIDTH + PAPER_SHADOW_WIDTH;

  private Printer getPrinter() {
    if (printer == null && printerData != null) {
      printer = new Printer(printerData);
      paperDisplayBounds = null;
    }
    return printer;
  }
View Full Code Here

    }
    return printer;
  }

  private Point getPaperSize() {
    Printer printer = getPrinter();
    if (paperSize == null && printer != null && page != null) {
      Rectangle paperBounds = SWTUtils.getPaperBounds(printer);
      this.paperSize = new Point( paperBounds.width, paperBounds.height);
    }
    return paperSize;
View Full Code Here

import factOrFiction.utils.SWTUtils;

public class PrintManager {

  static public void print(PrinterData printerData, PageFrame frame) {
    Printer printer = new Printer(printerData);
    GC gc = new GC(printer);
    PrintContext context = new PrintContext( gc, printer.getDPI() );

    // start the print job and assign it a title
    printer.startJob( "Deck" );

    // get full paper size
    Rectangle pageArea = SWTUtils.getPrintableBounds(printer);
    context.translate( new Point(pageArea.x, pageArea.y));
   
    frame.doPrint( context, new Point(pageArea.width, pageArea.height) );
   
    printer.endPage();            // end the last page
    printer.endJob();            // end the print job
   
    gc.dispose();
  }
View Full Code Here

    final PrintDialog dialog= new PrintDialog(shell, SWT.PRIMARY_MODAL);
    dialog.setPrinterData(fgPrinterData);
    final PrinterData data= dialog.open();

    if (data != null) {
      final Printer printer= new Printer(data);
      final Runnable styledTextPrinter= fTextWidget.print(printer, options);

      Thread printingThread= new Thread("Printing") { //$NON-NLS-1$
        public void run() {
          styledTextPrinter.run();
          printer.dispose();
        }
      };
      printingThread.start();

      /*
 
View Full Code Here

    public void print(final Shell shell) {
        // turn viewport off to ensure calculation of the print pages for the
        // whole table
        layer.doCommand(new TurnViewportOffCommand());

        Printer printer = null;
        try {
            printer = setupPrinter(shell);
            if (printer == null) {
                return;
            }
View Full Code Here

     *            The Shell which should be the parent for the PrintDialog
     * @return The selected printer with the print configuration made by the
     *         user.
     */
    private Printer setupPrinter(final Shell shell) {
        Printer defaultPrinter = new Printer();
        Point pageCount = getPageCount(defaultPrinter);
        defaultPrinter.dispose();

        final PrintDialog printDialog = new PrintDialog(shell);
        printDialog.setStartPage(1);
        printDialog.setEndPage(pageCount.x * pageCount.y);
        printDialog.setScope(PrinterData.ALL_PAGES);

        PrinterData printerData = printDialog.open();
        if (printerData == null) {
            return null;
        }
        return new Printer(printerData);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.printing.Printer

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.