[2951] in java-interest

home help back first fref pref prev next nref lref last post

Finished first applet, now some questions...

daemon@ATHENA.MIT.EDU (Eric Richards)
Mon Oct 23 02:27:33 1995

Date: Sun, 22 Oct 1995 21:32:43 -0700
From: Eric Richards <richards@teleport.com>
To: java-interest@java.sun.com
Cc: richards@teleport.com


Hello!                                                       (I <heart> Java!)

   I've tackled my first simple applet and, being that I decided to learn by
doing rather than studying everything first, I have some basic questions to
fill in my gaps.  

   (Oh, and rather than post all the source to this applet in question, please
see <URL:http://www.teleport.com/~richards/Java/> for a pointer via my new Java
Barista notebook.)

   The applet is just a simple animator that takes a single filmstrip gif file
and then copies the current frame out of the image to the paint() method's
graphic.  To copy the current frame, a line like the following is used:

   g.drawImage( fImageStrip, 0, -(fFrame * fFrameHeight), this );
   
Why is the negative height needed?  Why can't a positive one be used?

   I used the Media Tracker class to make sure the image is really acquired
before being used.  But, I have to do the following to get valid width:
   
   fFrameWidth  = fImageStrip.getWidth(this);
   fFrameHeight = fImageStrip.getHeight(this) / fNumFrames;
   fFrameWidth  = fImageStrip.getWidth(this);
   
The first fFrameWidth gets -1.  After that, the pump seems "primed."  Is there
a more proper way of dealing with an Image instance after the image is known to
have been retrieved?

   The only thing really special about this animator is that it has an option
for the first frame to be a background and all subsequent frames "transparent"
with foreground images to go over the background.  Right now, this is too
unattractive to be worth it.  While normal animation appears smooth, this
animation lurches along, skipping frames.  I can only guess that since 3
drawImage() calls have to be used instead of one (and one of those deals with a
transparent image) the overhead takes too much time and screen updates are
dropped.  I have an idea for a workaround...


   -- Eric
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post