use of org.geotools.styling.StyledLayer in project sldeditor by robward-scisys.
the class SLDUtils method findEquivalentRule.
/**
* Find equivalent rule.
*
* @param otherSLD the other SLD
* @param styledLayerIndex the styled layer index
* @param isNamedLayer the is named layer
* @param styleIndex the style index
* @param ftsIndex the fts index
* @param ruleIndex the rule index
* @return the rule
*/
private static Rule findEquivalentRule(StyledLayerDescriptor otherSLD, int styledLayerIndex, boolean isNamedLayer, int styleIndex, int ftsIndex, int ruleIndex) {
if (otherSLD != null) {
List<StyledLayer> styledLayerList = otherSLD.layers();
if (styledLayerList != null) {
try {
StyledLayer styledLayer = styledLayerList.get(styledLayerIndex);
List<Style> styleList = null;
if (isNamedLayer) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
} else {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
}
if (styleList != null) {
Style style = styleList.get(styleIndex);
FeatureTypeStyle fts = style.featureTypeStyles().get(ftsIndex);
return fts.rules().get(ruleIndex);
}
} catch (IndexOutOfBoundsException exception) {
// Do nothing
}
}
}
return null;
}
use of org.geotools.styling.StyledLayer in project sldeditor by robward-scisys.
the class SLDUtils method findSymbolizer.
/**
* Find symbolizer.
*
* @param sld the sld
* @param symbolizerToFind the symbolizer to find
* @param otherSLD the other SLD
* @return the symbolizer
*/
public static Symbolizer findSymbolizer(StyledLayerDescriptor sld, Symbolizer symbolizerToFind, StyledLayerDescriptor otherSLD) {
List<StyledLayer> styledLayerList = sld.layers();
if (styledLayerList != null) {
int styledLayerIndex = 0;
int styleIndex = 0;
int ftsIndex = 0;
int ruleIndex = 0;
int symbolizerIndex = 0;
boolean isNamedLayer = true;
for (StyledLayer styledLayer : styledLayerList) {
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
isNamedLayer = true;
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
isNamedLayer = false;
}
if (styleList != null) {
styleIndex = 0;
for (Style style : styleList) {
ftsIndex = 0;
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
ruleIndex = 0;
for (Rule rule : fts.rules()) {
symbolizerIndex = 0;
for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer == symbolizerToFind) {
return findEquivalentSymbolizer(otherSLD, styledLayerIndex, isNamedLayer, styleIndex, ftsIndex, ruleIndex, symbolizerIndex);
}
symbolizerIndex++;
}
ruleIndex++;
}
ftsIndex++;
}
styleIndex++;
}
}
styledLayerIndex++;
}
}
return null;
}
use of org.geotools.styling.StyledLayer in project sldeditor by robward-scisys.
the class SelectedSymbol method removeUserNamedLayer.
/**
* Removes the named/user layer.
*
* @param layerToDelete the named/user layer to delete
*/
public void removeUserNamedLayer(StyledLayer layerToDelete) {
List<StyledLayer> styledLayerList = this.sld.layers();
int indexFound = -1;
int index = 0;
for (StyledLayer styledLayer : styledLayerList) {
if (styledLayer == layerToDelete) {
indexFound = index;
break;
} else {
index++;
}
}
if (indexFound > -1) {
styledLayerList.remove(indexFound);
}
}
use of org.geotools.styling.StyledLayer in project sldeditor by robward-scisys.
the class SymbolizerDetailsPanel method getMinimumVersion.
/**
* Gets the minimum version vendor option present in the SLD.
*
* @param parentObj the parent obj
* @param sldObj the sld obj
* @param vendorOptionsPresentList the vendor options present list
*/
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
Class<?> parentClass = null;
Class<?> classSelected = sldObj.getClass();
if (sldObj instanceof StyledLayerDescriptor) {
// No parent
} else if (sldObj instanceof StyledLayer) {
parentClass = StyledLayerDescriptor.class;
} else if (sldObj instanceof Style) {
parentClass = StyledLayer.class;
} else if (sldObj instanceof FeatureTypeStyle) {
parentClass = Style.class;
} else if (sldObj instanceof Rule) {
parentClass = FeatureTypeStyle.class;
} else if (sldObj instanceof Symbolizer) {
parentClass = Rule.class;
}
internal_getMinimumVersion(parentObj, sldObj, vendorOptionsPresentList, parentClass, classSelected);
if (sldObj instanceof PointSymbolizerImpl) {
PointSymbolizerImpl pointSymbolizer = (PointSymbolizerImpl) sldObj;
parentClass = PointSymbolizerImpl.class;
classSelected = FillImpl.class;
internal_getMinimumVersion(pointSymbolizer, pointSymbolizer.getGraphic(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof LineSymbolizerImpl) {
LineSymbolizerImpl lineSymbolizer = (LineSymbolizerImpl) sldObj;
parentClass = LineSymbolizerImpl.class;
classSelected = StrokeImpl.class;
internal_getMinimumVersion(lineSymbolizer, lineSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof PolygonSymbolizerImpl) {
PolygonSymbolizerImpl polygonSymbolizer = (PolygonSymbolizerImpl) sldObj;
parentClass = PolygonSymbolizerImpl.class;
classSelected = FillImpl.class;
internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getFill(), vendorOptionsPresentList, parentClass, classSelected);
classSelected = StrokeImpl.class;
internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof TextSymbolizerImpl) {
TextSymbolizerImpl textSymbolizer = (TextSymbolizerImpl) sldObj;
parentClass = Rule.class;
classSelected = TextSymbolizerImpl.class;
internal_getMinimumVersion(parentObj, textSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof RasterSymbolizerImpl) {
RasterSymbolizerImpl rasterSymbolizer = (RasterSymbolizerImpl) sldObj;
parentClass = Rule.class;
classSelected = RasterSymbolizerImpl.class;
internal_getMinimumVersion(parentObj, rasterSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
}
}
use of org.geotools.styling.StyledLayer 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();
}
}
Aggregations