A9-Drawing and Graphics

On This Page


Overview

The main points of this assignment are to:

    1. Write recursive methods
    2. Create a graphical application by using a JFrame class
    3. Use inheritance by extending a JPanel class
    4. Use some of Java's graphics capabilities to draw shapes
    5. Make use of colors in Java

Program Specifications

Write a Java application that displays a drawing on a JPanel added to a JFrame. The specifications include:

  1. The drawing must be done on a subclass of JPanel named MyDrawing.
  2. The application must display a drawing between 400 to 1200 pixels wide by 300 to 800 pixels high.
  3. Your drawing must use at least two types of shapes drawn repeatedly (lines, rectangles, ovals, etc).
  4. Your drawing must use at least two colors.
  5. You must use loops to draw repeated the shapes and not just repeat groups of statements.
  6. Draw at least one of your shapes using a recursive method and identify the method in your README.txt file.

    You must use different recursive methods than those shown in the lecture notes, though the techniques can be the same. For instance, you will not get credit for turning in the drawTree() method. Also, using a Turtle is optional, but encouraged.

  7. You must include your name in the drawing using anti-aliased text.
  8. Each shape (or text) must be drawn in its own method. For example, you would put the code to draw lines in a method like:
  9. public void drawLines(Graphics g) {
        // code to draw lines here
    }
    
  10. To your MyDrawing class, add a main() method that displays the drawing. Your drawing must display and run to completion without any user input.
  11. Do not use any package statements.
  12. Make an executable JAR of your program containing all the files described in the section of this document: What to Turn In.

Sample Drawing

example drawing

Also, you can download and run the asn09demo JAR file. Notice that you can run graphics programs from JAR files by double-clicking the JAR file.

Extra Credit

Adding the following are worth extra credit points:

  1. Use Java2D to fill shapes with gradients or textures. (1 point)
  2. Add a Koch snowflake fractal to your drawing. (1 point)
  3. Add a Sierpinski triangle fractal to your drawing. (1 point)
  4. Add a dragon curve fractal to your drawing. (1 point)

Make certain that your README.txt file describes any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Program Compilation

  • 4: Source code compiles with no errors or warnings
  • 2: Source code compiles with warnings
  • 0: Does not compile or wrong file turned in

Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lesson(s) appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute or no specifications met

Program Style

  • 4: Code is well-documented
  • 3: Code has minor documentation errors
    • Has 1 documentation error
  • 2: Code has some documentation errors
    • Has 2-3 documentation errors
  • 1: Code has many documentation errors
    • Has more than 3 documentation errors
  • 0: No apparent attempt to document code

REAME.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Maximum Score: 20, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Include the following items for grading:

  1. README.txt file
  2. All Java source code and class files in a single executable JAR file

You must submit all the files needed for your assignment to compile and work correctly. Do not assume that the instructors has any files. Also, do not turn in files that are not part of your assignment, especially ones that do not compile. Your assignment must compile after removing all the .class files and running: javac *.java. In addition, your code must work as submitted.

Home | Blackboard | Announcements | Schedule | Room Policies | Course Info
Help | FAQ's | HowTo's | Links
Last Updated: April 28 2009 @16:47:26