Elements of Graphics: Assignment Four


Due Midnight, Thursday Oct 9.

In this assignment you will extend the hierarchical modeler presented in class to allow for more flexible drawing.

The files you should start with are:

ApplicationFrame.java (same as before)
BufferingFrame.java (same as before)
AnimationFrame.java (same as before)
ModelDraw.java (the drawing class for animated hierarchical models)
GrModel.java (the model building class for animated hierarchical models)
GrObject.java (the object class for animated hierarchical models)
GrInstance.java (the instance class for animated hierarchical models)

Your job is to add attributes to the model that will allow much more flexible drawing. You should be able to specify a fill color and an outline color for each instance in the model; if none is specified, default values are used. You should also be able to specify whether each instance is drawn (in outline), filled, or both. You should also be able to change the thickness of the outline for each instance. These things should be controllable from methods in the GrInstance class that can be invoked from other classes in which the model is created (like GrModel). You do not need to be able to change these attributes on a shape by shape basis within a GrInstance or GrObject. Once you've done that, build a more elaborate model with your system than the one I handed out in GrModel.java, demonstrating all of your new attribute capabilities. That means remove what I have in the body of the makeModel() and moveModel methods and replace it with your own stuff. You should change the animation, your new animation should employ translations and scaling as well as rotations (you can use shears too if you like). The motion should be at least as complex as that I have given you, several objects should move in different ways, and there should be at least two levels in the hierarchy at which motion occurs. Hint: The current code draws in the ModelDraw class by just setting the color to dark blue and filling whatever shape it finds going through the model. This is usable at best for a default color (although there may be better ways to get that too.) One way to improve on this is to provide methods in the GrInstance/GrObject classes to retrieve attributes and use them to draw in the recursive drawing routine itself. Or you could put a drawing method in the GrObject and GrInstance classes (like nextInstance is in both, for example, although the drawing method in GrInstance may extend that in GrObject in this case) and let the recursive routine in ModelDraw use these drawing methods to draw the model. In either case, you'll have to provide mechanisms to specify attributes and store them in the model, just like we store shapes and instances there now.


Don Fussell