..
2025-03-24 23:18:10 -07:00
2025-03-26 21:14:46 -07:00
2025-03-24 01:38:54 -07:00
2025-03-26 21:41:13 -07:00
2025-03-24 01:38:54 -07:00
2025-03-24 01:38:54 -07:00
2025-03-24 01:38:54 -07:00

Objectives

Design and implement a desktop-based photo album manager using Java Swing. The application should demonstrate the use of the Iterator pattern, the MVC pattern, and the Strategy pattern to allow flexible behavior for sorting and displaying images.

Problem Statement

Create a photo album manager application that allows users to:

  • Add, view, and delete photos in the album.
  • Navigate through the album using next/previous buttons.
  • Display the photos in three different sorting orders by name, date added, and file size.
  • The sorting should be implemented using the Strategy pattern, allowing different sorting strategies to be selected.
  • The album should be iterated through using the Iterator pattern.
  • The application should follow the MVC (Model-View-Controller) pattern to separate business logic, user interface, and control flow.

Functional Requirements

  • Photo Management:
    • The program manages real images.
    • Users should be able to add new photos (with a name, file path, and date).
    • Users can delete photos by name from the album.
    • Display a list of photos (name and thumbnail preview).
    • Display the current photo.
  • Navigation:
    • The "Next" and "Previous" buttons change the current photo to the next photo and the previous photo, respectively. The next and previous photo are determined by the current sorting order of the list of photos.
    • The application must implement an Iterator to traverse the photo collection.
  • Sorting Photos:
    • Users can sort the list of photos by name, date added, or file size.
    • The sorting behavior should be dynamic and implemented using the Strategy pattern.
  • The system should handle the following edge cases: empty photo albums (e.g. can't delete from an empty photo album) and non-existent file paths.

Use of Patterns

MVC

  • Model (PhotoAlbumModel) Represents the photo collection and the current state of the album. Notifies the view when there is a change in the photo collection (by adding or deleting). Photo class contains attributes like name, file path, and date added.
  • View (PhotoAlbumView) A Swing-based UI that displays the up-to-date list of photos in the order of date by default and the current photo.
  • Controller (PhotoAlbumController) Provides controls (buttons for adding, deleting, sorting, navigating). Has buttons like "Add Photo", "Delete Photo", "Next", "Previous", and "Sort By" (Name/Date/Size). Responds to user actions and modifies the model accordingly. Manages the connection between user input (e.g., button clicks) and the photo album (model).

Iterator Pattern

Implement an AlbumIterator class (class that implements the AlbumIterator interface) to iterate over the photos in the album.

Strategy Pattern

Create three different sorting strategies, specifically SortByName, SortByDate, SortBySize for sorting the photos. The user can select different strategies dynamically to change the sorting order of the photos.

Rough Layout of the User Interface

You should adhere to the layout provided below as closely as possible, but some reasonable flexibility is allowed. Photo Manager

Submission

Submit hw3.zip through the course web site. The file hw3.zip should contain the following:

  • All source files
    • PhotoAlbumApp.java (with main), Photo.java, PhotoAlbumController.java, PhotoAlbumModel.java, PhotoAlbumView.java, SortByDate.java, SortByName.java, SortBySize.java, SortingStrategy.java.
    • Put javadoc comments in the source codes.
    • Remove all package statements from the source files.
    • All .java files (not .class files)
  • googledoc.txt: In this text file, specify a link to your google doc, titled as CS151_HW3_YOUR ID. Be sure to make this document available to ANYONE WHO HAS THE LINK (There will be point deductions if this requirement is not met.) The google doc should not be modified after the due date . The followings are required to present in the google document.
    • Screen 1: Initial screen without any photos.
    • Screen 2: After adding the first photo, the list and the current photo change.
    • Screen 3: After adding the second photo, the list updates. Photos are displayed in order of date, with the first photo in the list set as the current photo.
    • Screen 4: After adding the third photo, the list updates. Photos are displayed in order of date, with the first photo in the list set as the current photo.
    • Screen 5: After sorting the list by name, both the list and the current photo change.
    • Screen 6: After sorting the list by size, both the list and the current photo change.
    • Screen 7: After sorting the list by date, both the list and the current photo change.
    • Screen 8: After the next button is clicked, the list remains the same but the current photo changes.
    • Screen 9: After the previous button is clicked, the list remains the same but the current photo changes.
    • Screen 10: After deleting one of the photos by name. The list changes. The current photo only changes if the deleted photo was the current one. If so, the first photo in the updated list becomes the new current photo.
    • Show the correct use of patterns (copy and paste the specified code from your Java programs and label them clearly):
      • MVC Pattern
        • Controller: The action listener code for the "Add" button, which calls the mutator of the model.
        • Model: The data structure and the mutator that updates the data structure and notifies the view.
        • View: The code that calls the model's accessor and triggers a repaint.
      • Strategy Pattern: A class diagram documenting the use of the Strategy pattern. One interface and three concrete classes are expected.
      • Iterator Pattern: The Iterator class. (That is, a class that implements the AlbumnIterator class.)