* @param name the name of the new style.
* @param oneFeaturetypestylePerRule switch to create a {@link FeatureTypeStyle} per {@link Rule}.
* @return the new style created.
*/
public static Style rulesToStyle( List<Rule> rules, String name, boolean oneFeaturetypestylePerRule ) {
Style namedStyle = Utilities.sf.createStyle();
if (!oneFeaturetypestylePerRule) {
FeatureTypeStyle featureTypeStyle = Utilities.sf.createFeatureTypeStyle();
List<Rule> currentRules = featureTypeStyle.rules();
for( int i = 0; i < rules.size(); i++ ) {
Rule rule = rules.get(i);
currentRules.add(rule);
}
namedStyle.featureTypeStyles().add(featureTypeStyle);
} else {
for( int i = 0; i < rules.size(); i++ ) {
FeatureTypeStyle featureTypeStyle = Utilities.sf.createFeatureTypeStyle();
Rule rule = rules.get(i);
featureTypeStyle.rules().add(rule);
namedStyle.featureTypeStyles().add(featureTypeStyle);
}
}
namedStyle.setName(name);
return namedStyle;
}