This page contains information about DrawingPanel, a graphics panel for use by students in various assignments.

Drawing Panel

Not many of our assignments use scaffolding code. We believe that providing too much framework early on can hinder the student's understanding, and that it is preferable for the students to write as much of the code that will execute as possible. That said, we provide this file to students for several of the assignments to give them a simple interface for drawing graphics on a panel.

Capabilities

The DrawingPanel is a relatively simple JPanel window that has a couple menu controls. It can save the image it is displaying, so that students can save and share the output of their programs. It can also do a diff between the image that it is displaying, and images stored locally as well as image files publicly available on the web. This gives the students a way to verify that their output is correct.

As an aside, this also creates some problems. Different systems have different defaults for drawing text and anti-aliasing, so if you provide images for the students to compare against, it is possible if not likely that some students will have differing pixels for a solution that matches the correct output to the naked eye. To mitigate this problem, we provide images created on Windows, OS X, and a flavor of Linux so that students can hopefully match the correct output pixel for pixel.

Usage (for the instructor)

Provide the DrawingPanel.java file to your students to use. They must save it in the same directory as the program that they are writing -- the java compiler is smart enough to find it and compile it when the student instantiates a DrawingPanel object.

In order to use the "Compare to web file" feature, you must modify a class constant in DrawingPanel.java before you distribute it. The class constant must be a URL of a publicly available text file that contains the URLs of images that students can compare their output against. The name of the class constant is "COURSE_WEB_SITE" -- make a drawingpanel.txt file that contains images for your assignment, make it publicly available on your course website, and then distribute DrawingPanel.java with the constant pointing to your drawingpanel.txt file. Note that you can update the drawingpanel.txt file as new assignments require different image comparisons.