Package org.geotools.styling

Examples of org.geotools.styling.Graphic


    public void testDynamicStrokeInGraphicFill() {
        Stroke markStroke = sb.createStroke();
        markStroke.setWidth(sb.getFilterFactory().property("myAttribute"));
        Mark mark = sb.createMark("square");
        mark.setStroke(markStroke);
        Graphic graphic = sb.createGraphic(null, mark, null);
        PolygonSymbolizer ps = sb.createPolygonSymbolizer();
        ps.getFill().setGraphicFill(graphic);

        Style style = sb.createStyle(ps);
        style.accept(visitor);
View Full Code Here


        }
        {
            FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles());
            Rule rule = assumeSingleElement(fts.rules());
            PointSymbolizer symb = assertSingleElement(rule.symbolizers(), PointSymbolizer.class);
            Graphic eg = symb.getGraphic();
            assertThat(eg.getRotation().evaluate(null).toString(), is("45.0"));
        }
    }
View Full Code Here

    @Test
    public void testGraphicFallbacks() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory();
        Style style =
            SLD.createPointStyle("circle", Color.RED, Color.yellow, 0.5f, 10f);
        Graphic g = SLD.graphic(SLD.pointSymbolizer(style));
        g.setRotation(ff.literal(45));
        g.setOpacity(ff.literal(0.5));

        Map<String,String> props = new HashMap<String, String>();
        props.put("0.0.0", "");

        style = IconPropertyInjector.injectProperties(style, props);
        g = SLD.graphic(SLD.pointSymbolizer(style));

        assertEquals(10.0, g.getSize().evaluate(null, Double.class), 0.1);
        assertEquals(45.0, g.getRotation().evaluate(null, Double.class), 0.1);
        assertEquals(0.5, g.getOpacity().evaluate(null, Double.class), 0.1);
    }
View Full Code Here

    }

    private void addStrokeSymbolizerIfNecessary(Stroke stroke) {
        if (stroke != null) {
            float[] dashArray = stroke.getDashArray();
            Graphic graphicStroke = stroke.getGraphicStroke();
            if (graphicStroke != null || dashArray != null && dashArray.length > 0) {
                addSolidLineSymbolier = true;
            }
        }
    }
View Full Code Here

                return SLD.pointSymbolizer(SLD.createPointStyle(name, stroke, fill, opacity, size));
            }

    protected final PointSymbolizer externalGraphic(String url, String format) {
        ExternalGraphic exGraphic = styleFactory.createExternalGraphic(url, format);
        Graphic graphic = styleFactory.createGraphic(new ExternalGraphic[] { exGraphic }, null, null, null, null, null);
        return styleFactory.createPointSymbolizer(graphic, null);
    }
View Full Code Here

    }

    @Test
    public void testDynamicOpacity() throws CQLException {
        final PointSymbolizer symbolizer = grayCircle();
        final Graphic graphic = symbolizer.getGraphic();
        graphic.setOpacity(toExpression("1 / field"));
        final Style s = styleFromRules(catchAllRule(symbolizer));
        assertEquals("0.0.0=&0.0.0.opacity=1.0", encode(s, fieldIs1));
        assertEquals("0.0.0=&0.0.0.opacity=0.5", encode(s, fieldIs2));
    }
View Full Code Here

    }

    @Test
    public void testDynamicRotation() throws CQLException {
        final PointSymbolizer symbolizer = grayCircle();
        final Graphic graphic = symbolizer.getGraphic();
        graphic.setRotation(toExpression("45 * field"));
        final Style s = styleFromRules(catchAllRule(symbolizer));
        assertEquals("0.0.0=&0.0.0.rotation=45.0", encode(s, fieldIs1));
        assertEquals("0.0.0=&0.0.0.rotation=90.0", encode(s, fieldIs2));
    }
View Full Code Here

    }

    @Test
    public void testDynamicSize() throws CQLException {
        final PointSymbolizer symbolizer = grayCircle();
        final Graphic graphic = symbolizer.getGraphic();
        graphic.setSize(toExpression("field * 16"));
        final Style s = styleFromRules(catchAllRule(symbolizer));
        assertEquals("0.0.0=&0.0.0.size=16.0", encode(s, fieldIs1));
        assertEquals("0.0.0=&0.0.0.size=32.0", encode(s, fieldIs2));
    }
View Full Code Here

    }
   
    @Test
    public void testLocalFileRotate() throws Exception {
        final PointSymbolizer symbolizer = externalGraphic("file:foo.png", "image/png");
        final Graphic graphic = symbolizer.getGraphic();
        graphic.setRotation(toExpression("45 * field"));
        final Style style = styleFromRules(catchAllRule(symbolizer));
        IconProperties prop1 = IconPropertyExtractor.extractProperties(style, fieldIs1);
        assertEquals("http://example.com/styles/foo.png", prop1.href("http://example.com/", null, "test"));
        assertEquals(45.0d, prop1.getHeading(), 0.0001);
        IconProperties prop2 = IconPropertyExtractor.extractProperties(style, fieldIs2);
View Full Code Here

   
    @Test
    public void testTwoLocalFilesRotate() throws Exception {
        final PointSymbolizer symbolizer1 = externalGraphic("file:foo.png", "image/png");
        final PointSymbolizer symbolizer2 = externalGraphic("file:bar.png", "image/png");
        final Graphic graphic1 = symbolizer1.getGraphic();
        graphic1.setRotation(toExpression("45 * field"));
        final Graphic graphic2 = symbolizer2.getGraphic();
        graphic2.setRotation(toExpression("22.5 * field"));
        final Style style = styleFromRules(catchAllRule(symbolizer1, symbolizer2));
        IconProperties prop = IconPropertyExtractor.extractProperties(style, fieldIs1);
        assertEquals("http://example.com/kml/icon/test?0.0.0=&0.0.0.rotation=45.0&0.0.1=&0.0.1.rotation=22.5", prop.href("http://example.com/", null, "test"));
        assertEquals(0.0d, prop.getHeading(), 0.0001);
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.Graphic

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.