use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class SelectedSymbol method removeStyle.
/**
* Removes the style.
*
* @param styleToDelete the style to delete
*/
public void removeStyle(Style styleToDelete) {
List<Style> styleList = null;
if (this.symbolData.getStyledLayer() instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) this.symbolData.getStyledLayer();
styleList = namedLayer.styles();
} else if (this.symbolData.getStyledLayer() instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) this.symbolData.getStyledLayer();
styleList = userLayer.userStyles();
}
if (styleList != null) {
int indexFound = -1;
int index = 0;
for (Style style : styleList) {
if (style == styleToDelete) {
indexFound = index;
break;
} else {
index++;
}
}
if (indexFound > -1) {
styleList.remove(indexFound);
}
}
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class RenderSymbol method getRenderStyle.
/**
* Gets the render style.
*
* @param selectedSymbol the selected symbol
* @return the render style
*/
public Style getRenderStyle(SelectedSymbol selectedSymbol) {
List<StyledLayer> styledLayerList = selectedSymbol.getSld().layers();
for (StyledLayer styledLayer : styledLayerList) {
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
styleList = namedLayer.styles();
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
styleList = userLayer.userStyles();
}
if (styleList != null) {
for (Style style : styleList) {
FeatureTypeStyle ftsToRender = selectedSymbol.getFeatureTypeStyle();
Rule ruleToRender = selectedSymbol.getRule();
// Check to see if style contains the rule to render
if (shouldRenderSymbol(style, ftsToRender, ruleToRender)) {
return renderSymbol(style, ftsToRender, ruleToRender, renderOptions);
}
}
}
}
return null;
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class MapRender method internalRenderStyle.
/**
* Internal render style.
*/
private void internalRenderStyle() {
if (!underTest) {
if (hasError()) {
mapPane.resetRenderer();
mapPane.getRenderer().addRenderListener(this);
resetError();
}
wmsEnvVarValues.setImageWidth(mapPane.getWidth());
wmsEnvVarValues.setImageHeight(mapPane.getHeight());
MapContent mapContent = mapPane.getMapContent();
if (mapContent == null) {
mapContent = new MapContent();
mapPane.setMapContent(mapContent);
}
Map<Object, Object> hints = new HashMap<Object, Object>();
clearLabelCache();
hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache);
mapPane.getRenderer().setRendererHints(hints);
// Add the layers back with the updated style
StyledLayerDescriptor sld = SelectedSymbol.getInstance().getSld();
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
for (StyledLayer styledLayer : styledLayerList) {
List<org.geotools.styling.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) {
renderSymbol(mapContent, styledLayer, style);
}
}
}
}
}
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class LegendManager method createSingleStyleLegend.
/**
* Creates the legend for a single SLD style.
*
* @param styleMap the style map
* @param selectedStyledLayer the selected styled layer
* @param selectedStyle the selected style
*/
private void createSingleStyleLegend(Map<String, Style> styleMap, StyledLayer selectedStyledLayer, Style selectedStyle) {
// A style has been selected
List<Style> styleList = null;
if (selectedStyledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) selectedStyledLayer;
styleList = namedLayer.styles();
} else if (selectedStyledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) selectedStyledLayer;
styleList = userLayer.userStyles();
}
String styleName;
if (selectedStyle.getName() != null) {
styleName = selectedStyle.getName();
} else {
styleName = String.format("Style %d", styleList.indexOf(selectedStyle));
}
styleMap.put(styleName, selectedStyle);
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class LegendManager method createMultipleStyleLegend.
/**
* Creates the legend for multiple SLD styles.
*
* @param sld the sld
* @param styleMap the style map
* @param selectedStyledLayer the selected styled layer
*/
private void createMultipleStyleLegend(StyledLayerDescriptor sld, Map<String, Style> styleMap, StyledLayer selectedStyledLayer) {
List<StyledLayer> styledLayerList = null;
if (selectedStyledLayer == null) {
styledLayerList = sld.layers();
} else {
styledLayerList = new ArrayList<StyledLayer>();
styledLayerList.add(selectedStyledLayer);
}
for (StyledLayer styledLayer : styledLayerList) {
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
styleList = namedLayer.styles();
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
styleList = userLayer.userStyles();
}
if (styleList != null) {
int count = 1;
for (Style style : styleList) {
String styleName;
if (style.getName() != null) {
styleName = style.getName();
} else {
styleName = String.format("Style %d", count);
}
styleMap.put(styleName, style);
count++;
}
}
}
}
Aggregations