confused about program design decisions for animation

D

Duane Evenson

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

Jeff Higgins

Duane said:
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
 
J

Jeff Higgins

Jeff Higgins said:
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/>
 
S

Stefan Ram

Duane Evenson said:
I've been looking without success for a good animation example but
can't find anything more complicated than a circle tracking the mouse.

See your

Java\jdk1.7.0\demo\jfc\Java2D\src

directory.
 
D

Duane Evenson

[...]
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top