|
Prev: (www.stefsclothes.com)supply t-shirt,Sandal,slipper,jersey,nike shoes(paypal accept)
Next: Threading : What's wrong with this ?
From: Duane Evenson on 20 Jul 2008 01:26 I'm having a problem figuring out how I should design my program. I am animating a network protocol stack, where the data expands out into multiple chunks and as they drop through the network layers, collecting the headers and tail. Each chunk, header, and tail is merely a colored rectangle. At the physical layer, animated arrows show the transmission to the receiver where the message rises back through the stack. The user can change the message and MTU, so the number and size of the packets is dynamic and I can't animate using a premade sequence of images. I've been looking without success for a good animation example but can't find anything more complicated than a circle tracking the mouse. Do I want to put all the animation in the paint() method? It gets big, but all the animation sequences are programmed in a sequential order. I could make 5 subclasses of a State class and cycle through them with state.doAnimate(), but that seems only a half measure. Or do I use sprite animation to animate each data chunk, header and tail? Any recommendations, directions, or hints by anyone with animation experience would be appreciated.
From: Peter Duniho on 20 Jul 2008 02:58 On Sat, 19 Jul 2008 22:26:45 -0700, Duane Evenson <duane(a)invalid.address> wrote: > [...] > Do I want to put all the animation in the paint() method? It gets big, > but all the animation sequences are programmed in a sequential order. No, you don't want to do this. I don't have any real experience with Java support for animation, but I can tell you for sure that your paint() method should only paint the _current_ animation frame. The method needs to draw the component _once_ and then return. > I could make 5 subclasses of a State class and cycle through them with > state.doAnimate(), but that seems only a half measure. What "State" class? The only one I see in the main Java SDK appears completely unrelated to animation (it's not even under the java/javax packages). > Or do I use sprite animation to animate each data chunk, header and tail? I'm not aware of any support for sprites in Java. Or is that not what you meant? You can maintain the animation state how you think is best. Possibly someone else here will have some good advice along those lines. But I can tell you for sure you don't want to have your paint() method know anything about the actual animation itself, other than how to draw the current animation frame. :) Pete
From: Jeff Higgins on 20 Jul 2008 06:23 Duane Evenson wrote: > I'm having a problem figuring out how I should design my program. > > I am animating a network protocol stack, ... > > I've been looking without success for a good animation example but > can't find anything more complicated than a circle tracking the mouse. > I've recently been struggling with the same question. Although I'm not completely comfortable with my current depth of knowledge, I've gained some insight by examining these open-source projects. Piccolo, JGraph, ArtofIllustration JH
From: Jeff Higgins on 20 Jul 2008 08:09 "Jeff Higgins" <oohiggins(a)yahoo.com> wrote in message news:48831231$0$4029$bbae4d71(a)news.suddenlink.net... > > Duane Evenson wrote: >> I'm having a problem figuring out how I should design my program. >> >> I am animating a network protocol stack, ... >> >> I've been looking without success for a good animation example but >> can't find anything more complicated than a circle tracking the mouse. >> > > I've recently been struggling with the same question. Although I'm > not completely comfortable with my current depth of knowledge, I've > gained some insight by examining these open-source projects. > > Piccolo, JGraph, ArtofIllustration > > JH > Also, I found this to be easier to grasp than the three previously mentioned. G - Java Graphics Library <http://geosoft.no/graphics/>
From: Duane Evenson on 20 Jul 2008 12:50
On Sat, 19 Jul 2008 23:58:31 -0700, Peter Duniho wrote: > On Sat, 19 Jul 2008 22:26:45 -0700, Duane Evenson <duane(a)invalid.address> > wrote: > >> [...] >> Do I want to put all the animation in the paint() method? It gets big, >> but all the animation sequences are programmed in a sequential order. > > No, you don't want to do this. I don't have any real experience with Java > support for animation, but I can tell you for sure that your paint() > method should only paint the _current_ animation frame. The method needs > to draw the component _once_ and then return. > >> I could make 5 subclasses of a State class and cycle through them with >> state.doAnimate(), but that seems only a half measure. > > What "State" class? The only one I see in the main Java SDK appears > completely unrelated to animation (it's not even under the java/javax > packages). > >> Or do I use sprite animation to animate each data chunk, header and tail? > > I'm not aware of any support for sprites in Java. Or is that not what you > meant? > > You can maintain the animation state how you think is best. Possibly > someone else here will have some good advice along those lines. But I can > tell you for sure you don't want to have your paint() method know anything > about the actual animation itself, other than how to draw the current > animation frame. :) > > Pete I mean using the State Design Pattern, the in this case each state would be Expand, Drop, Arrow, Rise, and Compact. The drawing would occur in each class's doAnimate method, there are a few shared methods in State that wouldn't be overridden, like appending elipses if the animation would exceed the available space (ie. might happen if there are many chunks). This design would break up the drawing but not simplify it much. If you go to the trail tutorial, they give a short explanation and example of sprite animation. Basically, it's making each drawn object a instance of a class. http://java.sun.com/docs/books/tutorial/uiswing/painting/refining.html |