package cse1030; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; /** * A controller for the image viewer application. * * @author CSE1030Z * */ public class ViewerController implements ActionListener { /** * String for the action command for opening files. */ public static final String OPEN = "OPEN"; /** * String for the action command for clearing all of the images. */ public static final String CLEAR = "CLEAR"; /** * String for the action command for showing the previous image. */ public static final String PREVIOUS = "PREVIOUS"; /** * String for the action command for showing the next image. */ public static final String NEXT = "NEXT"; private ViewerModel model; private ViewerView view; /** * Creates a controller with the given model and view. * * @param model a ViewerModel * @param view a ViewerView */ public ViewerController(ViewerModel model, ViewerView view) { this.model = model; this.view = view; } /** * Method that responds to action events emitted from the view controls. * * @param event an event to respond to * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent event) { String action = event.getActionCommand(); /* You need to implement the following: if the action is OPEN ask the view for which files to open ask the model to open the files ask the view to set the image to the current image else if the action is CLEAR ask the model to clear the images ask the view to set the image to the current image else if the action is PREVIOUS ask the view to set the image to the previous image else if the action is NEXT ask the view to set the image to the next image */ } }