/* (non-Javadoc)
* @see org.ajax4jsf.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext, java.lang.Object)
*/
protected Object getDataToStore(FacesContext context, Object data) {
if (data instanceof UIPaint2D) {
UIPaint2D paint2D = (UIPaint2D) data;
ImageData dataToStore = new ImageData();
dataToStore._width = paint2D.getWidth();
dataToStore._height = paint2D.getHeight();
dataToStore._data = paint2D.getData();
dataToStore._paint = UIComponentBase.saveAttachedState(context, paint2D.getPaint());
String format = paint2D.getFormat();
if("jpeg".equalsIgnoreCase(format)) {
dataToStore._format = 1;
} else if("png".equalsIgnoreCase(format)) {
dataToStore._format = 2;
}
String bgColor = paint2D.getBgcolor();
try {
dataToStore._bgColor = HtmlColor.decode(bgColor).getRGB();
} catch (Exception e) {}
dataToStore.cacheable = paint2D.isCacheable();
return dataToStore;
} else {
throw new FacesException("Data for painting image resource not instance of UIPaint2D");
}