Assignment 2: Extending Swing components

This is an INDIVIDUAL assignment. Due: Week 6, February 11.

Objective

In the last assignment you learned how to put together Swing applications by using existing components. In this assignment, you'll learn how to create your own Swing component from scratch and populate your journal with notes, images and sketches. You'll be building the tools that let you make multiimedia journal entries, including "energy use views" of the journal application. Entries can contain simple text as well as an imported image as well as sketches and annotations added by the user. This means that you are developing several custom components for content:

  1. a JournalEntryPanel. The JournalEntry panel will contain a content area that can hold text and/or graphics/images. It contains
  2. the EnergyUse View. This will be a static graphic chart for now. You can also add annotations to the EnergyUseView.
  3. a JournalView: the collected view of journal entries. For the moment this can be a simple list.

When you have finished this assignment you will have gained:

Description

This seems like a big assignment, but it is extremely modular, and you can do it in pieces. Don't be intimidated by the length of the homework description! Although long, most of this writeup is here just to provide detail about what I expect from this assignment, as well as some hints about how best to do the implementation.

In this assignment, you will create custom Swing components that serve as the content editors and viewers in the energy Journal application. The basic idea is that the journal contains entries that each can comprise text/notes, optional images imported from disk, and optional sketches and notes entered freehand by the user. The Journal Entry panel or the JournalView will sit in the blank content area of the shell you built in Assignment 1 (you toggle between them). The EnergyUse view will be a separate window. These are described in detail below.

There are a number of specific requirements for this assignment:
  1. Journal entry.
  2. ImagePanel
    1. Picture:Your component will hold a single image that you import. Since the component may be larger or smaller than the image it displays (because the user may resize the window, for example), you need to provide a background behind the image, and a "frame" or some sorts around it. For example, you could do a beige paper background, or something with a pattern (blue graph paper maybe). For the frame around the picture you can have a simple white border or something resembling a film slide, or "scrapbook corners". The background should be rendered underneath the image itself. The frame can either be rendered above or below the image.
  1. EnergyView
  2. JournalView. You should provide a navigatable view of journal entries in your sidebar. A simple scrolling lit will suffice for now, but implementing the calendar thmbnail view with selectable date will gain you extra points (Hint: you would use a JTable). For the moment, as you are only expected to to provide one journal entry. this list may be small.
  1. Integration with the rest of the application. Once you've implemented and debugged yourImagePanel, it's time to integrate it into the application you wrote for Assignment #1. When your application starts up, it should contain no images, and hence no ImagePanels.

Deliverable

This is an INDIVIDUAL assignment; while you may ask others for help on Java or Swing details, please write the code on your own. While you can use any development environment you choose, you are not allowed to use "GUI builder" type tools (like JBuilder or Eclipse GUI Builder).

While this assignment is significantly more difficult than the previous one, most of the parts should be fairly straightforward. Start with the basic component architecture and get that working in your application first; one easy way to do this is to implement the UI class's paint method so that it only draws the component background. This way you'll be able to see your component show up and know it's working correctly. After this do the stroke processing (it's the next easiest), followed by the text processing (slightly more complicated). Finally, once all of this is working, it should be fairly straightforward to keep a list ofImagePanels in your application and make the New/Delete/Next/Previous controls work.

To turn in the assignment, please follow the same process as last time:

0. Make sure your program is runnable from the command line using the command "java energyJournal". Use exactly this name (with no package) to make things easier on me and the TAs.

1. Create a new directory using your last name as the name of the directory.

2. Compile your application and place both the sources and classfiles into this directory (they can be at the top-level or in a subdirectory, whatever you want).

3. Put a README.txt file (described below) into the top level of the directory. This file should contain your name and email address, the version of Java you used (1.5.x or 1.6.x, please) as well as any special info I might need in order to run your code (command line arguments, etc.) BE SURE TO TELL ME ANY SPECIAL EXTRAS YOU ADDED OR ISSUES YOU HAD.

5. VERY IMPORTANT. Submit a thorough Software Design Document (see the explanation here).

4. ZIP this directory and submit it via webct.