Package org.mapfish.print.attribute.map

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


    }

    private void writeInfoLayouts(final JSONWriter json, final Configuration configuration) throws JSONException {
        Double maxDpi = null;
        double[] dpiSuggestions = null;
        ZoomLevels zoomLevels = null;

        json.key("layouts");
        json.array();
        for (String name : configuration.getTemplates().keySet()) {
            json.object();
            {
                json.key("name").value(name);
                json.key("rotation").value(true);

                Template template = configuration.getTemplates().get(name);

                // find the map attribute
                MapAttribute map = null;
                for (Attribute attribute : template.getAttributes().values()) {
                    if (attribute instanceof MapAttribute) {
                        if (map != null) {
                            throw new UnsupportedOperationException("Template '" + name + "' contains "
                                                                    + "more than one map configuration. The legacy API "
                                                                    + "supports only one map per template.");
                        } else {
                            map = (MapAttribute) attribute;
                        }
                    }
                }
                if (map == null) {
                    throw new UnsupportedOperationException("Template '" + name + "' contains "
                                                            + "no map configuration.");
                }
               
                MapAttributeValues mapValues = map.createValue(template);
                json.key("map");
                json.object();
                {
                    json.key("width").value(mapValues.getMapSize().width);
                    json.key("height").value(mapValues.getMapSize().height);
                }
                json.endObject();
               
                // get the zoom levels and dpi values from the first template
                if (maxDpi == null) {
                    maxDpi = map.getMaxDpi();
                    dpiSuggestions = map.getDpiSuggestions();
                }
                if (zoomLevels == null) {
                    zoomLevels = mapValues.getZoomLevels();
                }
            }
            json.endObject();
        }
        json.endArray();

        json.key("dpis");
        json.array();
        {
            if (dpiSuggestions != null) {
                for (Double dpi : dpiSuggestions) {
                    json.object();
                    {
                        json.key("name").value(Integer.toString(dpi.intValue()));
                        json.key("value").value(Integer.toString(dpi.intValue()));
                    }
                    json.endObject();
                }
            }
        }
        json.endArray();

        json.key("scales");
        json.array();
        {
            if (zoomLevels != null) {
                {
                    for (int i = 0; i < zoomLevels.size(); i++) {
                        double scale = zoomLevels.get(i);
                        json.object();
                        {
                            String scaleValue = new DecimalFormat("#.##").format(scale);
                            json.key("name").value("1:" + scaleValue);
                            json.key("value").value(scaleValue);
View Full Code Here

TOP

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

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.