Package org.mapfish.print.attribute.map

Examples of org.mapfish.print.attribute.map.MapBounds


    public final void render(final Graphics2D graphics2D,
                             final MfClientHttpRequestFactory clientHttpRequestFactory,
                             final MapfishMapContext transformer,
                             final boolean isFirstLayer) {
        Rectangle paintArea = new Rectangle(transformer.getMapSize());
        MapBounds bounds = transformer.getBounds();

        MapfishMapContext layerTransformer = transformer;
        if (transformer.getRotation() != 0.0 && !this.supportsNativeRotation()) {
            // if a rotation is set and the rotation can not be handled natively
            // by the layer, we have to adjust the bounds and map size
            paintArea = new Rectangle(transformer.getRotatedMapSize());
            bounds = transformer.getRotatedBounds();
            graphics2D.setTransform(transformer.getTransform());
            Dimension mapSize = new Dimension(paintArea.width, paintArea.height);
            layerTransformer = new MapfishMapContext(bounds, mapSize, transformer.getRotation(), transformer.getDPI(),
                    transformer.getRequestorDPI(), transformer.isForceLongitudeFirst(), transformer.isDpiSensitiveStyle());
        }


        MapContent content = new MapContent();
        try {
            List<? extends Layer> layers = getLayers(clientHttpRequestFactory, layerTransformer, isFirstLayer);
            content.addLayers(layers);

            StreamingRenderer renderer = new StreamingRenderer();

            RenderingHints hints = new RenderingHints(Collections.<RenderingHints.Key, Object>emptyMap());
            hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
                    RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY));
            hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON));
            hints.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
                    RenderingHints.VALUE_COLOR_RENDER_QUALITY));
            hints.add(new RenderingHints(RenderingHints.KEY_DITHERING,
                    RenderingHints.VALUE_DITHER_ENABLE));
            hints.add(new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS,
                    RenderingHints.VALUE_FRACTIONALMETRICS_ON));
            hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION,
                    RenderingHints.VALUE_INTERPOLATION_BICUBIC));
            hints.add(new RenderingHints(RenderingHints.KEY_RENDERING,
                    RenderingHints.VALUE_RENDER_QUALITY));
            hints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL,
                    RenderingHints.VALUE_STROKE_PURE));
            hints.add(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING,
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON));

            graphics2D.addRenderingHints(hints);
            renderer.setJava2DHints(hints);
            Map<String, Object> renderHints = Maps.newHashMap();
            if (transformer.isForceLongitudeFirst() != null) {
                renderHints.put(StreamingRenderer.FORCE_EPSG_AXIS_ORDER_KEY, transformer.isForceLongitudeFirst());
            }
            renderer.setRendererHints(renderHints);

            renderer.setMapContent(content);
            renderer.setThreadPool(this.executorService);

            final ReferencedEnvelope mapArea = bounds.toReferencedEnvelope(paintArea, transformer.getDPI());
            renderer.paint(graphics2D, paintArea, mapArea);
        } catch (Exception e) {
            throw ExceptionUtils.getRuntimeException(e);
        } finally {
            content.dispose();
View Full Code Here


    @Override
    protected final List<? extends Layer> getLayers(final MfClientHttpRequestFactory httpRequestFactory,
                                                    final MapfishMapContext mapContext,
                                                    final boolean isFirstLayer) throws Exception {
        double dpi = mapContext.getDPI();
        MapBounds bounds = mapContext.getBounds();
        Rectangle paintArea = new Rectangle(mapContext.getMapSize());
        TileCacheInformation tileCacheInformation = createTileInformation(bounds, paintArea, dpi, isFirstLayer);
        final TileLoaderTask task = new TileLoaderTask(httpRequestFactory, dpi,
                mapContext, tileCacheInformation);
        final GridCoverage2D gridCoverage2D = this.forkJoinPool.invoke(task);
View Full Code Here

            image = loadImage(httpRequestFactory, mapContext, isFirstLayer);
        } catch (Throwable t) {
            throw ExceptionUtils.getRuntimeException(t);
        }
       
        final MapBounds bounds = mapContext.getBounds();
        final ReferencedEnvelope mapEnvelope = bounds.toReferencedEnvelope(mapContext.getPaintArea(), mapContext.getDPI());
       
        GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
        GeneralEnvelope gridEnvelope = new GeneralEnvelope(mapEnvelope.getCoordinateReferenceSystem());
        gridEnvelope.setEnvelope(mapEnvelope.getMinX(), mapEnvelope.getMinY(), mapEnvelope.getMaxX(), mapEnvelope.getMaxY());
        final String coverageName = getClass().getSimpleName();
View Full Code Here

        Rectangle paintArea = new Rectangle(mapSize);

        final double dpi = mapValues.getDpi();
        final double dpiOfRequestor = mapValues.getRequestorDPI();

        MapBounds bounds = mapValues.getMapBounds();
        bounds = adjustBoundsToScaleAndMapSize(mapValues, dpiOfRequestor, paintArea, bounds);

        // if the DPI is higher than the PDF DPI we need to make the image larger so the image put in the PDF is large enough for the
        // higher DPI printer
        final double dpiRatio = dpi / dpiOfRequestor;
View Full Code Here

     * @param bounds         The map bounds.
     */
    public static MapBounds adjustBoundsToScaleAndMapSize(
            final MapAttribute.MapAttributeValues mapValues, final double dpiOfRequestor,
            final Rectangle paintArea, final MapBounds bounds) {
        MapBounds newBounds = bounds;
        if (mapValues.isUseNearestScale()) {
            newBounds = newBounds.adjustBoundsToNearestScale(
                    mapValues.getZoomLevels(),
                    mapValues.getZoomSnapTolerance(),
                    mapValues.getZoomLevelSnapStrategy(), paintArea, dpiOfRequestor);
        }

        newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea, dpiOfRequestor));

        if (mapValues.isUseAdjustBounds()) {
            newBounds = newBounds.adjustedEnvelope(paintArea);
        }
        return newBounds;
    }
View Full Code Here

        mapProcessorValues.map = mapParams;

        // TODO validate parameters (dpi? mapParams.postConstruct())

        // NOTE: Original map is the map that is the "subject/target" of this overview map
        MapBounds boundsOfOriginalMap = mapParams.getOriginalBounds();
        setOriginalMapExtentLayer(boundsOfOriginalMap, values, mapParams);
        setZoomedOutBounds(mapParams, boundsOfOriginalMap, values);

        CreateMapProcessor.Output output = this.mapProcessor.execute(mapProcessorValues, context);
        return new Output(output.layerGraphics, output.mapSubReport);
View Full Code Here

    private void setOriginalMapExtentLayer(final MapBounds originalBounds,
            final Input values,
            final MapAttribute.OverriddenMapAttributeValues mapParams)
            throws IOException {
        Rectangle originalPaintArea = new Rectangle(values.map.getMapSize());
        MapBounds adjustedBounds =
                CreateMapProcessor.adjustBoundsToScaleAndMapSize(values.map, values.map.getDpi(), originalPaintArea, originalBounds);
        ReferencedEnvelope originalEnvelope =
                adjustedBounds.toReferencedEnvelope(originalPaintArea, values.map.getDpi());

        Geometry mapExtent = JTS.toGeometry(originalEnvelope);
        if (values.map.getRotation() != 0.0) {
            mapExtent = rotateExtent(mapExtent, values.map.getRotation(), originalEnvelope);
        }
View Full Code Here

    private void setZoomedOutBounds(
            final MapAttribute.OverriddenMapAttributeValues mapParams,
            final MapBounds originalBounds, final Input values) {
        // zoom-out the bounds by the given factor
        MapBounds overviewMapBounds = originalBounds.zoomOut(values.overviewMap.getZoomFactor());

        // adjust the bounds to size of the overview map, because the overview map
        // might have a different aspect ratio than the main map
        overviewMapBounds = overviewMapBounds.adjustedEnvelope(new Rectangle(values.overviewMap.getMapSize()));
        mapParams.setZoomedOutBounds(overviewMapBounds);
    }
View Full Code Here

        final GridLayerPlugin plugin = new GridLayerPlugin();
        StyleParser styleParser = new StyleParser();
        plugin.setParser(styleParser);
        final GridLayer layer = plugin.parse(template, layerData);

        MapBounds bounds = new BBoxMapBounds(DefaultEngineeringCRS.GENERIC_2D, 100, 100, 140, 140);
        Dimension mapSize = new Dimension(400, 400);
        double rotation = 0;
        double dpi = 72;
        MapfishMapContext context = new MapfishMapContext(bounds, mapSize, rotation, dpi, Constants.PDF_DPI, null, true);
        final List<? extends Layer> layers = layer.getLayers(null, context, true);
View Full Code Here

        final GridLayerPlugin plugin = new GridLayerPlugin();
        StyleParser styleParser = new StyleParser();
        plugin.setParser(styleParser);
        final GridLayer layer = plugin.parse(template, layerData);

        MapBounds bounds = new BBoxMapBounds(DefaultEngineeringCRS.GENERIC_2D, 110, 90, 150, 132);
        Dimension mapSize = new Dimension(400, 400);
        double rotation = 0;
        double dpi = 72;
        MapfishMapContext context = new MapfishMapContext(bounds, mapSize, rotation, dpi, Constants.PDF_DPI, null, true);
        final List<? extends Layer> layers = layer.getLayers(null, context, true);
View Full Code Here

TOP

Related Classes of org.mapfish.print.attribute.map.MapBounds

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.