Assignment IV: Slide Show

Submission

This is one of 4 options for Assignment IV: Application.

Please zip your entire directory and submit it via moodle by Monday 4/30 at 11:59pm.

Goals

Use your priority queue from Assignment I: Heaps (or ask me for solutions to create a slideshow application. The slideshow application allows the user to display precisely paced slideshows. The user can create the show by entering “slide text” and “slide times” and pressing the “Add Slide” button. The user does not have to enter slides in order. The slideshow application should order the slides so that they appear on queue at the time the user specified. Finally, the user can press a “Start the Show” button and the slide text should appear in order in the slideshow application according to the schedule entered by the user.

This is being called a “slide show” but you do not have to display images for full credit (see Bonus section). You are only displaying text. However, you can imaging that if the text where image file names or URLs it would be a short leap from the text based “slide show” you are creating ton image based slide show.

Slide show GUI

The design

First, you must come up with a Java GUI skeleton for your slideshow application.

Example Interface:

Implementing your GUI

  1. Implement your GUI with “stub” methods for any action listeners or mouse listeners that you need.
    • The stub methods should print out something like “add slide button has been clicked” and are there to help you test that the GUI is hooked up properly.
  2. Once your stub methods are set up, use the interface and “stub” class for the backend to complete set up for your code.

Slideshow Backend

Create the backend for your slideshow.

You will need a clock that keeps track of the “slideshow time.” This means you’ll need some sort of timer from java. Since I want you to practice with priority queues, you may only use a single timer for this assignment. You may wish to refer to the Java API documentation or the TimerDemo sample class below that demonstrates a method for implementing a timer.

You should use a priority queue to keep track of the next “event” that will occur – an event would be the showing the next slide or ending the show. The key for such an event should be its display time in terms of “slideshow time.”

For example, if the user enters a second show with slide B displaying at 5 seconds, slide C displaying at 9 seconds, and slide A showing at 1 seconds. Each time the user enters a new slide, the time for beginning the slide and an associated slide text should be entered into the priority queue. Once the user presses the button to begin the slideshow, then the slideshow begin to show slide A, then next show slide B at 4 seconds after beginning, show slide C at 8 seconds after the beginning, and finally complete the show at 10 seconds after the beginning. Each time a slide is shown, it should be extracted from the priority queue.

The maximum length of slideshows will be 10 seconds. You will only need to support 10 slides at maximum.

The design

Come up with a design for your slideshow application. What classes do you think you need? Create skeleton files for each class (this should include instance properties and method declarations with comments!).

A reminder: If you feel like you are struggling with program design (what classes to have, what properties and methods each class should have), you can attend office hours or the TA session to discuss creating a starting point.

Completing the implementation

Complete your implementation by defining a class that implements your interface for the backend.

Then hook it up to your GUI (this should only require modifying few lines of code).

Bonus:

Figure out how to show user selected pictures instead of text.

  • Make sure that your program works with local paths so that it can be run on a machine other than the one you developed on.
  • You must test that your program can be unzipped and run on a different machine!
  • Take a video of your slideshow working as backup!

TimerDemo class

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Edited by Jane Q Student on 2/22/2017
 *
 * Created by peter on 2/18/16.
 *
 * This is an example of using an ActionListener in
 * conjunction with a timer. You may find this useful in
 * implementing your slideshow.
 *
 */
public class TimerDemo {
    protected int time;
    protected Timer timer;
    protected ActionListener timerListener;

    public TimerDemo()
    {
        time = 0;

        timerListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                time += 1;


            }
        };
    }

    public void startTimer() {
        // slideshowListener is called every 1000 milliseconds (1 second)
        timer = new Timer(1000, timerListener );
        System.out.print("listener starting...");
        timer.start();
    }

    public static void main(String[] args) {
        System.out.println("welcome to the timer demo\n");
        TimerDemo t = new TimerDemo();
        t.startTimer();
        System.out.println("listener started.");
    }
}