}
return namedStyleInfo;
}
private NamedStyleInfo convert(UserStyleInfo userStyle, FeatureInfo featureInfo) {
NamedStyleInfo namedStyleInfo = new NamedStyleInfo();
LabelStyleInfo labelStyleInfo = new LabelStyleInfo();
List<FeatureStyleInfo> featureStyleInfos = new ArrayList<FeatureStyleInfo>();
for (FeatureTypeStyleInfo featureTypeStyleInfo : userStyle.getFeatureTypeStyleList()) {
int styleIndex = 0;
for (RuleInfo ruleInfo : featureTypeStyleInfo.getRuleList()) {
FeatureStyleInfo featureStyleInfo = new FeatureStyleInfo();
if (ruleInfo.getChoice() != null) {
if (ruleInfo.getChoice().ifFilter()) {
featureStyleInfo.setFormula(convertFormula(ruleInfo.getChoice().getFilter(), featureInfo));
}
}
for (SymbolizerTypeInfo symbolizerTypeInfo : ruleInfo.getSymbolizerList()) {
if (symbolizerTypeInfo instanceof PointSymbolizerInfo) {
PointSymbolizerInfo pointInfo = (PointSymbolizerInfo) symbolizerTypeInfo;
convertSymbol(featureStyleInfo, pointInfo);
} else if (symbolizerTypeInfo instanceof LineSymbolizerInfo) {
LineSymbolizerInfo lineInfo = (LineSymbolizerInfo) symbolizerTypeInfo;
convertStroke(featureStyleInfo, lineInfo.getStroke());
} else if (symbolizerTypeInfo instanceof PolygonSymbolizerInfo) {
PolygonSymbolizerInfo polygonInfo = (PolygonSymbolizerInfo) symbolizerTypeInfo;
convertFill(featureStyleInfo, polygonInfo.getFill());
convertStroke(featureStyleInfo, polygonInfo.getStroke());
} else if (symbolizerTypeInfo instanceof TextSymbolizerInfo) {
TextSymbolizerInfo textInfo = (TextSymbolizerInfo) symbolizerTypeInfo;
labelStyleInfo.setFontStyle(convertFont(textInfo.getFont()));
for (ExpressionInfo expr : textInfo.getLabel().getExpressionList()) {
labelStyleInfo.setLabelAttributeName(expr.getValue());
}
convertFontFill(labelStyleInfo.getFontStyle(), textInfo.getFill());
FeatureStyleInfo background = new FeatureStyleInfo();
if (textInfo.getHalo() != null) {
convertFill(background, textInfo.getHalo().getFill());
}
labelStyleInfo.setBackgroundStyle(background);
}
}
if (featureStyleInfo.getStrokeColor() == null && featureStyleInfo.getFillColor() != null) {
// avoid default stroke by setting invisible
featureStyleInfo.setStrokeColor("black");
featureStyleInfo.setStrokeOpacity(0);
featureStyleInfo.setStrokeWidth(0);
}
featureStyleInfo.setIndex(styleIndex++);
featureStyleInfo.setName(ruleInfo.getTitle() != null ? ruleInfo.getTitle() : ruleInfo.getName());
featureStyleInfos.add(featureStyleInfo);
}
}
namedStyleInfo.setName(userStyle.getTitle() != null ? userStyle.getTitle() : userStyle.getName());
namedStyleInfo.setFeatureStyles(featureStyleInfos);
namedStyleInfo.setLabelStyle(labelStyleInfo);
return namedStyleInfo;
}