Title: Gui Drawing Summary
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Gui Drawing Summary

Drawing Basics

- Overriding the paint method and using the Graphics class to do basic drawing.
- Fundmentals of coordinate system and using the Color class change the color of the drawing object.
- Demonstrating many of the Graphics methods: drawRect, drawOval, fillRect, fillOval, drawLine, drawString, drawRoundRect, draw3DRect, drawArc, drawPolygon, etc.
- Using the Font class and discovering the Fonts supported

Drawing Sizing

- Taking into account drawing borders with Insets
- Resizing by finding out the size of the screen with getSize
- Placing an object at the screen: center, lower right, upper right.
- Scaling a Polygon (Forida.java example)
- Working with Font sizes: getFontMetrics, and its associated methods to perfectly place text
- GraphBeginnings.java - A resizeable Graph of data

Drawing Images

- Loading an image and obtaining it's dimensions
- The many variations of the drawImage Graphics method
- Drawing checkers on a checker board with the image centered in their respective squares
- Loading chess piece images and drawing a chess board

User Input Mechanisms

- Basic Mouse Motion is demonstrated using the MouseMotion inteface. Several examples are created: Spots.java, SpotsSave.java.
- To detect Mouse Motion and dragging, we add one more interface called MouseMotionListener to create the example SpotsArt.java
- A program can access key strokes by implementing the KeyListener interface.
- Using inner classes to implement interfaces such as the MouseListener interface.
- Using adapter classes: An inner class extending the MouseAdapter class to accomplish the same result as the previous example.
- Converting the previous example to an anonymous class.

Animation and Simple Threads

- Extending the Thread class to create a thread.
- Creating a thread by having a class implement the Runnable interface.
- Using a thread to update the time on a screen: Timer.java
- Using a thread to create a simple animation that successively loads images.
- Eliminating screen flicker by creating a memory screen image that gets updated and then copied to the real screen.
- Simple one person Pong game that uses the concepts in this set of notes.

Shape Drawing

- MVC: Model View Controller approach
- Starter code to a simple drawing program(used in one of the JH assignments):
- abstract Shape, Rectangle, Scribble classes
- Drawing.java - has the concept of a drawing program
- DrawingProgram.java - actually contains the JFrame and associated paint routine and Mouse interface routines. Actual work is delegated to the Drawing.java code.

Last Modified: June 6, 2014 11:07 PM