Package org.geotools.styling

Examples of org.geotools.styling.LineSymbolizer


    protected LineSymbolizer createLineSymbolizer( Color colour, boolean dashed ) {
        return createLineSymbolizer(colour, dashed, 1, 1.0);
    }
    protected LineSymbolizer createLineSymbolizer( Color colour, boolean dashed, int thickness,
            double opacity ) {
        LineSymbolizer symbolizer = styleBuilder.createLineSymbolizer();

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

        return symbolizer;
    }
View Full Code Here


                // Lines
                if (!lineStyles.isEmpty()) {
                    Iterator<LineSymbolizer> iter = lineStyles.iterator();
                    while (iter.hasNext()) {
                        LineSymbolizer sym = (LineSymbolizer) iter.next();
                        try {
                            LineStyle2D style = (LineStyle2D) styleFactory
                                    .createStyle(feature, sym, scaleRange);
                            encodeLineStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for "
                                    + sym.toString());
                        }
                    }
                }

                // 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

                && sym instanceof LineSymbolizer) {
            if (((LineStyle2D) style).getStroke() == null) {
                LOGGER.info("Empty LineSymbolizer, using default stroke.");
            }

            LineSymbolizer lineSym = (LineSymbolizer) sym;

            // ** LABEL **
            final StringBuffer styleString = new StringBuffer();
            styleString.append("<IconStyle>");

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

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

            // ** LINE **
            styleString.append("<LineStyle><color>");

            if (lineSym.getStroke() != null) {
                int opacity = 255;

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

                Paint p = ((LineStyle2D) 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 (lineSym.getStroke().getWidth() != null) {
                    int width = getWidth(lineSym.getStroke().getWidth());
                    styleString.append("<width>").append(width).append(
                            "</width>");
                }
            } else // no style defined, so use default
            {
View Full Code Here

        final Fill fill = builder.createFill(Color.blue, 0.2);
        return builder.createPolygonSymbolizer(stroke, fill);
    }

    private Style createGridStyle(final StyleBuilder builder) {
        final LineSymbolizer lineSymbolizer = builder.createLineSymbolizer();
        //CSOFF:MagicNumber
        final Color strokeColor = new Color(127, 127, 255);
        final Color textColor = new Color(50, 50, 255);
        lineSymbolizer.setStroke(builder.createStroke(strokeColor, 1, new float[]{4f, 4f}));
        //CSON:MagicNumber

        final Style style = builder.createStyle(lineSymbolizer);
        final List<Symbolizer> symbolizers = style.featureTypeStyles().get(0).rules().get(0).symbolizers();
        symbolizers.add(0, createGridTextSymbolizer(builder, textColor));
View Full Code Here

    private List<Rule> createStyleRule(final String styleKey,
                                       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;
View Full Code Here

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

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

        for (Rule rule : rules) {
            Filter geomSelectFunction = null;
View Full Code Here

        assertEquals("circle", valueOf(mark.getWellKnownName()));
        assertEquals(30, (Double) valueOf(symbolizer.getGraphic().getRotation()), DELTA);
        assertEquals(0.4, (Double) valueOf(symbolizer.getGraphic().getOpacity()), DELTA);
        assertEquals("#00FF00", valueOf(mark.getStroke().getColor()));

        LineSymbolizer lineSymbolizer = (LineSymbolizer) rule.symbolizers().get(1);
        assertNull(lineSymbolizer.getStroke().getDashArray());
    }
View Full Code Here

        assertEquals(Filter.INCLUDE, rule.getFilter());

        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);
View Full Code Here

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

        LineSymbolizer symbolizer = helper.createLineSymbolizer(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);
    }
View Full Code Here

    @Test
    public void testDefaultLineSymbolizer() throws Exception {
        helper.setAllowNullSymbolizer(false);
        JSONObject json = new JSONObject();
        PJsonObject pJson = new PJsonObject(json, "symbolizers");
        final LineSymbolizer lineSymbolizer = this.helper.createLineSymbolizer(pJson);
        assertNotNull(lineSymbolizer);

        final Stroke stroke = lineSymbolizer.getStroke();
        assertNotNull(stroke);

        assertNull(stroke.getDashArray());
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.LineSymbolizer

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.