⇤ ← Revision 1 as of 2005-04-08 12:14:58
2266
Comment:
|
← Revision 2 as of 2008-10-03 20:20:39 ⇥
2266
converted to 1.6 markup
|
No differences found! |
1 package nl.tue.id.dps.swing;
2
3 import nl.tue.id.dps.TimedPresentation;
4 import java.util.Date;
5 import java.net.URL;
6 import nl.tue.id.dps.PresentationEvent;
7
8 /**
9 * <p>Title: ITML</p>
10 *
11 * <p>Description: Distributed Media Extension to X-Smiles</p>
12 *
13 * <p>Copyright: Copyright (c) 2004</p>
14 *
15 * <p>Company: ID, TU/e</p>
16 *
17 * @author HU, Jun
18 * @version 1.0
19 */
20 public class TemperatureTimedPresentation
21 extends TimedPresentation implements BallListener {
22
23 static BallFrame ball = new BallFrame();
24 String temperature = "cold";
25
26 public TemperatureTimedPresentation() {
27
28 }
29
30 protected void create(URL src) {
31 temperature = removeExtension(getFileName(src));
32 if(!ball.isVisible()){
33 ball.pack();
34 ball.cold();
35 ball.show();
36 }
37 }
38
39 protected void destroy() {
40 }
41
42 protected void pause() {
43 }
44
45 protected void start() {
46 ball.addBallListener(this);
47
48 if(temperature.equals("cold")){
49 ball.cold();
50 }
51 else if(temperature.equals("warm")){
52 ball.warm();
53 }
54 else if(temperature.equals("warmer")){
55 ball.warmer();
56 }
57 else if(temperature.equals("warmest")){
58 ball.warmest();
59 }
60 }
61
62 protected void stop() {
63 ball.removeBallListener(this);
64 }
65
66 protected boolean couldBePaused() {
67 return false;
68 }
69
70 private String getFileName(final URL url) {
71 final String file = url.getFile();
72 final int last = file.lastIndexOf("/");
73 if (last < 0) {
74 return file;
75 }
76 return file.substring(last + 1);
77 }
78
79 private String removeExtension(final String filename) {
80 final int index = filename.lastIndexOf('.');
81
82 if ( -1 == index) {
83 return filename;
84 }
85 else {
86 return filename.substring(0, index);
87 }
88 }
89
90 public void becomeWarm() {
91 this.fireEvent(new PresentationEvent("temperature","warm"));
92 }
93
94 public void becomeCold() {
95 this.fireEvent(new PresentationEvent("temperature","cold"));
96 }
97
98 public void becomeWarmer() {
99 this.fireEvent(new PresentationEvent("temperature","warmer"));
100 }
101
102 public void becomeWarmest() {
103 this.fireEvent(new PresentationEvent("temperature","warmest"));
104 }
105
106 }