Package org.geotools.styling

Examples of org.geotools.styling.PolygonSymbolizer


        assertEquals(20, img.getWidth());
    }
   
    public void testResizeGraphicFill() throws Exception {
        URL url = StreamingRenderer.class.getResource("test-data/");
        PolygonSymbolizer symb = sf.createPolygonSymbolizer();
        ExternalGraphic eg = sf.createExternalGraphic(url + "icon64.png", "image/png");
        Graphic g = sf.createGraphic(new ExternalGraphic[] {eg}, null, null, null, ff.literal(20), null);
        Fill fill = sf.createFill(null, null, null, g);
        symb.setFill(fill);
       
        PolygonStyle2D ps = sld.createPolygonStyle(feature, symb, range);
        assertTrue(ps.getFill() instanceof TexturePaint);
        TexturePaint paint = (TexturePaint) ps.getFill();
        assertEquals(20, paint.getImage().getWidth());
View Full Code Here


        assertEquals( Color.BLUE, s2.getContour() );
        assertNotNull( s2.getStroke() );
    }
   
    public void testTexturePaintNoSize() throws Exception {
        PolygonSymbolizer symb = sf.createPolygonSymbolizer();
        Mark myMark = sf.createMark();
        myMark.setWellKnownName(ff.literal("square"));
        org.geotools.styling.Fill fill = sf.createFill(null);
        fill.setGraphicFill(sf.createGraphic(null, new Mark[] {myMark}, null, null, null, null));
        symb.setFill(fill);
       
        PolygonStyle2D ps = (PolygonStyle2D) sld.createPolygonStyle(feature, symb, range);
        assertTrue(ps.getFill() instanceof TexturePaint);
    }
View Full Code Here

private void quickPolygonSymbolizer() {
    // quickPolygonSymbolizer start
    StyleBuilder styleBuilder = new StyleBuilder();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
   
    PolygonSymbolizer polygonSymbolizer = styleBuilder.createPolygonSymbolizer(Color.BLUE);
    polygonSymbolizer.getFill().setOpacity(ff.literal(0.5)); // 50% blue
   
    polygonSymbolizer.setStroke(styleBuilder.createStroke(Color.BLACK, 2.0));
   
    // will create a default feature type style and rule etc...
    Style style = styleBuilder.createStyle(polygonSymbolizer);
    // quickPolygonSymbolizer end
}
View Full Code Here

    }

    @Override
    public void visit(PolygonSymbolizer poly) {
        super.visit(poly);
        PolygonSymbolizer copy = (PolygonSymbolizer) pages.peek();

        Unit<Length> uom = copy.getUnitOfMeasure();
        rescaleStroke(copy.getStroke(), uom);
        rescaleFill(copy.getFill(), uom);
        copy.setUnitOfMeasure(NonSI.PIXEL);
    }
View Full Code Here

        }
        pages.push(copy);
    }

    public void visit(PolygonSymbolizer poly) {
        PolygonSymbolizer copy = sf.createPolygonSymbolizer();
        copy.setFill( copy( poly.getFill()));
       
        copy.setGeometry(copy(poly.getGeometry()));
       
        copy.setUnitOfMeasure(poly.getUnitOfMeasure());
        copy.setStroke(copy(poly.getStroke()));
        copy.getOptions().putAll(poly.getOptions());
       
        if( STRICT && !copy.equals( poly )){
            throw new IllegalStateException("Was unable to duplicate provided PolygonSymbolizer:"+poly );
        }
        pages.push(copy);
    }
View Full Code Here

    }

    public void testPolygonSymbolizer() {
        try {
            //visitor.setStrict(true);
            PolygonSymbolizer polygonSymb = sf.createPolygonSymbolizer();
            PolygonSymbolizer clone = (PolygonSymbolizer) visitor
                    .copy(polygonSymb);
            assertCopy(polygonSymb, clone);

            PolygonSymbolizer notEq = sf.getDefaultPolygonSymbolizer();
            notEq.setGeometryPropertyName("something_else");

            assertEqualsContract(clone, notEq, polygonSymb);
        } finally {
            visitor.setStrict(false);
        }
View Full Code Here

    }

    public void testPolygonSymbolizerWithUOM() {
        try {
            //visitor.setStrict(true);
            PolygonSymbolizer polygonSymb = sf.createPolygonSymbolizer();
            polygonSymb.setUnitOfMeasure(UomOgcMapping.FOOT.getUnit());
            PolygonSymbolizer clone = (PolygonSymbolizer) visitor
                    .copy(polygonSymb);
            assertCopy(polygonSymb, clone);

            PolygonSymbolizer notEq = sf.getDefaultPolygonSymbolizer();
            notEq.setUnitOfMeasure(UomOgcMapping.PIXEL.getUnit());

            assertEqualsContract(clone, notEq, polygonSymb);
        } finally {
            visitor.setStrict(false);
        }
View Full Code Here

        assertEquals("Any Expression set as Geometry must be correctly replicated", geomFunc, copy
                .getGeometry());
    }

    public void testPolygonSymbolizerWithGeometryFunction() {
        PolygonSymbolizer symb = sf.createPolygonSymbolizer();

        // Set a function as geometry
        Function geomFunc = ff.function("centroid", ff.property("thr_geom"));
        symb.setGeometry(geomFunc);

        PolygonSymbolizer copy = (PolygonSymbolizer) visitor.copy(symb);

        // compare it
        assertEquals("Any Expression set as Geometry must be correctly replicated", geomFunc, copy
                .getGeometry());
    }
View Full Code Here

            placement = SLDs.getPlacement(SLDs.ALIGN_LEFT, SLDs.ALIGN_MIDDLE, 0);

            name = sym == null ? null : sym.getGeometryPropertyName();
        } else if (mode == Mode.POLYGON) {
            polyMode.setSelection(true);
            PolygonSymbolizer sym = SLDs.polySymbolizer(fts);
            stroke = SLDs.stroke(sym);
            fill = SLDs.fill(sym);
            placement = SLDs.getPlacement(SLDs.ALIGN_CENTER, SLDs.ALIGN_MIDDLE, 0);

            name = sym == null ? null : sym.getGeometryPropertyName();
        } else if (mode == Mode.POINT || mode == Mode.ALL) { // default to handling as Point
            pointMode.setSelection(true);

            PointSymbolizer sym = SLDs.pointSymbolizer(fts);
            stroke = SLDs.stroke(sym);
            fill = SLDs.fill(sym);
            graphic = SLDs.graphic(sym);
            placement = SLDs.getPlacement(SLDs.ALIGN_LEFT, SLDs.ALIGN_MIDDLE, 0);

            name = sym == null ? null : sym.getGeometryPropertyName();
        }

        text = SLDs.textSymbolizer(fts);
        if (text != null && placement != null) {
            text.setLabelPlacement(placement);
View Full Code Here

            }
        }
            break;

        case POLYGON: {
            PolygonSymbolizer polygonSymbolizer = this.build.createPolygonSymbolizer(this.line.getStroke(this.build),
                    this.fill.getFill(this.build));
            polygonSymbolizer.setGeometryPropertyName(geometryPropertyName);
            acquire.add(polygonSymbolizer);
            if (textSym != null) {
                acquire.add(textSym);
            }
        }
            break;

        case POINT: {
            PointSymbolizer pointSymbolizer = this.build.createPointSymbolizer(this.point.getGraphic(
                    this.fill.getFill(this.build), this.line.getStroke(this.build), this.build));
            pointSymbolizer.setGeometryPropertyName(geometryPropertyName);
            acquire.add(pointSymbolizer);
            if (textSym != null) {
                acquire.add(textSym);
            }
        }
            break;
        case ALL: {
            LineSymbolizer lineSymbolizer = this.build.createLineSymbolizer(this.line.getStroke(this.build));
            acquire.add(lineSymbolizer);
            acquire.add(lineSymbolizer);
            PolygonSymbolizer polygonSymbolizer = this.build.createPolygonSymbolizer(this.line.getStroke(this.build),
                    this.fill.getFill(this.build));
            polygonSymbolizer.setGeometryPropertyName(geometryPropertyName);
            acquire.add(polygonSymbolizer);
            PointSymbolizer pointSymbolizer = this.build.createPointSymbolizer(this.point.getGraphic(
                    this.fill.getFill(this.build), this.line.getStroke(this.build), this.build));
            pointSymbolizer.setGeometryPropertyName(geometryPropertyName);
            acquire.add(pointSymbolizer);
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.