View Javadoc
1 /* 2 * Created on Nov 14, 2003 3 * 4 * To change the template for this generated file go to 5 * Window>Preferences>Java>Code Generation>Code and Comments 6 */ 7 package portaview.server; 8 9 import portaview.Log; 10 import portaview.Registry; 11 import portaview.model.PortaViewModel; 12 import portaview.model.SlideSettings; 13 14 /*** 15 * Thread that updates the displayer every seconds and see if you need to 16 * advance to the next slide. 17 * @author William Lee 18 */ 19 public class SlideRunner extends Thread 20 { 21 private boolean shutdown = false; 22 private int POLL_TIME = 1000; 23 private long nextRefreshTime = 0; 24 25 /*** 26 * Polls every second and see whether the current PortaView needs to change its picture. 27 */ 28 public void run() 29 { 30 while (shutdown == false) 31 { 32 try 33 { 34 Thread.sleep(POLL_TIME); 35 if (shutdown) 36 break; 37 PortaViewModel pm = 38 Registry.getMainApplication().getThisPortaViewModel(); 39 SlideSettings ss = pm.getSlideSettings(); 40 // if the slide is in pause mode, we just want to go on. 41 if (ss.getPlayState() == SlideSettings.PAUSE) 42 continue; 43 // Otherwise, test for the time whether the time you 44 // need to refresh 45 if (System.currentTimeMillis() > nextRefreshTime) 46 { 47 Log.debug("Time's up at " + System.currentTimeMillis()); 48 // advance to the next slide. 49 pm.nextSlide(); 50 // set the next notify time 51 nextRefreshTime = 52 System.currentTimeMillis() + (ss.getSpeed() * 1000); 53 } 54 } 55 catch (InterruptedException e) 56 { 57 if (shutdown) 58 break; 59 } 60 } 61 } 62 63 /*** 64 * Sets the next refresh time. 65 */ 66 public void setNextRefreshTime(long time) 67 { 68 nextRefreshTime = time; 69 } 70 71 /*** 72 * Shutdowns the thread. 73 */ 74 public void shutdown() 75 { 76 shutdown = true; 77 this.interrupt(); 78 } 79 80 }

This page was automatically generated by Maven