SwingPix Photo Organizerswingpix.sourceforge.net/docs/design/DesignDoc.doc · Web viewDate...
Transcript of SwingPix Photo Organizerswingpix.sourceforge.net/docs/design/DesignDoc.doc · Web viewDate...
SwingPix Photo OrganizerProject Design Document
By:Justin BerstlerAju MathewYinka OgungbemiYinka OlabinjoJohn RountreeMathew Schaffer
Submitted for Drexel University’s Software Engineering Workshop 2Monday June 2, 2003
This document is also available athttp://swingpix.sourceforge.net/docs/design/
Document Revision History
Date Revision Description
3/7/2003 0.01 Initial document framework creation and front-matter creation
3/8/2003 0.1 Incorporation of implementation schedule
3/10/2003 1.0 Document completion
5/30/2003 1.1 Front-matter editing (Sections 1 and 2), initial editing in section 3
6/01/2003 1.2 Section 3 editing
SwingPix Requirements Specification ii
Table of Contents
1 INTRODUCTION...................................................................................................................1
1.1 Purpose......................................................................................................................................... 11.2 Audience........................................................................................................................................ 11.3 References.................................................................................................................................... 11.4 Document Overview..................................................................................................................... 1
2 GENERAL SUBSYSTEM INTERACTION............................................................................23 MAJOR SYSTEM COMPONENTS.......................................................................................23.1 Main Application Driver................................................................................................................2
3.1.1 Main Driver................................................................................................................................. 2
3.2 Main Graphical Interface..............................................................................................................33.3 Application Workspace..............................................................................................................14
3.3.1 WorkSpace............................................................................................................................... 143.3.2 FileManager.............................................................................................................................. 18
3.4 Data Importing............................................................................................................................ 193.4.1 ImportWizardUI.........................................................................................................................193.4.2 Import....................................................................................................................................... 20
3.5 Database Handling...................................................................................................................... 223.5.1 Database System plan.............................................................................................................223.5.2 DBDriver Class.........................................................................................................................23
3.6 Image Editing.............................................................................................................................. 243.6.1 ImageEditor.............................................................................................................................. 24
3.7 Printing........................................................................................................................................ 253.7.1 PrintJob.................................................................................................................................... 253.7.2 PageLayout.............................................................................................................................. 273.7.3 PrintSize................................................................................................................................... 273.7.4 PrintSystemInterface................................................................................................................283.7.5 AwtPrintSystem........................................................................................................................29
3.8 CD Burning.................................................................................................................................. 323.8.1 CDBurner................................................................................................................................. 323.8.2 CDRecordHandler.................................................................................................................... 333.8.3 ISO Maker................................................................................................................................ 343.8.4 CDDevice................................................................................................................................. 34
3.9 Utility Classes............................................................................................................................. 353.9.1 Configuration............................................................................................................................ 353.9.2 PhotoAlbum.............................................................................................................................. 363.9.3 StorablePhoto........................................................................................................................... 373.9.4 ViewablePhoto.......................................................................................................................... 38
4 DEVELOPMENT SCHEDULES..........................................................................................404.1 System Implementation..............................................................................................................404.2 Planned feature addition............................................................................................................40
5 Glossary...............................................................................................................................42
SwingPix Requirements Specification iii
Figures and Screenshots Index
Figure 1: Subsystem Interaction....................................................................................................2
Figure 2: MainInterface Class Dependency Diagram....................................................................3
Figure 3: Main User Interface........................................................................................................5
Figure 4: Icon palette.....................................................................................................................6
Figure 5: File menu........................................................................................................................7
Figure 6: Edit menu.......................................................................................................................9
Figure 7: Tools menu...................................................................................................................11
Figure 8: Help menu....................................................................................................................12
Figure 9: Database-specific interactions.....................................................................................22
SwingPix Requirements Specification iv
1 Introduction1.1 Purpose
This document is a full design for the SwingPix photo organization system. This
document will present a full subsystem-oriented outline of the SwingPix software
system. Each subsystem will then be described in adequate detail to implement a
working system. As such, this document will provide the basis for the
implementation of the system by the SwingPix development team.
1.2 AudienceThis document will be a highly detailed description of the SwingPix photo
organization system. This document will be used by any developers implementing
the SwingPix system. Additional intended audiences include those who are
interested in learning about the inner workings of the SwingPix photo organization
system who also have some knowledge of the workings of computer software
applications. This document is not intended to give a simple overview of the
proposed software system, please use the requirements document for any non-
technical information on the system.
1.3 ReferencesThe SwingPix Requirements Specification document will provide additional non-
technical information about this system.
1.4 Document OverviewThis document will begin with a general overview of the system, going over the
individual components in little detail. Following the overview, there will be more
detailed explanations of the classes that make up each of the system components.
The document will conclude with a general development schedule and the current
list of future development items.
SwingPix Requirements Specification 1
2 General Subsystem InteractionThe SwingPix photo organization application will be divided into seven subsystems.
Each of which will be described in detail in the following pages of this document. These
subsystems are as follows:
Main Driver
Main GUI
Application Workspace
Database System
Image Editing System
Printing System
CD Writing System
The following diagram has been provided to detail the interaction between these
systems. The arrows are to indicate interactions between subsystems. This interaction
will either be in the form of data communications, or functional communications,
depending on the process being carried out. The systems surrounded by a double
border will have graphics interface components. Most of the components will
communicate with both the Main GUI and the Workspace systems, so for the sake of
simplicity, a unifying box has been drawn around the Main GUI and Workspace. Any
system connected to the unifying box will communicate with both the Main GUI and
Workspace systems.
Figure 1: Subsystem Interaction
SwingPix Requirements Specification
PrintingHandles printing single photographs or thumbnail sheets
Main GUIInteracts with the user and calls appropriate subsystems
ImportingHandles importing new images into the system.
DatabaseHandles database management for easy storage and retrieval of shared program data.
Application Workspace Handle requests for data manipulations and data access.
CD BurningHandles archiving images or burning images to CDs for sharing.
EditingHandles modifying images per user request
Main DriverWill start basic system components and transfer control to main GUI.
2
3 Major System ComponentsThe following tables detail individual system components. Each table will define
some type of system component (usually an object class). The table headings
are as follows:
o Identification – an identifying name for the component
o Type – the type of component being detailed
o Function – the high level role of the component in the system
o Subordinates – components that are used by the component
being detailed
o Dependencies – components that the component being detailed
builds on
o Interface – the methods of interaction with the component (e.g.,
member functions of a class)
o Processing – the general operating procedures of the component
o Data – the data that will be contained in the component
3.1 Main Application Driver3.1.1 Main DriverIdentification Main Driver (name: swingpix.run.SwingPix)
Type Class
FunctionThe Main Driver class will run basic configuration functions, then
invoke the Main Graphical Interface.
Subordinates none
Dependencies
The Main Driver operates with the Configuration system and the
Main GUI.
InterfaceThe Main Driver will be main class for this program; as such it does
not have any methods of its own other than a main function to be
invoked upon the program’s execution.
ProcessingThe Main Driver first calls upon the Configuration system to initialize
system-specific data, then instantiates the Main Graphical Interface.
Data None.
SwingPix Requirements Specification 3
3.2 Main Graphical Interface
SwingPix Requirements Specification 4
Figure 2: MainInterface Class Dependency Diagram
Identification MainInterface
Type Class
Purpose MainInterface acts as a controller for each subsystem in SwingPix.
Function The main function of this class is to handle the events triggered by
the user and translate these events to specific subsystem requests.
Subordinates MainInterface will contain and manipulate instances of each of the
following classes;
ImportWizard Workspace PrintSystemInterface ImageEditor CDBurner Search
Frames;
ImportWizardGUI PrintWizardGUI EditGUI CDBurnerGUI SearchGUI
Dependencies
None
Processing
The main method of this class will start the application. When the
application is started, the MainGUI will be loaded which is also the
User Interface. This will also initialize the workspace (WorkSpace
class). Each subsystem is called from MainGUI class by an
actionperformed method. For instance, in order to launch the import
wizard, the user has to either select “Import” from the File Menu or
select the “Import Wizard” icon from the icon palette. The same
actionperformed method is used to load each of theses instances.
Here is an example of what the actionperformed method will look like
for the import wizard;
void import_actionPerformed(ActionEvent evt) {
ImportWizard importWizard = new ImportWizard(); //Here the
SwingPix Requirements Specification 5
}//class is being instantiated
The above method is then called while adding an actionListener to
the import object. Here is an example of what the actionListener will
look like;
import.addActionListener(new ActionListener(){
void import_actionPerformed(ActionEvent evt) {
ImportWizard importWizard = new ImportWizard();
}
});
Subsytems The internal structure of the main system (MainGUI) and how each
component interacts with one another as specified in the functional
requirements.
Interfaces
SwingPix Requirements Specification 6
Figure 3: Main User Interface
Figure 4: Icon palette
Main Screen The main screen will have three panes as displayed above. One
consisting of the album tree, the second one consisting of thumbnails of the picture(s) that exist in an album, and the last pane consisting of icons. Initially, there will be a default album and picture(s) as displayed in Figure 1.0, the first time a user launches the application. When the user selects an album from the album tree, the thumbnails of the picture(s) that exist in the album will be displayed in the thumbnail pane as you can see in the Figure 1.0.
The “Create New Album” button when clicked will load the ImportWizard class that will launch the ImportWizardGUI where the user can either create a new album and import picture(s) to it or import picture(s) to an existing album. The following method will be called in MainGUI class;
void importWizard_actionPerformed(ActionEvent evt) {
ImportWizard importWizard = new ImportWizard();
}
The “Previous Album” button when clicked, acts as a navigation tool for the user to view previous picture(s) that exist in the previous album(s) up the album tree hierarchy, if any exists.
The “Next Album” button when clicked, also acts as a navigation tool for the user to view other picture(s) in album(s) that exist down the album tree hierarchy, if any exits.
The “Print, Rotate, Write to CD, Save for Email, and Import Picture(s)” icons, are displayed at the bottom pane for quick
SwingPix Requirements Specification 7
access. When the user double clicks on any of these icons, a method is called and a new window or dialog is displayed that pertains to that icon’s class.
Note: It’s the same method that is used to handle the
actionPerformed when the user selects a quick access icon
from the icon palette or a menu item from the file and tools
menu.
Figure 5: File menu
Under the “File” menu will exist the following menu items; Open, Import, Save album, Save for email, Close, Print, and Write to CD, as shown in figure 1.2. When any of these menu items is selected, a method is called that will load a class which will then launch a dialog or window pertaining to the menu item selected. Look at figure 1.7 for the menu items and their methods. The
SwingPix Requirements Specification 8
“Close” menu item will allow the user to exit the system.
Open When open is selected, a method is called that will launch a file
dialog which will enable the user to select a picture or image to
be viewed from a specified directory or device. Hee is an example of
what the method will look like;
void open_actionPerformed() {
FileDialog fileDialog = new FileDialog();
}
ImportWhen import is oselected, ImportWizard class will be loaded which
will extend ImportWizardGUI that will launch the import
wizard. Here the user can import picture(s) into an existing album or
create a new album to import picture(s) to. Here is an example of that
the ImportWizard class will look like;
public class ImportWizard extends ImportWizardGUI {
}
Save album and Save for emailWhen either of these menu items is selected, a method will be called
that will allow the user to save the album or picture for email in the
save album or save for email directories under the workspace
directory.
PrintWhen print is selelcted, PrintWizard class will be loaded which will
extend PrintWizardGUI that will launch the print wizard. Here the
user can select picture(s) to be printed and the sizes the picture(s)
should be printed as. Here is an example of what the PrintWizard
class will look like;
SwingPix Requirements Specification 9
public class PrintWizard extends PrintWizardGUI {
}
Write to cdWhen print is selelcted, CDBurner class will be loaded which will
extend CDBurnerGUI that will launch the cd burning wizard. Here the
user can select picture(s) and/or album(s) to be burned unto a cd.
Here is an example of what the CDBurner class will look like;
public class CDBurner extends CDBurnerGUI {
}
CloseWhen close is selected, a method is called that will exit the system.
To find out what the method will look like, go to figure 1.7.
SwingPix Requirements Specification 10
Figure 6: Edit menu
Under the “Edit” menu will exist the following menu items; Delete, and Rename, as shown in figure 1.4. When any of these menu items is selected, a method is called that will load a class which will then launch a dialog or window pertaining to the menu item selected. Look at figure 1.7 for the menu items and their methods.
DeleteWhen delete is selected a method will be called that will allow the
user to delete album(s) or picture(s). Look at figure 1.7 for what the
method will look like.
RenameWhen rename is selected, a method is called that will allow the user
SwingPix Requirements Specification 11
to rename an album or picture. Look at figure 1.7 for
what the method will look like.
Figure 7: Tools menu
Under the “Tools” menu will exist the following menu items; Rotate, Crop, Zoom in (+), Zoom out (-), Next album (Page Down), and Previous Album (Page Up) , as shown in figure 1.5. When any of these menu items is selected, a method is called that will load a class which will then launch a dialog or window pertaining to the menu item selected. Each of this menu items will be handled by methods in the Edit class.
SwingPix Requirements Specification 12
Figure 8: Help menu
Under the “Help!” menu will exist the following menu items; About, Search, and Help with…, as shown in figure 1.6. When any of these menu items is selected, a method is called that will load a class which will then launch a dialog or window pertaining to the menu item selected. Look at figure 1.7 for the menu items and their methods.
AboutWhen selected, will display a small dialog that will tell the user what
version of the system he/she is using, an overview of the system,
and copyright laws.
Help with...
SwingPix Requirements Specification 13
When selected, will load call a method This will then load the
HelpWith window. This is where a user’s question can be answered
concerning the system.
SearchWhen selected, will load the Search class which extends SearchGUI
that will launch the search window. The user can search for an album
or picture by name. If the album(s) or picture(s) exist, they will be
displayed in a list, and if not, a message will be displayed telling the
user to either check the search string entered, or enter a new search
string. Look at figure 1.7 for what the method will look like.
Here are the following methods called when any of the menu items is selected;
Menu item
Method
Import void
importWizard_actionPerformed(ActionEvent evt)
{
ImportWizard importWizard = new
ImportWizard();
}
Open void open_actionPerformed(ActionEvent evt)
Save void save_actionPerformed(ActionEvent evt)
Save for
void
saveForEmail_actionPerformed(ActionEvent
evt)
Print void printWizard_actionPerformed(ActionEvent
evt)
PrintWizard printWizard = new PrintWizard();
SwingPix Requirements Specification 14
}
Write to
CD
void writeToCd_actionPerformed(ActionEvent
evt)
{
WriteToCd writeToCd = new WriteToCd();
}
Close private void exitForm(WindowEvent evt) {
System.exit(0);
}
Rename void renamePhoto( Photo photo, String name)
void renameAlbum(PhotoAlbum album String
name)
Delete void deleteAlbum(PhotoAlbum album)
void deletePhoto(Photo photo, PhotoAlbum
album)
About void about(JDialog dialog, JLabel label)
Search void searchAlbum(String album)
void searchPhoto(String photo)
HelpWith void helpWith(String word)
Data This class is static and therefore no instance of it shall be created.
3.3 Application Workspace3.3.1 WorkSpaceIdentification WorkSpace
Type Class
Function The WorkSpace is a management tool. Its purpose is to manage
albums and their contents while keeping the filesystem and database
up-to-date. It will communicate with DBDriver for data updates and
retrieval. It will also need to handle any and all errors when
performing its operations.
Subordinates none
Dependencies Communicates with MainGUI, DBDriver, FileManager, AppDriver,
SwingPix Requirements Specification 15
Editing, cd burning and import wizard classes.
Interfaces void initialize()
PhotoAlbum createAlbum(String name)
vector getAllAlbums()
Photo getPhoto()
PhotoAlbum getAlbum()
void addPhoto(Photo photo, PhotoAlbum album)
void copyPhoto(Photo photo, PhotoAlbum sourceAlbum,
PhotoAlbum destAlbum)
void movePhoto(Photo photo, PhotoAlbum sourceAlbum,
PhotoAlbum destAlbum)
void renamePhoto(Photo photo, String name)
void renameAlbum(PhotoAlbum album, String name)
void deletePhoto(Photo photo, PhotoAlbum album)
void deleteAlbum(PhotoAlbum album)
void savePhoto(Photo photo)
Processing void initialize()
As soon as WorkSpace is created it will need to begin the
initialization process. This includes creating the database container
and using it to access the database. Album objects will also be
created at this time.
PhotoAlbum createAlbum(String name)
Tell DBDriver to create new album. Create an instance of the new
album. Call on FileManager to create a folder for the new album on
the hard disk. Handle disk write and DBDriver exceptions.
vector getAllAlbums()
Get list of albums from DB. Make a call to getAlbum() for each
album in list. Handle disk read and DBDriver exceptions.
PhotoAlbum getAlbum()
Make a call to getPhoto() for each image in the album.
SwingPix Requirements Specification 16
Photo getPhoto()
Call readImage method in FileManager class. Construct a new
Photo object with the Graphic2d that is returned. Handle disk read
exceptions.
void addPhoto(Photo photo, PhotoAlbum album)
Call on DBDriver to create this image in the database. Call
writeImage function in FileManager class. Handle disk write or
DBDriver exceptions.
void copyPhoto(Photo photo, PhotoAlbum sourceAlbum,
PhotoAlbum destAlbum)
Call writeImage function in FileManager class to write the copied
image to the new location. Make update call to DBDriver. Update
the PhotoAlbum objects. Handle disk write and DBDriver
exceptions.
void movePhoto(Photo photo, PhotoAlbum sourceAlbum,
PhotoAlbum destAlbum)
Call deleteImage in FileManager class to remove the image from the
source album. Call writeImage in FileManager class to write the
image to the destination album. Make update call to DBDriver.
Update the PhotoAlbum objects. Handle disk write and DBDriver
exceptions.
void renamePhoto(Photo photo, String name)
Make update call to DBDriver. Handle DBDriver exception.
void renameAlbum(PhotoAlbum album, String name)
Make update call to DBDriver. Handle DBDriver exception.
void deleteAlbum(PhotoAlbum album)
Call on DBDriver to delete the album from the database. Call
deleteAlbum in FileManager class to remove it from the hard disk.
SwingPix Requirements Specification 17
Handle disk write and DBDriver exceptions.
void deletePhoto(Photo photo, PhotoAlbum album)
Call on DBDriver to delete the image from the database. Call
deleteImage in FileManager class to remove it from the hard disk
Handle disk write and DBDriver exceptions.
void savePhoto(Photo photo)
Call writeImage in FileManager class to write the new version of the
image to the hard disk. Handle disk write exception.
Data private DBDriver dbDriver
3.3.2 FileManagerIdentification FileManager
Type Static Class
Function The FileManager class is a static class and will be responsible for
maintaining the Swingpix directory structure on the hard disk. It will
write image files to the disk as well as read images from the hard
disk or a cd.
Subordinates none
Dependencies The FileManager can only be referenced by the WorkSpace class.
Interfaces void createAlbum(String folderName)
Graphics2d readImage(String path, String filename)
void writeImage(Graphics2d image, String path, String filename)
void deleteImage(String path, String filename)
void deleteAlbum(String folderName)
SwingPix Requirements Specification 18
Processing void createAlbum(String folderName)
This method will create a folder for the new album.
Graphics2d readImage(String path, String filename)
This method will read an image file from the disk and store it in the
Photo object that will be returned.
void writeImage(Graphics2d image, String path, String filename)
This method will write the given image to disk.
void deleteImage(String path, String filename)
This method will delete the given image from the given album’s
folder.
void deleteAlbum(String folderName)
This method will delete the given folder and all its contents.
Resources FilesystemThe filesystem will be organized as follows:
Each album will have a folder Each album folder will have one subdirectory for each of the
following: images, thumbnails, and original images. Each image belonging to an album will be stored in the
appropriate album’s images folder
The directory structure will look like this:
-Swingpix (Base directory)
-Data
-Album (each album will have a folder at this level)
-Images
-Thumbnails
-Backup
SwingPix Requirements Specification 19
3.4 Data Importing3.4.1 ImportWizardUIIdentification ImportWizardGUI
Type Class
Function This class provides a graphical interface that allows the user to
import pictures to a new or existing album. Images can be added
or removed from the working album while working with the wizard.
Subordinates none
Dependencies none
Interfaces void onAddImages(Vector photoCollection)
void onAddImage(Photo photo)
void onRemoveImage(Photo photo)
void onCreateNewAlbum()
void onOpenExistingAlbum()
Processing void onAddImages()
Calls on import object to add the selected photos to the album.
void onAddImage()
Calls on import object to add the selected image to the import
void onRemoveImage()
This method calls on the import object to remove the selected
image from the import.
void onCreateNewAlbum()
This method calls on the import object to create a new album to
import images to.
void onOpenExistingAlbum()
This method calls on the import object to retrieve an existing album
from the WorkSpace to import images to.
SwingPix Requirements Specification 20
void onPerformImport()
Data Import import
3.4.2 ImportIdentification Import
Type Class
Function This class provides a data type to store all relevant information
about an import. This information includes the images to be added.
Subordinates none
Dependencies none
Interfaces void addImages(Vector photoCollection)
void addImage(Photo photo)
void removeImage(Photo photo)
void createNewAlbum()
void openExistingAlbum( )
Processing void addImages(Vector photoCollection)
Adds the collection of images to the import
void addImage(Photo photo)
Adds the image to the import
void removeImage(Photo photo)
Removes the image from the import
void createNewAlbum()
This method has the WorkSpace create a new album that images
will be imported into.
void openExistingAlbum(
Gets an existing album from the WorkSpace to import images to.
void performImport()
SwingPix Requirements Specification 21
This method will ask the WorkSpace to add all the selected images
to the album that was chosen during the import process.
Data private Vector imageCollection
private Album importAlbum
SwingPix Requirements Specification 22
3.5 Database Handling3.5.1 Database System plan
Figure 9: Database-specific interactions
SwingPix Requirements Specification
DB (JDBM)
JDBM API’s
DBDriver
createTable( )
deleteTable( )
insertRecord( )
deleteRecord( )
updateRecord( )
findRecord( )
CD Burning
getSize( )
getPath( )
Search(Main GUI)
findImage( )
findAlbum( )
Workspace
createAlbum( )
deleteAlbum( )
addPhoto( )
deletePhoto( )
renameAlbum( )
renamePhoto( )
23
For our purposes we are using JDBM 0.12, an open source database available through
http://jdbm.sourceforge.net. JDBM is a simple transactional persistent engine for Java. It
aims to be for Java what GDBM is for C/C++, Perl, Python, etc: a fast, simple
persistence engine. All the API’s are available on the website.
3.5.2 DBDriver ClassIdentification DBDriver
Type Class
Function
This class will act as a communication portal between the Database
and the other subsystems. The DBDriver will handle all the requests
made to the database by the other subsystems and will use the build-
in functions of the database to give appropriate output. The DBDriver
will have to create methods to handle each request.
Subordinates none
Dependencies
This module is responsible for orchestrating data accuracy within the
program, as it will be responsible for dealing directly with the
database.
It will rely on the accuracy of its methods and the format of the
request heavily to perform its task. In order for the DBDriver to run,
all the JDBM API files must be available. The module will completely
depend on the hardware and software being used by the system, the
operating system being either Windows or Linux.
Interface
The DBDriver is the interface of the database. The DBDriver wouldn’t
need a graphical interface of its own, as the subsystems will know
how to invoke the methods of the DBDriver.
This class will create the following methods:
createTable( ) – Creates a new table
deleteTable( ) – Deletes an existing table
insertRecord( ) – Insert a new record into an existing table.
deleteRecord( ) – Delete existing record/records
updateRecord( ) – Update changes to a record.
findRecord( ) - Search for a record within the database.
Processing 1. The Subsystems will request information using their defined
SwingPix Requirements Specification 24
methods.
2. The DBDriver will take the request and figure out what the
subsystem requests of the database.
3. The DBDriver then uses its methods to get the requested
information from the database using the appropriate query.
4. The database acts on the requested query and gives an
output accordingly.
5. The DB will get the output provided by the database, arrange
it and present it to the subsystem in the way they requested it.
DataThe data being handled will be metadata, mostly information about
the images in terms of its size, the album it’s being stored in and the
path to the image location.
3.6 Image Editing3.6.1 ImageEditorIdentification ImageEditor
Type Class
Function
This class will provide static methods for operating on
BufferedImages. All of the functions contained in this class will
operate on and return BufferedImage objects, as such, the first
argument of every function is a BufferedImage.
Subordinates None.
Dependencies None.
Interfaces
toBlackandWhite(…)
setColors(…, double, double, double)
zoom(…, double)
copy(…)
scale(…, double[, double[, int]])
resize(…, double, double)
rotate(…, double) [also rotateCW, rotateCCW]
flip[Horizontal/Vertical]
createThumbnail(…)
constrain(…, Dimension, boolean)
SwingPix Requirements Specification 25
Processing
toBlackandWhite()- this function is a convenience function for
setColors(…, 0, 0, -1)
setColors()- adjusts the brightness, contrast, and saturation of an
image respectively. All parameters are ranged [-1,1]
zoom()- convenience function for fast scaling
copy()- creates a new BufferedImage from the provided image.
scale()- scale an image in one or both directions, with an int
parameter to specify the type of scaling.
resize()- resizes an image to a particular pixel or percentage
proportion
rotate()- rotates an image by the specified number of degrees, or 90
degrees clockwise/counterclockwise.
flip[Horizontal/Vertical]- flips the image in a mirror fashion either
vertically or horizontally.
createThumbnail()- creates a thumbnail sized image from the
provided image.
constrain(…, Dimension, boolean)- constrains an image to specific
proportions without changing the image aspect ratio, the boolean
specifies whether the image should be scaled up to the
proportions or not.
DataNone. All image data is passed into functions and immediately
passed back out.
3.7 Printing3.7.1 PrintJobIdentification PrintJob
Type Class
Function This class provides a data type to store all relevant information
about a print job. This information includes the photos to be
printed, the size of each photo, and the page layout. This class is
what is expected by all implementing classes of the
PrintSystemInterface in order to properly print.
Subordinates none
SwingPix Requirements Specification 26
Dependencies none
Interfaces void addPhotos(Vector photoCollection)
void addPhoto(Photo photo)
void removePhoto(Photo photo)
void setLayout(PageLayout layout)
PageLayout getLayout()
void setPrintSize(PrintSize size)
PrintSize getPrintSize()
Processing void addPhotos(Vector photoCollection)
Adds the photoCollection to the PrintJob
void addPhoto(Photo photo)
Adds the photo to the PrintJob
void removePhoto(Photo photo)
Removes the photo from the PrintJob
void setLayout(PageLayout layout)
Sets the layout of the PrintJob to layout (see PageLayout).
PageLayout getLayout()
Returns a reference to the current PageLayout (see PageLayout).
void setPrintSize(PrintSize size)
Sets the PrintSize to size (see PrintSize).
PrintSize getPrintSize()
Returns a reference to the current PrintSize (see PrintSize).
Data private ArrayList photos
Collection of StorablePhotos to be printed
private PageLayout layout
PageLayout used to print the photos
SwingPix Requirements Specification 27
private PrintSize size
PrintSize to be used
3.7.2 PageLayoutIdentification PageLayout
Type Class
Function This class provides a simple abstraction of the two page layout
choices: “Pretty Print” and “Maximum Output”. Pretty Printing
ensures that all photos on each printed page face the same
direction are centered horizontally on the page, contain captions
indicating their user-given photo names, and that photos are
separated vertically by at least ½ inch. Maximum Output printing
indicates that any measures may be taken to place photos on each
page to maximize the number of photos per sheet of printed paper
as long as the print size is retained and that all photos are
separated by at least ¼ inch.
Subordinates none
Dependencies none
Interfaces void setLayout(final int layout)
final int getLayout()
Processing void setLayout(final int layout)
This method takes one of the final int data members of PageLayout
to set the layout field appropriately (see Data section).
final int getLayout()
Returns the current layout data field.
Data public static final int PRETTY_PRINT = 0
public static final int MAX_FIT = 1;
private static final int NUM_LAYOUTS = 2;
The total number or available layouts – used for error checking
3.7.3 PrintSizeIdentification PrintSize
SwingPix Requirements Specification 28
Type Class
Function This class provides a simple abstraction to the variety of printable
photo sizes available (any of the supported standard photo sizes or
other options – see Data section). Each option is characterized by
a final int data member of the PrintSize class.
Subordinates none
Dependencies none
Interfaces void setSize(final int size)
int getSize()
Processing void setSize(final int size)
Set the photo size of the current instance to size.
int getSize()
Return the current print size int.
Data int printSize
private static final int 3_BY_5 = 0
3”x5” standard photo size
private static final int 4_BY_6 = 1
4”x6” standard photo size
private static final int 5_BY_7 = 2
5”x7” standard photo size
private static final int 8_BY_10 = 3
8”x10” standard photo size
private static final int FREE_SIZE = 4
Print the photo by it’s current size
private static final int MAX_SIZE
Maximize the photo to fit on a single sheet while still retaining its
aspect ratio (i.e. shape).
3.7.4 PrintSystemInterfaceIdentification PrintSystemInterface
Type Interface
Function This interface provides the minimum requirements that an
implementation should support. Basically, any print system
SwingPix Requirements Specification 29
implementation should support the print(PrintJob job) method, no
matter what API it uses to accomplish the task of turning the
PrintJob into dead trees.
Subordinates none
Dependencies none
Interfaces void print(PrintJob job, int resolution) throws PrintException
Processing void print(PrintJob job) throws PrintException
This method should use whatever means necessary to convert the
PrintJob from bits and bytes into sheets of paper with the photos of
the job laid out exactly as specified in the job. In case of a printing
error, a PrintException should be thrown with a message indicating
the nature of the error.
Data
3.7.5 AwtPrintSystemIdentification AwtPrintSystem
Type Class
Function This class implements the PrintSystemInterface using the AWT
printing API. Currently, this is the API we expect to use for all of
SwingPix’s printing needs, but just in case, we made sure to first
create the PrintSystemInterface so that we may change our minds
without drastically changing our code.
Subordinates none
Dependencies AWT Printing API
Interfaces void print(PrintJob job, int resolution) throws PrintException
Processing public AwtPrintSystem(Frame frame, Workspace workspace)
Constructor
void print(PrintJob job, int resolution) throws PrintException
This method employs the Java2D API to print the job to paper as
described specifically by the job’s PageLayout and PrintSize.
private int layoutPage(
SwingPix Requirements Specification 30
ArrayList allPhotos,
int index,
PrintJob job,
Dimension pageSize,
Graphics page)
Method for laying out the next page in the document – makes a call
to either layoutPagePretty() or layoutPageSqueezed() depending
on the PageLayout of the PrintJob.
allPhotos – all StorablePhotos to be printed
index – index into allPhotos of the next photo to be laid out
job – the PrintJob being printed
pageSize – the printable area of the page
page – the current page to be drawn to
Returns the number of photos laid out onto page.
private int layoutPagePretty(
ArrayList allphotos,
int index,
PrintJob job,
Dimension pageSize,
Graphics page)
This method follows the “Pretty Print” guidelines for laying out
photos onto the current page.
allPhotos – all StorablePhotos to be printed
index – index into allPhotos of the next photo to be laid out
job – the PrintJob being printed
pageSize – the printable area of the page
page – the current page to be drawn to
Returns the number of photos laid out onto the page.
private int layoutPageSqueezed(
ArrayList allphotos,
int index,
PrintJob job,
SwingPix Requirements Specification 31
Dimension pageSize,
Graphics page)
~NOT IMPLEMENTED~ This method follows the “Max Output”
method of laying out photos onto the current page.
allPhotos – all StorablePhotos to be printed
index – index into allPhotos of the next photo to be laid out
job – the PrintJob being printed
pageSize – the printable area of the page
page – the current page to be drawn to
Returns the number of photos laid out onto the page.
private BufferedImage resizePhoto(
BufferedImage photo,
PrintSize printSize,
Dimension pageSize)
This method will resize the photo (if necessary) to match the
printSize while still retaining the photo’s aspect ratio (shape) AND
not allowing the photo to be larger than the page.
Please note that in the case of the standard photo PrintSizes, the
original photo may not be the same aspect ration as the requested
output size. In such cases, resizing will occur such that the largest
dimension of the output image will be exactly the largest dimension
of the desired size AND the smallest dimension of the output image
will be greater than or equal to the smallest dimension of the
desired size but less than or equal to the largest dimension of the
requested size. In simpler terms, either the output will be exactly
the requested dimensions or only one dimension (length or width)
will need to be trimmed (by cutting manually) in order to make the
printed output into the standard photo size. The motivation for this
method is to allow the user to chop off whatever parts of the image
they find most suitable – rather than programmatically doing it or
distorting the image’s original shape.
photo – photo to be resized
printSize – desired output size
SwingPix Requirements Specification 32
pageSize – printable area of the page.
private BufferedImage getBufferedImage(StorablePhoto
currentPhoto)
This method uses the workspace to return the BufferedImage which
corresponds to the currentPhoto’s full sized image.
Data private static int printerResolution
Resolution in dots per inch (dpi) to print at
private static final PageAttributes.PrintQualityType
PRINT_QUALITY
One of the three available print quality in the AWT system
private Frame parentFrame
Frame to which the AWT print dialog belongs
private final Workspace workspace
Workspace used to convert StorablePhotos to BufferedImages
private BufferedImage cachedPhoto
When implementing the Pretty Print layout, it became necessary to
look ahead to the next photo, which requires loading it into memory.
In the case that this photo cannot fit on the current page, it is
cached here so that it does not need to be retrieved again when
laying out the next page – pretty slick, eh?
3.8 CD Burning3.8.1 CDBurnerIdentification CDBurner
Type Class
Function This is the main class for handling CD burning. Any CD
burning process will start by instantiating an object of this
class. This class will have the functions necessary to
SwingPix Requirements Specification 33
specify what data is to be burned, and how.
Subordinates CDRecordHandler, ISOMaker
Dependencies None
Interfaces void setFiles(Vector filelist) throws FileException
void setMode(int burnmode) throws InputException
Vector getDevices()
CDDevice getFirstDevice()
void setDevice(CDDevice dev) throws IOException
void burn() throws BurnException
Processing construction – CDBurner must be given a reference to the
program’s Workspace object
setFiles(Vector filelist) – will define the set of files (or
directories) to be burned to the CD
setMode(int burnmode) – takes one of CDBurner.COPY or
CDBurner.ARCHIVE and uses it to define what type of disc
to write
getDevices() – returns a vector of CDDevice objects, each
referencing a particular possible CD burning device.
getFirstDevice() – returns the first device reported by the
CDRecordHandler
setDevice(CDDevice dev) – sets the device to write to as
specified by dev
burn() – tells the CDBurner to begin the burn process
Data The CDBurner object keeps internal copies of the data
passed to it.
3.8.2 CDRecordHandlerIdentification CDRecordHandler
Type Class
Function This class is an abstraction for ‘cdrecord’, the program used
to interact with the CD recording hardware.
Subordinates None
Dependencies presence of ‘cdrecord’ in the system (where it is expected to
SwingPix Requirements Specification 34
be found)
Interfaces Vector getDevices()
void writeDisc(CDDevice dev, String isofilename) throws
IOException
Processing getDevices() – returns a vector of CDDevice objects, each
referencing a particular possible CD burning device.
writeDisc(…) – starts the burning process for the selected
ISO using the specified writing device
Data None
3.8.3 ISO MakerIdentification ISOMaker
Type Class
Function This class is an abstraction for ‘mkisofs’, the program used
to build the ISO files used to make CDs
Subordinates None
Dependencies presence of ‘mkisofs’ on the system (where it is expected to
be found)
Interfaces void setFiles(Vector filelist) throws FileException
String getISOFilename()
Processing setFiles(…) – returns a vector of CDDevice objects, each
referencing a particular possible CD burning device.
getISOFilename()) – builds an ISO and returns the file name
and path of the generated ISO.
Data Holds a record of files to be included in the ISO.
Contains a hardcoded member dictating the ISO type as
either Joliet (Romeo if necessary) or Rockridge
3.8.4 CDDeviceIdentification CDDevice
Type Class
Function This is a data class intended to represent a particular CD
writing device. It will contain all the data about the particular
SwingPix Requirements Specification 35
device.
Subordinates None
Dependencies None
Interfaces int getLUNAdapter()
int getLUNHost()
int getLUNDev()
int getID()
String getLongName()
String getShortName()
String toString()
Processing construction – specify LUN (comma separated string), Long
name, and Short name
getLUNAdapter() – returns the adapter number of the device
getLUNHost() – returns the host number of the device
getLUNDev() – returns the device number of the device
getID() – returns the unique identifier for the device
getLongName() – returns the device name (with model info)
getShortName() – returns the short device name (for UI)
toString() – outputs LUN as a comma separated triplet
Data Holds a record of specified LUN, long name, and short
name
3.9 Utility ClassesThese classes are common classes across every subsystem used for data storage
and handling.
3.9.1 ConfigurationIdentification Configuration
Type Class
Function This class holds static members and functions used to hold
system configuration data.
Subordinates None.
Dependencies None.
Interfaces public void setOS()
SwingPix Requirements Specification 36
numerous public static data members
Processing setOS()- sets public static data members that are operating-
system dependent
static data members- these data members encompass
various operational parameters for the system (e.g., JPEG
compression, external program locations, thumbnail sizes,
image formats).
Data All data for this class is in the form of public static member
variables. They are provided by the class directly. As such
any instantiation of this class has no personal data.
3.9.2 PhotoAlbumIdentification PhotoAlbum
Type Class
Function This class serves as data storage for a collection of
StorablePhoto objects.
Subordinates StorablePhoto
Dependencies None.
Interfaces addPhotoCollection(Collection)
addPhoto(StorablePhoto)
removePhoto(StorablePhoto)
setName(String)
getName(String)
getId()
size()
getPhoto(int)
search(String)
Processing addPhotoCollection(Collection)- appends a java Collection
of StorablePhoto objects to this album in the order that
they are returned by the Collection’s iterator.
addPhoto(StorablePhoto)- adds a single StorablePhoto to
this album.
removePhoto(StorablePhoto)- removes a specific
SwingPix Requirements Specification 37
StorablePhoto from this album.
setName(String)- sets the album name.
getName(String)- returns the album name.
getId()- returns the album’s ID.
size()- returns the number of StorablePhoto objects in the
album.
getPhoto(int)- returns a specific StorablePhoto by index in
the album
search(String)- searches for any StorablePhoto whose
textual data matches the provided regular expression.
Data photos- a collection of StorablePhotos in the album
name- the name of the photo album
id- the ID for this album
3.9.3 StorablePhotoIdentification StorablePhoto
Type Class
Function This class represents all the non-graphical data associated
with a photograph in the system. This object is serializable
(able to be represented by a string) so that it can be stored
in the database.
Subordinates None.
Dependencies None.
Interfaces setName(String)
getName()
setId(String)
getId()
getAlbumName()
Processing setName(String)- sets the name for this photo
getName()- returns the name for this photo
setId(String)- sets the ID for this photo
getId()- returns the ID for this photo
getAlbumName()- returns the album name
Data name- the name for this photo
SwingPix Requirements Specification 38
id- the ID for this photo (unique within an album)
albumName- the parent album name for this photo
3.9.4 ViewablePhotoIdentification ViewablePhoto
Type Class
Function This class is an encapsulation of StorablePhoto that also
contains the graphical data associated with the
StorablePhoto. It is not serializable, because storing this
class directly into the database would also put graphical
information in the database.
Subordinates StorablePhoto
Dependencies None.
Interfaces updateThumbnail()
getPhoto()
getThumbnail()
setStorableInfo(StorablePhoto)
getStorableInfo()
getAlbumName()
getPhotoID()
getName()
getDiskLocation()
Processing updateThumbnail()- creates a new thumbnail image using
the full sized image as a reference.
getPhoto()- returns the full sized BufferedImage.
getThumbnail()- returns the thumbnail BufferedImage.
setStorableInfo(StorablePhoto)- sets the StorablePhoto data
for this object.
getStorableInfo()- returns the StorablePhoto data for this
object.
getAlbumName()- returns the parent album name (taken
from the internal StorablePhoto).
getPhotoID()- returns the ID of this photo (taken from
SwingPix Requirements Specification 39
internal StorablePhoto).
getName()- returns the name of this photo (taken from
internal StorablePhoto).
getDiskLocation()- returns the location of the file from which
this photo was created, on disk.
Data photo- the full size image, as a BufferedImage object
thumbnail- the thumbnail-sized image, as a BufferedImage
storableInfo- the StorablePhoto from which this
ViewablePhoto was created
diskLocation- the location of the file representing this photo,
on disk
SwingPix Requirements Specification 40
4 Development Schedules4.1 System Implementation
1. Build Photo class
2. Build Album class
3. Build DB class
a. Implement data storage
b. Implement data searching
4. Test function and integration between Photo, Album, and DB classes
5. Build Main GUI
6. Build Main Driver
a. Test function and integration between completed components
7. Build Workspace
8. Build Importing System
9. Test partially completed system for integration and photo management
capabilities
10. Build Editing System
11. Test Editing System
12. Build Printing System
13. Test Printing System
14. Build CD Burning System
15. Test CD Burning System
16. Test whole system for completeness and reliability
17. Build installation guide program
18. Test software package as a whole until package is prepared for initial release
4.2 Planned feature additionThe SwingPix photo system will be complete for basic use upon initial release.
However, there are a number of features that have been discussed for possible release.
These features will not be available until subsequent releases. These features may
include the following possibilities, as well as any features that may be suggested during
the course of user testing.
Rendering albums to HTML for sharing purposes
SwingPix Requirements Specification 41
Uploading rendered HTML pages to user web space
Automatic photograph enhancement
Direct importing from devices that use TWAIN style interfaces
Album encryption and keyed access
SwingPix Requirements Specification 42
5 GlossaryTWAIN: [Technology Without An Interesting Name] A common protocol used
for communications with advanced graphic devices such as scanners
and digital cameras.
ISO: [International Organization for Standardization] When used as a noun,
this acronym refers to a disk image adhering to the ISO9660
standard.
disk image: The contents of an entire storage device’s data represented as a
single file. This file can be used to reproduce copies of a data storage
device’s contents, in their entirety.
ISO9660: A standardized data file format commonly used on CD-ROMs.
Joliet: A Microsoft file system designed to be encapsulated into an ISO9660
image. This file system has support for long file names, and is
compatible with the DOS 8.3 file naming convention.
Romeo: An extended Joliet file system. This file system can handle longer file
names than Joliet, but is not compatible with the DOS 8.3 file naming
convention.
Rockridge: An open file system designed to be encapsulated into an ISO9660
image. This file system conforms to the extended file system
standard, commonly used on Linux systems.
LUN: [Logical Unit Number] A numeric triplet (e.g., 0, 6, 0) used to identify
devices on a SCSI device adapter.
SCSI: [Small Computer System Interface] An interface to mass storage
devices commonly used for high-bandwidth data transfers. All
SwingPix Requirements Specification 43
recordable CD devices operate over either hardware or software SCSI
channels.
SwingPix Requirements Specification 44