Homework 5

Due : 11am, December 12, 2003. (No Extensions).


There are many problems in Civil Engineering analysis that involve the synthesis of polygons, followed by the derivation of engineering properties (e.g., cross section area; moments of inertia; position of the centroid...).

Prototype Application

Figure 1 is a screendump from a prototype implementation for an engineering polygon viewer.

Figure 1. Screendump of Engineering Polygon Viewer

The graphical user interface is assembed from two panels. The center panel is a Canvas object, which can display all kinds of two-dimenasional graphics. This is where the polygon, the graphical axes, and textual strings can be drawn. A second panel positioned along the bottom of the interface contains four buttons;

The normal sequence of operational events is: (1) load the polygon, (2) draw the polygon, and (3) compute and print the polygon properties. However, all three steps can be executed by moving the cursor to the graphics canvas, pressing and then releasing the mouse button.

Links to Files

You should download the following files:

to a directory in your glue/wam account.

Compiling and Running the Program

To compile the program, simply type:

    prompt >> javac PolygonGUI.java

The Java compiler will automatically establish the connection between PolygonGUI.java and PolygonAnalysis.java and generate bytecode files for both source code files. To run the program as a Java applet, type:

    prompt >> appletviewer PolygonGUI.html

Things to Do

The prototype viewer is very incomplete. The purpose of our last assignment is to take the next couple of steps in the design and implementation of the polygon viewer.

  1. Extend the polygonDraw() method in PolygonGUI.java so that small arrowheads are drawn at the end of each coordinate axis. Also, draw small circles (or rectangles) at each polygon cooordinate.
  2. The main() method of PolygonAnalysis.java contains code for computing the maximum/minimum x- and y- coordinates for the polygon, as well as the maximum/minimum radial distances of the polygon coordinates from the origin. See, for example, the output that is generated by typing:
        prompt >> java PolygonAnalysis
    

    Reorganize the source code in PolygonAnalysis.java so that these quantities are calculated in separate methods, and, can be called from PolygonGUI.java.

  3. Extend the capabilities of polygonProperties() in PolygonGUI.java so that the max/min coordinate information is displayed on the screen.
  4. Fill in the details of drawCentroid() in PolygonGUI.java. Add a new "Centroid" button to the graphical interface. Connect it to the drawCentroid() method.
  5. Create a screendump of your revised graphical interface.

What to Hand in

Hand in printouts of your revised versions of PolygonGUI.java and PolygonAnalysis.java, and a screendump of the new graphical interface. Clearly indicated on the source code where you have modified/added new code ... this will help the grader.

This assignment is due on the last day of classes ... so if everything still isn't working, just hand in what you have, clearly indicating what works and what still needs to be implemented.


Developed in December 2003 by Mark Austin
Copyright © 2003, Department of Civil and Environmental Engineering, University of Maryland