You will do this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.
GoalsThis exercise will let you:
In Part 2 of this exercise (to be done later in the term), you will continue the above and additionally:
|
Grading rubricYou start with 50 points. For each stage that is missing or implemented incorrectly, you lose 10 points.
Because this is an exploratory exercise, no documentation is required, and magic numbers are OK.
|
You will implement this project in stages, testing at each stage to see if the project works correctly through that stage.
|
|
||
|
You don't normally draw directly onto a JFrame. Instead, you:
|
|
|
|
||
|
|
|
For this stage, you will want to examine the Java documentation on the following classes:
|
For this stage, you will want to examine the Java documentation on the following methods:
Doing Font font = new Font("Times New Roman", Font.PLAIN, 72); graphics2.setFont(font);will set the font for graphics2 to Times New Roman, plain, font size 72. That font stays in effect for all drawing operations on graphics2 until you do another setFont on graphics2.
|
Colors are easy: just ask the Graphics object to set the color, and then that color is used for that Graphics object until you tell it otherwise. For example: graphics2.setColor(Color.red); graphics2.draw(new Rectangle(10, 430, 20, 40)); graphics2.draw(new Ellipse2D.Double(5, 440, 40, 20)); graphics2.setColor(new Color(0, 128, 255)); graphics2.fill(new Ellipse2D.Double(30, 470, 20, 40)); graphics2.setColor(new Color(255, 0, 0, 50)); graphics2.fill(new Ellipse2D.Double(80, 480, 40, 30));Note how I used:
|
For this stage, you will want to examine the Java documentation on the Arc2D.Double class. But briefly:
|
A Graphics2D object can be translated, rotated and resized. Doing so applies the transformation to all the objects drawn thereafter on the Graphics2D object. The picture to the right shows a blue ellipse drawn 4 times, per this code:
|
Commit your project to your individual repository when you are done.