Programming Assignment 3
CS 45500
Computer Graphics
Fall, 2023

This assignment makes use of the files contained in this zip file. This assignment is due Tuesday, November 21.

For this assignment, you will implement a simple event driven GUI program that combines our 3D renderer with the Java GUI framework.

In the zip file there is a program Hw3.java that you need to complete. Also in the zip file is a runnable demo program hw3_demo.jar that you can run (on Windows) by double clicking on hw3_demo.cmd. On Linux or Macs (and also on Windows) you can run the demo program from the command-line with this command.

        > java  -jar  hw3_demo.jar

Play around with the demo program quite a bit to get a sense of what your code should implement.

Carefully read the code in Hw3.java to understand the outline of what you need to write. Think in terms of the Model-View-Controller (MVC) design pattern. Notice how the program's outline specifies code for each of the model, the view, and the controller. The model part of MVC is pretty much complete in Hw3.java. You need to implement most of the view part and almost all of the controller part.

You need to implement two (broad) steps. First, create all the components needed by the program and add them to the GUI. Second, define event handlers for all of the components.

Write your program in small steps. First, get the components in the north panel to appear (but not do anything). Then get all the components in the east panel and then the south panel to appear (but not do anything).

When you implement the east panel, notice that the panel is defined for you in Hw3.java as a Box container. The Box container has the ability to equally space its components vertically in the container. (A standard JPanel with a BoxLayout manager would bunch all the components together at the top of the panel.) To get the Box container to equally space it components, you need to put glue into the container between the components (specifically, vertical glue).

After the GUI looks correct, start to implement the event handlers. Start with the event handlers for moving the models. Look in the folder hw3\buttons-and-models for example code that shows how to implement button handlers that choose a model and then move it. The folder hw3\buttons-and-models contains programs that demonstrate many of the ideas needed in this assignment. The examples in that folder implement event handlers in multiple ways. For this assignment, it is up to you to choose a technique for defining the event handlers. You can even use different techniques for different event handlers as a way to practice these ideas (private classes, inner classes, anonymous inner classes).

After you can choose a model and move it around, implement the handlers for the check boxes that make each model visible or invisible. One important feature to notice, that you can see by using the demo program, is that selecting one of these check boxes also changes which model is the current model.

After you can change the visibility of each model, write the event handler for the color combo box. Renderers 4 and 5 contain a utility class called ModelShading that contains static methods for shading models in a number of different ways. Read the Javadocs for renderer_4 (or renderer_5) for the API to the ModelShading class.

After you can change a model's color, write the event handler for the model combo box. This combo box lets you replace the currently selected model with any model listed in the combo box. This combo box lists a large number of models to choose from (that list is defined for you in the file ModelList.java, which you do not need to modify (but you do need to look at)). One detail about this combo box, that you can see by using the demo program, is that when you change which model is the current model (using the top row of buttons), this combo box should be updated to display the current model's model name. You do this with the JComboBox method setSelectedIndex() (and the index that you need for the currentModel should be in the array modelIndex). The same is true for the visibility check boxes. Selecting one of those check boxes should cause the model combo box to update the displayed model name.

After you can change the model objects in the scene, implement the event handler for the "Screenshot" button. Look in the clients folder from renderer_2 for the file InteractiveModelsAll_R2.java. It implements a "screenshot" feature using the '+' key command.

Finally, do NOT try to write all the code for this program and then start to debug it. That will never work. You need to get one event handler at a time working. Writing event handlers is not easy. Debugging multiple event handlers at once is extremely difficult and foolish since you don't have to write your code that way.

Turn in a zip file called CS455Hw3Surname.zip (where Surname is your last name) containing Hw3.java, ModelList.java, and any other files that you created as part of your solution.

This assignment is due Tuesday, November 21.

Here are references to relevant classes in the Java API.