Package org.geotools.styling

Examples of org.geotools.styling.PolygonSymbolizer


            polySymb.getStroke().setWidth(filterFactory.literal(size));

            visitor = new UomRescaleStyleVisitor(scaleMetersToPixel);

            polySymb.accept(visitor);
            PolygonSymbolizer rescaledPolySymb = (PolygonSymbolizer) visitor.getCopy();
            double rescaledSize = rescaledPolySymb.getStroke().getWidth().evaluate(null, Double.class);
           
            assertEquals(Math.round(expectedRescaledSize), Math.round(rescaledSize));
            assertNotSame(rescaledPolySymb, polySymb);
        }
        catch (Exception e2)
View Full Code Here


            PolygonSymbolizerImpl polySymb = (PolygonSymbolizerImpl) styleBuilder.createPolygonSymbolizer(null, fill);
           
            visitor = new UomRescaleStyleVisitor(10);

            polySymb.accept(visitor);
            PolygonSymbolizer rescaledPolySymb = (PolygonSymbolizer) visitor.getCopy();
           
            assertEquals(polySymb.getFill(), rescaledPolySymb.getFill());
            assertNull(rescaledPolySymb.getStroke());
            assertNotSame(rescaledPolySymb, polySymb);
        }
        catch (Exception e2)
        {
            e2.printStackTrace();
View Full Code Here

        Fill fill = sb.createFill();
        fill.setColor(null);
        fill.setGraphicFill(sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
       
        // a polygon and line symbolizer using them
        PolygonSymbolizer ps = sb.createPolygonSymbolizer(stroke, fill);
        ps.setUnitOfMeasure(SI.METER);
       
        // rescale it
        UomRescaleStyleVisitor visitor = new UomRescaleStyleVisitor(10);
        ps.accept(visitor);
        PolygonSymbolizer rps = (PolygonSymbolizer) visitor.getCopy();
        Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0);
        assertEquals(10.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
        rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0);
        assertEquals(20.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);

       
        // a line symbolizer that uses a graphic stroke
        LineSymbolizer ls = sb.createLineSymbolizer(stroke);
View Full Code Here

        Rule rule = ftStyle.getRules()[0];
        assertEquals("main", rule.getName());
        assertEquals(1, rule.getSymbolizers().length);

        PolygonSymbolizer ps = (PolygonSymbolizer) rule.getSymbolizers()[0];
        assertEquals("GEOMETRY", ps.getGeometryPropertyName());

        Color color = SLD.color(ps.getFill().getColor());
        assertEquals(Integer.parseInt("96", 16), color.getRed());
        assertEquals(Integer.parseInt("C3", 16), color.getGreen());
        assertEquals(Integer.parseInt("F5", 16), color.getBlue());
    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        PolygonSymbolizer ps = styleFactory.createPolygonSymbolizer();

        //<xsd:element ref="sld:Geometry" minOccurs="0"/>
        if(node.hasChild("Geometry")) {
            Expression geometry = (Expression) node.getChildValue("Geometry");
            if(geometry instanceof PropertyName) {
                PropertyName propertyName = (PropertyName) geometry;
                ps.setGeometryPropertyName(propertyName.getPropertyName());
            } else {
                ps.setGeometry(geometry);
            }
        }

        //<xsd:element ref="sld:Fill" minOccurs="0"/>
        if (node.hasChild(Fill.class)) {
            ps.setFill((Fill) node.getChildValue(Fill.class));
        }

        //<xsd:element ref="sld:Stroke" minOccurs="0"/>
        if (node.hasChild(Stroke.class)) {
            ps.setStroke((Stroke) node.getChildValue(Stroke.class));
        }
       
        //<xsd:element ref="sld:VendorOption" minOccurs="0" maxOccurs="unbounded"/>
        for (CssParameter param : (List<CssParameter>) node.getChildValues(CssParameter.class)) {
            ps.getOptions().put(param.getName(), param.getExpression().evaluate(null, String.class));
        }

        return ps;
    }
View Full Code Here

    }

    public void test() throws Exception {
        SLDMockData.polygonSymbolizer(document, document);

        PolygonSymbolizer ps = (PolygonSymbolizer) parse();
        assertNotNull(ps);
        assertNotNull(ps.getFill());
        assertNotNull(ps.getStroke());
    }
View Full Code Here

    }
   
    public void testTransform() throws Exception {
        SLDMockData.transformedPolygonSymbolizer(document, document);

        PolygonSymbolizer ps = (PolygonSymbolizer) parse();
        assertNotNull(ps);
        assertNotNull(ps.getFill());
        assertNotNull(ps.getStroke());
        assertNotNull(ps.getGeometry());
        Function tx = (Function) ps.getGeometry();
        assertEquals("buffer", tx.getName());
    }
View Full Code Here

        </Fill>
        <Stroke>
            <SvgParameter name="stroke">#0000aa</SvgParameter>
        </Stroke>
    </PolygonSymbolizer>*/
        PolygonSymbolizer sym = (PolygonSymbolizer) parse("example-polygonsymbolizer.xml");
        assertEquals("MyPolygonSymbolizer", sym.getName());
        assertEquals("Example PolygonSymbolizer", sym.getDescription().getTitle().toString());
        assertEquals("This is just a simple example of a polygon symbolizer.",
                sym.getDescription().getAbstract().toString());
       
        Fill f = sym.getFill();
        Color c = f.getColor().evaluate(null, Color.class);
        assertEquals(170, c.getRed());
        assertEquals(170, c.getGreen());
        assertEquals(255, c.getBlue());
       
        c = sym.getStroke().getColor().evaluate(null, Color.class);
        assertEquals(170, c.getBlue());
    }
View Full Code Here

        Rule rule = fts.rules().get(0);
        assertEquals("main", rule.getName());
       
        assertEquals(1, rule.symbolizers().size());
       
        PolygonSymbolizer sym = (PolygonSymbolizer) rule.symbolizers().get(0);
        assertEquals(UomOgcMapping.PIXEL.getUnit(), sym.getUnitOfMeasure());
        assertEquals(SLD.toColor("#96C3F5"), sym.getFill().getColor().evaluate(null, Color.class));
       
    }
View Full Code Here

       
        Rule r = fts.rules().get(0);
        assertEquals("main", r.getName());
        assertEquals(1, r.symbolizers().size());
       
        PolygonSymbolizer sym = (PolygonSymbolizer) r.symbolizers().get(0);
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.PolygonSymbolizer

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.