} else if (sprite instanceof TextSprite) {
// Handle text (special handling required)
setTextAttributes((TextSprite) sprite, element);
} else if (sprite instanceof ImageSprite) {
ImageSprite image = (ImageSprite) sprite;
if (image.isXDirty() || ignoreOptimizations) {
element.setLeft((int) Math.round(image.getX()));
}
if (image.isYDirty() || ignoreOptimizations) {
element.setTop((int) Math.round(image.getY()));
}
if (image.isWidthDirty() || image.isHeightDirty() || ignoreOptimizations) {
element.setSize(new Size((int) Math.round(image.getWidth()), (int) Math.round(image.getHeight())));
}
if (image.isResourceDirty() || ignoreOptimizations) {
ImageResource resource = image.getResource();
StringBuilder builder = new StringBuilder();
builder.append("url(").append(image.getResource().getSafeUri().asString()).append(") ");
builder.append(-1 * resource.getLeft()).append("px ");
builder.append(-1 * resource.getTop()).append("px");
element.getStyle().setProperty("background", builder.toString());
}
}