|20-CS-694||Advanced Programming Techniques||Spring 2012|
This series shows how to use some of the classes associated with
animating objects. Click on the class names in the following table
to see class details.
||-||A thread is started and every 50 milliseconds it causes a checker to move slightly and be repainted on a bicolor background. There is some flicker.|
||-||The flicker of the above is reduced because only the area whose colors change as a result of the checker movement are repainted. This is accomplished with method clipRect of class Graphics.|
||-||Double buffering eliminates all the flicker.|
Simple animation of objects - only paint is used.
Eight dots are drawn at home positions. Drag dots, with the mouse
to another position. Release the mouse button and dots will return
to their home positions. The last "touched" dot is always brought
to the top (draws over all other dots). Observe the object trails
as they are moved from home positions.
MyObjectList is a doubly linked list of cells holding Dot objects. Its purpose is to support the illusion that one dot is "on top of" another. The head of the list holds the dot that is on the "bottom" and the tail holds the dot that is on the "top". Searching for a dot when the mouse button is pressed starts from the tail. But drawing dots starts from the head. Hence a doubly linked list is most efficient.
|-||There is no double buffering in this applet but the background is painted to erase dots from frame to frame. Observe the flicker.|
|-||Trails and flicker are gone due to double buffering.|
|-||Demonstrates the effect of synchronized when applied to the critical section update.|
|-||With StackCanvas and CodeCanvas classes, painting Canvases during window events is possible. Drawing to an offscreen image insures correct painting will appear after window events occur.|
||-||Use of threads to control time critical process. Point mouse and click at several places in both chambers. Click on the 'Start' button to start the simulation. Edit the temperature fields during the simulation and see the effect.|
|-||Nice use of threads.|