View Javadoc
1 /* 2 * Created on Oct 26, 2003 3 */ 4 package portaview; 5 6 import java.util.Observer; 7 8 import portaview.model.PortaViewModel; 9 import portaview.view.AbstractDisplayerView; 10 11 /*** 12 * The general implementation of a viewer controller. This is used in the 13 * case where one needs to show a preview or full-screen view of an image. 14 * Note that this is an controller, not a view. 15 * @author William Lee 16 */ 17 public abstract class AbstractViewer implements Observer 18 { 19 protected PortaViewModel model = null; 20 protected AbstractDisplayerView view = null; 21 22 /*** 23 * Constructs an AbstractViewer, given the model that that this view observes on. 24 * @param m the PortaViewModel that this view observes on. 25 */ 26 public AbstractViewer(PortaViewModel m) 27 { 28 this.model = m; 29 } 30 31 /*** 32 * @return the PortaView model 33 */ 34 public PortaViewModel getModel() 35 { 36 return model; 37 } 38 39 /*** 40 * Changes the internal PortaView model for this view. 41 * @param model the PortaView model. 42 */ 43 public void setModel(PortaViewModel model) 44 { 45 // we want to make sure that we unregister the listener 46 // to the model and ask the view to do so. 47 if (this.model != null) 48 { 49 this.model.deleteObserver(this); 50 } 51 this.model = model; 52 this.model.addObserver(this); 53 view.setPortaViewModel(model); 54 } 55 56 /*** 57 * Moves to the next slide. 58 */ 59 public void nextSlide() 60 { 61 model.nextSlide(); 62 } 63 64 /*** 65 * Moves to the previous slide. 66 * 67 */ 68 public void prevSlide() 69 { 70 model.prevSlide(); 71 } 72 73 /*** 74 * Sets the viewer to play. 75 * 76 */ 77 public void play() 78 { 79 model.play(); 80 } 81 82 /*** 83 * Sets the viewer to pause. 84 */ 85 public void pause() 86 { 87 model.pause(); 88 } 89 90 /*** 91 * @return the view associated with this controller. 92 */ 93 public AbstractDisplayerView getView() 94 { 95 return view; 96 } 97 98 /*** 99 * Changes the view associated with this controller. 100 * @param view the view to set. 101 */ 102 public void setView(AbstractDisplayerView view) 103 { 104 this.view = view; 105 } 106 107 }

This page was automatically generated by Maven