LinkedList<PolygonSymbolizer> polyStyles = new LinkedList<PolygonSymbolizer>();
// * Not used: <kml:BalloonStyle>
// * Not used: <kml:ListStyle>
for (int i = 0; i < symbolizers.length; i++) {
Symbolizer sym = symbolizers[i];
if (sym instanceof PointSymbolizer) {
iconStyles.add((PointSymbolizer) sym);
} else if (sym instanceof TextSymbolizer) {
labelStyles.add((TextSymbolizer) sym);
} else if (sym instanceof LineSymbolizer) {
lineStyles.add((LineSymbolizer) sym);
} else if (sym instanceof PolygonSymbolizer) {
polyStyles.add((PolygonSymbolizer) sym);
}
LOGGER.finer(new StringBuffer("Adding symbolizer ").append(
sym).toString());
}
// Points / Icons
if (iconStyles.isEmpty()) {
// Add a default point symbolizer, so people have something
// to click on
encodeDefaultIconStyle(feature);
} else {
Iterator<PointSymbolizer> iter = iconStyles.iterator();
while (iter.hasNext()) {
PointSymbolizer sym = (PointSymbolizer) iter.next();
try {
Style2D style = styleFactory.createStyle(feature,
sym, scaleRange);
encodePointStyle(feature, style, sym);
} catch (IllegalArgumentException iae) {
LOGGER.fine(iae.getMessage() + " for "
+ sym.toString());
}
}
}
// Labels / Text
if (labelStyles.isEmpty()) {
encodeDefaultTextStyle();
} else {
Iterator<TextSymbolizer> iter = labelStyles.iterator();
while (iter.hasNext()) {
TextSymbolizer sym = (TextSymbolizer) iter.next();
try {
TextStyle2D style = (TextStyle2D) styleFactory
.createStyle(feature, sym, scaleRange);
encodeTextStyle(feature, style, sym);
} catch (IllegalArgumentException iae) {
LOGGER.fine(iae.getMessage() + " for "
+ sym.toString());
}
}
}
// Lines
if (!lineStyles.isEmpty()) {
Iterator<LineSymbolizer> iter = lineStyles.iterator();
while (iter.hasNext()) {
LineSymbolizer sym = (LineSymbolizer) iter.next();
try {
LineStyle2D style = (LineStyle2D) styleFactory
.createStyle(feature, sym, scaleRange);
encodeLineStyle(feature, style, sym);
} catch (IllegalArgumentException iae) {
LOGGER.fine(iae.getMessage() + " for "
+ sym.toString());
}
}
}
// Polygons
if (!polyStyles.isEmpty()) {
Iterator<PolygonSymbolizer> iter = polyStyles.iterator();
while (iter.hasNext()) {
PolygonSymbolizer sym = (PolygonSymbolizer) iter.next();
try {
PolygonStyle2D style = (PolygonStyle2D) styleFactory
.createStyle(feature, sym, scaleRange);
// The last argument is forced outline
encodePolygonStyle(feature, style, sym, !lineStyles
.isEmpty());
} catch (IllegalArgumentException iae) {
LOGGER.fine(iae.getMessage() + " for "
+ sym.toString());
}
}
}
} catch (Exception e) {