Package org.geotools.styling

Examples of org.geotools.styling.LineSymbolizer


        helper.setVersion(Versions.TWO);
        JSONObject json = new JSONObject();
        json.put(JsonStyleParserHelper.JSON_STROKE_DASHSTYLE, "5 4");

        PJsonObject pJson = new PJsonObject(json, "symbolizers");
        final LineSymbolizer lineSymbolizer = this.helper.createLineSymbolizer(pJson);
        assertNotNull(lineSymbolizer);

        final Stroke stroke = lineSymbolizer.getStroke();
        assertArrayEquals(Arrays.toString(stroke.getDashArray()), new float[]{5f, 4f}, stroke.getDashArray(), FLOAT_DELTA);
    }
View Full Code Here


        String jsonString = Files.toString(getFile("v2-style-all-properies-as-expressions.json"), Constants.DEFAULT_CHARSET);
        PJsonObject json = MapPrinter.parseSpec(jsonString).getJSONObject("*");

        final PJsonArray symb = json.getJSONArray(MapfishJsonStyleVersion2.JSON_SYMB);
        final PointSymbolizer pointSymbolizer = this.helper.createPointSymbolizer(symb.getJSONObject(0));
        final LineSymbolizer lineSymbolizer = this.helper.createLineSymbolizer(symb.getJSONObject(1));
        final PolygonSymbolizer polygonSymbolizer = this.helper.createPolygonSymbolizer(symb.getJSONObject(2));
        final TextSymbolizer textSymbolizer = this.helper.createTextSymbolizer(symb.getJSONObject(3));

        final Graphic graphic = pointSymbolizer.getGraphic();
        assertEquals("rotation", propertyName(graphic.getRotation()));
        assertEquals("graphicOpacity", propertyName(graphic.getOpacity()));
        assertEquals("pointRadius", propertyName(graphic.getSize()));

        Mark mark = (Mark) graphic.graphicalSymbols().get(0);
        assertEquals("graphicName", propertyName(mark.getWellKnownName()));

        assertEquals("fillOpacity", propertyName(mark.getFill().getOpacity()));
        assertEquals("fillColor", propertyName(mark.getFill().getColor()));

        assertEquals("strokeColor", propertyName(mark.getStroke().getColor()));
        assertEquals("strokeOpacity", propertyName(mark.getStroke().getOpacity()));
        assertEquals("strokeWidth", propertyName(mark.getStroke().getWidth()));
        assertEquals("strokeLinecap", propertyName(mark.getStroke().getLineCap()));

        assertEquals("lineStrokeColor", propertyName(lineSymbolizer.getStroke().getColor()));
        assertEquals("lineStrokeOpacity", propertyName(lineSymbolizer.getStroke().getOpacity()));
        assertEquals("lineStrokeWidth", propertyName(lineSymbolizer.getStroke().getWidth()));
        assertEquals("lineStrokeLinecap", propertyName(lineSymbolizer.getStroke().getLineCap()));

        assertEquals("PolyStrokeColor", propertyName(polygonSymbolizer.getStroke().getColor()));
        assertEquals("PolyStrokeOpacity", propertyName(polygonSymbolizer.getStroke().getOpacity()));
        assertEquals("PolyStrokeWidth", propertyName(polygonSymbolizer.getStroke().getWidth()));
        assertEquals("PolyStrokeLinecap", propertyName(polygonSymbolizer.getStroke().getLineCap()));
View Full Code Here

    }
   
    @Test
    public void testNullStroke() throws Exception {
        StyleBuilder sb = new StyleBuilder();
        LineSymbolizer ls = sb.createLineSymbolizer(Stroke.NULL);
        Style style = sb.createStyle(ls);
       
        MetaBufferEstimator estimator = new MetaBufferEstimator();
        style.accept(estimator);
        assertTrue(estimator.isEstimateAccurate());
View Full Code Here

                g.draw( shape );
            }
        }
        if( symb instanceof LineSymbolizer){
            LineSymbolizer lineSymbolizer = (LineSymbolizer) symb;
            Color c = SLD.color( lineSymbolizer );
            int w = SLD.width( lineSymbolizer );
            if( c != null && w > 0 ){
                g.setColor( c );
View Full Code Here

        String xml = "<LineStyle>" + "<color>ffff0000</color>" + "<width>2</width>"
            + "</LineStyle>";

        buildDocument(xml);

        LineSymbolizer line = (LineSymbolizer) parse();
        assertEquals(Color.RED, SLD.color(line));
        assertEquals(2, SLD.width(line));

        xml = "<LineStyle>" + "</LineStyle>";
        buildDocument(xml);
View Full Code Here

            PointSymbolizer ps = (PointSymbolizer) sym;
            ps.accept(this);
        }

        if (sym instanceof LineSymbolizer) {
            LineSymbolizer ps = (LineSymbolizer) sym;
            ps.accept(this);
        }

        if (sym instanceof PolygonSymbolizer) {
            PolygonSymbolizer ps = (PolygonSymbolizer) sym;
            ps.accept(this);
        }

        if (sym instanceof RasterSymbolizer) {
            RasterSymbolizer rs = (RasterSymbolizer) sym;
            rs.accept(this);
View Full Code Here

        assertEquals(1, collector.featureTypeStyles.size());
        assertEquals(1, collector.rules.size());
        assertEquals(2, collector.symbolizers.size());

        // check the line
        LineSymbolizer ls = (LineSymbolizer) collector.symbolizers.get(0);
        assertEquals(1, (int) ls.getStroke().getWidth().evaluate(null, Integer.class));
        assertEquals(Color.BLUE, (Color) ls.getStroke().getColor().evaluate(null, Color.class));
        assertTrue(Arrays.equals(new float[] { 10, 10 }, ls.getStroke().getDashArray()));

        // check the dots
        ls = (LineSymbolizer) collector.symbolizers.get(1);
        assertTrue(Arrays.equals(new float[] { 5, 15 }, ls.getStroke().getDashArray()));
        assertEquals(7.5, ls.getStroke().getDashOffset().evaluate(null, Double.class), 0.0);
        Graphic graphic = ls.getStroke().getGraphicStroke();
        List<GraphicalSymbol> symbols = graphic.graphicalSymbols();
        assertEquals(1, symbols.size());
        Mark mark = (Mark) symbols.get(0);
        assertEquals("circle", mark.getWellKnownName().evaluate(null));
        assertEquals("#000033", mark.getStroke().getColor().evaluate(null, String.class));
View Full Code Here

                .get(1).getFilter());
        assertEquals(ff.equals(ff.property("type"), ff.literal("highway")), collector.rules.get(2)
                .getFilter());

        // check symbolizers
        LineSymbolizer ls = (LineSymbolizer) collector.symbolizers.get(0);
        assertEquals(2, (int) ls.getStroke().getWidth().evaluate(null, Integer.class));
        assertEquals("#009933", ls.getStroke().getColor().evaluate(null, String.class));
        ls = (LineSymbolizer) collector.symbolizers.get(1);
        assertEquals(3, (int) ls.getStroke().getWidth().evaluate(null, Integer.class));
        assertEquals("#0055CC", ls.getStroke().getColor().evaluate(null, String.class));
        ls = (LineSymbolizer) collector.symbolizers.get(2);
        assertEquals(6, (int) ls.getStroke().getWidth().evaluate(null, Integer.class));
        assertEquals("#FF0000", ls.getStroke().getColor().evaluate(null, String.class));
    }
View Full Code Here

        StyleCollector collector = new StyleCollector();
        style.accept(collector);
        assertSimpleStyle(collector);

        // check the function is there were we expect it
        LineSymbolizer ls = (LineSymbolizer) collector.symbolizers.get(0);
        assertTrue(ls.getStroke().getColor() instanceof RecodeFunction);
        assertTrue(ls.getStroke().getWidth() instanceof RecodeFunction);
    }
View Full Code Here

            double maxDenominator, int size) {
        assertEquals(name, rule.getName());
        assertEquals(minDenominator, rule.getMinScaleDenominator(), 0.0);
        assertEquals(maxDenominator, rule.getMaxScaleDenominator(), 0.0);
        assertEquals(1, rule.getSymbolizers().length);
        LineSymbolizer ls = (LineSymbolizer) rule.getSymbolizers()[0];
        assertEquals(size, (int) ls.getStroke().getWidth().evaluate(null, Integer.class));
    }
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.