use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDExternalImages method externalGraphicSymbolVisitor.
/**
* Find the SLD graphical symbols.
*
* @param resourceLocator the resource locator
* @param sld the sld
* @param externalImageList the external image list
* @param process the process
*/
private static void externalGraphicSymbolVisitor(URL resourceLocator, StyledLayerDescriptor sld, List<String> externalImageList, ProcessGraphicSymbolInterface process) {
if (sld == null) {
return;
}
if (process == null) {
return;
}
for (StyledLayer styledLayer : sld.layers()) {
List<Style> styles = null;
if (styledLayer instanceof NamedLayer) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
styles = namedLayer.styles();
} else if (styledLayer instanceof UserLayer) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
styles = userLayer.userStyles();
}
if (styles != null) {
for (Style style : styles) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point.getGraphic() != null) {
process.processGraphicalSymbol(resourceLocator, point.getGraphic().graphicalSymbols(), externalImageList);
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer line = (LineSymbolizer) symbolizer;
updateStroke(resourceLocator, line.getStroke(), externalImageList, process);
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer;
updateStroke(resourceLocator, polygon.getStroke(), externalImageList, process);
updateFill(resourceLocator, polygon.getFill(), externalImageList, process);
}
}
}
}
}
}
}
}
use of org.geotools.styling.LineSymbolizer 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.LineSymbolizer 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.LineSymbolizer 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;
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class ExtractAttributes method visit.
/**
* (non-Javadoc)
*
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.LineSymbolizer)
*/
public void visit(LineSymbolizer line) {
LineSymbolizer copy = sf.getDefaultLineSymbolizer();
copy.setGeometry(copy(LineString.class, line.getGeometry()));
copy.setUnitOfMeasure(line.getUnitOfMeasure());
copy.setStroke(copy(line.getStroke()));
copy.getOptions().putAll(line.getOptions());
copy.setPerpendicularOffset(line.getPerpendicularOffset());
if (STRICT && !copy.equals(line)) {
throw new IllegalStateException("Was unable to duplicate provided LineSymbolizer:" + line);
}
pages.push(copy);
}
Aggregations