Monday, January 6, 2014

Re: using "applyto()" with a Composite initWidget(Image);

Ah, it seems;

imageContents = SetFrames[0].createImage();
initWidget(imageContents);

Fixs the problem.
Interesting...applyTo() doesnt work on a image thats created ( = new Image() ) but not set?


On Monday, January 6, 2014 3:49:51 PM UTC+1, darkflame wrote:

Pre-amble:
I have been using an AnimatedIcon class I made myself for a few years now.
It extended Image and had two constructors;

1. Takes an ImageURL and a number of frames, and use's setURL to cycle over them (foo1.png,foo2.png etc)
2. Takes a AbstractImagePrototype[] and uses applyto(this) to cycle over the images.

This worked pretty wonderfully, allowing compile time images to use fast image strips, and runtime picked images to load from urls.

However, I now wanted to add a 3rd image animation type; a deckpanel that hide/shows a preloaded stack of images. This mode would be usefull for testing animations
off a local hard drive without using a server. (as frame switching times are vastly slower - presumably due to no caching).

In order to do this, however, my class would ideally need two methods of construction. A "normal" method for 1/2 where it is just a image widget and a "flickbook" mode where its a deckpanel with images inside it.
I figured if I just made it a composite class this would allow it to be a different widget depending how its used.

This is how it now looks;

public class AnimatedIcon extends Composite { // Image
...
Image imageContents = new Image();

public AnimatedIcon(AbstractImagePrototype[] SetFrames){
// super();
initWidget(imageContents);
....

The "applyTo()" comands are now changed to;

Frames.get(0).applyTo(imageContents);

instead of applyTo(this);

And, naturally, where I was using this.seturl I now use imageContents.seturl();

However, on testing the code I find only the sprites which have been setup to directly use urls (.setURL) work. The sprites which uses bundles and applyTo() don't display at all.
In the html they seem empty;

<div tabindex="0" unselectable="on" aria-hidden="false" style="opacity: 100; outline: rgb(255, 0, 0) solid 2px;"><input type="text" tabindex="-1" role="presentation" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;">
<img class="gwt-Image">
</div>

Question;

1. Can "Image" be used in a composite and still use applyTo(AbstractImagePrototype)?

2. Is there additional setup I should be doing to handle images in this way.

3. If not, and I am forced to go back just to extending image, would it be crazy to store runtime specified images as DataURL's in an internal array, effectively handling cacheing myself?

Thanks for any thoughts.





--
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


Real Estate