Package org.locationtech.udig.printing.ui

Examples of org.locationtech.udig.printing.ui.Template


        Object[] allChecked = listViewer.getCheckedElements();
        if (allChecked.length == 0) {
            return;
        }
        TemplateFactory selectedFactory = (TemplateFactory)allChecked[0];
        Template selectedTemplate = selectedFactory.createTemplate();
        int orientation = selectedTemplate.getPreferredOrientation();
        if (orientation == Template.ORIENTATION_LANDSCAPE) {
            landscapeButton.setSelection(true);
            portraitButton.setSelection(false);
        }
        else {
View Full Code Here


                System.getProperty("file.separator")+ //$NON-NLS-1$
                page1.getOutputFile();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));
            document.open();           
            Graphics2D graphics = null;
            Template template = getTemplate();
           
            int i = 0;
            int numPages = 1;
            do {
               
                //sets the active page
                template.setActivePage(i);
               
                PdfContentByte cb = writer.getDirectContent();    
               
                Page page = makePage(pageSize, document, template);
               
                graphics = cb.createGraphics(pageSize.getWidth(), pageSize.getHeight());
                        
                //instantiate a PrinterEngine (pass in the Page instance)
                PrintingEngine engine = new PrintingEngine(page);
               
                //make page format
                PageFormat pageFormat = new PageFormat();
                pageFormat.setOrientation(PageFormat.PORTRAIT);
                java.awt.print.Paper awtPaper = new java.awt.print.Paper();
                awtPaper.setSize(pageSize.getWidth() * 3, pageSize.getHeight() *3);
                awtPaper.setImageableArea(0, 0, pageSize.getWidth(), pageSize.getHeight());
                pageFormat.setPaper(awtPaper);
               
                //run PrinterEngine's print function
                engine.print(graphics, pageFormat, 0);
                 
                graphics.dispose();
                document.newPage();
                if (i == 0) {
                    numPages = template.getNumPages();
                }
                i++;
               
            } while (i < numPages);
           
View Full Code Here

     * @return a template
     */
    private Template getTemplate() {
          
        TemplateFactory templateFactory = page1.getTemplateFactory();
        Template template = templateFactory.createTemplate();
               
        return template;
    }
View Full Code Here

        Object[] allChecked = listViewer.getCheckedElements();
        if (allChecked.length == 0) {
            return;
        }
        TemplateFactory selectedFactory = (TemplateFactory)allChecked[0];
        Template selectedTemplate = selectedFactory.createTemplate();
        int orientation = selectedTemplate.getPreferredOrientation();
    }
View Full Code Here

                    Messages.CreatePageAction_printError_text);
        }

        MapPart mapEditor = (MapPart) activeEditor;
       
        Template template = getPageTemplate();

        if (template == null) {
            return;
        }
View Full Code Here

        int result = dialog.open();
        if (result == Window.CANCEL || dialog.getResult().length == 0) {
            return null;
        }

        Template template = null;

        templateFactory = ((TemplateFactory) dialog.getResult()[0]);

        if (templateFactory == null) {
            PrintingPlugin.log(Messages.CreatePageAction_error_cannotFindDefaultTemplate, null);
View Full Code Here

    }
   
    @Override
    public boolean performFinish() {
   
        Template template = page1.getTemplateFactory().createTemplate();
        boolean showRasters = page1.getRasterEnabled();
       
        //adjust scale       
        double currentViewportScaleDenom = map.getViewportModel().getScaleDenominator();
        if (currentViewportScaleDenom == -1)
            throw new IllegalStateException("no scale denominator is available from the viewport model"); //$NON-NLS-1$
       
        if (page1.getScaleOption() == PrintWizardPage1.CUSTOM_MAP_SCALE) {
            float customScale = page1.getCustomScale();
            template.setMapScaleHint(customScale);
        }
        else if (page1.getScaleOption() == PrintWizardPage1.CURRENT_MAP_SCALE) {
           template.setMapScaleHint(currentViewportScaleDenom);           
        }
        else if (page1.getScaleOption() == PrintWizardPage1.ZOOM_TO_SELECTION) {
            template.setZoomToSelectionHint(true);
            template.setMapScaleHint(currentViewportScaleDenom);
       
       
       
        final PrinterJob printerJob = PrinterJob.getPrinterJob();
        final PageFormat pageFormat = printerJob.defaultPage();
View Full Code Here

        throw new IllegalArgumentException(pageSizeName + " is not a supported page size"); //$NON-NLS-1$
    }
   
    protected Page makePage(int width, int height) {
       
        Template template = getTemplate()
       
        Map mapCopy = null;
       
        //make one copy of the map with no raster layers
        mapCopy = (Map) ApplicationGIS.copyMap(map);
        List<Layer> layersNoRasters = mapCopy.getLayersInternal();
       
        if (!page1.getRasterEnabled()){
            List<Layer> toRemove = new ArrayList<Layer>();
            for (Layer layer : layersNoRasters ) {
                for (IGeoResource resource : layer.getGeoResources()) {
                    if (resource.canResolve(GridCoverageReader.class)) {
                        toRemove.add(layer);
                    }
                }
            }
            layersNoRasters.removeAll(toRemove);
        }
       
       
        //adjust scale       
        if (page1.getScaleOption() == PrintWizardPage1.CUSTOM_MAP_SCALE) {
            float customScale = page1.getCustomScale();
            template.setMapScaleHint(customScale);
        }
        else if (page1.getScaleOption() == PrintWizardPage1.CURRENT_MAP_SCALE) {
            double currentViewportScaleDenom = map.getViewportModel().getScaleDenominator();
            if (currentViewportScaleDenom == -1)
                throw new IllegalStateException("no scale denominator is available from the viewport model"); //$NON-NLS-1$
           template.setMapScaleHint(currentViewportScaleDenom);           
        }
        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

     *
     * @return a page
     */
    protected Page makePage2(float width, float height) {
       
        Template template = getTemplate()
       
        //2. get *copy* of map
        IEditorInput input = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
        .getActiveEditor().getEditorInput();
       
        //get a copy of the map and the project
        Map mapCopy = null;
        Map map = (Map) ((MapEditorInput) input).getProjectElement();
        mapCopy = (Map) ApplicationGIS.copyMap(map);
       
        //adjust scale       
        if (page1.getScaleOption() == ExportPDFWizardPage1.CUSTOM_MAP_SCALE) {
            float customScale = page1.getCustomScale();
            template.setMapScaleHint(customScale);
        }
        else if (page1.getScaleOption() == ExportPDFWizardPage1.CURRENT_MAP_SCALE) {
            double currentViewportScaleDenom = map.getViewportModel().getScaleDenominator();
            if (currentViewportScaleDenom == -1)
                throw new IllegalStateException("no scale denominator is available from the viewport model"); //$NON-NLS-1$
           template.setMapScaleHint(currentViewportScaleDenom);           
        }
        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;
       
View Full Code Here

     * @return a template
     */
    private Template getTemplate() {
          
        TemplateFactory templateFactory = page1.getTemplateFactory();
        Template template = templateFactory.createTemplate();
               
        return template;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.printing.ui.Template

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.