Package org.mapfish.print.attribute

Examples of org.mapfish.print.attribute.ScalebarAttribute


            GenericMapAttribute<?> genericMapAttribute = (GenericMapAttribute<?>) att;
            genericMapAttribute.setWidth(500);
            genericMapAttribute.setHeight(500);
            genericMapAttribute.setMaxDpi(400.0);
        } else if (att instanceof ScalebarAttribute) {
            ScalebarAttribute scalebarAttribute = (ScalebarAttribute) att;
            scalebarAttribute.setWidth(300);
            scalebarAttribute.setHeight(120);
        } else if (att instanceof NorthArrowAttribute) {
            NorthArrowAttribute northArrowAttribute = (NorthArrowAttribute) att;
            northArrowAttribute.setSize(50);
        }
    }
View Full Code Here


    }

    @Test
    public void testGetSize() {
        // horizontal
        ScalebarAttribute attribute = new ScalebarAttribute();
        attribute.setWidth(180);
        attribute.setHeight(40);
        ScalebarAttributeValues params = attribute.createValue(null);
        params.labelDistance = 3;
        params.barSize = 8;
        ScaleBarRenderSettings settings = new ScaleBarRenderSettings();
        settings.setParams(params);
        settings.setDpiRatio(1.0);
        settings.setIntervalLengthInPixels(40);
        settings.setLeftLabelMargin(3.0f);
        settings.setRightLabelMargin(4.0f);
        settings.setMaxSize(new Dimension(180, 40));
        settings.setBarSize(8);
        settings.setPadding(4);
        settings.setLabelDistance(3);

        assertEquals(
                new Dimension(135, 31),
                ScalebarGraphic.getSize(params, settings, new Dimension(30, 12)));


        // horizontal: barSize and labelDistance calculated from height
        params.orientation = Orientation.HORIZONTAL_LABELS_ABOVE.getLabel();
        params.labelDistance = null;
        params.barSize = null;
        settings.setBarSize(ScalebarGraphic.getBarSize(settings));
        settings.setLabelDistance(ScalebarGraphic.getLabelDistance(settings));

        assertEquals(
                new Dimension(135, 34),
                ScalebarGraphic.getSize(params, settings, new Dimension(30, 12)));


        // vertical
        attribute.setWidth(60);
        attribute.setHeight(180);
        settings.setMaxSize(new Dimension(60, 180));
        params = attribute.createValue(null);
        settings.setParams(params);
        params.orientation = Orientation.VERTICAL_LABELS_LEFT.getLabel();
        params.labelDistance = 3;
        params.barSize = 8;
        settings.setTopLabelMargin(5.0f);
View Full Code Here

        mapParams.center = new double[]{-8235878.4938425, 4979784.7605681};
        mapParams.scale = 26000.0;
        mapParams.layers = new PJsonArray(null, new JSONArray(), "");
        mapParams.postConstruct();

        ScalebarAttribute scalebarAttibute = new ScalebarAttribute();
        scalebarAttibute.setWidth(300);
        scalebarAttibute.setHeight(40);
        ScalebarAttributeValues scalebarParams = scalebarAttibute.createValue(null);
        scalebarParams.verticalAlign = VerticalAlign.TOP.getLabel();

        ScalebarGraphic scalebar = new ScalebarGraphic();
        URI file = scalebar.render(mapParams, scalebarParams, folder.getRoot(), this.template);
//      Files.copy(new File(file), new File("/tmp/" + getClass().getSimpleName() + "expected-scalebar-graphic.tiff"));
View Full Code Here

        mapParams.center = new double[]{-8235878.4938425, 4979784.7605681};
        mapParams.scale = 26000.0;
        mapParams.layers = new PJsonArray(null, new JSONArray(), "");
        mapParams.postConstruct();

        ScalebarAttribute scalebarAttibute = new ScalebarAttribute();
        scalebarAttibute.setWidth(300);
        scalebarAttibute.setHeight(40);
        ScalebarAttributeValues scalebarParams = scalebarAttibute.createValue(null);

        ScalebarGraphic scalebar = new ScalebarGraphic();
        URI file = scalebar.render(mapParams, scalebarParams, folder.getRoot(), this.template);
//      Files.copy(new File(file), new File("/tmp/" + getClass().getSimpleName() + "expected-scalebar-graphic-dpi.tiff"));
        new ImageSimilarity(new File(file), 4).assertSimilarity(getFile("expected-scalebar-graphic-dpi.tiff"), 15);
View Full Code Here

        mapParams.center = new double[]{-8235878.4938425, 4979784.7605681};
        mapParams.scale = 26000.0;
        mapParams.layers = new PJsonArray(null, new JSONArray(), "");
        mapParams.postConstruct();

        ScalebarAttribute scalebarAttibute = new ScalebarAttribute();
        scalebarAttibute.setWidth(300);
        scalebarAttibute.setHeight(40);
        ScalebarAttributeValues scalebarParams = scalebarAttibute.createValue(null);
        scalebarParams.verticalAlign = VerticalAlign.TOP.getLabel();
        scalebarParams.renderAsSvg = true;

        ScalebarGraphic scalebar = new ScalebarGraphic();
        URI file = scalebar.render(mapParams, scalebarParams, folder.getRoot(), this.template);
View Full Code Here

//        ImageSimilarity.writeUncompressedImage(bufferedImage, "e:/tmp/expected-scalebar-middle-center.tiff");
        new ImageSimilarity(bufferedImage, 4).assertSimilarity(getFile(expectedDir + "expected-scalebar-middle-center.tiff"), 40);
    }

    private ScaleBarRenderSettings getSettings(final Graphics2D graphics2d, int numSubIntervals) {
        ScalebarAttribute attribute = new ScalebarAttribute();
        attribute.setWidth(180);
        attribute.setHeight(40);
        ScalebarAttributeValues params = attribute.createValue(null);
        params.labelDistance = 4;
        params.barSize = 10;
        ScaleBarRenderSettings settings = new ScaleBarRenderSettings();
        settings.setParams(params);
View Full Code Here

TOP

Related Classes of org.mapfish.print.attribute.ScalebarAttribute

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.