BufferedImage img = null;
double dsize;
AffineTransform scaleTx;
AffineTransformOp ato;
BufferedImage scaledImage;
Mark mark;
Shape shape;
MarkStyle2D ms2d;
for (GraphicalSymbol symbol : symbols) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("trying to render symbol " + symbol);
}
// try loading external graphic and creating a GraphicsStyle2D
if (symbol instanceof ExternalGraphic) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("rendering External graphic");
}
eg = (ExternalGraphic) symbol;
// if the icon size becomes too big we switch to vector
// rendering too, since
// pre-rasterizing and caching the result will use too much
// memory
if (vectorRenderingEnabled || forceVector || size > MAX_RASTERIZATION_SIZE) {
Icon icon = getIcon(eg, feature, -1);
if (icon == null) {
// no icon -> no image either, there is no raster
// fallback
continue;
} else if(icon instanceof ImageIcon) {
// when the icon is an image better use the graphic style, we have
// better rendering code for it
GraphicStyle2D g2d = getGraphicStyle(eg, (Feature) feature, size, 1);
if (g2d == null) {
continue;
} else {
g2d.setRotation(rotation);
g2d.setOpacity(opacity);
retval = g2d;
break;
}
} else {
if (icon.getIconHeight() != size && size != 0) {
double scale = ((double) size)
/ icon.getIconHeight();
icon = new RescaledIcon(icon, scale);
}
retval = new IconStyle2D(icon, feature, displacementX,
displacementY, rotation, composite);
break;
}
} else {
GraphicStyle2D g2d = getGraphicStyle(eg, (Feature) feature, size, 1);
if (g2d != null) {
g2d.setRotation(rotation);
g2d.setOpacity(opacity);
retval = g2d;
break;
}
}
}
if (symbol instanceof Mark) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("rendering mark @ PointRenderer "
+ symbol.toString());
}
retval = createMarkStyle((Mark) symbol, feature, symbolizer, size, rotation);
break;
}
}
if (retval != null) {
setScaleRange(retval, scaleRange);
} else {
// from SLD spec:
// The default if neither an ExternalGraphic nor a Mark is specified is to use the default
// mark of a "square" with a 50%-gray fill and a black outline, with a size of 6 pixels,
// unless an explicit Size is specified
StyleFactory sf = CommonFactoryFinder.getStyleFactory();
Mark defaultMark = sf.mark(ff.literal("square"),
sf.fill(null, ff.literal("#808080"), null),
sf.createStroke(ff.literal("#000000"), ff.literal(1))
);
if (size <= 0) {
size = 6;