Workshops

Anchor(javaworkshop)

Java D workshop

Schedule

itml example

<itml>
  <head>
    <layout>
      <actor id="rutger" top="0" left="0" width="1024" height="768" 
      fit="fill" address="localhost:7086"/>
    </layout>
  </head>
  <body>
  <par>
      <action id="coldid" src="file:/cold.tmp" 
             actor="rutger" dur="5000s">
        <anchor onevent="coldid.warmest" href="#showgoogle" />
      </action>
  </par>
  <action id="showgoogle" src="http://www.google.com/intl/zh-CN/about.html" 
       actor="rutger" />
  </body>
</itml>

BallListener


   1 package nl.tue.id.dps.swing;
   2 
   3 /**
   4  * <p>Title: ITML</p>
   5  *
   6  * <p>Description: Distributed Media Extension to X-Smiles</p>
   7  *
   8  * <p>Copyright: Copyright (c) 2004</p>
   9  *
  10  * <p>Company: ID, TU/e</p>
  11  *
  12  * @author HU, Jun
  13  * @version 1.0
  14  */
  15 public interface BallListener {
  16   public void becomeWarm();
  17   public void becomeCold();
  18   public void becomeWarmer();
  19   public void becomeWarmest();
  20 }

BallFrame


   1 package nl.tue.id.dps.swing;
   2 
   3 import java.awt.*;
   4 import javax.swing.*;
   5 import java.awt.event.MouseEvent;
   6 import java.awt.event.MouseAdapter;
   7 import java.util.Vector;
   8 import java.util.Iterator;
   9 
  10 /**
  11  * <p>Title: ITML</p>
  12  *
  13  * <p>Description: Distributed Media Extension to X-Smiles</p>
  14  *
  15  * <p>Copyright: Copyright (c) 2004</p>
  16  *
  17  * <p>Company: ID, TU/e</p>
  18  *
  19  * @author HU, Jun
  20  * @version 1.0
  21  */
  22 public class BallFrame
  23     extends JFrame {
  24   TimeCounter counter = new TimeCounter();
  25   BorderLayout borderLayout1 = new BorderLayout();
  26   JPanel ballPanel = new JPanel();
  27   Vector listeners = new Vector();
  28 
  29   public void addBallListener(BallListener listener){
  30     listeners.add(listener);
  31   }
  32 
  33   public void removeBallListener(BallListener listener){
  34     listeners.remove(listener);
  35   }
  36 
  37   public static void main(String arg[]){
  38     BallFrame ball = new BallFrame();
  39     ball.pack();
  40     ball.show();
  41     ball.cold();
  42   }
  43 
  44   public BallFrame() {
  45     try {
  46       jbInit();
  47     }
  48     catch (Exception exception) {
  49       exception.printStackTrace();
  50     }
  51     counter.start();
  52   }
  53 
  54   private void jbInit() throws Exception {
  55     getContentPane().setLayout(borderLayout1);
  56     ballPanel.addMouseListener(new BallFrame_ballPanel_mouseAdapter(this));
  57     this.getContentPane().add(ballPanel, java.awt.BorderLayout.CENTER);
  58     ballPanel.setMinimumSize(new Dimension(640, 480));
  59     ballPanel.setPreferredSize(new Dimension(640, 480));
  60   }
  61 
  62   public void setBallColor(Color c){
  63     ballPanel.setBackground(c);
  64   }
  65 
  66   public void ballPanel_mousePressed(MouseEvent e) {
  67     counter.startCounting();
  68 
  69   }
  70 
  71   public void ballPanel_mouseReleased(MouseEvent e) {
  72     counter.stopCounting();
  73   }
  74 
  75   public void cold(){
  76     setBallColor(Color.blue);
  77     Iterator i = listeners.iterator();
  78     while(i.hasNext()){
  79       BallListener ballListener = (BallListener)i.next();
  80       ballListener.becomeCold();
  81     }
  82   }
  83 
  84   public void warm(){
  85     setBallColor(Color.yellow);
  86     Iterator i = listeners.iterator();
  87     while(i.hasNext()){
  88       BallListener ballListener = (BallListener)i.next();
  89       ballListener.becomeWarm();
  90     }
  91   }
  92 
  93   public void warmer(){
  94     setBallColor(Color.orange);
  95     Iterator i = listeners.iterator();
  96     while(i.hasNext()){
  97       BallListener ballListener = (BallListener)i.next();
  98       ballListener.becomeWarmer();
  99     }
 100   }
 101 
 102   public void warmest(){
 103     setBallColor(Color.red);
 104     Iterator i = listeners.iterator();
 105     while(i.hasNext()){
 106       BallListener ballListener = (BallListener)i.next();
 107       ballListener.becomeWarmest();
 108     }
 109   }
 110 
 111   class TimeCounter extends Thread {
 112   boolean counting = false;
 113   int n = 0;
 114   public void run(){
 115     while(true){
 116       if(counting){
 117         try {
 118           sleep(2000);
 119         }
 120         catch (InterruptedException ex1) {
 121         }
 122         n = n+1;
 123         if (n == 1){
 124           warm();
 125         }
 126         else if (n== 2){
 127           warmer();
 128         }
 129         else if (n==3){
 130           warmest();
 131         }
 132         else{
 133           n = 4;
 134         }
 135 
 136       }
 137       else{
 138         try {
 139           sleep(2000);
 140         }
 141         catch (InterruptedException ex1) {
 142         }
 143         n = n-1;
 144         if (n == 3){
 145           warmest();
 146         }
 147         else if (n== 2){
 148           warmer();
 149         }
 150         else if (n==1){
 151           warm();
 152         }
 153         else{
 154           n = 0;
 155           cold();
 156         }
 157 
 158       }
 159     }
 160 
 161   }
 162   public void startCounting(){
 163     counting = true;
 164   }
 165   public void stopCounting(){
 166     counting = false;
 167   }
 168 }
 169 
 170 
 171 }
 172 
 173 
 174 class BallFrame_ballPanel_mouseAdapter
 175     extends MouseAdapter {
 176   private BallFrame adaptee;
 177   BallFrame_ballPanel_mouseAdapter(BallFrame adaptee) {
 178     this.adaptee = adaptee;
 179   }
 180 
 181   public void mousePressed(MouseEvent e) {
 182     adaptee.ballPanel_mousePressed(e);
 183   }
 184 
 185   public void mouseReleased(MouseEvent e){
 186     adaptee.ballPanel_mouseReleased(e);
 187   }
 188 }

TemperatureTimedPresentation


   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 }

TPFactoryImpl

   1 package nl.tue.id.dps.swing;
   2 
   3 import nl.tue.id.dps.*;
   4 
   5 /**
   6  * <p>Title: </p>
   7  * <p>Description: </p>
   8  * <p>Copyright: Copyright (c) 2003</p>
   9  * <p>Company: </p>
  10  *
  11  * @author     not attributable
  12  * @created    March 14, 2003
  13  * @version    1.0
  14  */
  15 public class TPFactoryImpl
  16     extends TPFactoryBasicImpl {
  17 
  18   protected void setTPManifest() {
  19     addPresentation(new String[] {"temperature"},
  20                     TemperatureTimedPresentation.class,
  21                     new String[] {
  22       "tmp"
  23     });
  24     addPresentation(new String[] {"image", "img"},
  25                     ImageTimedPresentation.class,
  26                     new String[] {
  27       "jpg","gif","png"
  28     });
  29     addPresentation(new String[]{"jmfvideo", "video"},
  30                     VideoTimedPresentation.class,
  31                     new String[] {
  32       "avi", "mvr","mpg","mov","swf", "spl"
  33     });
  34     addPresentation(new String[]{"jmpaudio", "audio"},
  35                     AudioTimedPresentation.class,
  36                     new String[] {
  37       "aif", "aiff","avi","gsm","mid","mp2","mp3","mov","au","wav"
  38     });
  39     addPresentation(new String[]{"smil", "itml"},
  40                     ITMLTimedPresentation.class,
  41                     new String[] {
  42       "smi","smil","itm","itml"
  43     });
  44     addPresentation(new String[] {"html", "htm"},
  45                     HTMLTimedPresentation.class,
  46                     new String[] {
  47       "htm","html"
  48     });
  49     addPresentation(new String[] {"xul"},
  50                     ThinletTimedPresentation.class,
  51                     new String[] {
  52       "xul"
  53     });
  54     addPresentation(new String[] {"lirc"},
  55                     LIRCTimedPresentation.class,
  56                     new String[] {
  57       "lirc"
  58     });
  59     addPresentation(new String[] {"behavior"},
  60                     TonyTimedPresentation.class,
  61                     new String[] {
  62       "bhv"
  63     });
  64 
  65   }
  66 
  67 }

Java C workshop

Schedule

Java Workshop

Schedule

Preparation

Anchor(smilworkshop)

SMIL Workshop

Preparation