Google Answers Logo
View Question
 
Q: Animation code for java using netbeans 3.3.1 ( Answered,   0 Comments )
Question  
Subject: Animation code for java using netbeans 3.3.1
Category: Computers > Programming
Asked by: shaz_600-ga
List Price: $100.00
Posted: 26 Nov 2002 12:40 PST
Expires: 26 Dec 2002 12:40 PST
Question ID: 115021
Produce a simple graphical image using appropriate Java code and the
Elements package

implement a simple animated graphic image as specified below.  This
will be done using the Elements drawing window class

The complexity of the shapes used and drawing facilities available in
the Element package must be complex.  The emphasis is on the design
and development of a suitable Java program to illustrate your design.

The Image
The image that you produce should be contained within a 200 x 200
pixel window and be something that you could animate in a fairly
simple way.  An animated image might be something like a ‘stick man’
where the limbs could move in a rudimentary way to simulate walking,
or a bird shape drawn with 4 lines that ‘flies’ across the screen.  On
the other hand, it could be as simple as a ‘pac-man’ type image where
a simple mouth shape is drawn in a slightly forward position each time
with the mouth opening or closing so that it appears to move forward
eating.  To summarise, by animation we mean that the image should
change over time (by being redrawn slightly differently) to give the
impression of movement.  (Hint: you could use the ‘waitNSeconds’
method introduced in lecture 5 to delay the computer until the next
‘frame’ of the image was drawn).  Some other comments on the image:

1.	The image must appear in an appropriately sized drawing window.
2.	You must use only the drawing facilities available from the
Elements drawing window class described in Bailey & Bailey(work book
that we take refrence from)
3.	Additionally, you may use colour from the awt colour class –
java.awt.Color
4.	There must be at least 2 lines of standard sized text at the bottom
of the window to describe what the image is.
Requirements
You are required to do the following:

1.	Each feature shown in your design must be drawn using a graphical
object from the Element package.
2.	You must code, test and document (using appropriate in-line
comments) a Java program that implements your design.

The following is not meant to be an exhaustive list, but amongst the
main characteristics we will be looking at when marking this work are
the following:
·	Code that is clearly laid out and easy to follow, uses meaningful
identifiers, and that separates the declaration and the
initialisation/instantiation of variables.
·	An appropriate level of explanatory comments (i.e. where they are
helpful and necessary, not on every statement).
·	The use of methods as a code-structuring mechanism to break the code
down into logical blocks that mirror your design.  It should be
possible to read just your main method in order to see what your
program is doing.  If your code is one long sequence of statements it
will not be possible to achieve more that a bare pass mark.

 
Assessment
The following criteria will be used to assess the understanding of the
work
·	A basic image design using perhaps 2 or 3 shapes
·	At least the basic features of graphic have been implemented in Java
·	Basic use of the drawing tools of the element package
·	Basic animation (2-3 frames of movement)
·	Code is appropriately structured and documented (in-line)
·	At least two colours have been used
·	More complex image design attempted and presented
·	Most features of the design have been implemented
·	Advanced use of some drawing features of the element package
·	Use of multiple colours and more detailed animation
·	Clear and well presented design documentation
·	Well structured and documented code using methods
·	Complex image design successfully implemented
·	Smooth and fairly detailed animation
·	The code is very well structured with advanced use of methods
·	Evidence of appropriate planning at both design and implementation
phases
·	Advanced use of the drawing facilities of the element package
I am using Netbeans verstion 3.3.1 and the text to which i am using as
a refrence is Baily and Baily.  I Know i have included alot of info on
the question thats because i have used tis service before and have
learnt and advised to "add as much information as possible".Hope you
can answer this question.It would be greatlty appreciated if you were
able to answer this question before or by thursday

Thankyou

Request for Question Clarification by seizer-ga on 27 Nov 2002 05:15 PST
Hi there shaz_600. I'm currently working on some code for you. Could
you please confirm for me that the Bailey Elements package that you
are using is the same as the one located here?

http://www.cs.williams.edu/~bailey/JavaElements/

Thanks,

--seizer-ga
Answer  
Subject: Re: Animation code for java using netbeans 3.3.1
Answered By: seizer-ga on 27 Nov 2002 09:47 PST
 
Hi there shaz_600. I've since had a closer look at the Elements
package, and it certainly seems to be the right one - so I've gone
ahead and finished the code for you. It's available from:

http://xult.org/shaz_600/MainWindow.java
http://xult.org/shaz_600/Animation.java
http://xult.org/shaz_600/ScreenSetup.java

Additionally, you may see a screenshot of the animation below. It
features a house, with a chimney blowing smoke. A FedEx truck races up
to the house, and every 75 frames the animation restarts.

http://xult.org/shaz_600/anim.gif

Let me give you a short overview of how the code works. If you feel
that you need more information, please feel free to ask. The code
assumes that the Elements classes are stored in the normal place, and
uses the statement:

import element.*

to import these. If your system stores these classes elsewhere, you
may need to change that line in each of the files I provided.

There are three classes:

MainWindow: This class merely sets up a DrawingWindow and passes it to
the Animation class. You must run this class to start the program (the
command "java MainWindow" should suffice, once all classes are
compiled).

Animation: This class runs as a thread, and performs most of the hard
work in the animation. It draws all of the moving items on the screen,
and works out where they should be placed each frame.

ScreenSetup: This class draws all the basic things which never need to
be changed. For instance, the sun, the grass, and the sky.

The code is well organized and fully commented, so it should be fairly
easy for you to work on and understand. If, however, you need further
assistance or help in understanding it, then please do not hesitate to
use the request clarification feature before rating this answer.

Thanks for an interesting challenge, and good luck with your course.

--seizer-ga

PS - If this is a school assignment, you may be interested to know
that Google has a specific category for getting help with these. It's
located at:

Google Answers >  Reference, Education and News >  Homework Help

If in the future you have more questions for us which are school
related, I'd advise you to post your question(s) there to receive more
appropriate attention. Thanks!

Request for Answer Clarification by shaz_600-ga on 27 Nov 2002 14:09 PST
May i first thank you for the work you have done its brillient.
However i still have to test to see if it works on my work computer
and if you could tell me a litllt more about threds and explain in a
little more detail to what each of the classes do.

And how i find out where the import elemont is stored and how to
change them

Thankyou very much for for your help

Shaz_600

Clarification of Answer by seizer-ga on 27 Nov 2002 14:27 PST
Hello there shaz_600. I'm glad you're pleased with the work.

It certainly should work on your computer. What you'll need to do is
to examine any previous exercises or assignments which used the Bailey
and Bailey Java Elements, and check for a line at the top of the code
which says something like:

import element.*;

If it's different in these files, then just include that alternative
line in the code I have given you, and it should compile well. I can't
really help you more on this one until you try it on your work
computer. Make sure that you have the latest version of the Java
Elements, from:

http://www.cs.williams.edu/~bailey/JavaElements/

As for threads, there's a lot that could be said - if you wanted a
really in depth breakdown, you could even post a new question: it's a
very interesting topic. The most simple description, is that a thread
lets you run part of a program on its own, while letting other bits
run at the same time: simultaneous execution. It's a bit like
multitasking. I used it in your program because it was the best way to
get the animation working. They're extremely simple to do in Java -
just make sure the class "implements Runnable", and make sure it has a
run() method. You can see this in the Animation class.

For more thread information, see here:

http://java.sun.com/docs/books/tutorial/essential/threads/

As for the classes themselves, I believe they're fairly self
explanatory. All you need to do is run the MainWindow class. If you
open each of them up in your editor, and read through the comment
lines, you'll be able to see that they're fairly well described. If
there's a specific detail that you're unclear on, though - please ask!

Good luck,

--seizer-ga
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy