use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class ExtractAttributes method visit.
/**
* (non-Javadoc)
*
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PolygonSymbolizer)
*/
public void visit(PolygonSymbolizer poly) {
PolygonSymbolizer copy = sf.createPolygonSymbolizer();
copy.setFill(copy(poly.getFill()));
copy.setGeometry(copy(MultiPolygon.class, 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);
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class PolygonSymbolizerDetails method populate.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) selectedSymbol.getSymbolizer();
if (polygonSymbolizer != null) {
populateStandardData(polygonSymbolizer);
fieldConfigVisitor.populateField(FieldIdEnum.PERPENDICULAR_OFFSET, polygonSymbolizer.getPerpendicularOffset());
fieldConfigVisitor.populateField(FieldIdEnum.GEOMETRY, polygonSymbolizer.getGeometry());
}
}
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class PolygonSymbolizerDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor);
Expression perpendicularOffset = fieldConfigVisitor.getExpression(FieldIdEnum.PERPENDICULAR_OFFSET);
//
// Displacement
//
Displacement displacement = null;
StandardData standardData = getStandardData();
PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) SelectedSymbol.getInstance().getSymbolizer();
if (polygonSymbolizer != null) {
polygonSymbolizer.setName(standardData.name);
polygonSymbolizer.setDescription(standardData.description);
polygonSymbolizer.setUnitOfMeasure(standardData.unit);
polygonSymbolizer.setDisplacement(displacement);
polygonSymbolizer.setGeometry(geometryField);
polygonSymbolizer.setPerpendicularOffset(perpendicularOffset);
this.fireUpdateSymbol();
}
}
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class CreateInternalDataSourceTest method testDetermineGeometryType.
/**
* Test method for
* {@link com.sldeditor.datasource.impl.CreateInternalDataSource#determineGeometryType(StyledLayerDescriptor)}.
*/
@Test
public void testDetermineGeometryType() {
TestCreateInternalDataSource ds = new TestCreateInternalDataSource();
assertEquals(GeometryTypeEnum.UNKNOWN, ds.callDetermineGeometryType(null));
// Create StyledLayerDescriptor
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
sld.addStyledLayer(namedLayer);
UserLayer userLayer = styleFactory.createUserLayer();
sld.addStyledLayer(userLayer);
Style style = styleFactory.createStyle();
namedLayer.addStyle(style);
List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
ftsList.add(fts);
Rule rule = styleFactory.createRule();
fts.rules().add(rule);
// Raster
RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
rule.symbolizers().add(raster);
assertEquals(GeometryTypeEnum.RASTER, ds.callDetermineGeometryType(sld));
// Polygon
rule.symbolizers().clear();
PolygonSymbolizer polygon = DefaultSymbols.createDefaultPolygonSymbolizer();
rule.symbolizers().add(polygon);
assertEquals(GeometryTypeEnum.POLYGON, ds.callDetermineGeometryType(sld));
// Line
rule.symbolizers().clear();
LineSymbolizer line = DefaultSymbols.createDefaultLineSymbolizer();
rule.symbolizers().add(line);
assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
// Point
rule.symbolizers().clear();
PointSymbolizer point = DefaultSymbols.createDefaultPointSymbolizer();
rule.symbolizers().add(point);
assertEquals(GeometryTypeEnum.POINT, ds.callDetermineGeometryType(sld));
// Add line to point
rule.symbolizers().add(line);
assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
// Add point, line
rule.symbolizers().clear();
rule.symbolizers().add(line);
rule.symbolizers().add(point);
assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
// Add polygon, line
rule.symbolizers().clear();
rule.symbolizers().add(point);
rule.symbolizers().add(polygon);
assertEquals(GeometryTypeEnum.POLYGON, ds.callDetermineGeometryType(sld));
}
use of org.geotools.styling.PolygonSymbolizer in project polymap4-core by Polymap4.
the class StyleModelTest method testSimplePolygon.
@Test
public void testSimplePolygon() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
PolygonStyle style = fs.members().createElement(PolygonStyle.defaults);
assertTrue(style.visibleIf.get() instanceof ConstantFilter);
style.fill.get().color.createValue(ConstantColor.defaults(0, 0, 0));
style.fill.get().opacity.createValue(ConstantNumber.defaults(0.0));
style.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
style.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
style.stroke.get().opacity.createValue(ConstantNumber.defaults(0.5));
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
assertEquals(1, result.featureTypeStyles().size());
FeatureTypeStyle fts = result.featureTypeStyles().get(0);
assertEquals(1, fts.rules().size());
Rule rule = fts.rules().get(0);
assertEquals(0, rule.getMinScaleDenominator(), 0);
assertEquals(Double.POSITIVE_INFINITY, rule.getMaxScaleDenominator(), 0);
assertEquals(1, rule.symbolizers().size());
assertNull(rule.getFilter());
PolygonSymbolizer polygon = (PolygonSymbolizer) rule.symbolizers().get(0);
assertEqualsLiteral(0.5, polygon.getStroke().getOpacity());
assertEqualsLiteral(5.0, polygon.getStroke().getWidth());
assertEqualsLiteral(0.0, polygon.getFill().getOpacity());
}
Aggregations