/* (non-Javadoc)
* @see org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext, java.lang.Object)
*/
public void send(ResourceContext context) throws IOException {
ImageData data = (ImageData) restoreData(context);
ImageRenderer renderer = (ImageRenderer) getRenderer(context);
FacesContext facesContext = FacesContext.getCurrentInstance();
try {
BufferedImage image = renderer.createImage(data._width,data._height);
Graphics2D graphics = image.createGraphics();
try {
if (data._bgColor != 0) {
Color color = new Color(data._bgColor);
graphics.setBackground(color);
graphics.clearRect(0, 0, data._width, data._height);
}
MethodBinding paint = (MethodBinding) UIComponentBase.restoreAttachedState(facesContext, data._paint);
paint.invoke(facesContext, new Object[] {graphics,data._data});
} finally {
if (graphics != null) {
graphics.dispose();
}
}
renderer.sendImage(context, image);
} catch (Exception e) {
// log.error("Error send image from resource "+context.getPathInfo(),e);
throw new FacesException("Error send image ",e);
}
}