Examples of PolygonSymbolizer


Examples of org.geotools.styling.PolygonSymbolizer

        return symbolizer;
    }

    protected PolygonSymbolizer createPolygonSymbolizer( Color colour, boolean dashed ) {
        PolygonSymbolizer symbolizer = styleBuilder.createPolygonSymbolizer();

        // Stroke stroke = builder.createStroke(Color., 3);
        // if( dashed ){
        // stroke.setDashArray(new float[]{5, 3});
        // }
        // symbolizer.setStroke(stroke);

        Fill fill = styleBuilder.createFill();
        fill.setColor(styleBuilder.colorExpression(colour));
        fill.setOpacity(styleBuilder.literalExpression(.5));
        symbolizer.setFill(fill);

        return symbolizer;
    }
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

                List<Rule> rules = newFTS.rules();
                for( Rule rule : rules ) {
                    List<Symbolizer> newSymbolizers = rule.symbolizers();
                    for( Symbolizer newSymbolizer : newSymbolizers ) {
                        if (newSymbolizer instanceof PolygonSymbolizer) {
                            PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer ) newSymbolizer;
                           
                            Fill previousFill = SLDs.fill(polygonSymbolizer);
                            previousFill.setOpacity(ff.literal(opac));
                           
                            Stroke stroke = SLDs.stroke(polygonSymbolizer);
                            if (stroke != null) {
                                if(borderColor!=null){
                                    stroke.setColor(ff.literal(borderColor));
                                }else{
                                    polygonSymbolizer.setStroke(null);
                                }
                            }
                           
                        }
                    }
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

                // Polygons
                if (!polyStyles.isEmpty()) {
                    Iterator<PolygonSymbolizer> iter = polyStyles.iterator();
                    while (iter.hasNext()) {
                        PolygonSymbolizer sym = (PolygonSymbolizer) iter.next();
                        try {
                            PolygonStyle2D style = (PolygonStyle2D) styleFactory
                                    .createStyle(feature, sym, scaleRange);
                            // The last argument is forced outline
                            encodePolygonStyle(feature, style, sym, !lineStyles
                                    .isEmpty());
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for "
                                    + sym.toString());
                        }
                    }
                }

            } catch (Exception e) {
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

                LOGGER.info("Empty PolygonSymbolizer, using default fill and stroke.");
            }

            final StringBuffer styleString = new StringBuffer();

            PolygonSymbolizer polySym = (PolygonSymbolizer) sym;

            // ** LABEL **
            styleString.append("<IconStyle>");

            if (!vectorNameDescription) { // if they don't want
                // attributes
                styleString.append("<color>#00ffffff</color>"); // fully
                // transparent
            }

            styleString.append("<Icon><href>root://icons/palette-3.png</href><x>224</x><w>32</w><h>32</h></Icon>");
            styleString.append("</IconStyle>");

            // ** FILL **
            styleString.append("<PolyStyle><color>");

            if (polySym.getFill() != null) // if they specified a fill
            {
                int opacity = 255; // default to full opacity

                if (polySym.getFill().getOpacity() != null) {
                    float op = getOpacity(polySym.getFill().getOpacity());
                    opacity = (new Float(255 * op)).intValue();
                }

                Paint p = ((PolygonStyle2D) style).getFill();

                if (p instanceof Color) {
                    styleString.append("#").append(intToHex(opacity)).append(
                            colorToHex((Color) p)); // transparancy needs to
                    // come from the opacity
                    // value.
                } else {
                    styleString.append("#ffaaaaaa"); // should not occure in
                    // normal parsing
                }
            } else { // no fill specified, make transparent
                styleString.append("#00aaaaaa");
            }

            // if there is an outline, specify that we have one, then style it
            styleString.append("</color>");

            if (polySym.getStroke() != null) {
                styleString.append("<outline>1</outline>");
            } else {
                styleString.append("<outline>0</outline>");
            }

            styleString.append("</PolyStyle>");

            // ** OUTLINE **
            if (polySym.getStroke() != null) // if there is an outline
            {
                styleString.append("<LineStyle><color>");

                int opacity = 255; // default to full opacity

                if (polySym.getStroke().getOpacity() != null) {
                    float op = getOpacity(polySym.getStroke().getOpacity());
                    opacity = (new Float(255 * op)).intValue();
                }

                Paint p = ((PolygonStyle2D) style).getContour();

                if (p instanceof Color) {
                    styleString.append("#").append(intToHex(opacity)).append(
                            colorToHex((Color) p)); // transparancy needs to
                    // come from the opacity
                    // value.
                } else {
                    styleString.append("#ffaaaaaa"); // should not occure in
                    // normal parsing
                }

                styleString.append("</color>");

                // stroke width
                if (polySym.getStroke().getWidth() != null) {
                    int width = getWidth(polySym.getStroke().getWidth());
                    styleString.append("<width>").append(width).append(
                            "</width>");
                }

                styleString.append("</LineStyle>");
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

                                       final PJsonObject styleJson,
                                       final String styleProperty) {

        final PointSymbolizer pointSymbolizer = this.parserHelper.createPointSymbolizer(styleJson);
        final LineSymbolizer lineSymbolizer = this.parserHelper.createLineSymbolizer(styleJson);
        final PolygonSymbolizer polygonSymbolizer = this.parserHelper.createPolygonSymbolizer(styleJson);
        final TextSymbolizer textSymbolizer = this.parserHelper.createTextSymbolizer(styleJson);

        Filter propertyMatches = createFilter(styleKey, styleProperty);
        Rule textRule = null;
        if (textSymbolizer != null) {
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

    protected PolygonSymbolizer createPolygonSymbolizer(final PJsonObject styleJson) {
        if (this.allowNullSymbolizer && !styleJson.has(JSON_FILL_COLOR)) {
            return null;
        }

        final PolygonSymbolizer symbolizer = this.styleBuilder.createPolygonSymbolizer();
        symbolizer.setFill(createFill(styleJson));

        symbolizer.setStroke(createStroke(styleJson, false));

        return symbolizer;
    }
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

        });
        assertEquals(4, rules.size());

        PointSymbolizer point = null;
        LineSymbolizer line = null;
        PolygonSymbolizer polygon = null;
        TextSymbolizer text = null;

        for (Rule rule : rules) {
            Filter geomSelectFunction = null;
            if (!(rule.getSymbolizers()[0] instanceof TextSymbolizer)) {
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

        assertEquals(4, rule.symbolizers().size());

        PointSymbolizer pointSymbolizer = (PointSymbolizer) rule.symbolizers().get(0);
        LineSymbolizer lineSymbolizer = (LineSymbolizer) rule.symbolizers().get(1);
        PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) rule.symbolizers().get(2);
        TextSymbolizer textSymbolizer = (TextSymbolizer) rule.symbolizers().get(3);

        assertNotNull(pointSymbolizer);
        assertNotNull(lineSymbolizer);
        assertNotNull(polygonSymbolizer);
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

        style.put("strokeOpacity", 0.2);
        style.put("strokeWidth", 2);
        style.put("strokeDashstyle", "5 2");
        style.put("strokeLinecap", "round");

        final PolygonSymbolizer symbolizer = helper.createPolygonSymbolizer(new PJsonObject(style, null));
        assertNotNull(symbolizer);

        transformer.transform(symbolizer); // verify it converts to xml correctly

        assertStroke(0.2, "round", symbolizer.getStroke(), "#FFFFFF", new float[]{5f, 2f}, 2.0);
        assertFill(0.3, "#EEEEEE", symbolizer.getFill());
    }
View Full Code Here

Examples of org.geotools.styling.PolygonSymbolizer

    @Test
    public void testDefaultPolygonSymbolizer() throws Exception {
        helper.setAllowNullSymbolizer(false);
        JSONObject json = new JSONObject();
        PJsonObject pJson = new PJsonObject(json, "symbolizers");
        final PolygonSymbolizer polygonSymbolizer = this.helper.createPolygonSymbolizer(pJson);
        assertNotNull(polygonSymbolizer);

        final Stroke stroke = polygonSymbolizer.getStroke();
        assertNotNull(stroke);
        assertNull(stroke.getDashArray());

        assertNotNull(polygonSymbolizer.getFill());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.