use of org.geotools.styling.UserLayerImpl in project sldeditor by robward-scisys.
the class UserLayerDetails method updateSymbol.
/**
* Update symbol.
*
* @param changedField the changed field
*/
private void updateSymbol(FieldIdEnum changedField) {
if (!Controller.getInstance().isPopulating()) {
UserLayer userLayer = getStyleFactory().createUserLayer();
String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
userLayer.setName(name);
// Feature type constraints
List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
if ((ftcList != null) && !ftcList.isEmpty()) {
FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
}
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
switch(selectedOption.getId()) {
case REMOTE_OWS_OPTION:
{
RemoteOWS remoteOWS = new RemoteOWSImpl();
String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
remoteOWS.setService(service);
String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
remoteOWS.setOnlineResource(onlineResource);
userLayer.setRemoteOWS(remoteOWS);
}
break;
case INLINE_FEATURE_OPTION:
{
String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
}
}
break;
default:
break;
}
}
StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
if (existingStyledLayer instanceof UserLayerImpl) {
UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
for (Style style : existingUserLayer.userStyles()) {
userLayer.addUserStyle(style);
}
}
SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
// reduces creation of datasources
if (changedField != null) {
if (changedField == FieldIdEnum.INLINE_FEATURE) {
DataSourceInterface dataSource = DataSourceFactory.getDataSource();
if (dataSource != null) {
dataSource.updateUserLayers();
}
}
}
this.fireUpdateSymbol();
}
}
use of org.geotools.styling.UserLayerImpl 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.UserLayerImpl 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.UserLayerImpl 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.UserLayerImpl 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