So you would obviously have to change it. Incremental command wouldn't help
you since you are doing animation Incremental commands are just a way of
allowing long-running data processes to maintain an interactive UI -
otherwise the UI would block while you did your processing. Thus they don't
help you here since you cannot control the interval.
MyBinClass [] unsortedBins;
int interval = 1000;
new Timer() {
private final MyBinClass [] bins = unsortedBins;
private int bin = 0;
public void run()
{
if (bin >= bins.length) {
return;
}
moveBinToCorrectSpot(bins[bin]);
bin++;
schedule(interval); // schedule the next step to run a
second after this one
}
}).schedule(0); // start the animation now.
This way, you can even adjust the sort interval between each step (if you
want to speed up during the animation or allow control by a slider).
Also, I'd take a look at the Animation
class as well which might help you with saying this animation must
complete in 10 seconds, and
base your calculations of the progress (since computer speed is variable)
On Mon, Feb 1, 2010 at 11:37 AM, Sean <[email protected]> wrote:
> Hi Vitali,
>
> That is what I'm doing now. However, I'm going to have something like
> //For example
> for(bin : bins)
> {
> moveBinToCorrectSpot(bin)
>
> }
>
> So each Bin will get it's own timer in moveBinToCorrectSpot that moves
> it to it's right spot. However, they'll all animate at the same time.
>
> Jeff,
>
> I will have to check out IncrementalCommand, I've never seen that
> before.
>
> Thanks for the tips all!
>
> On Feb 1, 12:53 pm, Sean <[email protected]> wrote:
> > I"m trying to do a visual sort. Imagine a bubble sort where you see
> > the items move from one bucket to the next. The way I would move them
> > visually is use a Timer with an AbsolutePanel and move them up.
> >
> > However, I wouldn't want to move the next guy until my last one has
> > finished animating. If I do that, then everything will animate at once
> > making a big mess that ends up correct, but you can't see the process
> > happening clearly.
> >
> > What I would want is, on the timer finishing, I'd like to do a
> > CallBack and say, I'm done, u can do the next one.
> >
> > What's the correct way to handle this? a While(Timer!=null){sleep}
> > type thing or somehow fake an AsyncCallback or some other way?
> >
> > Thanks in advance for your suggestions!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.