if (defaultStroke == null) {
defaultStroke = sb.createStroke();
}
//answer goes here
FeatureTypeStyle fts = sf.createFeatureTypeStyle();
// update the number of classes
int numClasses = classifier.getSize();
// if (elseMode == ELSEMODE_IGNORE) {
// numClasses++;
// }
//numeric
if (classifier instanceof RangedClassifier) {
RangedClassifier ranged = (RangedClassifier) classifier;
Object localMin = null;
Object localMax = null;
// for each class
for (int i = 0; i < ranged.getSize(); i++) {
// obtain min/max values
localMin = ranged.getMin(i);
localMax = ranged.getMax(i);
Rule rule = createRuleRanged(ranged, expression, localMin, localMax,
geometryAttrType, i, elseMode, colors, opacity, defaultStroke);
fts.addRule(rule);
}
} else if (classifier instanceof ExplicitClassifier) {
ExplicitClassifier explicit = (ExplicitClassifier) classifier;
// for each class
for (int i = 0; i < explicit.getSize(); i++) {
Set value = (Set) explicit.getValues(i);
Rule rule = createRuleExplicit(explicit, expression, value, geometryAttrType, i,
elseMode, colors, opacity, defaultStroke);
fts.addRule(rule);
}
} else {
LOGGER.log(Level.SEVERE, "Error: no handler for this Classifier type");
}
// add an else rule to capture any missing features?
if (elseMode != ELSEMODE_IGNORE) {
Symbolizer symb = createSymbolizer(geometryAttrType, getElseColor(elseMode, colors),
opacity, defaultStroke);
Rule elseRule = sb.createRule(symb);
elseRule.setIsElseFilter(true);
elseRule.setTitle("Else");
elseRule.setName("else");
fts.addRule(elseRule);
}
// sort the FeatureTypeStyle rules
Rule[] rule = fts.getRules();
if (elseMode == ELSEMODE_INCLUDEASMIN) {
//move last rule to the front
for (int i = rule.length - 1; i > 0; i--) {
Rule tempRule = rule[i];
rule[i] = rule[i - 1];
rule[i - 1] = tempRule;
}
}
//our syntax will be: ColorBrewer:id
fts.setSemanticTypeIdentifiers(new String[] { "generic:geometry", "colorbrewer:" + typeId });
return fts;
}