Assignment 3, CS 349, W13: MVC

Due Friday, March 15, 2013 @ 11:59pm

Note the 48 hour grace period policy in the course slides.

The programming language for this assignment is Java

Check out K-Sketch, the Ph.D. research of a colleague of mine, Richard Davis.

Your task for this assignment will be to create a very simple version of K-Sketch, one that you would be happy to show to your friends, but one that is, perhaps, not quite as polished as the version Richard created (his is in C#).

For your UI, you must have a drawing area, a toolbar at the top, and a slider at the bottom with buttons beneath it. Consider the JToolbar, JSlider, and JButton classes as useful classes for your interface. The other class that I've always found useful when creating Toolbars is the AbstractAction class. Check out the tutorial on using Actions for an overview of how to use Actions.

Consider the execution of your application. Some details:

To time the animation, use the speed of your drag operation. The idea is as follows: Once something has been selected, you mouse down on that object. This starts the animation. Start a timer (javax.swing.Timer) and make it tick based on your desired frame-per-second rate. As you drag the object around the screen, update the location of the object using the displacement of your mouse pointer (e.getX(), e.getY()). When the timer ticks, you want to store the location (delta-x, delta-y, t) in a displacement vector, where t is the time since the start of the animation. If it were me, I would only call repaint after I'd stored the detal-x, delta-y, t in the timer class (i.e. I would NOT repaint when updating displacement in the mouseDragged method of the MouseMotionListener. This ensures that timer "ticks" are captured as quickly and accurately as possible. After a timer ticks, you have lots of time to repaint before the next tick.

For this assignment, classes like Line2D and Polygon are very useful. For example, Line2D has methods that can measure the distance of a point from line segments. Polygon has a contains method that can check to see if another point or polygon is contained within it. The Polygon class is useful for lasso selection (which is the selection method you should support in your application).

Note: This assignment requires that you follow MVC architecture. As a result, you will also need to submit your class diagram in a pdf document alongside your source code. I have always found PowerPoint acceptable for drawing class diagrams for assignments like this. However, if you've got a good UML design tool, feel free to use that instead.

Enhancements

Submission

Submit the following:

Assessment

FAQ

  1. Say I can't do a very good enhancement. What happens if I do two half-baked enhancements? One good enhancement is worth more than two half-baked enhancements. The TAs will be looking to a single, good enhancement to generate that bulk of the additional marks. Don't try to half do a bunch of things. Pick one thing and do it well.