JMU JMU - Department of Computer Science
Help Tools
PA2: 2-D Vectors and Graphics


1 Purpose

The primary purpose of this assignment is to help you review (and demonstrate that you have acquired) the knowledge and skills required to create graphical applications that make use of 2-D graphics and basic vector arithmetic.

It will also help you learn a little bit about how to write JUnit tests for GUI components.

2 Overview

Nearby is a (fictitious) company that develops personal navigation systems, en-route and mobile commerce systems, location-based services, and geographic tracking/location services. They are in the process of developing a personal navigation system called Way. They have hired you to construct several interfaces/classes that could be used to collect the data required by Way. Specifically, you will will be developing some components for a digitizer.

3 Design Document

Nearby has provided you with the following design document:

4 Questions to Think About Before You Start Programming

You do not need to submit answers to the following questions, but you should think about them before you start writing code.
  1. What are the advantages of using the model-view-controller pattern?
  2. For simplicity, the current design uses a List<Line2D.Double> in the document to manage the lines that are being digitized? Might it be better to use a Set, Map, or some other abstract data type. In other words, what operations need to be performed on the model?
  3. How are you going to distinguish (programmatically) between drawing a new line and selecting an existing line?

5 Testing

You must write unit tests for the Vector, DisplayDigtizerDocument, and DigitizerPanel classes. You must use JUnit (v5) for this purpose. Your JUnit test suite must cover 80% of all statements and all branches (as measured by EclEmma) in these classes. Your unit tests must be in a package named testing and each test class must include the word "Test" in its name.

You must also perform system testing on all of the components you write. Nearby has provided you with the following classes and an image that you can use for this purpose.

The image file (which is an orthographic photograph of the area near JMU) must be accessed from the current working directory (i.e., they must not be accessed using a path). In Eclipse, this means that you must copy the files into the project directory/folder (not the src folder or any folder underneath it).

6 Submission

You must submit (using Gradescope) a .zip file named pa2.zip that contains:
  1. Your gui, math, and testing packages (packaged appropriately). Do not submit the app package and do not submit any images.

There is no limit on the number of submissions and no penalty for excessive submissions.

7 Grading

Your submission will be "autograded" as follows:

Gradescope will provide you with hints, but may not completely identify the defects in your submission.

Note that some of the criteria are described as "Success Required". This means that Gradescope will not assess subsequent criteria unless this criterion is satisfied (and you will receive a grade of 0 for the criteria that aren't assessed). So, for this assignment, if your code does not conform to the style guide then nothing else will be assessed (and you will receive a grade of 0 for the assignment). You should be able to use the tools on your computer to comply with the style guide and you should be able to tset your code, without assistance from Gradescope.

Points will be deducted manually (i.e., after the due date) for code that is unclear, inelegant, and/or poorly documented.

8 Help

Help is available on the following topics.

8.1 Help with JUnit Testing of GUI Components

You probably have not written JUnit tests for GUI components in the past. Help is available on the CS Wiki at:

Before you submit to Gradescope, make sure that your JUnit tests terminate completely (without invoking System.exit(). If they do not terminate properly, Gradescope will run for 10 minutes but not complete the assessment. One common mistak in this regard is forgetting to invoke dispose() on the JWindow object.

9 Questions to Think About After You Submit

You do not need to submit answers to the following questions, but you should think about them before you start writing code.
  1. What are the advantages and disadvantages of using a double[] to represent points rather than a Point2D or two double values?
  2. What is a java.awt.MouseAdapter? Why wasn't it used in the existing design? (Hint: Think about single inheritance.)
  3. What do you think about the tools you used to test the GUI components?

Copyright 2025