Differences between revisions 2 and 3
Revision 2 as of 2005-04-08 12:04:39
Size: 13304
Editor: dyn-176115
Comment:
Revision 3 as of 2005-04-08 12:16:44
Size: 3948
Editor: dyn-176115
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
   * ITML examples    * /ItmlExample
   * /BallFrame
   * /BallListener
   * /TemperatureTimedPresentation
Line 11: Line 14:
==== itml example ====
{{{#!VimColor type=smil
<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 ====
----
{{{#!java
package nl.tue.id.dps.swing;

/**
 * <p>Title: ITML</p>
 *
 * <p>Description: Distributed Media Extension to X-Smiles</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: ID, TU/e</p>
 *
 * @author HU, Jun
 * @version 1.0
 */
public interface BallListener {
  public void becomeWarm();
  public void becomeCold();
  public void becomeWarmer();
  public void becomeWarmest();
}

}}}

==== BallFrame ====
----
{{{#!java

package nl.tue.id.dps.swing;

import java.awt.*;
import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.Vector;
import java.util.Iterator;

/**
 * <p>Title: ITML</p>
 *
 * <p>Description: Distributed Media Extension to X-Smiles</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: ID, TU/e</p>
 *
 * @author HU, Jun
 * @version 1.0
 */
public class BallFrame
    extends JFrame {
  TimeCounter counter = new TimeCounter();
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel ballPanel = new JPanel();
  Vector listeners = new Vector();

  public void addBallListener(BallListener listener){
    listeners.add(listener);
  }

  public void removeBallListener(BallListener listener){
    listeners.remove(listener);
  }

  public static void main(String arg[]){
    BallFrame ball = new BallFrame();
    ball.pack();
    ball.show();
    ball.cold();
  }

  public BallFrame() {
    try {
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
    counter.start();
  }

  private void jbInit() throws Exception {
    getContentPane().setLayout(borderLayout1);
    ballPanel.addMouseListener(new BallFrame_ballPanel_mouseAdapter(this));
    this.getContentPane().add(ballPanel, java.awt.BorderLayout.CENTER);
    ballPanel.setMinimumSize(new Dimension(640, 480));
    ballPanel.setPreferredSize(new Dimension(640, 480));
  }

  public void setBallColor(Color c){
    ballPanel.setBackground(c);
  }

  public void ballPanel_mousePressed(MouseEvent e) {
    counter.startCounting();

  }

  public void ballPanel_mouseReleased(MouseEvent e) {
    counter.stopCounting();
  }

  public void cold(){
    setBallColor(Color.blue);
    Iterator i = listeners.iterator();
    while(i.hasNext()){
      BallListener ballListener = (BallListener)i.next();
      ballListener.becomeCold();
    }
  }

  public void warm(){
    setBallColor(Color.yellow);
    Iterator i = listeners.iterator();
    while(i.hasNext()){
      BallListener ballListener = (BallListener)i.next();
      ballListener.becomeWarm();
    }
  }

  public void warmer(){
    setBallColor(Color.orange);
    Iterator i = listeners.iterator();
    while(i.hasNext()){
      BallListener ballListener = (BallListener)i.next();
      ballListener.becomeWarmer();
    }
  }

  public void warmest(){
    setBallColor(Color.red);
    Iterator i = listeners.iterator();
    while(i.hasNext()){
      BallListener ballListener = (BallListener)i.next();
      ballListener.becomeWarmest();
    }
  }

  class TimeCounter extends Thread {
  boolean counting = false;
  int n = 0;
  public void run(){
    while(true){
      if(counting){
        try {
          sleep(2000);
        }
        catch (InterruptedException ex1) {
        }
        n = n+1;
        if (n == 1){
          warm();
        }
        else if (n== 2){
          warmer();
        }
        else if (n==3){
          warmest();
        }
        else{
          n = 4;
        }

      }
      else{
        try {
          sleep(2000);
        }
        catch (InterruptedException ex1) {
        }
        n = n-1;
        if (n == 3){
          warmest();
        }
        else if (n== 2){
          warmer();
        }
        else if (n==1){
          warm();
        }
        else{
          n = 0;
          cold();
        }

      }
    }

  }
  public void startCounting(){
    counting = true;
  }
  public void stopCounting(){
    counting = false;
  }
}


}


class BallFrame_ballPanel_mouseAdapter
    extends MouseAdapter {
  private BallFrame adaptee;
  BallFrame_ballPanel_mouseAdapter(BallFrame adaptee) {
    this.adaptee = adaptee;
  }

  public void mousePressed(MouseEvent e) {
    adaptee.ballPanel_mousePressed(e);
  }

  public void mouseReleased(MouseEvent e){
    adaptee.ballPanel_mouseReleased(e);
  }
}

}}}

==== TemperatureTimedPresentation ====
----
{{{#!java
package nl.tue.id.dps.swing;

import nl.tue.id.dps.TimedPresentation;
import java.util.Date;
import java.net.URL;
import nl.tue.id.dps.PresentationEvent;

/**
 * <p>Title: ITML</p>
 *
 * <p>Description: Distributed Media Extension to X-Smiles</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: ID, TU/e</p>
 *
 * @author HU, Jun
 * @version 1.0
 */
public class TemperatureTimedPresentation
    extends TimedPresentation implements BallListener {

  static BallFrame ball = new BallFrame();
  String temperature = "cold";

  public TemperatureTimedPresentation() {

  }

  protected void create(URL src) {
    temperature = removeExtension(getFileName(src));
    if(!ball.isVisible()){
      ball.pack();
      ball.cold();
      ball.show();
     }
  }

  protected void destroy() {
  }

  protected void pause() {
  }

  protected void start() {
    ball.addBallListener(this);

    if(temperature.equals("cold")){
      ball.cold();
    }
    else if(temperature.equals("warm")){
      ball.warm();
    }
    else if(temperature.equals("warmer")){
      ball.warmer();
    }
    else if(temperature.equals("warmest")){
      ball.warmest();
    }
  }

  protected void stop() {
    ball.removeBallListener(this);
  }

  protected boolean couldBePaused() {
    return false;
  }

  private String getFileName(final URL url) {
    final String file = url.getFile();
    final int last = file.lastIndexOf("/");
    if (last < 0) {
      return file;
    }
    return file.substring(last + 1);
  }

  private String removeExtension(final String filename) {
    final int index = filename.lastIndexOf('.');

    if ( -1 == index) {
      return filename;
    }
    else {
      return filename.substring(0, index);
    }
  }

  public void becomeWarm() {
    this.fireEvent(new PresentationEvent("temperature","warm"));
  }

  public void becomeCold() {
    this.fireEvent(new PresentationEvent("temperature","cold"));
  }

  public void becomeWarmer() {
    this.fireEvent(new PresentationEvent("temperature","warmer"));
  }

  public void becomeWarmest() {
    this.fireEvent(new PresentationEvent("temperature","warmest"));
  }

}
}}}

==== TPFactoryImpl ====

{{{#!java
package nl.tue.id.dps.swing;

import nl.tue.id.dps.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 *
 * @author not attributable
 * @created March 14, 2003
 * @version 1.0
 */
public class TPFactoryImpl
    extends TPFactoryBasicImpl {

  protected void setTPManifest() {
    addPresentation(new String[] {"temperature"},
                    TemperatureTimedPresentation.class,
                    new String[] {
      "tmp"
    });
    addPresentation(new String[] {"image", "img"},
                    ImageTimedPresentation.class,
                    new String[] {
      "jpg","gif","png"
    });
    addPresentation(new String[]{"jmfvideo", "video"},
                    VideoTimedPresentation.class,
                    new String[] {
      "avi", "mvr","mpg","mov","swf", "spl"
    });
    addPresentation(new String[]{"jmpaudio", "audio"},
                    AudioTimedPresentation.class,
                    new String[] {
      "aif", "aiff","avi","gsm","mid","mp2","mp3","mov","au","wav"
    });
    addPresentation(new String[]{"smil", "itml"},
                    ITMLTimedPresentation.class,
                    new String[] {
      "smi","smil","itm","itml"
    });
    addPresentation(new String[] {"html", "htm"},
                    HTMLTimedPresentation.class,
                    new String[] {
      "htm","html"
    });
    addPresentation(new String[] {"xul"},
                    ThinletTimedPresentation.class,
                    new String[] {
      "xul"
    });
    addPresentation(new String[] {"lirc"},
                    LIRCTimedPresentation.class,
                    new String[] {
      "lirc"
    });
    addPresentation(new String[] {"behavior"},
                    TonyTimedPresentation.class,
                    new String[] {
      "bhv"
    });

  }

}

}}}

Workshops

Anchor(javaworkshop)

Java D workshop

Schedule

Java C workshop

Schedule

  • March 24, Thursday, 10:30am - 12:30pm, HG4.95
  • Topics
    • Distributed Media
      • ITML
      • An example: distributed presentations.
      • attachment:TOONS.zip

Java Workshop

Schedule

  • March 17, Thursday, 13:30pm - 16:00pm, HG4.95
  • There will be no powerpoint slide shows, but a projector is necessary.
  • Everybody brings her/his computer to the workshop, with a network cable. We are going to do some hands-on programming.
  • Topics:
    • Object-oriented programming
    • Working with JBuilder - an IDE (integrated development environment)
      • Projects
      • packages
      • uml/refactory
      • help/documentation
      • debug
    • Distributed Media
      • ITML
      • An example: distributed presentations.

Preparation

  • Please install Borland JBuilder 2005. It is available as [http://w3.tue.nl/en/services/dienst_ict/organisatie/groepen/wins/campus_software/borland_jbuilder/ campus sofware].

  • Make sure your Java Media Framework properly installed.
  • [attachment:itml.zip ITML player source code + libraries]. Please download it, unzip it to anywhere on your harddisk.
    • It is indeed pretty big (80+M), becuase it includes all kinds of libraries, and some MPG movies. Don't worry, you may always remove it from your computer easily by removing entire itml0.91 directory with no harm.

Anchor(smilworkshop)

SMIL Workshop

  • A introduction on SMIL (JunHu)

  • Hands-on practice: Let's make an interactive movie.
    • [http://www.helio.org/products/smil/tutorial/ SMIL tutorial] by Helio. Download a copy to your hard disk. try to play the smil documents (in chapter8/sources) with X-smiles.

    • [http://ttt.forno.us/en/tutorial/learning_to_smil/ Learning to SMIL]: a SMIL 2.0 tutorial into 10 lessons and provides (minimal) exercises with answers

    • [http://www.geocities.com/ramirez_j2001/smil_intro/smil_intro_direct.smil Intro to SMIL version 1.0], Tutorial on SMIL written in SMIL - pretty cool ! requires RealNetworks G2, 80KB SMIL 1.0 with RealText.

    • The example I failed to show you in the workshop is fixed here. It demostrates the user interaction event based synchronization:

      <smil>
       <head>
        <layout>
         <root-layout width="300" height="200" background-color="white" />
         <region id="vim_icon" left="75" top="50" width="32" height="32" />
         <region id="soja_icon" left="150" top="50" width="100" height="30" />
        </layout>
       </head>
       <body>
         <par begin="2s" dur="6s">
            <img id="vim" src="vim32x32.gif" alt="The vim icon"
              region="vim_icon" dur="6s" />
            <img src="madewithsoja.gif" alt="Made with SOJA"
              region="soja_icon" dur="4s" begin="vim.activateEvent" />
         </par>
       </body>
      </smil>
      After 2 seconds, it shows you a Vim icon. You have 4 seconds chance to click on the icon. If it is clicked (vim.activateEvent), it will show "madewithsoja.gif". To see this SMIL example in action, you should have vim32x32.gif and madewithsoja.gif in the same directory. Try it out. then smile.

Preparation

JunHu: Dc222Home/WorkShops (last edited 2008-10-03 20:18:32 by localhost)