Package org.locationtech.udig.printing.model

Examples of org.locationtech.udig.printing.model.Page


    public void run( IAction action ) {
        run();
    }

    public void run() {
        Page page = null;
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        UDIGEditorInput editorInput = (UDIGEditorInput) workbenchWindow.getActivePage()
                .getActiveEditor().getEditorInput();
        if (editorInput instanceof PageEditorInput) {
            page = (Page) ((PageEditorInput) editorInput).getProjectElement();
        }
        if (page == null) {
            throw new RuntimeException(Messages.PrintAction_pageError);
        }

        Dimension pSize = page.getSize();

        float factor = (float) pSize.height / (float) pSize.width;
        float xPlus = 10f;
        float yPlus = xPlus * factor;
        int w = pSize.width - (int) xPlus;
        int h = pSize.height - (int) yPlus;
        page.setSize(new Dimension(w, h));

    }
View Full Code Here


    public PrintAction() {
        super();
    }

    public void run() {
        Page page = null;
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        UDIGEditorInput editorInput = (UDIGEditorInput) workbenchWindow.getActivePage()
                .getActiveEditor().getEditorInput();
        if (editorInput instanceof PageEditorInput) {
            page = (Page) ((PageEditorInput) editorInput).getProjectElement();
        }
        if (page == null) {
            throw new RuntimeException(Messages.PrintAction_pageError);
        }

        FileDialog fileDialog = new FileDialog(workbenchWindow.getShell(), SWT.SAVE);
        String path = fileDialog.open();

        File outFile = null;
        if (path == null || path.length() < 1) {
            return;
        } else {
            if (!path.endsWith(".pdf") && !path.endsWith(".PDF")) {
                path = path + ".pdf";
            }
            outFile = new File(path);
        }

        // copy the page before modifying it
        final Page copy = (Page) EcoreUtil.copy((EObject) page);
        final PdfPrintingEngine engine = new PdfPrintingEngine(copy, outFile);

        Job job = new Job(Messages.PrintAction_jobTitle){
            protected IStatus run( IProgressMonitor monitor ) {
View Full Code Here

        else {
          //java.awt.Dimension size = map.getRenderManager().getMapDisplay().getDisplaySize();
          //Point partSize = new Point(size.width,size.height);
          partSize = new Point(500,500);
        }
        Page page = createPage(template, map, project, partSize );

        ApplicationGIS.openProjectElement(page, false);
    }
View Full Code Here

            PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage();
            width = new Double(pageFormat.getImageableWidth()).intValue();
            height = new Double(pageFormat.getImageableHeight()).intValue();
        }

        Page page = ModelFactory.eINSTANCE.createPage();

        page.setSize(new Dimension(width, height));

        MessageFormat formatter = new MessageFormat("{0} - " + template.getAbbreviation(), Locale
                .getDefault());
        if (page.getName() == null || page.getName().length() == 0) {
            page.setName(formatter.format(new Object[]{map.getName()}));
        }

        page.setProjectInternal(project);
        template.init(page, map);
        Iterator<Box> iter = template.iterator();
        while( iter.hasNext() ) {
            page.getBoxes().add(iter.next());
        }
        return page;
    }
View Full Code Here

        else if (page1.getScaleOption() == PrintWizardPage1.ZOOM_TO_SELECTION) {
            template.setZoomToSelectionHint(true);
        }    
       
        //3. make the page itself
        Page page = ModelFactory.eINSTANCE.createPage();
        page.setSize(new Dimension(width, height));

        //page name stuff not required, because this page will just get discarded
        MessageFormat formatter = new MessageFormat(Messages.CreatePageAction_newPageName, Locale.getDefault());
        if (page.getName() == null || page.getName().length() == 0) {
            page.setName(formatter.format(new Object[] { mapCopy.getName() }));
        }

        template.init(page, mapCopy);
       
        //copy the boxes from the template into the page
        Iterator<Box> iter = template.iterator();       
        while (iter.hasNext()) {
            page.getBoxes().add(iter.next());
        }
        return page;
    }
View Full Code Here

        else if (page1.getScaleOption() == ExportPDFWizardPage1.ZOOM_TO_SELECTION) {
            template.setZoomToSelectionHint(true);
        }       
       
        //3. make the page itself
        Page page = ModelFactory.eINSTANCE.createPage();
        page.setSize(new Dimension((int)width, (int)height));

        //page name stuff not required, because this page will just get discarded
        MessageFormat formatter = new MessageFormat(Messages.CreatePageAction_newPageName, Locale.getDefault());
        if (page.getName() == null || page.getName().length() == 0) {
            page.setName(formatter.format(new Object[] { mapCopy.getName() }));
        }

        //page.setProjectInternal(project);
        template.init(page, mapCopy);
       
        //copy the boxes from the template into the page
        Iterator<Box> iter = template.iterator();       
        while (iter.hasNext()) {
            page.getBoxes().add(iter.next());
        }
        return page;
       
       
        //TODO Throw some sort of exception if the page can't be created
View Full Code Here

        run();
    }

    public void run() {

        Page page = null;
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        UDIGEditorInput editorInput = (UDIGEditorInput) workbenchWindow.getActivePage()
                .getActiveEditor().getEditorInput();
        if (editorInput instanceof PageEditorInput) {
            page = (Page) ((PageEditorInput) editorInput).getProjectElement();
        }
        if (page == null) {
            throw new RuntimeException(Messages.PrintAction_pageError);
        }

        Dimension pSize = page.getSize();

        float factor = (float) pSize.height / (float) pSize.width;
        float xPlus = 10f;
        float yPlus = xPlus * factor;
        int w = pSize.width + (int) xPlus;
        int h = pSize.height + (int) yPlus;
        page.setSize(new Dimension(w, h));

        // IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        // IEditorPart activeEditor = workbenchWindow.getActivePage().getActiveEditor();
        // PageEditor pageEditor = (PageEditor) activeEditor;
        // ZoomManager zoomManager = (ZoomManager) pageEditor.getAdapter(ZoomManager.class);
View Full Code Here

        template.setActivePage(pageIndex);
       
        //Paper paper = pageFormat.getPaper();
        //paper.setImageableArea(MARGIN, MARGIN, paper.getWidth() - MARGIN*2, paper.getHeight() - MARGIN*2);
        //pageFormat.setPaper(paper);
        Page page = makePage(map, pageFormat, template, showRasters, scaleHint);
        Graphics2D graphics2d = (Graphics2D) graphics;

        AffineTransform at = graphics2d.getTransform();
        double dpi = at.getScaleX() * 72;

        if (PrintingPlugin.isDebugging(TRACE_PRINTING)) {
            PrintingPlugin.log("-Printing page " + pageIndex, null); //$NON-NLS-1$
            System.out.println("-PageFormat: " + pageFormat); //$NON-NLS-1$
            System.out.println("-PageFormat height: " + pageFormat.getHeight()); //$NON-NLS-1$
            System.out.println("-PageFormat width: " + pageFormat.getWidth()); //$NON-NLS-1$
            System.out.println("-PageFormat imageableX,Y " + pageFormat.getImageableX() + ", " + pageFormat.getImageableY()); //$NON-NLS-1$ //$NON-NLS-2$
            System.out.println("-PageFormat imageable height: " + pageFormat.getImageableHeight()); //$NON-NLS-1$
            System.out.println("-PageFormat imageable width: " + pageFormat.getImageableWidth()); //$NON-NLS-1$
            System.out.println("-PageFormat orientation (LANDSCAPE=" + PageFormat.LANDSCAPE + ", PORTRAIT=" + PageFormat.PORTRAIT + "): " + pageFormat.getOrientation()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$

            System.out.println("-Graphics: clip bounds: " + graphics2d.getClipBounds()); //$NON-NLS-1$
            System.out.println("-Transform: scaleX: " + at.getScaleX()); //$NON-NLS-1$
            System.out.println("-Transform: scaleY: " + at.getScaleY()); //$NON-NLS-1$
            System.out.println("-DPI?? : " + dpi); //$NON-NLS-1$
        }

        graphics2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());

        Iterator<Box> iter = page.getBoxes().iterator();
        while( iter.hasNext() ) {

            Box box = iter.next();
            graphics2d = (Graphics2D) graphics.create(box.getLocation().x, box.getLocation().y, box
                    .getSize().width, box.getSize().height);
View Full Code Here

        //if (scaleHint != -1) {
        //    template.setMapScaleHint(scaleHint);
        //}       
       
        //make the page itself
        Page page = ModelFactory.eINSTANCE.createPage();
        page.setSize(new Dimension((int)pf.getImageableWidth(), (int)pf.getImageableHeight()));

        //page name stuff not required, because this page will just get discarded
        MessageFormat formatter = new MessageFormat(Messages.CreatePageAction_newPageName, Locale.getDefault());
        if (page.getName() == null || page.getName().length() == 0) {
            page.setName(formatter.format(new Object[] { mapCopy.getName() }));
        }

        template.init(page, mapCopy);
       
        //copy the boxes from the template into the page
        Iterator<Box> iter = template.iterator();       
        while (iter.hasNext()) {
            page.getBoxes().add(iter.next());
        }
        return page;
       
        //TODO Throw some sort of exception if the page can't be created
View Full Code Here

TOP

Related Classes of org.locationtech.udig.printing.model.Page

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.