use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class StrokeDetails method populate.
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
Stroke stroke = null;
if (selectedSymbol != null) {
symbolizer = selectedSymbol.getSymbolizer();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbolizer.getGraphic();
List<GraphicalSymbol> graphicalSymbols = graphic.graphicalSymbols();
if (graphicalSymbols.size() > 0) {
GraphicalSymbol symbol = graphicalSymbols.get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
stroke = markerSymbol.getStroke();
}
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
stroke = lineSymbol.getStroke();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
stroke = polygonSymbol.getStroke();
}
}
Class<?> symbolizerClass = null;
if (symbolizer != null) {
symbolizerClass = symbolizer.getClass();
}
populateStroke(symbolizerClass, stroke);
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class StrokeDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Stroke stroke = getStroke();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbol.getGraphic();
GraphicalSymbol symbol = graphic.graphicalSymbols().get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
markerSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol);
this.fireUpdateSymbol();
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
lineSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol);
this.fireUpdateSymbol();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
polygonSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol);
this.fireUpdateSymbol();
}
}
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class RuleRenderVisitor 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(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 VOGeoServerTextSpacingTest method testVOGeoServerTextSpacingTest.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacingTest#VOGeoServerTextSpacingTest(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
*/
@Test
public void testVOGeoServerTextSpacingTest() {
TextSymbolizerDetails panel = new TextSymbolizerDetails();
TextSymbolizer2 textSymbolizer = null;
VOGeoServerTextSpacing testObj = new VOGeoServerTextSpacing(panel.getClass());
testObj.setParentPanel(panel);
testObj.populate(textSymbolizer);
testObj.updateSymbol(textSymbolizer);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Literal featureDescription = ff.literal("feature description");
textSymbolizer.setFeatureDescription(featureDescription);
OtherText otherText = new OtherTextImpl();
otherText.setTarget("target");
Literal otherTextExpression = ff.literal("other text");
otherText.setText(otherTextExpression);
textSymbolizer.setOtherText(otherText);
Literal snippet = ff.literal("snippet");
textSymbolizer.setSnippet(snippet);
// Try with marker symbol
Graphic graphic = styleFactory.createDefaultGraphic();
graphic.graphicalSymbols().add(styleFactory.createMark());
textSymbolizer.setGraphic(graphic);
Controller.getInstance().setPopulating(true);
testObj.populate(textSymbolizer);
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(textSymbolizer);
// Try with external graphic
graphic = styleFactory.createDefaultGraphic();
try {
graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
textSymbolizer.setGraphic(graphic);
textSymbolizer.getOptions().put("wordSpacing", String.valueOf(42));
textSymbolizer.getOptions().put("charSpacing", String.valueOf(21));
Controller.getInstance().setPopulating(true);
testObj.populate(textSymbolizer);
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(textSymbolizer);
// Find minimum version with textSymbolizer2 values set
List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
assertEquals(2, vendorOptionsPresentList.size());
// Find minimum version with no textSymbolizer2 values set
vendorOptionsPresentList.clear();
testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
assertEquals(0, vendorOptionsPresentList.size());
// Get the code coverage values up
testObj.populate(SelectedSymbol.getInstance());
PolygonSymbolizer polygon = null;
testObj.populate(polygon);
testObj.updateSymbol(polygon);
FeatureTypeStyle fts = null;
testObj.populate(fts);
testObj.updateSymbol(fts);
RasterSymbolizer raster = null;
testObj.populate(raster);
testObj.updateSymbol(raster);
testObj.preLoadSymbol();
assertTrue(testObj.isDataPresent());
}
use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class CreateInternalDataSource method internal_determineGeometryType.
/**
* Internal determine geometry type.
*
* @param sld the sld
* @return the geometry type enum
*/
protected GeometryTypeEnum internal_determineGeometryType(StyledLayerDescriptor sld) {
GeometryTypeEnum geometryType = GeometryTypeEnum.UNKNOWN;
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
int pointCount = 0;
int lineCount = 0;
int polygonCount = 0;
int rasterCount = 0;
for (StyledLayer styledLayer : styledLayerList) {
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
}
if (styleList != null) {
for (Style style : styleList) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof PointSymbolizer) {
pointCount++;
} else if (symbolizer instanceof LineSymbolizer) {
lineCount++;
} else if (symbolizer instanceof PolygonSymbolizer) {
polygonCount++;
} else if (symbolizer instanceof RasterSymbolizer) {
rasterCount++;
}
}
}
}
}
}
}
if (polygonCount > 0) {
geometryType = GeometryTypeEnum.POLYGON;
} else if (lineCount > 0) {
geometryType = GeometryTypeEnum.LINE;
} else if (pointCount > 0) {
geometryType = GeometryTypeEnum.POINT;
} else if (rasterCount > 0) {
geometryType = GeometryTypeEnum.RASTER;
}
}
return geometryType;
}
Aggregations