Re: ImageResource question
Thanks for asking that question - it led me to a solution to a problem that I've had, which is "skinning" an app using different versions of resources loaded asynchronously from the war directory as opposed to coded into a ClientBundle.
I created a client bundle extending SimplePager.Resources, with sources that reference dummy placeholder images in my source tree, then created a separate class implementing that interface. In the constructor I populate it from the GWT.created bundle (since some of the resources aren't dynamic, and I can just delegate through to them) but then load my dynamic images into Image widgets. Those, in turn, are each given to an implementation of ImageResource that holds an Image widget, and obtains the width, height, url, etc. from it (wasn't sure what the heck to do with getName, or how to implement isAnimated). Those are the return values from the associated methods in my resource object. And then I give that to the pager constructor.
The asychronicity turned out to be a bear, since I'm using a LoadHandler for each image to know when the size values will be available, and that won't do anything unless I actually add the Image to the document, so I had to create a hidden div to put them into. I haven't yet tested if that's necessary with a data: url. And a lot of layout tasks had to be pushed off into a callback.
The concept works, but I suspect that unless I make all versions of a particular image the same size, I can't use any CssResource tricks based on the image. That's probably not a big deal - since the variations generally would all be the same size. Also, I don't think that there's any existing Resource class in the API with CSS resources that depend on the images, so it would only be an issue with custom resource classes.
On Wednesday, August 14, 2013 3:42:34 AM UTC-4, df wrote:
-- I created a client bundle extending SimplePager.Resources, with sources that reference dummy placeholder images in my source tree, then created a separate class implementing that interface. In the constructor I populate it from the GWT.created bundle (since some of the resources aren't dynamic, and I can just delegate through to them) but then load my dynamic images into Image widgets. Those, in turn, are each given to an implementation of ImageResource that holds an Image widget, and obtains the width, height, url, etc. from it (wasn't sure what the heck to do with getName, or how to implement isAnimated). Those are the return values from the associated methods in my resource object. And then I give that to the pager constructor.
The asychronicity turned out to be a bear, since I'm using a LoadHandler for each image to know when the size values will be available, and that won't do anything unless I actually add the Image to the document, so I had to create a hidden div to put them into. I haven't yet tested if that's necessary with a data: url. And a lot of layout tasks had to be pushed off into a callback.
The concept works, but I suspect that unless I make all versions of a particular image the same size, I can't use any CssResource tricks based on the image. That's probably not a big deal - since the variations generally would all be the same size. Also, I don't think that there's any existing Resource class in the API with CSS resources that depend on the images, so it would only be an issue with custom resource classes.
On Wednesday, August 14, 2013 3:42:34 AM UTC-4, df wrote:
Hello. Is There any way to create ImageResource dynamically? For example : I get images from WebService in base64 format and I don't have opportunity to have all images on the server at compile time. Can i cast Images to ImageResource? Or is there any other solution?Thanks for help.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home