private void paint( ViewportGraphics g, SimpleFeature feature, LiteShape shape, Symbolizer symb ) {
if (symb instanceof PolygonSymbolizer) {
PolygonSymbolizer polySymb = (PolygonSymbolizer) symb;
double opacity = SLDs.polyFillOpacity(polySymb);
Color fillColor = SLDs.polyFill(polySymb);
Stroke stroke = SLDs.stroke(polySymb);
Color strokeColor = SLDs.polyColor(polySymb);
int width = SLDs.width(stroke);
if (width == SLDs.NOTFOUND)
width = 1;
if (Double.isNaN(opacity))
opacity = 1.0;
if (fillColor != null) {
fillColor = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), (int) (255 * opacity));
g.setColor(fillColor);
g.fill(shape);
}
if (stroke != null && strokeColor != null) {
Graphics2D g2d = g.getGraphics(Graphics2D.class);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(strokeColor);
float[] dashArray = stroke.getDashArray();
Float dashOffset = stroke.getDashOffset().evaluate(null, Float.class);
if (dashOffset == null) {
dashOffset = 0f;
}
String cap = stroke.getLineCap().evaluate(null, String.class);
int capInt = Utilities.sld2awtCap(cap);
String join = stroke.getLineJoin().evaluate(null, String.class);
int joinInt = Utilities.sld2awtJoin(join);
BasicStroke bStroke = new BasicStroke(width, capInt, joinInt, 1f, dashArray, dashOffset);
g2d.setStroke(bStroke);
g2d.draw(shape);
}
}
if (symb instanceof LineSymbolizer) {
LineSymbolizer lineSymbolizer = (LineSymbolizer) symb;
Color c = SLDs.color(lineSymbolizer);
int w = SLDs.width(lineSymbolizer);
Stroke stroke = SLDs.stroke(lineSymbolizer);
if (c != null && w > 0) {
Graphics2D g2d = g.getGraphics(Graphics2D.class);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(c);
float[] dashArray = stroke.getDashArray();
Float dashOffset = stroke.getDashOffset().evaluate(null, Float.class);
if (dashOffset == null) {
dashOffset = 0f;
}
String cap = stroke.getLineCap().evaluate(null, String.class);
int capInt = Utilities.sld2awtCap(cap);
String join = stroke.getLineJoin().evaluate(null, String.class);
int joinInt = Utilities.sld2awtJoin(join);
BasicStroke bStroke = new BasicStroke(w, capInt, joinInt, 1f, dashArray, dashOffset);
g2d.setStroke(bStroke);
g2d.draw(shape);
}