# HG changeset patch # User bastiena # Date 1332516276 -3600 # Node ID 925b7ee746e32f294e921dd83a2bf04e9aa234e8 # Parent 0f44b7360c8dbe30fc9c500fe2d596d2da1cb59c Front Processing : Changed utf-8 to utf-8 without BOM diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/doc/tutorial_front_processing.html --- a/front_processing/doc/tutorial_front_processing.html Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/doc/tutorial_front_processing.html Fri Mar 23 16:24:36 2012 +0100 @@ -238,7 +238,6 @@
  • Trakers_gestures : Permet d'afficher le code des gestures détectées par Kinect et notifiées depuis le Middleware.
  • Fluid_manipulation (code importé de processing.org) : Simule l'action des mains sur un fluide.
  • Smoke_manipulation (code importé de processing.org) : Simule l'action des mains sur de la fumée.
  • -
  • Processing.org
  • Interaction examples (code importé de processing.org) : Quelques petits exemples utilisant des formes basiques et réagissant à la position de la main la plus proche de Kinect.
  • diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioClient.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,643 +1,643 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package TUIO; - -import com.illposed.osc.*; -import java.util.*; - -/** - * The TuioClient class is the central TUIO protocol decoder component. It provides a simple callback infrastructure using the {@link TuioListener} interface. - * In order to receive and decode TUIO messages an instance of TuioClient needs to be created. The TuioClient instance then generates TUIO events - * which are broadcasted to all registered classes that implement the {@link TuioListener} interface.

    - * - * TuioClient client = new TuioClient();
    - * client.addTuioListener(myTuioListener);
    - * client.connect();
    - *
    - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public class TuioClient implements OSCListener { - - public String comm; - - private int port = 3333; - private OSCPortIn oscPort; - private boolean connected = false; - private Hashtable objectList = new Hashtable(); - private Vector aliveObjectList = new Vector(); - private Vector newObjectList = new Vector(); - private Hashtable cursorList = new Hashtable(); - private Vector aliveCursorList = new Vector(); - private Vector newCursorList = new Vector(); - private Hashtable stringList = new Hashtable(); - private Vector aliveStringList = new Vector(); - private Vector newStringList = new Vector(); - - private Vector frameObjects = new Vector(); - private Vector frameCursors = new Vector(); - private Vector frameStrings = new Vector(); - - private Vector freeCursorList = new Vector(); - private int maxCursorID = -1; - - private Vector freeStringList = new Vector(); - private int maxStringID = -1; - - private long currentFrame = 0; - private TuioTime currentTime; - - private Vector listenerList = new Vector(); - - /** - * The default constructor creates a client that listens to the default TUIO port 3333 - */ - public TuioClient() {} - - /** - * This constructor creates a client that listens to the provided port - * - * @param port the listening port number - */ - public TuioClient(int port) { - this.port = port; - } - - /** - * The TuioClient starts listening to TUIO messages on the configured UDP port - * All reveived TUIO messages are decoded and the resulting TUIO events are broadcasted to all registered TuioListeners - */ - public void connect() { - - TuioTime.initSession(); - currentTime = new TuioTime(); - currentTime.reset(); - - try { - oscPort = new OSCPortIn(port); - oscPort.addListener("/tuio/2Dobj",this); - oscPort.addListener("/tuio/3Dcur",this); - oscPort.addListener("/tuio/_siP",this); - oscPort.startListening(); - connected = true; - } catch (Exception e) { - System.out.println("TuioClient: failed to connect to port "+port); - connected = false; - } - } - - /** - * The TuioClient stops listening to TUIO messages on the configured UDP port - */ - public void disconnect() { - oscPort.stopListening(); - try { Thread.sleep(100); } - catch (Exception e) {}; - oscPort.close(); - connected = false; - } - - /** - * Returns true if this TuioClient is currently connected. - * @return true if this TuioClient is currently connected - */ - public boolean isConnected() { return connected; } - - /** - * Adds the provided TuioListener to the list of registered TUIO event listeners - * - * @param listener the TuioListener to add - */ - public void addTuioListener(TuioListener listener) { - listenerList.addElement(listener); - } - - /** - * Removes the provided TuioListener from the list of registered TUIO event listeners - * - * @param listener the TuioListener to remove - */ - public void removeTuioListener(TuioListener listener) { - listenerList.removeElement(listener); - } - - /** - * Removes all TuioListener from the list of registered TUIO event listeners - */ - public void removeAllTuioListeners() { - listenerList.clear(); - } - - /** - * Returns a Vector of all currently active TuioObjects - * - * @return a Vector of all currently active TuioObjects - */ - public Vector getTuioObjects() { - return new Vector(objectList.values()); - } - - /** - * Returns a Vector of all currently active TuioCursors - * - * @return a Vector of all currently active TuioCursors - */ - public Vector getTuioCursors() { - return new Vector(cursorList.values()); - } - - /** - * Returns a Vector of all currently active TuioStrings - * - * @return a Vector of all currently active TuioStrings - */ - public Vector getTuioStrings() { - return new Vector(stringList.values()); - } - - /** - * Returns the TuioObject corresponding to the provided Session ID - * or NULL if the Session ID does not refer to an active TuioObject - * - * @return an active TuioObject corresponding to the provided Session ID or NULL - */ - public TuioObject getTuioObject(long s_id) { - return objectList.get(s_id); - } - - /** - * Returns the TuioCursor corresponding to the provided Session ID - * or NULL if the Session ID does not refer to an active TuioCursor - * - * @return an active TuioCursor corresponding to the provided Session ID or NULL - */ - public TuioCursor getTuioCursor(long s_id) { - return cursorList.get(s_id); - } - - /** - * Returns the TuioString corresponding to the provided Session ID - * or NULL if the Session ID does not refer to an active TuioString - * - * @return an active TuioString corresponding to the provided Session ID or NULL - */ - public TuioString getTuioString(long s_id) { - return stringList.get(s_id); - } - - /** - * The OSC callback method where all TUIO messages are received and decoded - * and where the TUIO event callbacks are dispatched - * - * @param date the time stamp of the OSC bundle - * @param message the received OSC message - */ - public void acceptMessage(Date date, OSCMessage message) { - - Object[] args = message.getArguments(); - String command = (String)args[0]; - String address = message.getAddress(); - - if (address.equals("/tuio/2Dobj")) { - - if (command.equals("set")) { - - long s_id = ((Integer)args[1]).longValue(); - int c_id = ((Integer)args[2]).intValue(); - float xpos = ((Float)args[3]).floatValue(); - float ypos = ((Float)args[4]).floatValue(); - float angle = ((Float)args[5]).floatValue(); - float xspeed = ((Float)args[6]).floatValue(); - float yspeed = ((Float)args[7]).floatValue(); - float rspeed = ((Float)args[8]).floatValue(); - float maccel = ((Float)args[9]).floatValue(); - float raccel = ((Float)args[10]).floatValue(); - - if (objectList.get(s_id) == null) { - - TuioObject addObject = new TuioObject(s_id,c_id,xpos,ypos,angle); - frameObjects.addElement(addObject); - - } else { - - TuioObject tobj = objectList.get(s_id); - if (tobj==null) return; - if ((tobj.xpos!=xpos) || (tobj.ypos!=ypos) || (tobj.angle!=angle) || (tobj.x_speed!=xspeed) || (tobj.y_speed!=yspeed) || (tobj.rotation_speed!=rspeed) || (tobj.motion_accel!=maccel) || (tobj.rotation_accel!=raccel)) { - - TuioObject updateObject = new TuioObject(s_id,c_id,xpos,ypos,angle); - updateObject.update(xpos,ypos,angle,xspeed,yspeed,rspeed,maccel,raccel); - frameObjects.addElement(updateObject); - } - - } - - } else if (command.equals("alive")) { - - newObjectList.clear(); - for (int i=1;i0) { - if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); - if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame=fseq; - else lateFrame = true; - } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { - currentTime = TuioTime.getSessionTime(); - } - - if (!lateFrame) { - Enumeration frameEnum = frameObjects.elements(); - while(frameEnum.hasMoreElements()) { - TuioObject tobj = frameEnum.nextElement(); - - switch (tobj.getTuioState()) { - case TuioObject.TUIO_REMOVED: - TuioObject removeObject = tobj; - removeObject.remove(currentTime); - for (int i=0;i buffer = aliveObjectList; - aliveObjectList = newObjectList; - // recycling the vector - newObjectList = buffer; - } - frameObjects.clear(); - } - } else if (address.equals("/tuio/3Dcur")) { - - if (command.equals("set")) { - - long s_id = ((Integer)args[1]).longValue(); - float xpos = ((Float)args[2]).floatValue(); - float ypos = ((Float)args[3]).floatValue(); - float zpos = ((Float)args[4]).floatValue(); - float xspeed = ((Float)args[5]).floatValue(); - float yspeed = ((Float)args[6]).floatValue(); - float maccel = ((Float)args[7]).floatValue(); - - if (cursorList.get(s_id) == null) { - - TuioCursor addCursor = new TuioCursor(s_id, -1 ,xpos,ypos,zpos); - frameCursors.addElement(addCursor); - - } else { - - TuioCursor tcur = cursorList.get(s_id); - if (tcur==null) return; - if ((tcur.xpos!=xpos) || (tcur.ypos!=ypos) || (tcur.zpos!=zpos) || (tcur.x_speed!=xspeed) || (tcur.y_speed!=yspeed) || (tcur.motion_accel!=maccel)) { - - TuioCursor updateCursor = new TuioCursor(s_id,tcur.getCursorID(),xpos,ypos,zpos); - updateCursor.update(xpos,ypos,zpos,xspeed,yspeed,maccel); - frameCursors.addElement(updateCursor); - } - } - - //System.out.println("set cur " + s_id+" "+xpos+" "+ypos+" "+xspeed+" "+yspeed+" "+maccel); - - } else if (command.equals("alive")) { - - newCursorList.clear(); - for (int i=1;i0) { - if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); - if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq; - else lateFrame = true; - } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { - currentTime = TuioTime.getSessionTime(); - } - if (!lateFrame) { - - Enumeration frameEnum = frameCursors.elements(); - while(frameEnum.hasMoreElements()) { - TuioCursor tcur = frameEnum.nextElement(); - - switch (tcur.getTuioState()) { - case TuioCursor.TUIO_REMOVED: - - TuioCursor removeCursor = tcur; - removeCursor.remove(currentTime); - - for (int i=0;i0) { - Enumeration clist = cursorList.elements(); - while (clist.hasMoreElements()) { - int c_id = clist.nextElement().getCursorID(); - if (c_id>maxCursorID) maxCursorID=c_id; - } - - Enumeration flist = freeCursorList.elements(); - while (flist.hasMoreElements()) { - int c_id = flist.nextElement().getCursorID(); - if (c_id>=maxCursorID) freeCursorList.removeElement(c_id); - } - } else freeCursorList.clear(); - } else if (removeCursor.getCursorID()0)) { - TuioCursor closestCursor = freeCursorList.firstElement(); - Enumeration testList = freeCursorList.elements(); - while (testList.hasMoreElements()) { - TuioCursor testCursor = testList.nextElement(); - if (testCursor.getDistance(tcur) buffer = aliveCursorList; - aliveCursorList = newCursorList; - // recycling the vector - newCursorList = buffer; - } - - frameCursors.clear(); - } - } else if (address.equals("/tuio/_siP")) { - - if (command.equals("set")) { - - long s_id = ((Integer)args[1]).longValue(); - String msg = args[2].toString(); - - if (stringList.get(s_id) == null) { - - TuioString addString = new TuioString(s_id, -1, msg); - frameStrings.addElement(addString); - - } else { - - TuioString tstr = stringList.get(s_id); - if (tstr==null) return; - if (!tstr.getMessage().equals(msg)) { - - TuioString updateString = new TuioString(s_id,tstr.getStringID(),msg); - updateString.update(msg); - frameStrings.addElement(updateString); - } - } - - //System.out.println("set cur " + s_id+" "+xpos+" "+ypos+" "+xspeed+" "+yspeed+" "+maccel); - - } else if (command.equals("alive")) { - - newStringList.clear(); - for (int i=1;i0) { - if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); - if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq; - else lateFrame = true; - } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { - currentTime = TuioTime.getSessionTime(); - } - if (!lateFrame) { - - Enumeration frameEnum = frameStrings.elements(); - while(frameEnum.hasMoreElements()) { - TuioString tstr = frameEnum.nextElement(); - - switch (tstr.getTuioState()) { - case TuioString.TUIO_REMOVED: - - TuioString removeString = tstr; - removeString.remove(currentTime); - - for (int i=0;i0) { - Enumeration slist = stringList.elements(); - while (slist.hasMoreElements()) { - int sl_id = slist.nextElement().getStringID(); - if (sl_id>maxStringID) maxStringID=sl_id; - } - - Enumeration flist = freeStringList.elements(); - while (flist.hasMoreElements()) { - int sl_id = flist.nextElement().getStringID(); - if (sl_id>=maxStringID) freeStringList.removeElement(sl_id); - } - } else freeStringList.clear(); - } else if (removeString.getStringID()0)) { - TuioString closestString = freeStringList.firstElement(); - Enumeration testList = freeStringList.elements(); - while (testList.hasMoreElements()) { - TuioString testString = testList.nextElement(); - //if (testString.getDistance(tstr) buffer = aliveStringList; - aliveStringList = newStringList; - // recycling the vector - newStringList = buffer; - } - - frameStrings.clear(); - } - } - - - } -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package TUIO; + +import com.illposed.osc.*; +import java.util.*; + +/** + * The TuioClient class is the central TUIO protocol decoder component. It provides a simple callback infrastructure using the {@link TuioListener} interface. + * In order to receive and decode TUIO messages an instance of TuioClient needs to be created. The TuioClient instance then generates TUIO events + * which are broadcasted to all registered classes that implement the {@link TuioListener} interface.

    + * + * TuioClient client = new TuioClient();
    + * client.addTuioListener(myTuioListener);
    + * client.connect();
    + *
    + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public class TuioClient implements OSCListener { + + public String comm; + + private int port = 3333; + private OSCPortIn oscPort; + private boolean connected = false; + private Hashtable objectList = new Hashtable(); + private Vector aliveObjectList = new Vector(); + private Vector newObjectList = new Vector(); + private Hashtable cursorList = new Hashtable(); + private Vector aliveCursorList = new Vector(); + private Vector newCursorList = new Vector(); + private Hashtable stringList = new Hashtable(); + private Vector aliveStringList = new Vector(); + private Vector newStringList = new Vector(); + + private Vector frameObjects = new Vector(); + private Vector frameCursors = new Vector(); + private Vector frameStrings = new Vector(); + + private Vector freeCursorList = new Vector(); + private int maxCursorID = -1; + + private Vector freeStringList = new Vector(); + private int maxStringID = -1; + + private long currentFrame = 0; + private TuioTime currentTime; + + private Vector listenerList = new Vector(); + + /** + * The default constructor creates a client that listens to the default TUIO port 3333 + */ + public TuioClient() {} + + /** + * This constructor creates a client that listens to the provided port + * + * @param port the listening port number + */ + public TuioClient(int port) { + this.port = port; + } + + /** + * The TuioClient starts listening to TUIO messages on the configured UDP port + * All reveived TUIO messages are decoded and the resulting TUIO events are broadcasted to all registered TuioListeners + */ + public void connect() { + + TuioTime.initSession(); + currentTime = new TuioTime(); + currentTime.reset(); + + try { + oscPort = new OSCPortIn(port); + oscPort.addListener("/tuio/2Dobj",this); + oscPort.addListener("/tuio/3Dcur",this); + oscPort.addListener("/tuio/_siP",this); + oscPort.startListening(); + connected = true; + } catch (Exception e) { + System.out.println("TuioClient: failed to connect to port "+port); + connected = false; + } + } + + /** + * The TuioClient stops listening to TUIO messages on the configured UDP port + */ + public void disconnect() { + oscPort.stopListening(); + try { Thread.sleep(100); } + catch (Exception e) {}; + oscPort.close(); + connected = false; + } + + /** + * Returns true if this TuioClient is currently connected. + * @return true if this TuioClient is currently connected + */ + public boolean isConnected() { return connected; } + + /** + * Adds the provided TuioListener to the list of registered TUIO event listeners + * + * @param listener the TuioListener to add + */ + public void addTuioListener(TuioListener listener) { + listenerList.addElement(listener); + } + + /** + * Removes the provided TuioListener from the list of registered TUIO event listeners + * + * @param listener the TuioListener to remove + */ + public void removeTuioListener(TuioListener listener) { + listenerList.removeElement(listener); + } + + /** + * Removes all TuioListener from the list of registered TUIO event listeners + */ + public void removeAllTuioListeners() { + listenerList.clear(); + } + + /** + * Returns a Vector of all currently active TuioObjects + * + * @return a Vector of all currently active TuioObjects + */ + public Vector getTuioObjects() { + return new Vector(objectList.values()); + } + + /** + * Returns a Vector of all currently active TuioCursors + * + * @return a Vector of all currently active TuioCursors + */ + public Vector getTuioCursors() { + return new Vector(cursorList.values()); + } + + /** + * Returns a Vector of all currently active TuioStrings + * + * @return a Vector of all currently active TuioStrings + */ + public Vector getTuioStrings() { + return new Vector(stringList.values()); + } + + /** + * Returns the TuioObject corresponding to the provided Session ID + * or NULL if the Session ID does not refer to an active TuioObject + * + * @return an active TuioObject corresponding to the provided Session ID or NULL + */ + public TuioObject getTuioObject(long s_id) { + return objectList.get(s_id); + } + + /** + * Returns the TuioCursor corresponding to the provided Session ID + * or NULL if the Session ID does not refer to an active TuioCursor + * + * @return an active TuioCursor corresponding to the provided Session ID or NULL + */ + public TuioCursor getTuioCursor(long s_id) { + return cursorList.get(s_id); + } + + /** + * Returns the TuioString corresponding to the provided Session ID + * or NULL if the Session ID does not refer to an active TuioString + * + * @return an active TuioString corresponding to the provided Session ID or NULL + */ + public TuioString getTuioString(long s_id) { + return stringList.get(s_id); + } + + /** + * The OSC callback method where all TUIO messages are received and decoded + * and where the TUIO event callbacks are dispatched + * + * @param date the time stamp of the OSC bundle + * @param message the received OSC message + */ + public void acceptMessage(Date date, OSCMessage message) { + + Object[] args = message.getArguments(); + String command = (String)args[0]; + String address = message.getAddress(); + + if (address.equals("/tuio/2Dobj")) { + + if (command.equals("set")) { + + long s_id = ((Integer)args[1]).longValue(); + int c_id = ((Integer)args[2]).intValue(); + float xpos = ((Float)args[3]).floatValue(); + float ypos = ((Float)args[4]).floatValue(); + float angle = ((Float)args[5]).floatValue(); + float xspeed = ((Float)args[6]).floatValue(); + float yspeed = ((Float)args[7]).floatValue(); + float rspeed = ((Float)args[8]).floatValue(); + float maccel = ((Float)args[9]).floatValue(); + float raccel = ((Float)args[10]).floatValue(); + + if (objectList.get(s_id) == null) { + + TuioObject addObject = new TuioObject(s_id,c_id,xpos,ypos,angle); + frameObjects.addElement(addObject); + + } else { + + TuioObject tobj = objectList.get(s_id); + if (tobj==null) return; + if ((tobj.xpos!=xpos) || (tobj.ypos!=ypos) || (tobj.angle!=angle) || (tobj.x_speed!=xspeed) || (tobj.y_speed!=yspeed) || (tobj.rotation_speed!=rspeed) || (tobj.motion_accel!=maccel) || (tobj.rotation_accel!=raccel)) { + + TuioObject updateObject = new TuioObject(s_id,c_id,xpos,ypos,angle); + updateObject.update(xpos,ypos,angle,xspeed,yspeed,rspeed,maccel,raccel); + frameObjects.addElement(updateObject); + } + + } + + } else if (command.equals("alive")) { + + newObjectList.clear(); + for (int i=1;i0) { + if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); + if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame=fseq; + else lateFrame = true; + } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { + currentTime = TuioTime.getSessionTime(); + } + + if (!lateFrame) { + Enumeration frameEnum = frameObjects.elements(); + while(frameEnum.hasMoreElements()) { + TuioObject tobj = frameEnum.nextElement(); + + switch (tobj.getTuioState()) { + case TuioObject.TUIO_REMOVED: + TuioObject removeObject = tobj; + removeObject.remove(currentTime); + for (int i=0;i buffer = aliveObjectList; + aliveObjectList = newObjectList; + // recycling the vector + newObjectList = buffer; + } + frameObjects.clear(); + } + } else if (address.equals("/tuio/3Dcur")) { + + if (command.equals("set")) { + + long s_id = ((Integer)args[1]).longValue(); + float xpos = ((Float)args[2]).floatValue(); + float ypos = ((Float)args[3]).floatValue(); + float zpos = ((Float)args[4]).floatValue(); + float xspeed = ((Float)args[5]).floatValue(); + float yspeed = ((Float)args[6]).floatValue(); + float maccel = ((Float)args[7]).floatValue(); + + if (cursorList.get(s_id) == null) { + + TuioCursor addCursor = new TuioCursor(s_id, -1 ,xpos,ypos,zpos); + frameCursors.addElement(addCursor); + + } else { + + TuioCursor tcur = cursorList.get(s_id); + if (tcur==null) return; + if ((tcur.xpos!=xpos) || (tcur.ypos!=ypos) || (tcur.zpos!=zpos) || (tcur.x_speed!=xspeed) || (tcur.y_speed!=yspeed) || (tcur.motion_accel!=maccel)) { + + TuioCursor updateCursor = new TuioCursor(s_id,tcur.getCursorID(),xpos,ypos,zpos); + updateCursor.update(xpos,ypos,zpos,xspeed,yspeed,maccel); + frameCursors.addElement(updateCursor); + } + } + + //System.out.println("set cur " + s_id+" "+xpos+" "+ypos+" "+xspeed+" "+yspeed+" "+maccel); + + } else if (command.equals("alive")) { + + newCursorList.clear(); + for (int i=1;i0) { + if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); + if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq; + else lateFrame = true; + } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { + currentTime = TuioTime.getSessionTime(); + } + if (!lateFrame) { + + Enumeration frameEnum = frameCursors.elements(); + while(frameEnum.hasMoreElements()) { + TuioCursor tcur = frameEnum.nextElement(); + + switch (tcur.getTuioState()) { + case TuioCursor.TUIO_REMOVED: + + TuioCursor removeCursor = tcur; + removeCursor.remove(currentTime); + + for (int i=0;i0) { + Enumeration clist = cursorList.elements(); + while (clist.hasMoreElements()) { + int c_id = clist.nextElement().getCursorID(); + if (c_id>maxCursorID) maxCursorID=c_id; + } + + Enumeration flist = freeCursorList.elements(); + while (flist.hasMoreElements()) { + int c_id = flist.nextElement().getCursorID(); + if (c_id>=maxCursorID) freeCursorList.removeElement(c_id); + } + } else freeCursorList.clear(); + } else if (removeCursor.getCursorID()0)) { + TuioCursor closestCursor = freeCursorList.firstElement(); + Enumeration testList = freeCursorList.elements(); + while (testList.hasMoreElements()) { + TuioCursor testCursor = testList.nextElement(); + if (testCursor.getDistance(tcur) buffer = aliveCursorList; + aliveCursorList = newCursorList; + // recycling the vector + newCursorList = buffer; + } + + frameCursors.clear(); + } + } else if (address.equals("/tuio/_siP")) { + + if (command.equals("set")) { + + long s_id = ((Integer)args[1]).longValue(); + String msg = args[2].toString(); + + if (stringList.get(s_id) == null) { + + TuioString addString = new TuioString(s_id, -1, msg); + frameStrings.addElement(addString); + + } else { + + TuioString tstr = stringList.get(s_id); + if (tstr==null) return; + if (!tstr.getMessage().equals(msg)) { + + TuioString updateString = new TuioString(s_id,tstr.getStringID(),msg); + updateString.update(msg); + frameStrings.addElement(updateString); + } + } + + //System.out.println("set cur " + s_id+" "+xpos+" "+ypos+" "+xspeed+" "+yspeed+" "+maccel); + + } else if (command.equals("alive")) { + + newStringList.clear(); + for (int i=1;i0) { + if (fseq>currentFrame) currentTime = TuioTime.getSessionTime(); + if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq; + else lateFrame = true; + } else if (TuioTime.getSessionTime().subtract(currentTime).getTotalMilliseconds()>100) { + currentTime = TuioTime.getSessionTime(); + } + if (!lateFrame) { + + Enumeration frameEnum = frameStrings.elements(); + while(frameEnum.hasMoreElements()) { + TuioString tstr = frameEnum.nextElement(); + + switch (tstr.getTuioState()) { + case TuioString.TUIO_REMOVED: + + TuioString removeString = tstr; + removeString.remove(currentTime); + + for (int i=0;i0) { + Enumeration slist = stringList.elements(); + while (slist.hasMoreElements()) { + int sl_id = slist.nextElement().getStringID(); + if (sl_id>maxStringID) maxStringID=sl_id; + } + + Enumeration flist = freeStringList.elements(); + while (flist.hasMoreElements()) { + int sl_id = flist.nextElement().getStringID(); + if (sl_id>=maxStringID) freeStringList.removeElement(sl_id); + } + } else freeStringList.clear(); + } else if (removeString.getStringID()0)) { + TuioString closestString = freeStringList.firstElement(); + Enumeration testList = freeStringList.elements(); + while (testList.hasMoreElements()) { + TuioString testString = testList.nextElement(); + //if (testString.getDistance(tstr) buffer = aliveStringList; + aliveStringList = newStringList; + // recycling the vector + newStringList = buffer; + } + + frameStrings.clear(); + } + } + + + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioContainer.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioContainer.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioContainer.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,463 +1,463 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package TUIO; - -import java.util.*; - -/** - * The abstract TuioContainer class defines common attributes that apply to both subclasses {@link TuioObject} and {@link TuioCursor}. - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -abstract class TuioContainer extends TuioPoint { - - /** - * The unique session ID number that is assigned to each TUIO object or cursor. - */ - protected long session_id; - /** - * The X-axis velocity value. - */ - protected float x_speed; - /** - * The Y-axis velocity value. - */ - protected float y_speed; - /** - * The motion speed value. - */ - protected float motion_speed; - /** - * The motion acceleration value. - */ - protected float motion_accel; - /** - * A Vector of TuioPoints containing all the previous positions of the TUIO component. - */ - protected Vector path; - /** - * Defines the ADDED state. - */ - public static final int TUIO_ADDED = 0; - /** - * Defines the ACCELERATING state. - */ - public static final int TUIO_ACCELERATING = 1; - /** - * Defines the DECELERATING state. - */ - public static final int TUIO_DECELERATING = 2; - /** - * Defines the STOPPED state. - */ - public static final int TUIO_STOPPED = 3; - /** - * Defines the REMOVED state. - */ - public static final int TUIO_REMOVED = 4; - /** - * Reflects the current state of the TuioComponent - */ - protected int state; - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, X and Y coordinate to the newly created TuioContainer. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - TuioContainer(TuioTime ttime, long si, float xp, float yp) { - super(ttime,xp,yp); - - session_id = si; - x_speed = 0.0f; - y_speed = 0.0f; - motion_speed = 0.0f; - motion_accel = 0.0f; - - path = new Vector(); - path.addElement(new TuioPoint(currentTime,xpos,ypos)); - state = TUIO_ADDED; - } - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, X, Y and Z coordinate to the newly created TuioContainer. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) { - super(ttime,xp,yp, zp); - - session_id = si; - x_speed = 0.0f; - y_speed = 0.0f; - motion_speed = 0.0f; - motion_accel = 0.0f; - - path = new Vector(); - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - state = TUIO_ADDED; - } - - /** - * This constructor takes the provided Session ID, X and Y coordinate - * and assigs these values to the newly created TuioContainer. - * - * @param si the Session ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - TuioContainer(long si, float xp, float yp) { - super(xp,yp); - - session_id = si; - x_speed = 0.0f; - y_speed = 0.0f; - motion_speed = 0.0f; - motion_accel = 0.0f; - - path = new Vector(); - path.addElement(new TuioPoint(currentTime,xpos,ypos)); - state = TUIO_ADDED; - } - - /** - * This constructor takes the provided Session ID, X, Y and Z coordinate - * and assigs these values to the newly created TuioContainer. - * - * @param si the Session ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - TuioContainer(long si, float xp, float yp, float zp) { - super(xp,yp,zp); - - session_id = si; - x_speed = 0.0f; - y_speed = 0.0f; - motion_speed = 0.0f; - motion_accel = 0.0f; - - path = new Vector(); - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - state = TUIO_ADDED; - } - - /** - * This constructor takes the atttibutes of the provided TuioContainer - * and assigs these values to the newly created TuioContainer. - * - * @param tcon the TuioContainer to assign - */ - TuioContainer(TuioContainer tcon) { - super(tcon); - - session_id = tcon.getSessionID(); - x_speed = 0.0f; - y_speed = 0.0f; - motion_speed = 0.0f; - motion_accel = 0.0f; - - path = new Vector(); - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - state = TUIO_ADDED; - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X and Y coordinate to the private TuioContainer attributes. - * The speed and accleration values are calculated accordingly. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public void update(TuioTime ttime, float xp, float yp) { - TuioPoint lastPoint = path.lastElement(); - super.update(ttime,xp,yp); - - TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); - float dt = diffTime.getTotalMilliseconds()/1000.0f; - float dx = this.xpos - lastPoint.getX(); - float dy = this.ypos - lastPoint.getY(); - float dist = (float)Math.sqrt(dx*dx+dy*dy); - float last_motion_speed = this.motion_speed; - - this.x_speed = dx/dt; - this.y_speed = dy/dt; - this.motion_speed = dist/dt; - this.motion_accel = (motion_speed - last_motion_speed)/dt; - - path.addElement(new TuioPoint(currentTime,xpos,ypos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X, Y and Z coordinate to the private TuioContainer attributes. - * The speed and accleration values are calculated accordingly. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public void update(TuioTime ttime, float xp, float yp, float zp) { - TuioPoint lastPoint = path.lastElement(); - super.update(ttime,xp,yp,zp); - - TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); - float dt = diffTime.getTotalMilliseconds()/1000.0f; - float dx = this.xpos - lastPoint.getX(); - float dy = this.ypos - lastPoint.getY(); - float dz = this.zpos - lastPoint.getZ(); - float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz); - float last_motion_speed = this.motion_speed; - - this.x_speed = dx/dt; - this.y_speed = dy/dt; - this.motion_speed = dist/dt; - this.motion_accel = (motion_speed - last_motion_speed)/dt; - - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * This method is used to calculate the speed and acceleration values of - * TuioContainers with unchanged positions. - */ - public void stop(TuioTime ttime) { - update(ttime,xpos,ypos,zpos); - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X and Y coordinate, X and Y velocity and acceleration - * to the private TuioContainer attributes. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param ma the acceleration to assign - */ - public void update(TuioTime ttime, float xp, float yp , float xs, float ys, float ma) { - super.update(ttime,xp,yp); - x_speed = xs; - y_speed = ys; - motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); - motion_accel = ma; - path.addElement(new TuioPoint(currentTime,xpos,ypos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X, Y and Z coordinate, X and Y velocity and acceleration - * to the private TuioContainer attributes. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param ma the acceleration to assign - */ - public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) { - super.update(ttime,xp,yp,zp); - x_speed = xs; - y_speed = ys; - motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); - motion_accel = ma; - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Assigns the provided X and Y coordinate, X and Y velocity and acceleration - * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param ma the acceleration to assign - */ - public void update(float xp, float yp,float xs,float ys,float ma) { - super.update(xp,yp); - x_speed = xs; - y_speed = ys; - motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); - motion_accel = ma; - path.addElement(new TuioPoint(currentTime,xpos,ypos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration - * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param ma the acceleration to assign - */ - public void update(float xp, float yp, float zp,float xs,float ys,float ma) { - super.update(xp,yp,zp); - x_speed = xs; - y_speed = ys; - motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); - motion_accel = ma; - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Takes the atttibutes of the provided TuioContainer - * and assigs these values to this TuioContainer. - * The TuioTime time stamp of this TuioContainer remains unchanged. - * - * @param tcon the TuioContainer to assign - */ - public void update (TuioContainer tcon) { - super.update(tcon); - x_speed = tcon.getXSpeed(); - y_speed = tcon.getYSpeed(); - motion_speed = tcon.getMotionSpeed(); - motion_accel = tcon.getMotionAccel(); - path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); - if (motion_accel>0) state = TUIO_ACCELERATING; - else if (motion_accel<0) state = TUIO_DECELERATING; - else state = TUIO_STOPPED; - } - - /** - * Assigns the REMOVE state to this TuioContainer and sets - * its TuioTime time stamp to the provided TuioTime argument. - * - * @param ttime the TuioTime to assign - */ - public void remove(TuioTime ttime) { - currentTime = new TuioTime(ttime); - state = TUIO_REMOVED; - } - - /** - * Returns the Session ID of this TuioContainer. - * @return the Session ID of this TuioContainer - */ - public long getSessionID() { - return session_id; - } - - /** - * Returns the X velocity of this TuioContainer. - * @return the X velocity of this TuioContainer - */ - public float getXSpeed() { - return x_speed; - } - - /** - * Returns the Y velocity of this TuioContainer. - * @return the Y velocity of this TuioContainer - */ - public float getYSpeed() { - return y_speed; - } - - /** - * Returns the position of this TuioContainer. - * @return the position of this TuioContainer - */ - public TuioPoint getPosition() { - return new TuioPoint(xpos,ypos,zpos); - } - - /** - * Returns the path of this TuioContainer. - * @return the path of this TuioContainer - */ - public Vector getPath() { - return path; - } - - /** - * Returns the motion speed of this TuioContainer. - * @return the motion speed of this TuioContainer - */ - public float getMotionSpeed() { - return motion_speed; - } - - /** - * Returns the motion acceleration of this TuioContainer. - * @return the motion acceleration of this TuioContainer - */ - public float getMotionAccel() { - return motion_accel; - } - - /** - * Returns the TUIO state of this TuioContainer. - * @return the TUIO state of this TuioContainer - */ - public int getTuioState() { - return state; - } - - /** - * Returns true of this TuioContainer is moving. - * @return true of this TuioContainer is moving - */ - public boolean isMoving() { - if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING)) return true; - else return false; - } - -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package TUIO; + +import java.util.*; + +/** + * The abstract TuioContainer class defines common attributes that apply to both subclasses {@link TuioObject} and {@link TuioCursor}. + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +abstract class TuioContainer extends TuioPoint { + + /** + * The unique session ID number that is assigned to each TUIO object or cursor. + */ + protected long session_id; + /** + * The X-axis velocity value. + */ + protected float x_speed; + /** + * The Y-axis velocity value. + */ + protected float y_speed; + /** + * The motion speed value. + */ + protected float motion_speed; + /** + * The motion acceleration value. + */ + protected float motion_accel; + /** + * A Vector of TuioPoints containing all the previous positions of the TUIO component. + */ + protected Vector path; + /** + * Defines the ADDED state. + */ + public static final int TUIO_ADDED = 0; + /** + * Defines the ACCELERATING state. + */ + public static final int TUIO_ACCELERATING = 1; + /** + * Defines the DECELERATING state. + */ + public static final int TUIO_DECELERATING = 2; + /** + * Defines the STOPPED state. + */ + public static final int TUIO_STOPPED = 3; + /** + * Defines the REMOVED state. + */ + public static final int TUIO_REMOVED = 4; + /** + * Reflects the current state of the TuioComponent + */ + protected int state; + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, X and Y coordinate to the newly created TuioContainer. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + TuioContainer(TuioTime ttime, long si, float xp, float yp) { + super(ttime,xp,yp); + + session_id = si; + x_speed = 0.0f; + y_speed = 0.0f; + motion_speed = 0.0f; + motion_accel = 0.0f; + + path = new Vector(); + path.addElement(new TuioPoint(currentTime,xpos,ypos)); + state = TUIO_ADDED; + } + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, X, Y and Z coordinate to the newly created TuioContainer. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) { + super(ttime,xp,yp, zp); + + session_id = si; + x_speed = 0.0f; + y_speed = 0.0f; + motion_speed = 0.0f; + motion_accel = 0.0f; + + path = new Vector(); + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + state = TUIO_ADDED; + } + + /** + * This constructor takes the provided Session ID, X and Y coordinate + * and assigs these values to the newly created TuioContainer. + * + * @param si the Session ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + TuioContainer(long si, float xp, float yp) { + super(xp,yp); + + session_id = si; + x_speed = 0.0f; + y_speed = 0.0f; + motion_speed = 0.0f; + motion_accel = 0.0f; + + path = new Vector(); + path.addElement(new TuioPoint(currentTime,xpos,ypos)); + state = TUIO_ADDED; + } + + /** + * This constructor takes the provided Session ID, X, Y and Z coordinate + * and assigs these values to the newly created TuioContainer. + * + * @param si the Session ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + TuioContainer(long si, float xp, float yp, float zp) { + super(xp,yp,zp); + + session_id = si; + x_speed = 0.0f; + y_speed = 0.0f; + motion_speed = 0.0f; + motion_accel = 0.0f; + + path = new Vector(); + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + state = TUIO_ADDED; + } + + /** + * This constructor takes the atttibutes of the provided TuioContainer + * and assigs these values to the newly created TuioContainer. + * + * @param tcon the TuioContainer to assign + */ + TuioContainer(TuioContainer tcon) { + super(tcon); + + session_id = tcon.getSessionID(); + x_speed = 0.0f; + y_speed = 0.0f; + motion_speed = 0.0f; + motion_accel = 0.0f; + + path = new Vector(); + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + state = TUIO_ADDED; + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X and Y coordinate to the private TuioContainer attributes. + * The speed and accleration values are calculated accordingly. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public void update(TuioTime ttime, float xp, float yp) { + TuioPoint lastPoint = path.lastElement(); + super.update(ttime,xp,yp); + + TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); + float dt = diffTime.getTotalMilliseconds()/1000.0f; + float dx = this.xpos - lastPoint.getX(); + float dy = this.ypos - lastPoint.getY(); + float dist = (float)Math.sqrt(dx*dx+dy*dy); + float last_motion_speed = this.motion_speed; + + this.x_speed = dx/dt; + this.y_speed = dy/dt; + this.motion_speed = dist/dt; + this.motion_accel = (motion_speed - last_motion_speed)/dt; + + path.addElement(new TuioPoint(currentTime,xpos,ypos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X, Y and Z coordinate to the private TuioContainer attributes. + * The speed and accleration values are calculated accordingly. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public void update(TuioTime ttime, float xp, float yp, float zp) { + TuioPoint lastPoint = path.lastElement(); + super.update(ttime,xp,yp,zp); + + TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); + float dt = diffTime.getTotalMilliseconds()/1000.0f; + float dx = this.xpos - lastPoint.getX(); + float dy = this.ypos - lastPoint.getY(); + float dz = this.zpos - lastPoint.getZ(); + float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz); + float last_motion_speed = this.motion_speed; + + this.x_speed = dx/dt; + this.y_speed = dy/dt; + this.motion_speed = dist/dt; + this.motion_accel = (motion_speed - last_motion_speed)/dt; + + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * This method is used to calculate the speed and acceleration values of + * TuioContainers with unchanged positions. + */ + public void stop(TuioTime ttime) { + update(ttime,xpos,ypos,zpos); + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X and Y coordinate, X and Y velocity and acceleration + * to the private TuioContainer attributes. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param ma the acceleration to assign + */ + public void update(TuioTime ttime, float xp, float yp , float xs, float ys, float ma) { + super.update(ttime,xp,yp); + x_speed = xs; + y_speed = ys; + motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); + motion_accel = ma; + path.addElement(new TuioPoint(currentTime,xpos,ypos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X, Y and Z coordinate, X and Y velocity and acceleration + * to the private TuioContainer attributes. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param ma the acceleration to assign + */ + public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) { + super.update(ttime,xp,yp,zp); + x_speed = xs; + y_speed = ys; + motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); + motion_accel = ma; + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Assigns the provided X and Y coordinate, X and Y velocity and acceleration + * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param ma the acceleration to assign + */ + public void update(float xp, float yp,float xs,float ys,float ma) { + super.update(xp,yp); + x_speed = xs; + y_speed = ys; + motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); + motion_accel = ma; + path.addElement(new TuioPoint(currentTime,xpos,ypos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration + * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param ma the acceleration to assign + */ + public void update(float xp, float yp, float zp,float xs,float ys,float ma) { + super.update(xp,yp,zp); + x_speed = xs; + y_speed = ys; + motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); + motion_accel = ma; + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Takes the atttibutes of the provided TuioContainer + * and assigs these values to this TuioContainer. + * The TuioTime time stamp of this TuioContainer remains unchanged. + * + * @param tcon the TuioContainer to assign + */ + public void update (TuioContainer tcon) { + super.update(tcon); + x_speed = tcon.getXSpeed(); + y_speed = tcon.getYSpeed(); + motion_speed = tcon.getMotionSpeed(); + motion_accel = tcon.getMotionAccel(); + path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); + if (motion_accel>0) state = TUIO_ACCELERATING; + else if (motion_accel<0) state = TUIO_DECELERATING; + else state = TUIO_STOPPED; + } + + /** + * Assigns the REMOVE state to this TuioContainer and sets + * its TuioTime time stamp to the provided TuioTime argument. + * + * @param ttime the TuioTime to assign + */ + public void remove(TuioTime ttime) { + currentTime = new TuioTime(ttime); + state = TUIO_REMOVED; + } + + /** + * Returns the Session ID of this TuioContainer. + * @return the Session ID of this TuioContainer + */ + public long getSessionID() { + return session_id; + } + + /** + * Returns the X velocity of this TuioContainer. + * @return the X velocity of this TuioContainer + */ + public float getXSpeed() { + return x_speed; + } + + /** + * Returns the Y velocity of this TuioContainer. + * @return the Y velocity of this TuioContainer + */ + public float getYSpeed() { + return y_speed; + } + + /** + * Returns the position of this TuioContainer. + * @return the position of this TuioContainer + */ + public TuioPoint getPosition() { + return new TuioPoint(xpos,ypos,zpos); + } + + /** + * Returns the path of this TuioContainer. + * @return the path of this TuioContainer + */ + public Vector getPath() { + return path; + } + + /** + * Returns the motion speed of this TuioContainer. + * @return the motion speed of this TuioContainer + */ + public float getMotionSpeed() { + return motion_speed; + } + + /** + * Returns the motion acceleration of this TuioContainer. + * @return the motion acceleration of this TuioContainer + */ + public float getMotionAccel() { + return motion_accel; + } + + /** + * Returns the TUIO state of this TuioContainer. + * @return the TUIO state of this TuioContainer + */ + public int getTuioState() { + return state; + } + + /** + * Returns true of this TuioContainer is moving. + * @return true of this TuioContainer is moving + */ + public boolean isMoving() { + if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING)) return true; + else return false; + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioCursor.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioCursor.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioCursor.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,115 +1,115 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package TUIO; - -/** - * The TuioCursor class encapsulates /tuio/2Dcur TUIO cursors. - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public class TuioCursor extends TuioContainer { - - /** - * The individual cursor ID number that is assigned to each TuioCursor. - */ - protected int cursor_id; - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, Cursor ID, X and Y coordinate to the newly created TuioCursor. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param ci the Cursor ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public TuioCursor (TuioTime ttime, long si, int ci, float xp, float yp) { - super(ttime, si,xp,yp); - this.cursor_id = ci; - } - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, Cursor ID, X, Y and Z coordinate to the newly created TuioCursor. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param ci the Cursor ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public TuioCursor (TuioTime ttime, long si, int ci, float xp, float yp, float zp) { - super(ttime, si,xp,yp,zp); - this.cursor_id = ci; - } - - /** - * This constructor takes the provided Session ID, Cursor ID, X and Y coordinate - * and assigs these values to the newly created TuioCursor. - * - * @param si the Session ID to assign - * @param ci the Cursor ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public TuioCursor (long si, int ci, float xp, float yp) { - super(si,xp,yp); - this.cursor_id = ci; - } - - /** - * This constructor takes the provided Session ID, Cursor ID, X, Y and Z coordinate - * and assigs these values to the newly created TuioCursor. - * - * @param si the Session ID to assign - * @param ci the Cursor ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public TuioCursor (long si, int ci, float xp, float yp, float zp) { - super(si,xp,yp,zp); - this.cursor_id = ci; - } - - /** - * This constructor takes the atttibutes of the provided TuioCursor - * and assigs these values to the newly created TuioCursor. - * - * @param tcur the TuioCursor to assign - */ - public TuioCursor (TuioCursor tcur) { - super(tcur); - this.cursor_id = tcur.getCursorID(); - } - - /** - * Returns the Cursor ID of this TuioCursor. - * @return the Cursor ID of this TuioCursor - */ - public int getCursorID() { - return cursor_id; - } - -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package TUIO; + +/** + * The TuioCursor class encapsulates /tuio/2Dcur TUIO cursors. + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public class TuioCursor extends TuioContainer { + + /** + * The individual cursor ID number that is assigned to each TuioCursor. + */ + protected int cursor_id; + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, Cursor ID, X and Y coordinate to the newly created TuioCursor. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param ci the Cursor ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public TuioCursor (TuioTime ttime, long si, int ci, float xp, float yp) { + super(ttime, si,xp,yp); + this.cursor_id = ci; + } + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, Cursor ID, X, Y and Z coordinate to the newly created TuioCursor. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param ci the Cursor ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public TuioCursor (TuioTime ttime, long si, int ci, float xp, float yp, float zp) { + super(ttime, si,xp,yp,zp); + this.cursor_id = ci; + } + + /** + * This constructor takes the provided Session ID, Cursor ID, X and Y coordinate + * and assigs these values to the newly created TuioCursor. + * + * @param si the Session ID to assign + * @param ci the Cursor ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public TuioCursor (long si, int ci, float xp, float yp) { + super(si,xp,yp); + this.cursor_id = ci; + } + + /** + * This constructor takes the provided Session ID, Cursor ID, X, Y and Z coordinate + * and assigs these values to the newly created TuioCursor. + * + * @param si the Session ID to assign + * @param ci the Cursor ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public TuioCursor (long si, int ci, float xp, float yp, float zp) { + super(si,xp,yp,zp); + this.cursor_id = ci; + } + + /** + * This constructor takes the atttibutes of the provided TuioCursor + * and assigs these values to the newly created TuioCursor. + * + * @param tcur the TuioCursor to assign + */ + public TuioCursor (TuioCursor tcur) { + super(tcur); + this.cursor_id = tcur.getCursorID(); + } + + /** + * Returns the Cursor ID of this TuioCursor. + * @return the Cursor ID of this TuioCursor + */ + public int getCursorID() { + return cursor_id; + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioListener.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioListener.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioListener.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,111 +1,111 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package TUIO; - -/** - * The TuioListener interface provides a simple callback infrastructure which is used by the {@link TuioClient} class - * to dispatch TUIO events to all registered instances of classes that implement the TuioListener interface defined here.

    - * Any class that implements the TuioListener interface is required to implement all of the callback methods defined here. - * The {@link TuioClient} makes use of these interface methods in order to dispatch TUIO events to all registered TuioListener implementations.

    - * - * public class MyTuioListener implements TuioListener
    - * ...

    - * MyTuioListener listener = new MyTuioListener();
    - * TuioClient client = new TuioClient();
    - * client.addTuioListener(listener);
    - * client.start();
    - *
    - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public interface TuioListener { - - /** - * This callback method is invoked by the TuioClient when a new TuioObject is added to the session. - * - * @param tobj the TuioObject reference associated to the addTuioObject event - */ - public void addTuioObject(TuioObject tobj); - - /** - * This callback method is invoked by the TuioClient when an existing TuioObject is updated during the session. - * - * @param tobj the TuioObject reference associated to the updateTuioObject event - */ - public void updateTuioObject(TuioObject tobj); - - /** - * This callback method is invoked by the TuioClient when an existing TuioObject is removed from the session. - * - * @param tobj the TuioObject reference associated to the removeTuioObject event - */ - public void removeTuioObject(TuioObject tobj); - - /** - * This callback method is invoked by the TuioClient when a new TuioCursor is added to the session. - * - * @param tcur the TuioCursor reference associated to the addTuioCursor event - */ - public void addTuioCursor(TuioCursor tcur); - - /** - * This callback method is invoked by the TuioClient when an existing TuioCursor is updated during the session. - * - * @param tcur the TuioCursor reference associated to the updateTuioCursor event - */ - public void updateTuioCursor(TuioCursor tcur); - - /** - * This callback method is invoked by the TuioClient when an existing TuioCursor is removed from the session. - * - * @param tcur the TuioCursor reference associated to the removeTuioCursor event - */ - public void removeTuioCursor(TuioCursor tcur); - - /** - * This callback method is invoked by the TuioClient when a new TuioString is added to the session. - * - * @param tstr the TuioString reference associated to the addTuioString event - */ - public void addTuioString(TuioString tstr); - - /** - * This callback method is invoked by the TuioClient when an existing TuioString is updated during the session. - * - * @param tstr the TuioString reference associated to the updateTuioString event - */ - public void updateTuioString(TuioString tstr); - - /** - * This callback method is invoked by the TuioClient when an existing TuioString is removed from the session. - * - * @param tstr the TuioString reference associated to the removeTuioString event - */ - public void removeTuioString(TuioString tstr); - - /** - * This callback method is invoked by the TuioClient to mark the end of a received TUIO message bundle. - * - * @param ftime the TuioTime associated to the current TUIO message bundle - */ - public void refresh(TuioTime ftime); -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package TUIO; + +/** + * The TuioListener interface provides a simple callback infrastructure which is used by the {@link TuioClient} class + * to dispatch TUIO events to all registered instances of classes that implement the TuioListener interface defined here.

    + * Any class that implements the TuioListener interface is required to implement all of the callback methods defined here. + * The {@link TuioClient} makes use of these interface methods in order to dispatch TUIO events to all registered TuioListener implementations.

    + * + * public class MyTuioListener implements TuioListener
    + * ...

    + * MyTuioListener listener = new MyTuioListener();
    + * TuioClient client = new TuioClient();
    + * client.addTuioListener(listener);
    + * client.start();
    + *
    + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public interface TuioListener { + + /** + * This callback method is invoked by the TuioClient when a new TuioObject is added to the session. + * + * @param tobj the TuioObject reference associated to the addTuioObject event + */ + public void addTuioObject(TuioObject tobj); + + /** + * This callback method is invoked by the TuioClient when an existing TuioObject is updated during the session. + * + * @param tobj the TuioObject reference associated to the updateTuioObject event + */ + public void updateTuioObject(TuioObject tobj); + + /** + * This callback method is invoked by the TuioClient when an existing TuioObject is removed from the session. + * + * @param tobj the TuioObject reference associated to the removeTuioObject event + */ + public void removeTuioObject(TuioObject tobj); + + /** + * This callback method is invoked by the TuioClient when a new TuioCursor is added to the session. + * + * @param tcur the TuioCursor reference associated to the addTuioCursor event + */ + public void addTuioCursor(TuioCursor tcur); + + /** + * This callback method is invoked by the TuioClient when an existing TuioCursor is updated during the session. + * + * @param tcur the TuioCursor reference associated to the updateTuioCursor event + */ + public void updateTuioCursor(TuioCursor tcur); + + /** + * This callback method is invoked by the TuioClient when an existing TuioCursor is removed from the session. + * + * @param tcur the TuioCursor reference associated to the removeTuioCursor event + */ + public void removeTuioCursor(TuioCursor tcur); + + /** + * This callback method is invoked by the TuioClient when a new TuioString is added to the session. + * + * @param tstr the TuioString reference associated to the addTuioString event + */ + public void addTuioString(TuioString tstr); + + /** + * This callback method is invoked by the TuioClient when an existing TuioString is updated during the session. + * + * @param tstr the TuioString reference associated to the updateTuioString event + */ + public void updateTuioString(TuioString tstr); + + /** + * This callback method is invoked by the TuioClient when an existing TuioString is removed from the session. + * + * @param tstr the TuioString reference associated to the removeTuioString event + */ + public void removeTuioString(TuioString tstr); + + /** + * This callback method is invoked by the TuioClient to mark the end of a received TUIO message bundle. + * + * @param ftime the TuioTime associated to the current TUIO message bundle + */ + public void refresh(TuioTime ftime); +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioObject.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioObject.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioObject.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,251 +1,251 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package TUIO; - -/** - * The TuioObject class encapsulates /tuio/2Dobj TUIO objects. - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public class TuioObject extends TuioContainer { - - /** - * The individual symbol ID number that is assigned to each TuioObject. - */ - protected int symbol_id; - /** - * The rotation angle value. - */ - protected float angle; - /** - * The rotation speed value. - */ - protected float rotation_speed; - /** - * The rotation acceleration value. - */ - protected float rotation_accel; - /** - * Defines the ROTATING state. - */ - public static final int TUIO_ROTATING = 5; - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, Symbol ID, X and Y coordinate and angle to the newly created TuioObject. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param sym the Symbol ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param a the angle to assign - */ - public TuioObject (TuioTime ttime, long si, int sym, float xp, float yp, float a) { - super(ttime, si,xp,yp); - symbol_id = sym; - angle = a; - rotation_speed = 0.0f; - rotation_accel = 0.0f; - } - - /** - * This constructor takes the provided Session ID, Symbol ID, X and Y coordinate - * and angle, and assigs these values to the newly created TuioObject. - * - * @param si the Session ID to assign - * @param sym the Symbol ID to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param a the angle to assign - */ - public TuioObject (long si, int sym, float xp, float yp, float a) { - super(si,xp,yp); - symbol_id = sym; - angle = angle; - rotation_speed = 0.0f; - rotation_accel = 0.0f; - } - - /** - * This constructor takes the atttibutes of the provided TuioObject - * and assigs these values to the newly created TuioObject. - * - * @param tobj the TuioObject to assign - */ - public TuioObject (TuioObject tobj) { - super(tobj); - symbol_id = tobj.getSymbolID(); - angle = tobj.getAngle(); - rotation_speed = 0.0f; - rotation_accel = 0.0f; - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X and Y coordinate, angle, X and Y velocity, motion acceleration, - * rotation speed and rotation acceleration to the private TuioObject attributes. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param a the angle coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param rs the rotation velocity to assign - * @param ma the motion acceleration to assign - * @param ra the rotation acceleration to assign - */ - public void update (TuioTime ttime, float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) { - super.update(ttime,xp,yp,xs,ys,ma); - angle = a; - rotation_speed = rs; - rotation_accel = ra; - if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; - } - - /** - * Assigns the provided X and Y coordinate, angle, X and Y velocity, motion acceleration - * rotation velocity and rotation acceleration to the private TuioContainer attributes. - * The TuioTime time stamp remains unchanged. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param a the angle coordinate to assign - * @param xs the X velocity to assign - * @param ys the Y velocity to assign - * @param rs the rotation velocity to assign - * @param ma the motion acceleration to assign - * @param ra the rotation acceleration to assign - */ - public void update (float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) { - super.update(xp,yp,xs,ys,ma); - angle = a; - rotation_speed = rs; - rotation_accel = ra; - if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * X and Y coordinate and angle to the private TuioObject attributes. - * The speed and accleration values are calculated accordingly. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param a the angle coordinate to assign - */ - public void update (TuioTime ttime, float xp, float yp, float a) { - TuioPoint lastPoint = path.lastElement(); - super.update(ttime,xp,yp); - - TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); - float dt = diffTime.getTotalMilliseconds()/1000.0f; - float last_angle = angle; - float last_rotation_speed = rotation_speed; - angle = a; - - float da = (this.angle-last_angle)/(2.0f*(float)Math.PI); - if (da>0.75f) da-=1.0f; - else if (da<-0.75f) da+=1.0f; - - rotation_speed = da/dt; - rotation_accel = (rotation_speed - last_rotation_speed)/dt; - if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; - } - - /** - * Takes the atttibutes of the provided TuioObject - * and assigs these values to this TuioObject. - * The TuioTime time stamp of this TuioContainer remains unchanged. - * - * @param tobj the TuioContainer to assign - */ - public void update (TuioObject tobj) { - super.update(tobj); - angle = tobj.getAngle(); - rotation_speed = tobj.getRotationSpeed(); - rotation_accel = tobj.getRotationAccel(); - if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; - } - - /** - * This method is used to calculate the speed and acceleration values of a - * TuioObject with unchanged position and angle. - * - * @param ttime the TuioTime to assign - */ - public void stop (TuioTime ttime) { - update(ttime,xpos,ypos, angle); - } - - /** - * Returns the symbol ID of this TuioObject. - * @return the symbol ID of this TuioObject - */ - public int getSymbolID() { - return symbol_id; - } - - /** - * Returns the rotation angle of this TuioObject. - * @return the rotation angle of this TuioObject - */ - public float getAngle() { - return angle; - } - - /** - * Returns the rotation angle in degrees of this TuioObject. - * @return the rotation angle in degrees of this TuioObject - */ - public float getAngleDegrees() { - return angle/(float)Math.PI*180.0f; - } - - /** - * Returns the rotation speed of this TuioObject. - * @return the rotation speed of this TuioObject - */ - public float getRotationSpeed() { - return rotation_speed; - } - - /** - * Returns the rotation acceleration of this TuioObject. - * @return the rotation acceleration of this TuioObject - */ - public float getRotationAccel() { - return rotation_accel; - } - - /** - * Returns true of this TuioObject is moving. - * @return true of this TuioObject is moving - */ - public boolean isMoving() { - if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING) || (state==TUIO_ROTATING)) return true; - else return false; - } - -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package TUIO; + +/** + * The TuioObject class encapsulates /tuio/2Dobj TUIO objects. + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public class TuioObject extends TuioContainer { + + /** + * The individual symbol ID number that is assigned to each TuioObject. + */ + protected int symbol_id; + /** + * The rotation angle value. + */ + protected float angle; + /** + * The rotation speed value. + */ + protected float rotation_speed; + /** + * The rotation acceleration value. + */ + protected float rotation_accel; + /** + * Defines the ROTATING state. + */ + public static final int TUIO_ROTATING = 5; + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, Symbol ID, X and Y coordinate and angle to the newly created TuioObject. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param sym the Symbol ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param a the angle to assign + */ + public TuioObject (TuioTime ttime, long si, int sym, float xp, float yp, float a) { + super(ttime, si,xp,yp); + symbol_id = sym; + angle = a; + rotation_speed = 0.0f; + rotation_accel = 0.0f; + } + + /** + * This constructor takes the provided Session ID, Symbol ID, X and Y coordinate + * and angle, and assigs these values to the newly created TuioObject. + * + * @param si the Session ID to assign + * @param sym the Symbol ID to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param a the angle to assign + */ + public TuioObject (long si, int sym, float xp, float yp, float a) { + super(si,xp,yp); + symbol_id = sym; + angle = angle; + rotation_speed = 0.0f; + rotation_accel = 0.0f; + } + + /** + * This constructor takes the atttibutes of the provided TuioObject + * and assigs these values to the newly created TuioObject. + * + * @param tobj the TuioObject to assign + */ + public TuioObject (TuioObject tobj) { + super(tobj); + symbol_id = tobj.getSymbolID(); + angle = tobj.getAngle(); + rotation_speed = 0.0f; + rotation_accel = 0.0f; + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X and Y coordinate, angle, X and Y velocity, motion acceleration, + * rotation speed and rotation acceleration to the private TuioObject attributes. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param a the angle coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param rs the rotation velocity to assign + * @param ma the motion acceleration to assign + * @param ra the rotation acceleration to assign + */ + public void update (TuioTime ttime, float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) { + super.update(ttime,xp,yp,xs,ys,ma); + angle = a; + rotation_speed = rs; + rotation_accel = ra; + if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; + } + + /** + * Assigns the provided X and Y coordinate, angle, X and Y velocity, motion acceleration + * rotation velocity and rotation acceleration to the private TuioContainer attributes. + * The TuioTime time stamp remains unchanged. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param a the angle coordinate to assign + * @param xs the X velocity to assign + * @param ys the Y velocity to assign + * @param rs the rotation velocity to assign + * @param ma the motion acceleration to assign + * @param ra the rotation acceleration to assign + */ + public void update (float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) { + super.update(xp,yp,xs,ys,ma); + angle = a; + rotation_speed = rs; + rotation_accel = ra; + if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * X and Y coordinate and angle to the private TuioObject attributes. + * The speed and accleration values are calculated accordingly. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param a the angle coordinate to assign + */ + public void update (TuioTime ttime, float xp, float yp, float a) { + TuioPoint lastPoint = path.lastElement(); + super.update(ttime,xp,yp); + + TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); + float dt = diffTime.getTotalMilliseconds()/1000.0f; + float last_angle = angle; + float last_rotation_speed = rotation_speed; + angle = a; + + float da = (this.angle-last_angle)/(2.0f*(float)Math.PI); + if (da>0.75f) da-=1.0f; + else if (da<-0.75f) da+=1.0f; + + rotation_speed = da/dt; + rotation_accel = (rotation_speed - last_rotation_speed)/dt; + if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; + } + + /** + * Takes the atttibutes of the provided TuioObject + * and assigs these values to this TuioObject. + * The TuioTime time stamp of this TuioContainer remains unchanged. + * + * @param tobj the TuioContainer to assign + */ + public void update (TuioObject tobj) { + super.update(tobj); + angle = tobj.getAngle(); + rotation_speed = tobj.getRotationSpeed(); + rotation_accel = tobj.getRotationAccel(); + if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING; + } + + /** + * This method is used to calculate the speed and acceleration values of a + * TuioObject with unchanged position and angle. + * + * @param ttime the TuioTime to assign + */ + public void stop (TuioTime ttime) { + update(ttime,xpos,ypos, angle); + } + + /** + * Returns the symbol ID of this TuioObject. + * @return the symbol ID of this TuioObject + */ + public int getSymbolID() { + return symbol_id; + } + + /** + * Returns the rotation angle of this TuioObject. + * @return the rotation angle of this TuioObject + */ + public float getAngle() { + return angle; + } + + /** + * Returns the rotation angle in degrees of this TuioObject. + * @return the rotation angle in degrees of this TuioObject + */ + public float getAngleDegrees() { + return angle/(float)Math.PI*180.0f; + } + + /** + * Returns the rotation speed of this TuioObject. + * @return the rotation speed of this TuioObject + */ + public float getRotationSpeed() { + return rotation_speed; + } + + /** + * Returns the rotation acceleration of this TuioObject. + * @return the rotation acceleration of this TuioObject + */ + public float getRotationAccel() { + return rotation_accel; + } + + /** + * Returns true of this TuioObject is moving. + * @return true of this TuioObject is moving + */ + public boolean isMoving() { + if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING) || (state==TUIO_ROTATING)) return true; + else return false; + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioPoint.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioPoint.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioPoint.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,363 +1,363 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package TUIO; - -/** - * The TuioPoint class on the one hand is a simple container and utility class to handle TUIO positions in general, - * on the other hand the TuioPoint is the base class for the TuioCursor and TuioObject classes. - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public class TuioPoint { - - public String comm; - - /** - * X coordinate, representated as a floating point value in a range of 0..1 - */ - protected float xpos; - /** - * Y coordinate, representated as a floating point value in a range of 0..1 - */ - protected float ypos; - /** - * Z coordinate, representated as a floating point value in a range of 0..1 - */ - protected float zpos; - /** - * The time stamp of the last update represented as TuioTime (time since session start) - */ - protected TuioTime currentTime; - /** - * The creation time of this TuioPoint represented as TuioTime (time since session start) - */ - protected TuioTime startTime; - - /** - * The default constructor takes no arguments and sets - * its coordinate attributes to zero and its time stamp to the current session time. - */ - public TuioPoint() { - xpos = 0.0f; - ypos = 0.0f; - zpos = 0.0f; - currentTime = TuioTime.getSessionTime(); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes two floating point coordinate arguments and sets - * its coordinate attributes to these values and its time stamp to the current session time. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public TuioPoint(float xp, float yp) { - xpos = xp; - ypos = yp; - zpos = 0.0f; - currentTime = TuioTime.getSessionTime(); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes three floating point coordinate arguments and sets - * its coordinate attributes to these values and its time stamp to the current session time. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public TuioPoint(float xp, float yp, float zp) { - xpos = xp; - ypos = yp; - zpos = zp; - currentTime = TuioTime.getSessionTime(); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes a TuioPoint argument and sets its coordinate attributes - * to the coordinates of the provided TuioPoint and its time stamp to the current session time. - * - * @param tpoint the TuioPoint to assign - */ - public TuioPoint(TuioPoint tpoint) { - xpos = tpoint.getX(); - ypos = tpoint.getY(); - zpos = tpoint.getZ(); - currentTime = TuioTime.getSessionTime(); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes a TuioTime object and two floating point coordinate arguments and sets - * its coordinate attributes to these values and its time stamp to the provided TUIO time object. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public TuioPoint(TuioTime ttime, float xp, float yp) { - xpos = xp; - ypos = yp; - zpos = 0.0f; - currentTime = new TuioTime(ttime); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes a TuioTime object and three floating point coordinate arguments and sets - * its coordinate attributes to these values and its time stamp to the provided TUIO time object. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public TuioPoint(TuioTime ttime, float xp, float yp, float zp) { - xpos = xp; - ypos = yp; - zpos = zp; - currentTime = new TuioTime(ttime); - startTime = new TuioTime(currentTime); - } - - /** - * Takes a TuioPoint argument and updates its coordinate attributes - * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. - * - * @param tpoint the TuioPoint to assign - */ - public void update(TuioPoint tpoint) { - xpos = tpoint.getX(); - ypos = tpoint.getY(); - zpos = tpoint.getZ(); - } - - /** - * Takes two floating point coordinate arguments and updates its coordinate attributes - * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public void update(float xp, float yp) { - xpos = xp; - ypos = yp; - } - - /** - * Takes three floating point coordinate arguments and updates its coordinate attributes - * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. - * - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public void update(float xp, float yp, float zp) { - xpos = xp; - ypos = yp; - zpos = zp; - } - - /** - * Takes a TuioTime object and two floating point coordinate arguments and updates its coordinate attributes - * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - */ - public void update(TuioTime ttime, float xp, float yp) { - xpos = xp; - ypos = yp; - currentTime = new TuioTime(ttime); - } - - /** - * Takes a TuioTime object and three floating point coordinate arguments and updates its coordinate attributes - * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object. - * - * @param ttime the TuioTime to assign - * @param xp the X coordinate to assign - * @param yp the Y coordinate to assign - * @param zp the Z coordinate to assign - */ - public void update(TuioTime ttime, float xp, float yp, float zp) { - xpos = xp; - ypos = yp; - zpos = zp; - currentTime = new TuioTime(ttime); - } - - /** - * Returns the X coordinate of this TuioPoint. - * @return the X coordinate of this TuioPoint - */ - public float getX() { - return xpos; - } - - /** - * Returns the Y coordinate of this TuioPoint. - * @return the Y coordinate of this TuioPoint - */ - public float getY() { - return ypos; - } - - /** - * Returns the Z coordinate of this TuioPoint. - * @return the Z coordinate of this TuioPoint - */ - public float getZ() { - return zpos; - } - - /** - * Returns the distance to the provided coordinates - * - * @param xp the X coordinate of the distant point - * @param yp the Y coordinate of the distant point - * @return the distance to the provided coordinates - */ - public float getDistance(float xp, float yp) { - float dx = xpos-xp; - float dy = ypos-yp; - return (float)Math.sqrt(dx*dx+dy*dy); - } - - /** - * Returns the distance to the provided coordinates - * - * @param xp the X coordinate of the distant point - * @param yp the Y coordinate of the distant point - * @param zp the Y coordinate of the distant point - * @return the distance to the provided coordinates - */ - public float getDistance(float xp, float yp, float zp) { - float dx = xpos-xp; - float dy = ypos-yp; - float dz = zpos-zp; - return (float)Math.sqrt(dx*dx+dy*dy+dz*dz); - } - - /** - * Returns the distance to the provided TuioPoint - * - * @param tpoint the distant TuioPoint - * @return the distance to the provided TuioPoint - */ - public float getDistance(TuioPoint tpoint) { - return getDistance(tpoint.getX(),tpoint.getY(), tpoint.getZ()); - } - - /** - * Returns the angle to the provided coordinates - * - * @param xp the X coordinate of the distant point - * @param yp the Y coordinate of the distant point - * @return the angle to the provided coordinates - */ - public float getAngle(float xp, float yp) { - - float side = xpos-xp; - float height = ypos-yp; - float distance = getDistance(xp,yp); - - float angle = (float)(Math.asin(side/distance)+Math.PI/2); - if (height<0) angle = 2.0f*(float)Math.PI-angle; - - return angle; - } - - /** - * Returns the angle to the provided TuioPoint - * - * @param tpoint the distant TuioPoint - * @return the angle to the provided TuioPoint - */ - public float getAngle(TuioPoint tpoint) { - return getAngle(tpoint.getX(),tpoint.getY()); - } - - /** - * Returns the angle in degrees to the provided coordinates - * - * @param xp the X coordinate of the distant point - * @param yp the Y coordinate of the distant point - * @return the angle in degrees to the provided TuioPoint - */ - public float getAngleDegrees(float xp, float yp) { - return (getAngle(xp,yp)/(float)Math.PI)*180.0f; - } - - /** - * Returns the angle in degrees to the provided TuioPoint - * - * @param tpoint the distant TuioPoint - * @return the angle in degrees to the provided TuioPoint - */ - public float getAngleDegrees(TuioPoint tpoint) { - return (getAngle(tpoint)/(float)Math.PI)*180.0f; - } - - /** - * Returns the X coordinate in pixels relative to the provided screen width. - * - * @param width the screen width - * @return the X coordinate of this TuioPoint in pixels relative to the provided screen width - */ - public int getScreenX(int width) { - return (int)Math.round(xpos*width); - } - - /** - * Returns the Y coordinate in pixels relative to the provided screen height. - * - * @param height the screen height - * @return the Y coordinate of this TuioPoint in pixels relative to the provided screen height - */ - public int getScreenY(int height) { - return (int)Math.round(ypos*height); - } - - /** - * Returns the time stamp of this TuioPoint as TuioTime. - * - * @return the time stamp of this TuioPoint as TuioTime - */ - public TuioTime getTuioTime() { - return new TuioTime(currentTime); - } - - /** - * Returns the start time of this TuioPoint as TuioTime. - * - * @return the start time of this TuioPoint as TuioTime - */ - public TuioTime getStartTime() { - return new TuioTime(startTime); - } -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package TUIO; + +/** + * The TuioPoint class on the one hand is a simple container and utility class to handle TUIO positions in general, + * on the other hand the TuioPoint is the base class for the TuioCursor and TuioObject classes. + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public class TuioPoint { + + public String comm; + + /** + * X coordinate, representated as a floating point value in a range of 0..1 + */ + protected float xpos; + /** + * Y coordinate, representated as a floating point value in a range of 0..1 + */ + protected float ypos; + /** + * Z coordinate, representated as a floating point value in a range of 0..1 + */ + protected float zpos; + /** + * The time stamp of the last update represented as TuioTime (time since session start) + */ + protected TuioTime currentTime; + /** + * The creation time of this TuioPoint represented as TuioTime (time since session start) + */ + protected TuioTime startTime; + + /** + * The default constructor takes no arguments and sets + * its coordinate attributes to zero and its time stamp to the current session time. + */ + public TuioPoint() { + xpos = 0.0f; + ypos = 0.0f; + zpos = 0.0f; + currentTime = TuioTime.getSessionTime(); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes two floating point coordinate arguments and sets + * its coordinate attributes to these values and its time stamp to the current session time. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public TuioPoint(float xp, float yp) { + xpos = xp; + ypos = yp; + zpos = 0.0f; + currentTime = TuioTime.getSessionTime(); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes three floating point coordinate arguments and sets + * its coordinate attributes to these values and its time stamp to the current session time. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public TuioPoint(float xp, float yp, float zp) { + xpos = xp; + ypos = yp; + zpos = zp; + currentTime = TuioTime.getSessionTime(); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes a TuioPoint argument and sets its coordinate attributes + * to the coordinates of the provided TuioPoint and its time stamp to the current session time. + * + * @param tpoint the TuioPoint to assign + */ + public TuioPoint(TuioPoint tpoint) { + xpos = tpoint.getX(); + ypos = tpoint.getY(); + zpos = tpoint.getZ(); + currentTime = TuioTime.getSessionTime(); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes a TuioTime object and two floating point coordinate arguments and sets + * its coordinate attributes to these values and its time stamp to the provided TUIO time object. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public TuioPoint(TuioTime ttime, float xp, float yp) { + xpos = xp; + ypos = yp; + zpos = 0.0f; + currentTime = new TuioTime(ttime); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes a TuioTime object and three floating point coordinate arguments and sets + * its coordinate attributes to these values and its time stamp to the provided TUIO time object. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public TuioPoint(TuioTime ttime, float xp, float yp, float zp) { + xpos = xp; + ypos = yp; + zpos = zp; + currentTime = new TuioTime(ttime); + startTime = new TuioTime(currentTime); + } + + /** + * Takes a TuioPoint argument and updates its coordinate attributes + * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. + * + * @param tpoint the TuioPoint to assign + */ + public void update(TuioPoint tpoint) { + xpos = tpoint.getX(); + ypos = tpoint.getY(); + zpos = tpoint.getZ(); + } + + /** + * Takes two floating point coordinate arguments and updates its coordinate attributes + * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public void update(float xp, float yp) { + xpos = xp; + ypos = yp; + } + + /** + * Takes three floating point coordinate arguments and updates its coordinate attributes + * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. + * + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public void update(float xp, float yp, float zp) { + xpos = xp; + ypos = yp; + zpos = zp; + } + + /** + * Takes a TuioTime object and two floating point coordinate arguments and updates its coordinate attributes + * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + */ + public void update(TuioTime ttime, float xp, float yp) { + xpos = xp; + ypos = yp; + currentTime = new TuioTime(ttime); + } + + /** + * Takes a TuioTime object and three floating point coordinate arguments and updates its coordinate attributes + * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object. + * + * @param ttime the TuioTime to assign + * @param xp the X coordinate to assign + * @param yp the Y coordinate to assign + * @param zp the Z coordinate to assign + */ + public void update(TuioTime ttime, float xp, float yp, float zp) { + xpos = xp; + ypos = yp; + zpos = zp; + currentTime = new TuioTime(ttime); + } + + /** + * Returns the X coordinate of this TuioPoint. + * @return the X coordinate of this TuioPoint + */ + public float getX() { + return xpos; + } + + /** + * Returns the Y coordinate of this TuioPoint. + * @return the Y coordinate of this TuioPoint + */ + public float getY() { + return ypos; + } + + /** + * Returns the Z coordinate of this TuioPoint. + * @return the Z coordinate of this TuioPoint + */ + public float getZ() { + return zpos; + } + + /** + * Returns the distance to the provided coordinates + * + * @param xp the X coordinate of the distant point + * @param yp the Y coordinate of the distant point + * @return the distance to the provided coordinates + */ + public float getDistance(float xp, float yp) { + float dx = xpos-xp; + float dy = ypos-yp; + return (float)Math.sqrt(dx*dx+dy*dy); + } + + /** + * Returns the distance to the provided coordinates + * + * @param xp the X coordinate of the distant point + * @param yp the Y coordinate of the distant point + * @param zp the Y coordinate of the distant point + * @return the distance to the provided coordinates + */ + public float getDistance(float xp, float yp, float zp) { + float dx = xpos-xp; + float dy = ypos-yp; + float dz = zpos-zp; + return (float)Math.sqrt(dx*dx+dy*dy+dz*dz); + } + + /** + * Returns the distance to the provided TuioPoint + * + * @param tpoint the distant TuioPoint + * @return the distance to the provided TuioPoint + */ + public float getDistance(TuioPoint tpoint) { + return getDistance(tpoint.getX(),tpoint.getY(), tpoint.getZ()); + } + + /** + * Returns the angle to the provided coordinates + * + * @param xp the X coordinate of the distant point + * @param yp the Y coordinate of the distant point + * @return the angle to the provided coordinates + */ + public float getAngle(float xp, float yp) { + + float side = xpos-xp; + float height = ypos-yp; + float distance = getDistance(xp,yp); + + float angle = (float)(Math.asin(side/distance)+Math.PI/2); + if (height<0) angle = 2.0f*(float)Math.PI-angle; + + return angle; + } + + /** + * Returns the angle to the provided TuioPoint + * + * @param tpoint the distant TuioPoint + * @return the angle to the provided TuioPoint + */ + public float getAngle(TuioPoint tpoint) { + return getAngle(tpoint.getX(),tpoint.getY()); + } + + /** + * Returns the angle in degrees to the provided coordinates + * + * @param xp the X coordinate of the distant point + * @param yp the Y coordinate of the distant point + * @return the angle in degrees to the provided TuioPoint + */ + public float getAngleDegrees(float xp, float yp) { + return (getAngle(xp,yp)/(float)Math.PI)*180.0f; + } + + /** + * Returns the angle in degrees to the provided TuioPoint + * + * @param tpoint the distant TuioPoint + * @return the angle in degrees to the provided TuioPoint + */ + public float getAngleDegrees(TuioPoint tpoint) { + return (getAngle(tpoint)/(float)Math.PI)*180.0f; + } + + /** + * Returns the X coordinate in pixels relative to the provided screen width. + * + * @param width the screen width + * @return the X coordinate of this TuioPoint in pixels relative to the provided screen width + */ + public int getScreenX(int width) { + return (int)Math.round(xpos*width); + } + + /** + * Returns the Y coordinate in pixels relative to the provided screen height. + * + * @param height the screen height + * @return the Y coordinate of this TuioPoint in pixels relative to the provided screen height + */ + public int getScreenY(int height) { + return (int)Math.round(ypos*height); + } + + /** + * Returns the time stamp of this TuioPoint as TuioTime. + * + * @return the time stamp of this TuioPoint as TuioTime + */ + public TuioTime getTuioTime() { + return new TuioTime(currentTime); + } + + /** + * Returns the start time of this TuioPoint as TuioTime. + * + * @return the start time of this TuioPoint as TuioTime + */ + public TuioTime getStartTime() { + return new TuioTime(startTime); + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioString.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioString.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioString.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,189 +1,189 @@ -/* -Added by alexandre.bastien@iri.centrepompidou.fr -*/ - -package TUIO; - -/** - * The TuioCursor class encapsulates /tuio/_siP TUIO strings. - * - */ -public class TuioString { - - /** - * The unique session ID number that is assigned to each TUIO string. - */ - protected long session_id; - - /** - * The individual string ID number that is assigned to each TuioString. - */ - protected int string_id; - - /** - * The individual string message that is assigned to each TuioString. - */ - protected String message; - - /** - * The time stamp of the last update represented as TuioTime (time since session start) - */ - protected TuioTime currentTime; - /** - * The creation time of this TuioString represented as TuioTime (time since session start) - */ - protected TuioTime startTime; - - /** - * Defines the ADDED state. - */ - public static final int TUIO_ADDED = 0; - /** - * Defines the REMOVED state. - */ - public static final int TUIO_REMOVED = 4; - /** - * Reflects the current state of the TuioString - */ - protected int state; - - /** - * This constructor takes a TuioTime argument and assigns it along with the provided - * Session ID, String ID and a message to the newly created TuioString. - * - * @param ttime the TuioTime to assign - * @param si the Session ID to assign - * @param sti the String ID to assign - * @param msg the message to assign - */ - public TuioString (TuioTime ttime, long si, int sti, String msg) { - this.session_id = si; - this.string_id = sti; - this.message = msg; - currentTime = new TuioTime(ttime); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes the provided Session ID, String ID and message - * and assigs these values to the newly created TuioString. - * - * @param si the Session ID to assign - * @param sti the String ID to assign - * @param msg the message to assign - */ - public TuioString (long si, int sti, String msg) { - this.session_id = si; - this.string_id = sti; - this.message = msg; - currentTime = TuioTime.getSessionTime(); - startTime = new TuioTime(currentTime); - } - - /** - * This constructor takes the atttibutes of the provided TuioCursor - * and assigs these values to the newly created TuioCursor. - * - * @param tcur the TuioCursor to assign - */ - public TuioString (TuioString tstr) { - this.session_id = tstr.getSessionID(); - this.string_id = tstr.getStringID(); - this.message = tstr.getMessage(); - currentTime = new TuioTime(tstr.getCurrentTime()); - startTime = new TuioTime(currentTime); - } - - /** - * Takes a TuioTime argument and assigns it along with the provided - * message to the private TuioString attributes. - * The speed and accleration values are calculated accordingly. - * - * @param ttime the TuioTime to assign - * @param message2 the message to assign - */ - public void update(TuioTime ttime, String message2) { - currentTime = new TuioTime(ttime); - message = message2; - } - - /** - * This method is used to update the TuioTime of a TuioString while keeping the same * * * message. - */ - public void stop(TuioTime ttime) { - update(ttime,message); - } - - /** - * Takes the atttibutes of the provided TuioString - * and assigs these values to this TuioString. - * The TuioTime time stamp of this TuioString remains unchanged. - * - * @param tstr the TuioString to assign - */ - public void update (TuioString tstr) { - message = tstr.getMessage(); - } - - /** - * Takes the message provided - * and assigs its value to this TuioString. - * The TuioTime time stamp of this TuioString remains unchanged. - * - * @param msg the message to assign - */ - public void update (String msg) { - message = msg; - } - - /** - * Assigns the REMOVE state to this TuioString and sets - * its TuioTime time stamp to the provided TuioTime argument. - * - * @param ttime the TuioTime to assign - */ - public void remove(TuioTime ttime) { - currentTime = new TuioTime(ttime); - state = TUIO_REMOVED; - } - - /** - * Returns the Session ID of this TuioString. - * @return the Session ID of this TuioString - */ - public long getSessionID() { - return session_id; - } - - /** - * Returns the String ID of this TuioString. - * @return the String ID of this TuioString - */ - public int getStringID() { - return string_id; - } - - /** - * Returns the Message of this TuioString. - * @return the Message of this TuioString - */ - public String getMessage() { - return message; - } - - /** - * Returns the Current Time of this TuioString. - * @return the Current Time of this TuioString - */ - public TuioTime getCurrentTime() { - return currentTime; - } - - /** - * Returns the TUIO state of this TuioString. - * @return the TUIO state of this TuioString - */ - public int getTuioState() { - return state; - } -} +/* +Added by alexandre.bastien@iri.centrepompidou.fr +*/ + +package TUIO; + +/** + * The TuioCursor class encapsulates /tuio/_siP TUIO strings. + * + */ +public class TuioString { + + /** + * The unique session ID number that is assigned to each TUIO string. + */ + protected long session_id; + + /** + * The individual string ID number that is assigned to each TuioString. + */ + protected int string_id; + + /** + * The individual string message that is assigned to each TuioString. + */ + protected String message; + + /** + * The time stamp of the last update represented as TuioTime (time since session start) + */ + protected TuioTime currentTime; + /** + * The creation time of this TuioString represented as TuioTime (time since session start) + */ + protected TuioTime startTime; + + /** + * Defines the ADDED state. + */ + public static final int TUIO_ADDED = 0; + /** + * Defines the REMOVED state. + */ + public static final int TUIO_REMOVED = 4; + /** + * Reflects the current state of the TuioString + */ + protected int state; + + /** + * This constructor takes a TuioTime argument and assigns it along with the provided + * Session ID, String ID and a message to the newly created TuioString. + * + * @param ttime the TuioTime to assign + * @param si the Session ID to assign + * @param sti the String ID to assign + * @param msg the message to assign + */ + public TuioString (TuioTime ttime, long si, int sti, String msg) { + this.session_id = si; + this.string_id = sti; + this.message = msg; + currentTime = new TuioTime(ttime); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes the provided Session ID, String ID and message + * and assigs these values to the newly created TuioString. + * + * @param si the Session ID to assign + * @param sti the String ID to assign + * @param msg the message to assign + */ + public TuioString (long si, int sti, String msg) { + this.session_id = si; + this.string_id = sti; + this.message = msg; + currentTime = TuioTime.getSessionTime(); + startTime = new TuioTime(currentTime); + } + + /** + * This constructor takes the atttibutes of the provided TuioCursor + * and assigs these values to the newly created TuioCursor. + * + * @param tcur the TuioCursor to assign + */ + public TuioString (TuioString tstr) { + this.session_id = tstr.getSessionID(); + this.string_id = tstr.getStringID(); + this.message = tstr.getMessage(); + currentTime = new TuioTime(tstr.getCurrentTime()); + startTime = new TuioTime(currentTime); + } + + /** + * Takes a TuioTime argument and assigns it along with the provided + * message to the private TuioString attributes. + * The speed and accleration values are calculated accordingly. + * + * @param ttime the TuioTime to assign + * @param message2 the message to assign + */ + public void update(TuioTime ttime, String message2) { + currentTime = new TuioTime(ttime); + message = message2; + } + + /** + * This method is used to update the TuioTime of a TuioString while keeping the same * * * message. + */ + public void stop(TuioTime ttime) { + update(ttime,message); + } + + /** + * Takes the atttibutes of the provided TuioString + * and assigs these values to this TuioString. + * The TuioTime time stamp of this TuioString remains unchanged. + * + * @param tstr the TuioString to assign + */ + public void update (TuioString tstr) { + message = tstr.getMessage(); + } + + /** + * Takes the message provided + * and assigs its value to this TuioString. + * The TuioTime time stamp of this TuioString remains unchanged. + * + * @param msg the message to assign + */ + public void update (String msg) { + message = msg; + } + + /** + * Assigns the REMOVE state to this TuioString and sets + * its TuioTime time stamp to the provided TuioTime argument. + * + * @param ttime the TuioTime to assign + */ + public void remove(TuioTime ttime) { + currentTime = new TuioTime(ttime); + state = TUIO_REMOVED; + } + + /** + * Returns the Session ID of this TuioString. + * @return the Session ID of this TuioString + */ + public long getSessionID() { + return session_id; + } + + /** + * Returns the String ID of this TuioString. + * @return the String ID of this TuioString + */ + public int getStringID() { + return string_id; + } + + /** + * Returns the Message of this TuioString. + * @return the Message of this TuioString + */ + public String getMessage() { + return message; + } + + /** + * Returns the Current Time of this TuioString. + * @return the Current Time of this TuioString + */ + public TuioTime getCurrentTime() { + return currentTime; + } + + /** + * Returns the TUIO state of this TuioString. + * @return the TUIO state of this TuioString + */ + public int getTuioState() { + return state; + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java --- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,236 +1,236 @@ -/* - TUIO Java backend - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package TUIO; - -/** - * The TuioTime class is a simple structure that is used to reprent the time that has elapsed since the session start. - * The time is internally represented as seconds and fractions of microseconds which should be more than sufficient for gesture related timing requirements. - * Therefore at the beginning of a typical TUIO session the static method initSession() will set the reference time for the session. - * Another important static method getSessionTime will return a TuioTime object representing the time elapsed since the session start. - * The class also provides various addtional convience method, which allow some simple time arithmetics. - * - * @author Martin Kaltenbrunner - * @version 1.4 - */ -public class TuioTime { - - /** - * the time since session start in seconds - */ - private long seconds = 0; - /** - * time fraction in microseconds - */ - private long micro_seconds = 0; - /** - * the session start time in seconds - */ - private static long start_seconds = 0; - /** - * start time fraction in microseconds - */ - private static long start_micro_seconds = 0; - - /** - * The default constructor takes no arguments and sets - * the Seconds and Microseconds attributes of the newly created TuioTime both to zero. - */ - public TuioTime () { - this.seconds = 0; - this.micro_seconds = 0; - } - - /** - * This constructor takes the provided time represented in total Milliseconds - * and assigs this value to the newly created TuioTime. - * - * @param msec the total time in Millseconds - */ - public TuioTime (long msec) { - this.seconds = msec/1000; - this.micro_seconds = 1000*(msec%1000); - } - - /** - * This constructor takes the provided time represented in Seconds and Microseconds - * and assigs these value to the newly created TuioTime. - * - * @param sec the total time in seconds - * @param usec the microseconds time component - */ - public TuioTime (long sec, long usec) { - this.seconds = sec; - this.micro_seconds = usec; - } - - /** - * This constructor takes the provided TuioTime - * and assigs its Seconds and Microseconds values to the newly created TuioTime. - * - * @param ttime the TuioTime used to copy - */ - public TuioTime (TuioTime ttime) { - this.seconds = ttime.getSeconds(); - this.micro_seconds = ttime.getMicroseconds(); - } - - /** - * Sums the provided time value represented in total Microseconds to this TuioTime. - * - * @param us the total time to add in Microseconds - * @return the sum of this TuioTime with the provided argument in microseconds - */ - public TuioTime add(long us) { - long sec = seconds + us/1000000; - long usec = micro_seconds + us%1000000; - return new TuioTime(sec,usec); - } - - /** - * Sums the provided TuioTime to the private Seconds and Microseconds attributes. - * - * @param ttime the TuioTime to add - * @return the sum of this TuioTime with the provided TuioTime argument - */ - public TuioTime add(TuioTime ttime) { - long sec = seconds + ttime.getSeconds(); - long usec = micro_seconds + ttime.getMicroseconds(); - sec += usec/1000000; - usec = usec%1000000; - return new TuioTime(sec,usec); - } - - /** - * Subtracts the provided time represented in Microseconds from the private Seconds and Microseconds attributes. - * - * @param us the total time to subtract in Microseconds - * @return the subtraction result of this TuioTime minus the provided time in Microseconds - */ - public TuioTime subtract(long us) { - long sec = seconds - us/1000000; - long usec = micro_seconds - us%1000000; - - if (usec<0) { - usec += 1000000; - sec--; - } - - return new TuioTime(sec,usec); - } - - /** - * Subtracts the provided TuioTime from the private Seconds and Microseconds attributes. - * - * @param ttime the TuioTime to subtract - * @return the subtraction result of this TuioTime minus the provided TuioTime - */ - public TuioTime subtract(TuioTime ttime) { - long sec = seconds - ttime.getSeconds(); - long usec = micro_seconds - ttime.getMicroseconds(); - - if (usec<0) { - usec += 1000000; - sec--; - } - - return new TuioTime(sec,usec); - } - - /** - * Takes a TuioTime argument and compares the provided TuioTime to the private Seconds and Microseconds attributes. - * - * @param ttime the TuioTime to compare - * @return true if the two TuioTime have equal Seconds and Microseconds attributes - */ - public boolean equals(TuioTime ttime) { - if ((seconds==ttime.getSeconds()) && (micro_seconds==ttime.getMicroseconds())) return true; - else return false; - } - - /** - * Resets the seconds and micro_seconds attributes to zero. - */ - public void reset() { - seconds = 0; - micro_seconds = 0; - } - - /** - * Returns the TuioTime Seconds component. - * @return the TuioTime Seconds component - */ - public long getSeconds() { - return seconds; - } - - /** - * Returns the TuioTime Microseconds component. - * @return the TuioTime Microseconds component - */ - public long getMicroseconds() { - return micro_seconds; - } - - /** - * Returns the total TuioTime in Milliseconds. - * @return the total TuioTime in Milliseconds - */ - public long getTotalMilliseconds() { - return seconds*1000+micro_seconds/1000; - } - - /** - * This static method globally resets the TUIO session time. - */ - public static void initSession() { - TuioTime startTime = getSystemTime(); - start_seconds = startTime.getSeconds(); - start_micro_seconds = startTime.getMicroseconds(); - } - - /** - * Returns the present TuioTime representing the time since session start. - * @return the present TuioTime representing the time since session start - */ - public static TuioTime getSessionTime() { - TuioTime sessionTime = getSystemTime().subtract(getStartTime()); - return sessionTime; - - } - - /** - * Returns the absolut TuioTime representing the session start. - * @return the absolut TuioTime representing the session start - */ - public static TuioTime getStartTime() { - return new TuioTime(start_seconds,start_micro_seconds); - } - - /** - * Returns the absolut TuioTime representing the current system time. - * @return the absolut TuioTime representing the current system time - */ - public static TuioTime getSystemTime() { - long usec = System.nanoTime()/1000; - return new TuioTime(usec/1000000,usec%1000000); - } -} +/* + TUIO Java backend - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package TUIO; + +/** + * The TuioTime class is a simple structure that is used to reprent the time that has elapsed since the session start. + * The time is internally represented as seconds and fractions of microseconds which should be more than sufficient for gesture related timing requirements. + * Therefore at the beginning of a typical TUIO session the static method initSession() will set the reference time for the session. + * Another important static method getSessionTime will return a TuioTime object representing the time elapsed since the session start. + * The class also provides various addtional convience method, which allow some simple time arithmetics. + * + * @author Martin Kaltenbrunner + * @version 1.4 + */ +public class TuioTime { + + /** + * the time since session start in seconds + */ + private long seconds = 0; + /** + * time fraction in microseconds + */ + private long micro_seconds = 0; + /** + * the session start time in seconds + */ + private static long start_seconds = 0; + /** + * start time fraction in microseconds + */ + private static long start_micro_seconds = 0; + + /** + * The default constructor takes no arguments and sets + * the Seconds and Microseconds attributes of the newly created TuioTime both to zero. + */ + public TuioTime () { + this.seconds = 0; + this.micro_seconds = 0; + } + + /** + * This constructor takes the provided time represented in total Milliseconds + * and assigs this value to the newly created TuioTime. + * + * @param msec the total time in Millseconds + */ + public TuioTime (long msec) { + this.seconds = msec/1000; + this.micro_seconds = 1000*(msec%1000); + } + + /** + * This constructor takes the provided time represented in Seconds and Microseconds + * and assigs these value to the newly created TuioTime. + * + * @param sec the total time in seconds + * @param usec the microseconds time component + */ + public TuioTime (long sec, long usec) { + this.seconds = sec; + this.micro_seconds = usec; + } + + /** + * This constructor takes the provided TuioTime + * and assigs its Seconds and Microseconds values to the newly created TuioTime. + * + * @param ttime the TuioTime used to copy + */ + public TuioTime (TuioTime ttime) { + this.seconds = ttime.getSeconds(); + this.micro_seconds = ttime.getMicroseconds(); + } + + /** + * Sums the provided time value represented in total Microseconds to this TuioTime. + * + * @param us the total time to add in Microseconds + * @return the sum of this TuioTime with the provided argument in microseconds + */ + public TuioTime add(long us) { + long sec = seconds + us/1000000; + long usec = micro_seconds + us%1000000; + return new TuioTime(sec,usec); + } + + /** + * Sums the provided TuioTime to the private Seconds and Microseconds attributes. + * + * @param ttime the TuioTime to add + * @return the sum of this TuioTime with the provided TuioTime argument + */ + public TuioTime add(TuioTime ttime) { + long sec = seconds + ttime.getSeconds(); + long usec = micro_seconds + ttime.getMicroseconds(); + sec += usec/1000000; + usec = usec%1000000; + return new TuioTime(sec,usec); + } + + /** + * Subtracts the provided time represented in Microseconds from the private Seconds and Microseconds attributes. + * + * @param us the total time to subtract in Microseconds + * @return the subtraction result of this TuioTime minus the provided time in Microseconds + */ + public TuioTime subtract(long us) { + long sec = seconds - us/1000000; + long usec = micro_seconds - us%1000000; + + if (usec<0) { + usec += 1000000; + sec--; + } + + return new TuioTime(sec,usec); + } + + /** + * Subtracts the provided TuioTime from the private Seconds and Microseconds attributes. + * + * @param ttime the TuioTime to subtract + * @return the subtraction result of this TuioTime minus the provided TuioTime + */ + public TuioTime subtract(TuioTime ttime) { + long sec = seconds - ttime.getSeconds(); + long usec = micro_seconds - ttime.getMicroseconds(); + + if (usec<0) { + usec += 1000000; + sec--; + } + + return new TuioTime(sec,usec); + } + + /** + * Takes a TuioTime argument and compares the provided TuioTime to the private Seconds and Microseconds attributes. + * + * @param ttime the TuioTime to compare + * @return true if the two TuioTime have equal Seconds and Microseconds attributes + */ + public boolean equals(TuioTime ttime) { + if ((seconds==ttime.getSeconds()) && (micro_seconds==ttime.getMicroseconds())) return true; + else return false; + } + + /** + * Resets the seconds and micro_seconds attributes to zero. + */ + public void reset() { + seconds = 0; + micro_seconds = 0; + } + + /** + * Returns the TuioTime Seconds component. + * @return the TuioTime Seconds component + */ + public long getSeconds() { + return seconds; + } + + /** + * Returns the TuioTime Microseconds component. + * @return the TuioTime Microseconds component + */ + public long getMicroseconds() { + return micro_seconds; + } + + /** + * Returns the total TuioTime in Milliseconds. + * @return the total TuioTime in Milliseconds + */ + public long getTotalMilliseconds() { + return seconds*1000+micro_seconds/1000; + } + + /** + * This static method globally resets the TUIO session time. + */ + public static void initSession() { + TuioTime startTime = getSystemTime(); + start_seconds = startTime.getSeconds(); + start_micro_seconds = startTime.getMicroseconds(); + } + + /** + * Returns the present TuioTime representing the time since session start. + * @return the present TuioTime representing the time since session start + */ + public static TuioTime getSessionTime() { + TuioTime sessionTime = getSystemTime().subtract(getStartTime()); + return sessionTime; + + } + + /** + * Returns the absolut TuioTime representing the session start. + * @return the absolut TuioTime representing the session start + */ + public static TuioTime getStartTime() { + return new TuioTime(start_seconds,start_micro_seconds); + } + + /** + * Returns the absolut TuioTime representing the current system time. + * @return the absolut TuioTime representing the current system time + */ + public static TuioTime getSystemTime() { + long usec = System.nanoTime()/1000; + return new TuioTime(usec/1000000,usec%1000000); + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TuioApplet.java --- a/front_processing/extern/TUIO_JAVA/src/TuioApplet.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TuioApplet.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* TUIO Java Demo - part of the reacTIVision project http://reactivision.sourceforge.net/ diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TuioDemo.java --- a/front_processing/extern/TUIO_JAVA/src/TuioDemo.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TuioDemo.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,143 +1,142 @@ -/* - TUIO Java Demo - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import java.awt.*; -import java.awt.geom.*; -import java.awt.event.*; -import java.awt.image.*; -import java.util.*; -import javax.swing.*; -import TUIO.*; - -public class TuioDemo { - - private final int window_width = 640; - private final int window_height = 480; - - private boolean fullscreen = false; - - private TuioDemoComponent demo; - private JFrame frame; - private GraphicsDevice device; - - public TuioDemo() { - demo = new TuioDemoComponent(); - device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - setupWindow(); - showWindow(); - } - - public TuioListener getTuioListener() { - return demo; - } - - public void setupWindow() { - - frame = new JFrame(); - frame.add(demo); - - frame.setTitle("TuioDemo"); - frame.setResizable(false); - - frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { - System.exit(0); - } }); - - frame.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent evt) { - if (evt.getKeyCode()==KeyEvent.VK_ESCAPE) System.exit(0); - else if (evt.getKeyCode()==KeyEvent.VK_F1) { - destroyWindow(); - setupWindow(); - fullscreen = !fullscreen; - showWindow(); - } - else if (evt.getKeyCode()==KeyEvent.VK_V) demo.verbose=!demo.verbose; - } }); - } - - public void destroyWindow() { - - frame.setVisible(false); - if (fullscreen) { - device.setFullScreenWindow(null); - } - frame = null; - } - - public void showWindow() { - - if (fullscreen) { - int width = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(); - int height = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight(); - demo.setSize(width,height); - - frame.setSize(width,height); - frame.setUndecorated(true); - device.setFullScreenWindow(frame); - } else { - int width = window_width; - int height = window_height; - demo.setSize(width,height); - - frame.pack(); - Insets insets = frame.getInsets(); - frame.setSize(width,height +insets.top); - - } - - frame.setVisible(true); - frame.repaint(); - - } - - public static void main(String argv[]) { - - TuioDemo demo = new TuioDemo(); - TuioClient client = null; - - switch (argv.length) { - case 1: - try { - client = new TuioClient( Integer.parseInt(argv[0])); - } catch (Exception e) { - System.out.println("usage: java TuioDemo [port]"); - System.exit(0); - } - break; - case 0: - client = new TuioClient(80); - break; - default: - System.out.println("usage: java TuioDemo [port]"); - System.exit(0); - break; - } - - if (client!=null) { - client.addTuioListener(demo.getTuioListener()); - client.connect(); - } else { - System.out.println("usage: java TuioDemo [port]"); - System.exit(0); - } - } - -} +/* + TUIO Java Demo - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +import java.awt.*; +import java.awt.geom.*; +import java.awt.event.*; +import java.awt.image.*; +import java.util.*; +import javax.swing.*; +import TUIO.*; + +public class TuioDemo { + private final int window_width = 640; + private final int window_height = 480; + + private boolean fullscreen = false; + + private TuioDemoComponent demo; + private JFrame frame; + private GraphicsDevice device; + + public TuioDemo() { + demo = new TuioDemoComponent(); + device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + setupWindow(); + showWindow(); + } + + public TuioListener getTuioListener() { + return demo; + } + + public void setupWindow() { + + frame = new JFrame(); + frame.add(demo); + + frame.setTitle("TuioDemo"); + frame.setResizable(false); + + frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { + System.exit(0); + } }); + + frame.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent evt) { + if (evt.getKeyCode()==KeyEvent.VK_ESCAPE) System.exit(0); + else if (evt.getKeyCode()==KeyEvent.VK_F1) { + destroyWindow(); + setupWindow(); + fullscreen = !fullscreen; + showWindow(); + } + else if (evt.getKeyCode()==KeyEvent.VK_V) demo.verbose=!demo.verbose; + } }); + } + + public void destroyWindow() { + + frame.setVisible(false); + if (fullscreen) { + device.setFullScreenWindow(null); + } + frame = null; + } + + public void showWindow() { + + if (fullscreen) { + int width = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + int height = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + demo.setSize(width,height); + + frame.setSize(width,height); + frame.setUndecorated(true); + device.setFullScreenWindow(frame); + } else { + int width = window_width; + int height = window_height; + demo.setSize(width,height); + + frame.pack(); + Insets insets = frame.getInsets(); + frame.setSize(width,height +insets.top); + + } + + frame.setVisible(true); + frame.repaint(); + + } + + public static void main(String argv[]) { + + TuioDemo demo = new TuioDemo(); + TuioClient client = null; + + switch (argv.length) { + case 1: + try { + client = new TuioClient( Integer.parseInt(argv[0])); + } catch (Exception e) { + System.out.println("usage: java TuioDemo [port]"); + System.exit(0); + } + break; + case 0: + client = new TuioClient(80); + break; + default: + System.out.println("usage: java TuioDemo [port]"); + System.exit(0); + break; + } + + if (client!=null) { + client.addTuioListener(demo.getTuioListener()); + client.connect(); + } else { + System.out.println("usage: java TuioDemo [port]"); + System.exit(0); + } + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TuioDemoComponent.java --- a/front_processing/extern/TUIO_JAVA/src/TuioDemoComponent.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TuioDemoComponent.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,182 +1,182 @@ -/* - TUIO Java Demo - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import java.awt.*; -import java.awt.geom.*; -import java.awt.event.*; -import java.awt.image.*; -import java.util.*; -import javax.swing.*; -import TUIO.*; - -public class TuioDemoComponent extends JComponent implements TuioListener { - - private Hashtable objectList = new Hashtable(); - private Hashtable cursorList = new Hashtable(); - private Hashtable stringList = new Hashtable(); - - public static final int finger_size = 15; - public static final int object_size = 60; - public static final int table_size = 760; - - public static int width, height; - private float scale = 1.0f; - public boolean verbose = false; - - public void setSize(int w, int h) { - super.setSize(w,h); - width = w; - height = h; - scale = height/(float)TuioDemoComponent.table_size; - } - - public void addTuioObject(TuioObject tobj) { - TuioDemoObject demo = new TuioDemoObject(tobj); - objectList.put(tobj.getSessionID(),demo); - - if (verbose) - System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()); - } - - public void updateTuioObject(TuioObject tobj) { - - TuioDemoObject demo = (TuioDemoObject)objectList.get(tobj.getSessionID()); - demo.update(tobj); - - if (verbose) - System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel()); - } - - public void removeTuioObject(TuioObject tobj) { - objectList.remove(tobj.getSessionID()); - - if (verbose) - System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")"); - } - - public void addTuioCursor(TuioCursor tcur) { - - if (!cursorList.containsKey(tcur.getSessionID())) { - cursorList.put(tcur.getSessionID(), tcur); - repaint(); - } - - if (verbose) - System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()); - } - - public void updateTuioCursor(TuioCursor tcur) { - - repaint(); - - if (verbose) - System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel()); - } - - public void removeTuioCursor(TuioCursor tcur) { - - cursorList.remove(tcur.getSessionID()); - repaint(); - - if (verbose) - System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")"); - } - - public void addTuioString(TuioString tstr) { - - if (!stringList.containsKey(tstr.getSessionID())) { - stringList.put(tstr.getSessionID(), tstr); - repaint(); - } - - if (verbose) - System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); - } - - public void updateTuioString(TuioString tstr) { - - repaint(); - - if (verbose) - System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); - } - - public void removeTuioString(TuioString tstr) { - - stringList.remove(tstr.getSessionID()); - repaint(); - - if (verbose) - System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")"); - } - - public void refresh(TuioTime frameTime) { - repaint(); - } - - public void paint(Graphics g) { - update(g); - } - - public void update(Graphics g) { - - Graphics2D g2 = (Graphics2D)g; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - - g2.setColor(Color.white); - g2.fillRect(0,0,width,height); - - int w = (int)Math.round(width-scale*finger_size/2.0f); - int h = (int)Math.round(height-scale*finger_size/2.0f); - - Enumeration cursors = cursorList.elements(); - while (cursors.hasMoreElements()) { - TuioCursor tcur = cursors.nextElement(); - if (tcur==null) continue; - Vector path = tcur.getPath(); - TuioPoint current_point = path.elementAt(0); - if (current_point!=null) { - // draw the cursor path - g2.setPaint(Color.blue); - for (int i=0;i objects = objectList.elements(); - while (objects.hasMoreElements()) { - TuioDemoObject tobj = objects.nextElement(); - if (tobj!=null) tobj.paint(g2, width,height); - } - } -} +/* + TUIO Java Demo - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +import java.awt.*; +import java.awt.geom.*; +import java.awt.event.*; +import java.awt.image.*; +import java.util.*; +import javax.swing.*; +import TUIO.*; + +public class TuioDemoComponent extends JComponent implements TuioListener { + + private Hashtable objectList = new Hashtable(); + private Hashtable cursorList = new Hashtable(); + private Hashtable stringList = new Hashtable(); + + public static final int finger_size = 15; + public static final int object_size = 60; + public static final int table_size = 760; + + public static int width, height; + private float scale = 1.0f; + public boolean verbose = false; + + public void setSize(int w, int h) { + super.setSize(w,h); + width = w; + height = h; + scale = height/(float)TuioDemoComponent.table_size; + } + + public void addTuioObject(TuioObject tobj) { + TuioDemoObject demo = new TuioDemoObject(tobj); + objectList.put(tobj.getSessionID(),demo); + + if (verbose) + System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()); + } + + public void updateTuioObject(TuioObject tobj) { + + TuioDemoObject demo = (TuioDemoObject)objectList.get(tobj.getSessionID()); + demo.update(tobj); + + if (verbose) + System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel()); + } + + public void removeTuioObject(TuioObject tobj) { + objectList.remove(tobj.getSessionID()); + + if (verbose) + System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")"); + } + + public void addTuioCursor(TuioCursor tcur) { + + if (!cursorList.containsKey(tcur.getSessionID())) { + cursorList.put(tcur.getSessionID(), tcur); + repaint(); + } + + if (verbose) + System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()); + } + + public void updateTuioCursor(TuioCursor tcur) { + + repaint(); + + if (verbose) + System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel()); + } + + public void removeTuioCursor(TuioCursor tcur) { + + cursorList.remove(tcur.getSessionID()); + repaint(); + + if (verbose) + System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")"); + } + + public void addTuioString(TuioString tstr) { + + if (!stringList.containsKey(tstr.getSessionID())) { + stringList.put(tstr.getSessionID(), tstr); + repaint(); + } + + if (verbose) + System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); + } + + public void updateTuioString(TuioString tstr) { + + repaint(); + + if (verbose) + System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); + } + + public void removeTuioString(TuioString tstr) { + + stringList.remove(tstr.getSessionID()); + repaint(); + + if (verbose) + System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")"); + } + + public void refresh(TuioTime frameTime) { + repaint(); + } + + public void paint(Graphics g) { + update(g); + } + + public void update(Graphics g) { + + Graphics2D g2 = (Graphics2D)g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + + g2.setColor(Color.white); + g2.fillRect(0,0,width,height); + + int w = (int)Math.round(width-scale*finger_size/2.0f); + int h = (int)Math.round(height-scale*finger_size/2.0f); + + Enumeration cursors = cursorList.elements(); + while (cursors.hasMoreElements()) { + TuioCursor tcur = cursors.nextElement(); + if (tcur==null) continue; + Vector path = tcur.getPath(); + TuioPoint current_point = path.elementAt(0); + if (current_point!=null) { + // draw the cursor path + g2.setPaint(Color.blue); + for (int i=0;i objects = objectList.elements(); + while (objects.hasMoreElements()) { + TuioDemoObject tobj = objects.nextElement(); + if (tobj!=null) tobj.paint(g2, width,height); + } + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TuioDemoObject.java --- a/front_processing/extern/TUIO_JAVA/src/TuioDemoObject.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TuioDemoObject.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,81 +1,81 @@ -/* - TUIO Java Demo - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import javax.swing.*; -import java.awt.geom.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import TUIO.*; - -public class TuioDemoObject extends TuioObject { - - private Shape square; - - public TuioDemoObject(TuioObject tobj) { - super(tobj); - int size = TuioDemoComponent.object_size; - square = new Rectangle2D.Float(-size/2,-size/2,size,size); - - AffineTransform transform = new AffineTransform(); - transform.translate(xpos,ypos); - transform.rotate(angle,xpos,ypos); - square = transform.createTransformedShape(square); - } - - public void paint(Graphics2D g, int width, int height) { - - float Xpos = xpos*width; - float Ypos = ypos*height; - float scale = height/(float)TuioDemoComponent.table_size; - - AffineTransform trans = new AffineTransform(); - trans.translate(-xpos,-ypos); - trans.translate(Xpos,Ypos); - trans.scale(scale,scale); - Shape s = trans.createTransformedShape(square); - - g.setPaint(Color.black); - g.fill(s); - g.setPaint(Color.white); - g.drawString(symbol_id+"",Xpos-10,Ypos); - } - - public void update(TuioObject tobj) { - - float dx = tobj.getX() - xpos; - float dy = tobj.getY() - ypos; - float da = tobj.getAngle() - angle; - - if ((dx!=0) || (dy!=0)) { - AffineTransform trans = AffineTransform.getTranslateInstance(dx,dy); - square = trans.createTransformedShape(square); - } - - if (da!=0) { - AffineTransform trans = AffineTransform.getRotateInstance(da,tobj.getX(),tobj.getY()); - square = trans.createTransformedShape(square); - } - - super.update(tobj); - } - -} +/* + TUIO Java Demo - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +import javax.swing.*; +import java.awt.geom.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import TUIO.*; + +public class TuioDemoObject extends TuioObject { + + private Shape square; + + public TuioDemoObject(TuioObject tobj) { + super(tobj); + int size = TuioDemoComponent.object_size; + square = new Rectangle2D.Float(-size/2,-size/2,size,size); + + AffineTransform transform = new AffineTransform(); + transform.translate(xpos,ypos); + transform.rotate(angle,xpos,ypos); + square = transform.createTransformedShape(square); + } + + public void paint(Graphics2D g, int width, int height) { + + float Xpos = xpos*width; + float Ypos = ypos*height; + float scale = height/(float)TuioDemoComponent.table_size; + + AffineTransform trans = new AffineTransform(); + trans.translate(-xpos,-ypos); + trans.translate(Xpos,Ypos); + trans.scale(scale,scale); + Shape s = trans.createTransformedShape(square); + + g.setPaint(Color.black); + g.fill(s); + g.setPaint(Color.white); + g.drawString(symbol_id+"",Xpos-10,Ypos); + } + + public void update(TuioObject tobj) { + + float dx = tobj.getX() - xpos; + float dy = tobj.getY() - ypos; + float da = tobj.getAngle() - angle; + + if ((dx!=0) || (dy!=0)) { + AffineTransform trans = AffineTransform.getTranslateInstance(dx,dy); + square = trans.createTransformedShape(square); + } + + if (da!=0) { + AffineTransform trans = AffineTransform.getRotateInstance(da,tobj.getX(),tobj.getY()); + square = trans.createTransformedShape(square); + } + + super.update(tobj); + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/TuioDump.java --- a/front_processing/extern/TUIO_JAVA/src/TuioDump.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/TuioDump.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,86 +1,86 @@ -/* - TUIO Java Example - part of the reacTIVision project - http://reactivision.sourceforge.net/ - - Copyright (c) 2005-2009 Martin Kaltenbrunner - - This program is free software;you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation;either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY;without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program;if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import javax.swing.*; -import java.awt.geom.*; -import java.awt.*; -import java.awt.event.*; -import TUIO.*; - -public class TuioDump implements TuioListener { - - public void addTuioObject(TuioObject tobj) { - System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()); - } - - public void updateTuioObject(TuioObject tobj) { - System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel()); - } - - public void removeTuioObject(TuioObject tobj) { - System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")"); - } - - public void addTuioCursor(TuioCursor tcur) { - System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()); - } - - public void updateTuioCursor(TuioCursor tcur) { - System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel()); - } - - public void removeTuioCursor(TuioCursor tcur) { - System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")"); - } - - public void addTuioString(TuioString tstr) { - System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); - } - - public void updateTuioString(TuioString tstr) { - System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); - } - - public void removeTuioString(TuioString tstr) { - System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")"); - } - - public void refresh(TuioTime frameTime) { - //System.out.println("refresh "+frameTime.getTotalMilliseconds()); - } - - public static void main(String argv[]) { - - int port = 3333; - - if (argv.length==1) { - try { port = Integer.parseInt(argv[0]); } - catch (Exception e) { System.out.println("usage: java TuioDump [port]"); } - } - - TuioDump demo = new TuioDump(); - TuioClient client = new TuioClient(port); - - System.out.println("listening to TUIO messages at port "+port); - client.addTuioListener(demo); - client.connect(); - } -} +/* + TUIO Java Example - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software;you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation;either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY;without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program;if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +import javax.swing.*; +import java.awt.geom.*; +import java.awt.*; +import java.awt.event.*; +import TUIO.*; + +public class TuioDump implements TuioListener { + + public void addTuioObject(TuioObject tobj) { + System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()); + } + + public void updateTuioObject(TuioObject tobj) { + System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel()); + } + + public void removeTuioObject(TuioObject tobj) { + System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")"); + } + + public void addTuioCursor(TuioCursor tcur) { + System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()); + } + + public void updateTuioCursor(TuioCursor tcur) { + System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel()); + } + + public void removeTuioCursor(TuioCursor tcur) { + System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")"); + } + + public void addTuioString(TuioString tstr) { + System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); + } + + public void updateTuioString(TuioString tstr) { + System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage()); + } + + public void removeTuioString(TuioString tstr) { + System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")"); + } + + public void refresh(TuioTime frameTime) { + //System.out.println("refresh "+frameTime.getTotalMilliseconds()); + } + + public static void main(String argv[]) { + + int port = 3333; + + if (argv.length==1) { + try { port = Integer.parseInt(argv[0]); } + catch (Exception e) { System.out.println("usage: java TuioDump [port]"); } + } + + TuioDump demo = new TuioDump(); + TuioClient client = new TuioClient(port); + + System.out.println("listening to TUIO messages at port "+port); + client.addTuioListener(demo); + client.connect(); + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCBundle.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCBundle.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCBundle.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,140 +1,140 @@ - -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OscBundle represents a collection of OscPackets. - * - * Use this when you want to send a bunch of OscPackets - * in one go. - * - * Internally, I use Vector to maintain jdk1.1 compatability - */ - -package com.illposed.osc; -import java.math.BigInteger; -import java.util.Date; -import java.util.Enumeration; -import java.util.GregorianCalendar; -import java.util.Vector; - -import com.illposed.osc.utility.*; - -public class OSCBundle extends OSCPacket { - - protected Date timestamp; - // protected OSCPacket[] packets; - protected Vector packets; - public static final BigInteger SECONDS_FROM_1900_to_1970 = - new BigInteger("2208988800"); - // 17 leap years - - /** - * Create a new OSCBundle, with a timestamp of now. - * You can add packets to the bundle with addPacket() - */ - public OSCBundle() { - this(null, GregorianCalendar.getInstance().getTime()); - } - - /** - * Create an OSCBundle with the specified timestamp - * @param timestamp - */ - public OSCBundle(Date timestamp) { - this(null, timestamp); - } - - /** - * @param newPackets Array of OSCPackets to initialize this object with - */ - public OSCBundle(OSCPacket[] newPackets) { - this(newPackets, GregorianCalendar.getInstance().getTime()); - } - - /** - * @param newPackets OscPacket[] - * @param time java.lang.Time - */ - public OSCBundle(OSCPacket[] newPackets, Date newTimestamp) { - super(); - if (null != newPackets) { - packets = new Vector(newPackets.length); - for (int i = 0; i < newPackets.length; i++) { - packets.add(newPackets[i]); - } - } else - packets = new Vector(); - timestamp = newTimestamp; - init(); - } - - /** - * Return the timestamp for this bundle - * @return a Date - */ - public Date getTimestamp() { - return timestamp; - } - - /** - * Set the timestamp for this bundle - * @param timestamp - */ - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - /** - * Add a packet to the list of packets in this bundle - * @param packet - */ - public void addPacket(OSCPacket packet) { - packets.add(packet); - } - - /** - * Get the packets contained in this bundle - * @return an array of packets - */ - public OSCPacket[] getPackets() { - OSCPacket[] packetArray = new OSCPacket[packets.size()]; - packets.toArray(packetArray); - return packetArray; - } - - protected void computeTimeTagByteArray(OSCJavaToByteArrayConverter stream) { - long millisecs = timestamp.getTime(); - long secsSince1970 = (long) (millisecs / 1000); - long secs = secsSince1970 + SECONDS_FROM_1900_to_1970.longValue(); - long picosecs = (long) (millisecs - (secsSince1970 * 1000)) * 1000; - - stream.write((int) secs); - stream.write((int) picosecs); - - } - - /** - * @param stream OscPacketByteArrayConverter - */ - protected void computeByteArray(OSCJavaToByteArrayConverter stream) { - stream.write("#bundle"); - computeTimeTagByteArray(stream); - Enumeration enm = packets.elements(); - OSCPacket nextElement; - byte[] packetBytes; - while (enm.hasMoreElements()) { - nextElement = (OSCPacket) enm.nextElement(); - packetBytes = nextElement.getByteArray(); - stream.write(packetBytes.length); - stream.write(packetBytes); - } - byteArray = stream.toByteArray(); - } - + +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OscBundle represents a collection of OscPackets. + * + * Use this when you want to send a bunch of OscPackets + * in one go. + * + * Internally, I use Vector to maintain jdk1.1 compatability + */ + +package com.illposed.osc; +import java.math.BigInteger; +import java.util.Date; +import java.util.Enumeration; +import java.util.GregorianCalendar; +import java.util.Vector; + +import com.illposed.osc.utility.*; + +public class OSCBundle extends OSCPacket { + + protected Date timestamp; + // protected OSCPacket[] packets; + protected Vector packets; + public static final BigInteger SECONDS_FROM_1900_to_1970 = + new BigInteger("2208988800"); + // 17 leap years + + /** + * Create a new OSCBundle, with a timestamp of now. + * You can add packets to the bundle with addPacket() + */ + public OSCBundle() { + this(null, GregorianCalendar.getInstance().getTime()); + } + + /** + * Create an OSCBundle with the specified timestamp + * @param timestamp + */ + public OSCBundle(Date timestamp) { + this(null, timestamp); + } + + /** + * @param newPackets Array of OSCPackets to initialize this object with + */ + public OSCBundle(OSCPacket[] newPackets) { + this(newPackets, GregorianCalendar.getInstance().getTime()); + } + + /** + * @param newPackets OscPacket[] + * @param time java.lang.Time + */ + public OSCBundle(OSCPacket[] newPackets, Date newTimestamp) { + super(); + if (null != newPackets) { + packets = new Vector(newPackets.length); + for (int i = 0; i < newPackets.length; i++) { + packets.add(newPackets[i]); + } + } else + packets = new Vector(); + timestamp = newTimestamp; + init(); + } + + /** + * Return the timestamp for this bundle + * @return a Date + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * Set the timestamp for this bundle + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + /** + * Add a packet to the list of packets in this bundle + * @param packet + */ + public void addPacket(OSCPacket packet) { + packets.add(packet); + } + + /** + * Get the packets contained in this bundle + * @return an array of packets + */ + public OSCPacket[] getPackets() { + OSCPacket[] packetArray = new OSCPacket[packets.size()]; + packets.toArray(packetArray); + return packetArray; + } + + protected void computeTimeTagByteArray(OSCJavaToByteArrayConverter stream) { + long millisecs = timestamp.getTime(); + long secsSince1970 = (long) (millisecs / 1000); + long secs = secsSince1970 + SECONDS_FROM_1900_to_1970.longValue(); + long picosecs = (long) (millisecs - (secsSince1970 * 1000)) * 1000; + + stream.write((int) secs); + stream.write((int) picosecs); + + } + + /** + * @param stream OscPacketByteArrayConverter + */ + protected void computeByteArray(OSCJavaToByteArrayConverter stream) { + stream.write("#bundle"); + computeTimeTagByteArray(stream); + Enumeration enm = packets.elements(); + OSCPacket nextElement; + byte[] packetBytes; + while (enm.hasMoreElements()) { + nextElement = (OSCPacket) enm.nextElement(); + packetBytes = nextElement.getByteArray(); + stream.write(packetBytes.length); + stream.write(packetBytes); + } + byteArray = stream.toByteArray(); + } + } \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCCanNotListenException.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCCanNotListenException.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCCanNotListenException.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,49 +1,49 @@ -/* $Id: OSCCanNotListenException.java,v 1.1.1.1 2006/11/13 14:47:21 modin Exp $ - * Created on 21.02.2004 - */ -package com.illposed.osc; - -/** - * @author cramakrishnan - * - * Copyright (C) 2004, C. Ramakrishnan / Auracle - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - */ -public class OSCCanNotListenException extends Exception { - - /** - * - */ - public OSCCanNotListenException() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param message - */ - public OSCCanNotListenException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ -/* public OSCCanNotListenException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } -*/ - /** - * @param cause - */ -/* public OSCCanNotListenException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } -*/ -} +/* $Id: OSCCanNotListenException.java,v 1.1.1.1 2006/11/13 14:47:21 modin Exp $ + * Created on 21.02.2004 + */ +package com.illposed.osc; + +/** + * @author cramakrishnan + * + * Copyright (C) 2004, C. Ramakrishnan / Auracle + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + */ +public class OSCCanNotListenException extends Exception { + + /** + * + */ + public OSCCanNotListenException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param message + */ + public OSCCanNotListenException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ +/* public OSCCanNotListenException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } +*/ + /** + * @param cause + */ +/* public OSCCanNotListenException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } +*/ +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCListener.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCListener.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCListener.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,27 +1,27 @@ -/* $Id: OSCListener.java,v 1.1.1.1 2006/11/13 14:47:21 modin Exp $ - * Created on 28.10.2003 - */ -package com.illposed.osc; - -import java.util.Date; - -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Auracle - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * Interface for things that listen for incoming OSC Messages - */ -public interface OSCListener { - - /** - * Accept an incoming OSCMessage - * @param time the time this message is to be executed. null means execute now - * @param message the message - */ - public void acceptMessage(Date time, OSCMessage message); - -} +/* $Id: OSCListener.java,v 1.1.1.1 2006/11/13 14:47:21 modin Exp $ + * Created on 28.10.2003 + */ +package com.illposed.osc; + +import java.util.Date; + +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Auracle + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * Interface for things that listen for incoming OSC Messages + */ +public interface OSCListener { + + /** + * Accept an incoming OSCMessage + * @param time the time this message is to be executed. null means execute now + * @param message the message + */ + public void acceptMessage(Date time, OSCMessage message); + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCMessage.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCMessage.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCMessage.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,118 +1,118 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * An simple (non-bundle) OSC message. An OSC message is made up of - * an address (who is this message sent to) - * and arguments (what is the contents of this message). - */ - -package com.illposed.osc; - -import java.util.Enumeration; -import java.util.Vector; - -import com.illposed.osc.utility.*; - -public class OSCMessage extends OSCPacket { - - protected String address; - protected Vector arguments; - - /** - * Create an empty OSC Message - * In order to send this osc message, you need to set the address - * and, perhaps, some arguments. - */ - public OSCMessage() { - super(); - arguments = new Vector(); - } - - /** - * Create an OSCMessage with an address already initialized - * @param newAddress The recepient of this OSC message - */ - public OSCMessage(String newAddress) { - this(newAddress, null); - } - - /** - * Create an OSCMessage with an address and arguments already initialized - * @param newAddress The recepient of this OSC message - * @param newArguments The data sent to the receiver - */ - public OSCMessage(String newAddress, Object[] newArguments) { - super(); - address = newAddress; - if (null != newArguments) { - arguments = new Vector(newArguments.length); - for (int i = 0; i < newArguments.length; i++) { - arguments.add(newArguments[i]); - } - } else - arguments = new Vector(); - init(); - } - - /** - * @return the address of this OSC Message - */ - public String getAddress() { - return address; - } - - /** - * Set the address of this messsage - * @param anAddress - */ - public void setAddress(String anAddress) { - address = anAddress; - } - - public void addArgument(Object argument) { - arguments.add(argument); - } - - public Object[] getArguments() { - return arguments.toArray(); - } - - /** - * @param stream OscPacketByteArrayConverter - */ - protected void computeAddressByteArray(OSCJavaToByteArrayConverter stream) { - stream.write(address); - } - - /** - * @param stream OscPacketByteArrayConverter - */ - protected void computeArgumentsByteArray(OSCJavaToByteArrayConverter stream) { - // SC starting at version 2.2.10 wants a comma at the beginning - // of the arguments array. - stream.write(','); - if (null == arguments) - return; - stream.writeTypes(arguments); - Enumeration enm = arguments.elements(); - while (enm.hasMoreElements()) { - stream.write(enm.nextElement()); - } - } - - /** - * @param stream OscPacketByteArrayConverter - */ - protected void computeByteArray(OSCJavaToByteArrayConverter stream) { - computeAddressByteArray(stream); - computeArgumentsByteArray(stream); - byteArray = stream.toByteArray(); - } - +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * An simple (non-bundle) OSC message. An OSC message is made up of + * an address (who is this message sent to) + * and arguments (what is the contents of this message). + */ + +package com.illposed.osc; + +import java.util.Enumeration; +import java.util.Vector; + +import com.illposed.osc.utility.*; + +public class OSCMessage extends OSCPacket { + + protected String address; + protected Vector arguments; + + /** + * Create an empty OSC Message + * In order to send this osc message, you need to set the address + * and, perhaps, some arguments. + */ + public OSCMessage() { + super(); + arguments = new Vector(); + } + + /** + * Create an OSCMessage with an address already initialized + * @param newAddress The recepient of this OSC message + */ + public OSCMessage(String newAddress) { + this(newAddress, null); + } + + /** + * Create an OSCMessage with an address and arguments already initialized + * @param newAddress The recepient of this OSC message + * @param newArguments The data sent to the receiver + */ + public OSCMessage(String newAddress, Object[] newArguments) { + super(); + address = newAddress; + if (null != newArguments) { + arguments = new Vector(newArguments.length); + for (int i = 0; i < newArguments.length; i++) { + arguments.add(newArguments[i]); + } + } else + arguments = new Vector(); + init(); + } + + /** + * @return the address of this OSC Message + */ + public String getAddress() { + return address; + } + + /** + * Set the address of this messsage + * @param anAddress + */ + public void setAddress(String anAddress) { + address = anAddress; + } + + public void addArgument(Object argument) { + arguments.add(argument); + } + + public Object[] getArguments() { + return arguments.toArray(); + } + + /** + * @param stream OscPacketByteArrayConverter + */ + protected void computeAddressByteArray(OSCJavaToByteArrayConverter stream) { + stream.write(address); + } + + /** + * @param stream OscPacketByteArrayConverter + */ + protected void computeArgumentsByteArray(OSCJavaToByteArrayConverter stream) { + // SC starting at version 2.2.10 wants a comma at the beginning + // of the arguments array. + stream.write(','); + if (null == arguments) + return; + stream.writeTypes(arguments); + Enumeration enm = arguments.elements(); + while (enm.hasMoreElements()) { + stream.write(enm.nextElement()); + } + } + + /** + * @param stream OscPacketByteArrayConverter + */ + protected void computeByteArray(OSCJavaToByteArrayConverter stream) { + computeAddressByteArray(stream); + computeArgumentsByteArray(stream); + byteArray = stream.toByteArray(); + } + } \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPacket.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPacket.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPacket.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,60 +1,60 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OscPacket is the abstract superclass for the various - * kinds of OSC Messages. Its direct subclasses are: - * OscMessage, OscBundle - * - * Subclasses need to know how to produce a byte array - * in the format specified by the OSC spec (or SuperCollider - * documentation, as the case may be). - * - * This implementation is based on Markus Gaelli and - * Iannis Zannos' OSC implementation in Squeak: - * http://www.emergent.de/Goodies/ - */ - -package com.illposed.osc; - -import com.illposed.osc.utility.*; - -public abstract class OSCPacket { - - protected byte[] byteArray; - - public OSCPacket() { - super(); - } - - protected void computeByteArray() { - OSCJavaToByteArrayConverter stream = new OSCJavaToByteArrayConverter(); - computeByteArray(stream); - } - - /** - * @param stream OscPacketByteArrayConverter - * - * Subclasses should implement this method to product a byte array - * formatted according to the OSC/SuperCollider specification. - */ - protected abstract void computeByteArray(OSCJavaToByteArrayConverter stream); - - /** - * @return byte[] - */ - public byte[] getByteArray() { - computeByteArray(); - return byteArray; - } - - protected void init() { - - } - +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OscPacket is the abstract superclass for the various + * kinds of OSC Messages. Its direct subclasses are: + * OscMessage, OscBundle + * + * Subclasses need to know how to produce a byte array + * in the format specified by the OSC spec (or SuperCollider + * documentation, as the case may be). + * + * This implementation is based on Markus Gaelli and + * Iannis Zannos' OSC implementation in Squeak: + * http://www.emergent.de/Goodies/ + */ + +package com.illposed.osc; + +import com.illposed.osc.utility.*; + +public abstract class OSCPacket { + + protected byte[] byteArray; + + public OSCPacket() { + super(); + } + + protected void computeByteArray() { + OSCJavaToByteArrayConverter stream = new OSCJavaToByteArrayConverter(); + computeByteArray(stream); + } + + /** + * @param stream OscPacketByteArrayConverter + * + * Subclasses should implement this method to product a byte array + * formatted according to the OSC/SuperCollider specification. + */ + protected abstract void computeByteArray(OSCJavaToByteArrayConverter stream); + + /** + * @return byte[] + */ + public byte[] getByteArray() { + computeByteArray(); + return byteArray; + } + + protected void init() { + + } + } \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPort.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPort.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPort.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,51 +1,51 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2004, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OSCPort is an abstract superclass. To send OSC messages, use OSCPortOut. - * To listen for OSC messages, use OSCPortIn. - * - */ - -package com.illposed.osc; - -import java.net.*; -import java.io.IOException; - -public abstract class OSCPort { - - protected DatagramSocket socket; - protected int port; - - /** - * The port that the SuperCollider synth engine ususally listens too - */ - public static final int defaultSCOSCPort = 57110; - - /** - * The port that the SuperCollider language engine ususally listens too - */ - public static final int defaultSCLangOSCPort = 57120; - - /** - * @see java.lang.Object#finalize() - */ - protected void finalize() throws Throwable { - super.finalize(); - socket.close(); - } - - /** - * Close the socket and free-up resources. It's recommended that clients call - * this when they are done with the port. - */ - public void close() { - socket.close(); - } - -} +/** + * @author cramakrishnan + * + * Copyright (C) 2004, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OSCPort is an abstract superclass. To send OSC messages, use OSCPortOut. + * To listen for OSC messages, use OSCPortIn. + * + */ + +package com.illposed.osc; + +import java.net.*; +import java.io.IOException; + +public abstract class OSCPort { + + protected DatagramSocket socket; + protected int port; + + /** + * The port that the SuperCollider synth engine ususally listens too + */ + public static final int defaultSCOSCPort = 57110; + + /** + * The port that the SuperCollider language engine ususally listens too + */ + public static final int defaultSCLangOSCPort = 57120; + + /** + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + super.finalize(); + socket.close(); + } + + /** + * Close the socket and free-up resources. It's recommended that clients call + * this when they are done with the port. + */ + public void close() { + socket.close(); + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortIn.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortIn.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortIn.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,114 +1,114 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2004, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OSCPortIn is the class that listens for OSC messages. - * - * To receive OSC, you need to construct the OSCPort with a - * - * An example based on com.illposed.osc.test.OSCPortTest::testReceiving() : - - receiver = new OSCPort(OSCPort.defaultSCOSCPort()); - OSCListener listener = new OSCListener() { - public void acceptMessage(java.util.Date time, OSCMessage message) { - System.out.println("Message received!"); - } - }; - receiver.addListener("/message/receiving", listener); - receiver.startListening(); - - * Then, using a program such as SuperCollider or sendOSC, send a message - * to this computer, port 57110 (defaultSCOSCPort), with the address /message/receiving - */ - -package com.illposed.osc; - -import java.net.*; -import java.io.IOException; -import com.illposed.osc.utility.OSCByteArrayToJavaConverter; -import com.illposed.osc.utility.OSCPacketDispatcher; - -public class OSCPortIn extends OSCPort implements Runnable { - - // state for listening - protected boolean isListening; - protected OSCByteArrayToJavaConverter converter = new OSCByteArrayToJavaConverter(); - protected OSCPacketDispatcher dispatcher = new OSCPacketDispatcher(); - - /** - * Create an OSCPort that listens on port - * @param port - * @throws SocketException - */ - public OSCPortIn(int port) throws SocketException { - socket = new DatagramSocket(port); - this.port = port; - } - - /** - * @see java.lang.Runnable#run() - */ - public void run() { - //maximum UDP packet size - byte[] buffer = new byte[65536]; - DatagramPacket packet = new DatagramPacket(buffer, 65536); - while (isListening) { - try { - packet.setLength(65536); - socket.receive(packet); - OSCPacket oscPacket = converter.convert(buffer, packet.getLength()); - dispatcher.dispatchPacket(oscPacket); - } catch (java.net.SocketException e) { - if (isListening) e.printStackTrace(); - } catch (IOException e) { - if (isListening) e.printStackTrace(); - } - } - } - - /** - * Start listening for incoming OSCPackets - */ - public void startListening() { - isListening = true; - Thread thread = new Thread(this); - thread.start(); - } - - /** - * Stop listening for incoming OSCPackets - */ - public void stopListening() { - isListening = false; - } - - /** - * Am I listening for packets? - */ - public boolean isListening() { - return isListening; - } - - /** - * Register the listener for incoming OSCPackets addressed to an Address - * @param anAddress the address to listen for - * @param listener the object to invoke when a message comes in - */ - public void addListener(String anAddress, OSCListener listener) { - dispatcher.addListener(anAddress, listener); - } - - /** - * Close the socket and free-up resources. It's recommended that clients call - * this when they are done with the port. - */ - public void close() { - socket.close(); - } - -} +/** + * @author cramakrishnan + * + * Copyright (C) 2004, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OSCPortIn is the class that listens for OSC messages. + * + * To receive OSC, you need to construct the OSCPort with a + * + * An example based on com.illposed.osc.test.OSCPortTest::testReceiving() : + + receiver = new OSCPort(OSCPort.defaultSCOSCPort()); + OSCListener listener = new OSCListener() { + public void acceptMessage(java.util.Date time, OSCMessage message) { + System.out.println("Message received!"); + } + }; + receiver.addListener("/message/receiving", listener); + receiver.startListening(); + + * Then, using a program such as SuperCollider or sendOSC, send a message + * to this computer, port 57110 (defaultSCOSCPort), with the address /message/receiving + */ + +package com.illposed.osc; + +import java.net.*; +import java.io.IOException; +import com.illposed.osc.utility.OSCByteArrayToJavaConverter; +import com.illposed.osc.utility.OSCPacketDispatcher; + +public class OSCPortIn extends OSCPort implements Runnable { + + // state for listening + protected boolean isListening; + protected OSCByteArrayToJavaConverter converter = new OSCByteArrayToJavaConverter(); + protected OSCPacketDispatcher dispatcher = new OSCPacketDispatcher(); + + /** + * Create an OSCPort that listens on port + * @param port + * @throws SocketException + */ + public OSCPortIn(int port) throws SocketException { + socket = new DatagramSocket(port); + this.port = port; + } + + /** + * @see java.lang.Runnable#run() + */ + public void run() { + //maximum UDP packet size + byte[] buffer = new byte[65536]; + DatagramPacket packet = new DatagramPacket(buffer, 65536); + while (isListening) { + try { + packet.setLength(65536); + socket.receive(packet); + OSCPacket oscPacket = converter.convert(buffer, packet.getLength()); + dispatcher.dispatchPacket(oscPacket); + } catch (java.net.SocketException e) { + if (isListening) e.printStackTrace(); + } catch (IOException e) { + if (isListening) e.printStackTrace(); + } + } + } + + /** + * Start listening for incoming OSCPackets + */ + public void startListening() { + isListening = true; + Thread thread = new Thread(this); + thread.start(); + } + + /** + * Stop listening for incoming OSCPackets + */ + public void stopListening() { + isListening = false; + } + + /** + * Am I listening for packets? + */ + public boolean isListening() { + return isListening; + } + + /** + * Register the listener for incoming OSCPackets addressed to an Address + * @param anAddress the address to listen for + * @param listener the object to invoke when a message comes in + */ + public void addListener(String anAddress, OSCListener listener) { + dispatcher.addListener(anAddress, listener); + } + + /** + * Close the socket and free-up resources. It's recommended that clients call + * this when they are done with the port. + */ + public void close() { + socket.close(); + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortOut.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortOut.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/OSCPortOut.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,79 +1,79 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2004, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OSCPortOut is the class that sends OSC messages. - * - * To send OSC, in your code you should instantiate and hold onto an OSCPort - * pointing at the address and port number for the receiver. - * - * When you want to send an OSC message, call send(). - * - * An example based on com.illposed.osc.test.OSCPortTest::testMessageWithArgs() : - OSCPort sender = new OSCPort(); - Object args[] = new Object[2]; - args[0] = new Integer(3); - args[1] = "hello"; - OSCMessage msg = new OSCMessage("/sayhello", args); - try { - sender.send(msg); - } catch (Exception e) { - showError("Couldn't send"); - } - */ - -package com.illposed.osc; - -import java.net.*; -import java.io.IOException; -import com.illposed.osc.utility.OSCByteArrayToJavaConverter; - -public class OSCPortOut extends OSCPort { - - protected InetAddress address; - - /** - * Create an OSCPort that sends to newAddress, newPort - * @param newAddress InetAddress - * @param newPort int - */ - public OSCPortOut(InetAddress newAddress, int newPort) throws SocketException { - socket = new DatagramSocket(); - address = newAddress; - port = newPort; - } - - /** - * Create an OSCPort that sends to newAddress, on the standard SuperCollider port - * @param newAddress InetAddress - * - * Default the port to the standard one for SuperCollider - */ - public OSCPortOut(InetAddress newAddress) throws SocketException { - this(newAddress, defaultSCOSCPort); - } - - /** - * Create an OSCPort that sends to localhost, on the standard SuperCollider port - * Default the address to localhost - * Default the port to the standard one for SuperCollider - */ - public OSCPortOut() throws UnknownHostException, SocketException { - this(InetAddress.getLocalHost(), defaultSCOSCPort); - } - - /** - * @param aPacket OSCPacket - */ - public void send(OSCPacket aPacket) throws IOException { - byte[] byteArray = aPacket.getByteArray(); - DatagramPacket packet = - new DatagramPacket(byteArray, byteArray.length,address,port); - socket.send(packet); - } -} +/** + * @author cramakrishnan + * + * Copyright (C) 2004, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OSCPortOut is the class that sends OSC messages. + * + * To send OSC, in your code you should instantiate and hold onto an OSCPort + * pointing at the address and port number for the receiver. + * + * When you want to send an OSC message, call send(). + * + * An example based on com.illposed.osc.test.OSCPortTest::testMessageWithArgs() : + OSCPort sender = new OSCPort(); + Object args[] = new Object[2]; + args[0] = new Integer(3); + args[1] = "hello"; + OSCMessage msg = new OSCMessage("/sayhello", args); + try { + sender.send(msg); + } catch (Exception e) { + showError("Couldn't send"); + } + */ + +package com.illposed.osc; + +import java.net.*; +import java.io.IOException; +import com.illposed.osc.utility.OSCByteArrayToJavaConverter; + +public class OSCPortOut extends OSCPort { + + protected InetAddress address; + + /** + * Create an OSCPort that sends to newAddress, newPort + * @param newAddress InetAddress + * @param newPort int + */ + public OSCPortOut(InetAddress newAddress, int newPort) throws SocketException { + socket = new DatagramSocket(); + address = newAddress; + port = newPort; + } + + /** + * Create an OSCPort that sends to newAddress, on the standard SuperCollider port + * @param newAddress InetAddress + * + * Default the port to the standard one for SuperCollider + */ + public OSCPortOut(InetAddress newAddress) throws SocketException { + this(newAddress, defaultSCOSCPort); + } + + /** + * Create an OSCPort that sends to localhost, on the standard SuperCollider port + * Default the address to localhost + * Default the port to the standard one for SuperCollider + */ + public OSCPortOut() throws UnknownHostException, SocketException { + this(InetAddress.getLocalHost(), defaultSCOSCPort); + } + + /** + * @param aPacket OSCPacket + */ + public void send(OSCPacket aPacket) throws IOException { + byte[] byteArray = aPacket.getByteArray(); + DatagramPacket packet = + new DatagramPacket(byteArray, byteArray.length,address,port); + socket.send(packet); + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCByteArrayToJavaConverter.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCByteArrayToJavaConverter.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCByteArrayToJavaConverter.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,280 +1,280 @@ -/* $Id: OSCByteArrayToJavaConverter.java,v 1.1.1.1 2006/11/13 14:47:22 modin Exp $ - * Created on 28.10.2003 - */ -package com.illposed.osc.utility; - -import java.math.BigInteger; -import java.util.Date; - -import com.illposed.osc.*; - -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Auracle - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - */ -public class OSCByteArrayToJavaConverter { - - byte[] bytes; - int bytesLength; - int streamPosition; - - private byte[] intBytes = new byte[4]; - private byte[] floatBytes = new byte[4]; - - private byte[] secondBytes = new byte[8]; - private byte[] picosecBytes = new byte[8]; - - /** - * Helper object for converting from a byte array to Java objects - */ - /*public OSCByteArrayToJavaConverter() { - super(); - }*/ - - public OSCPacket convert(byte[] byteArray, int bytesLength) { - bytes = byteArray; - this.bytesLength = bytesLength; - streamPosition = 0; - if (isBundle()) - return convertBundle(); - else - return convertMessage(); - } - - private boolean isBundle() { - // only need the first 7 to check if it is a bundle - String bytesAsString = new String(bytes, 0, 7); - return bytesAsString.startsWith("#bundle"); - } - - private OSCBundle convertBundle() { - // skip the "#bundle " stuff - streamPosition = 8; - Date timestamp = readTimeTag(); - OSCBundle bundle = new OSCBundle(timestamp); - OSCByteArrayToJavaConverter myConverter = new OSCByteArrayToJavaConverter(); - while (streamPosition < bytesLength) { - // recursively read through the stream and convert packets you find - int packetLength = ((Integer) readInteger()).intValue(); - byte[] packetBytes = new byte[packetLength]; - //streamPosition++; - System.arraycopy(bytes,streamPosition,packetBytes,0,packetLength); - streamPosition+=packetLength; - //for (int i = 0; i < packetLength; i++) - // packetBytes[i] = bytes[streamPosition++]; - OSCPacket packet = myConverter.convert(packetBytes, packetLength); - bundle.addPacket(packet); - } - return bundle; - } - - private OSCMessage convertMessage() { - OSCMessage message = new OSCMessage(); - message.setAddress(readString()); - char[] types = readTypes(); - if (null == types) { - // we are done - return message; - } - moveToFourByteBoundry(); - for (int i = 0; i < types.length; i++) { - if ('[' == types[i]) { - // we're looking at an array -- read it in - message.addArgument(readArray(types, i)); - // then increment i to the end of the array - while (']' != types[i]) - i++; - } else - message.addArgument(readArgument(types[i])); - } - return message; - } - - private String readString() { - int strLen = lengthOfCurrentString(); - char[] stringChars = new char[strLen]; - //System.arraycopy(bytes,streamPosition,stringChars,0,strLen); - //streamPosition+=strLen; - for (int i = 0; i < strLen; i++) - stringChars[i] = (char) bytes[streamPosition++]; - moveToFourByteBoundry(); - return new String(stringChars); - } - - /** - * @return a char array with the types of the arguments - */ - private char[] readTypes() { - // the next byte should be a "," - if (bytes[streamPosition] != 0x2C) - return null; - streamPosition++; - // find out how long the list of types is - int typesLen = lengthOfCurrentString(); - if (0 == typesLen) { - return null; - } - // read in the types - char[] typesChars = new char[typesLen]; - for (int i = 0; i < typesLen; i++) { - typesChars[i] = (char) bytes[streamPosition++]; - } - return typesChars; - } - - /** - * @param c type of argument - * @return a Java representation of the argument - */ - private Object readArgument(char c) { - switch (c) { - case 'i' : - return readInteger(); - case 'h' : - return readBigInteger(); - case 'f' : - return readFloat(); - case 'd' : - return readDouble(); - case 's' : - return readString(); - case 'c' : - return readChar(); - case 'T' : - return Boolean.TRUE; - case 'F' : - return Boolean.FALSE; - } - - return null; - } - - /** - * @return a Character - */ - private Object readChar() { - return new Character((char) bytes[streamPosition++]); - } - - /** - * @return a Double - */ - private Object readDouble() { - return readFloat(); - } - - /** - * @return a Float - */ - private Object readFloat() { - //byte[] floatBytes = new byte[4]; - floatBytes[0] = bytes[streamPosition++]; - floatBytes[1] = bytes[streamPosition++]; - floatBytes[2] = bytes[streamPosition++]; - floatBytes[3] = bytes[streamPosition++]; - - int floatBits = - ((floatBytes[3] & 0xFF) ) + - ((floatBytes[2] & 0xFF) << 8) + - ((floatBytes[1] & 0xFF) << 16) + - ((floatBytes[0] & 0xFF) << 24); - - return new Float(Float.intBitsToFloat(floatBits)); - } - - /** - * @return a BigInteger - */ - private Object readBigInteger() { - //byte[] intBytes = new byte[4]; - intBytes[0] = bytes[streamPosition++]; - intBytes[1] = bytes[streamPosition++]; - intBytes[2] = bytes[streamPosition++]; - intBytes[3] = bytes[streamPosition++]; - - int intBits = - ((intBytes[3] & 0xFF) ) + - ((intBytes[2] & 0xFF) << 8) + - ((intBytes[1] & 0xFF) << 16) + - ((intBytes[0] & 0xFF) << 24); - - return new Integer(intBits); - } - - /** - * @return an Integer - */ - private Object readInteger() { - //byte[] intBytes = new byte[4]; - intBytes[0] = bytes[streamPosition++]; - intBytes[1] = bytes[streamPosition++]; - intBytes[2] = bytes[streamPosition++]; - intBytes[3] = bytes[streamPosition++]; - - int intBits = - ((intBytes[3] & 0xFF) ) + - ((intBytes[2] & 0xFF) << 8) + - ((intBytes[1] & 0xFF) << 16) + - ((intBytes[0] & 0xFF) << 24); - - return new Integer(intBits); - } - - /** - * @return a Date - */ - private Date readTimeTag() { - //byte[] secondBytes = new byte[8]; - //byte[] picosecBytes = new byte[8]; - /*for (int i = 4; i < 8; i++) - secondBytes[i] = bytes[streamPosition++]; - for (int i = 4; i < 8; i++) - picosecBytes[i] = bytes[streamPosition++];*/ - System.arraycopy(bytes,streamPosition,secondBytes,4,4); - streamPosition+=4; - System.arraycopy(bytes,streamPosition,picosecBytes,4,4); - streamPosition+=4; - - BigInteger secsSince1900 = new BigInteger(secondBytes); - long secsSince1970 = secsSince1900.longValue() - OSCBundle.SECONDS_FROM_1900_to_1970.longValue(); - if (secsSince1970 < 0) secsSince1970 = 0; // no point maintaining times in the distant past - BigInteger picosecs = new BigInteger(picosecBytes); - long millisecs = (secsSince1970 * 1000) + (picosecs.longValue() / 1000); - return new Date(millisecs); - } - - /** - * @param types - * @param i - * @return an Array - */ - private Object[] readArray(char[] types, int i) { - int arrayLen = 0; - while (types[i + arrayLen] != ']') - arrayLen++; - Object[] array = new Object[arrayLen]; - for (int j = 0; i < arrayLen; j++) { - array[j] = readArgument(types[i + j]); - } - return array; - } - - private int lengthOfCurrentString() { - int i = 0; - while (bytes[streamPosition + i] != 0) - i++; - return i; - } - - private void moveToFourByteBoundry() { - // If i'm already at a 4 byte boundry, I need to move to the next one - int mod = streamPosition % 4; - streamPosition += (4 - mod); - } - -} - +/* $Id: OSCByteArrayToJavaConverter.java,v 1.1.1.1 2006/11/13 14:47:22 modin Exp $ + * Created on 28.10.2003 + */ +package com.illposed.osc.utility; + +import java.math.BigInteger; +import java.util.Date; + +import com.illposed.osc.*; + +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Auracle + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + */ +public class OSCByteArrayToJavaConverter { + + byte[] bytes; + int bytesLength; + int streamPosition; + + private byte[] intBytes = new byte[4]; + private byte[] floatBytes = new byte[4]; + + private byte[] secondBytes = new byte[8]; + private byte[] picosecBytes = new byte[8]; + + /** + * Helper object for converting from a byte array to Java objects + */ + /*public OSCByteArrayToJavaConverter() { + super(); + }*/ + + public OSCPacket convert(byte[] byteArray, int bytesLength) { + bytes = byteArray; + this.bytesLength = bytesLength; + streamPosition = 0; + if (isBundle()) + return convertBundle(); + else + return convertMessage(); + } + + private boolean isBundle() { + // only need the first 7 to check if it is a bundle + String bytesAsString = new String(bytes, 0, 7); + return bytesAsString.startsWith("#bundle"); + } + + private OSCBundle convertBundle() { + // skip the "#bundle " stuff + streamPosition = 8; + Date timestamp = readTimeTag(); + OSCBundle bundle = new OSCBundle(timestamp); + OSCByteArrayToJavaConverter myConverter = new OSCByteArrayToJavaConverter(); + while (streamPosition < bytesLength) { + // recursively read through the stream and convert packets you find + int packetLength = ((Integer) readInteger()).intValue(); + byte[] packetBytes = new byte[packetLength]; + //streamPosition++; + System.arraycopy(bytes,streamPosition,packetBytes,0,packetLength); + streamPosition+=packetLength; + //for (int i = 0; i < packetLength; i++) + // packetBytes[i] = bytes[streamPosition++]; + OSCPacket packet = myConverter.convert(packetBytes, packetLength); + bundle.addPacket(packet); + } + return bundle; + } + + private OSCMessage convertMessage() { + OSCMessage message = new OSCMessage(); + message.setAddress(readString()); + char[] types = readTypes(); + if (null == types) { + // we are done + return message; + } + moveToFourByteBoundry(); + for (int i = 0; i < types.length; i++) { + if ('[' == types[i]) { + // we're looking at an array -- read it in + message.addArgument(readArray(types, i)); + // then increment i to the end of the array + while (']' != types[i]) + i++; + } else + message.addArgument(readArgument(types[i])); + } + return message; + } + + private String readString() { + int strLen = lengthOfCurrentString(); + char[] stringChars = new char[strLen]; + //System.arraycopy(bytes,streamPosition,stringChars,0,strLen); + //streamPosition+=strLen; + for (int i = 0; i < strLen; i++) + stringChars[i] = (char) bytes[streamPosition++]; + moveToFourByteBoundry(); + return new String(stringChars); + } + + /** + * @return a char array with the types of the arguments + */ + private char[] readTypes() { + // the next byte should be a "," + if (bytes[streamPosition] != 0x2C) + return null; + streamPosition++; + // find out how long the list of types is + int typesLen = lengthOfCurrentString(); + if (0 == typesLen) { + return null; + } + // read in the types + char[] typesChars = new char[typesLen]; + for (int i = 0; i < typesLen; i++) { + typesChars[i] = (char) bytes[streamPosition++]; + } + return typesChars; + } + + /** + * @param c type of argument + * @return a Java representation of the argument + */ + private Object readArgument(char c) { + switch (c) { + case 'i' : + return readInteger(); + case 'h' : + return readBigInteger(); + case 'f' : + return readFloat(); + case 'd' : + return readDouble(); + case 's' : + return readString(); + case 'c' : + return readChar(); + case 'T' : + return Boolean.TRUE; + case 'F' : + return Boolean.FALSE; + } + + return null; + } + + /** + * @return a Character + */ + private Object readChar() { + return new Character((char) bytes[streamPosition++]); + } + + /** + * @return a Double + */ + private Object readDouble() { + return readFloat(); + } + + /** + * @return a Float + */ + private Object readFloat() { + //byte[] floatBytes = new byte[4]; + floatBytes[0] = bytes[streamPosition++]; + floatBytes[1] = bytes[streamPosition++]; + floatBytes[2] = bytes[streamPosition++]; + floatBytes[3] = bytes[streamPosition++]; + + int floatBits = + ((floatBytes[3] & 0xFF) ) + + ((floatBytes[2] & 0xFF) << 8) + + ((floatBytes[1] & 0xFF) << 16) + + ((floatBytes[0] & 0xFF) << 24); + + return new Float(Float.intBitsToFloat(floatBits)); + } + + /** + * @return a BigInteger + */ + private Object readBigInteger() { + //byte[] intBytes = new byte[4]; + intBytes[0] = bytes[streamPosition++]; + intBytes[1] = bytes[streamPosition++]; + intBytes[2] = bytes[streamPosition++]; + intBytes[3] = bytes[streamPosition++]; + + int intBits = + ((intBytes[3] & 0xFF) ) + + ((intBytes[2] & 0xFF) << 8) + + ((intBytes[1] & 0xFF) << 16) + + ((intBytes[0] & 0xFF) << 24); + + return new Integer(intBits); + } + + /** + * @return an Integer + */ + private Object readInteger() { + //byte[] intBytes = new byte[4]; + intBytes[0] = bytes[streamPosition++]; + intBytes[1] = bytes[streamPosition++]; + intBytes[2] = bytes[streamPosition++]; + intBytes[3] = bytes[streamPosition++]; + + int intBits = + ((intBytes[3] & 0xFF) ) + + ((intBytes[2] & 0xFF) << 8) + + ((intBytes[1] & 0xFF) << 16) + + ((intBytes[0] & 0xFF) << 24); + + return new Integer(intBits); + } + + /** + * @return a Date + */ + private Date readTimeTag() { + //byte[] secondBytes = new byte[8]; + //byte[] picosecBytes = new byte[8]; + /*for (int i = 4; i < 8; i++) + secondBytes[i] = bytes[streamPosition++]; + for (int i = 4; i < 8; i++) + picosecBytes[i] = bytes[streamPosition++];*/ + System.arraycopy(bytes,streamPosition,secondBytes,4,4); + streamPosition+=4; + System.arraycopy(bytes,streamPosition,picosecBytes,4,4); + streamPosition+=4; + + BigInteger secsSince1900 = new BigInteger(secondBytes); + long secsSince1970 = secsSince1900.longValue() - OSCBundle.SECONDS_FROM_1900_to_1970.longValue(); + if (secsSince1970 < 0) secsSince1970 = 0; // no point maintaining times in the distant past + BigInteger picosecs = new BigInteger(picosecBytes); + long millisecs = (secsSince1970 * 1000) + (picosecs.longValue() / 1000); + return new Date(millisecs); + } + + /** + * @param types + * @param i + * @return an Array + */ + private Object[] readArray(char[] types, int i) { + int arrayLen = 0; + while (types[i + arrayLen] != ']') + arrayLen++; + Object[] array = new Object[arrayLen]; + for (int j = 0; i < arrayLen; j++) { + array[j] = readArgument(types[i + j]); + } + return array; + } + + private int lengthOfCurrentString() { + int i = 0; + while (bytes[streamPosition + i] != 0) + i++; + return i; + } + + private void moveToFourByteBoundry() { + // If i'm already at a 4 byte boundry, I need to move to the next one + int mod = streamPosition % 4; + streamPosition += (4 - mod); + } + +} + diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCJavaToByteArrayConverter.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCJavaToByteArrayConverter.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCJavaToByteArrayConverter.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,310 +1,310 @@ -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Illposed Software - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * - * OSCJavaToByteArrayConverter is a helper class that translates - * from Java types to the format the OSC spec specifies for those - * types. - * - * This implementation is based on Markus Gaelli and - * Iannis Zannos' OSC implementation in Squeak: - * http://www.emergent.de/Goodies/ - */ - -package com.illposed.osc.utility; - -import java.io.IOException; -import java.io.ByteArrayOutputStream; -import java.math.BigInteger; -import java.util.Enumeration; -import java.util.Vector; - - -public class OSCJavaToByteArrayConverter { - - protected ByteArrayOutputStream stream = new ByteArrayOutputStream(); - private byte[] intBytes = new byte[4]; - - /*public OSCJavaToByteArrayConverter() { - super(); - }*/ - - /** - * Creation date: (2/23/2001 2:43:25 AM) - * @param anArray java.lang.Object[] - * - */ - public void appendNullCharToAlignStream() { - int mod = stream.size() % 4; - int pad = 4 - mod; - for (int i = 0; i < pad; i++) - stream.write(0); - } - - /** - * Creation date: (2/23/2001 2:21:53 AM) - * @return byte[] - */ - public byte[] toByteArray() { - return stream.toByteArray(); - } - - /** - * Creation date: (2/23/2001 2:14:23 AM) - * @param bytes byte[] - */ - public void write(byte[] bytes) { - writeBigEndToFourByteBoundry(bytes); - } - - /** - * Creation date: (2/23/2001 2:21:04 AM) - * @param i int - */ - public void write(int i) { - writeIntegerToByteArray(i); - } - - /** - * Creation date: (2/23/2001 2:03:57 AM) - * @param f java.lang.Float - */ - public void write(Float f) { - writeIntegerToByteArray(Float.floatToIntBits(f.floatValue())); - } - - /** - * Creation date: (2/23/2001 2:08:36 AM) - * @param i java.lang.Integer - */ - public void write(Integer i) { - writeIntegerToByteArray(i.intValue()); - } - - /** - * Creation date: (2/23/2001 1:57:35 AM) - * @param str java.lang.String - */ - public void write(String str) { - writeLittleEndToFourByteBoundry(str.getBytes()); - } - - /** - * Creation date: (2/23/2001 2:08:36 AM) - * @param c char - */ - public void write(char c) { - stream.write(c); - } - - /** - * Creation date: (2/23/2001 2:02:54 AM) - * @param anObject java.lang.Object - */ - public void write(Object anObject) { - // Can't do switch on class - if (null == anObject) - return; - if (anObject instanceof Float) { - write((Float) anObject); - return; - } - if (anObject instanceof String) { - write((String) anObject); - return; - } - if (anObject instanceof Integer) { - write((Integer) anObject); - return; - } - } - - /** - * Creation date: (2/23/2001 2:43:25 AM) - * @param aClass Class - */ - public void writeType(Class c) { - // A big ol' case statement -- what's polymorphism mean, again? - // I really wish I could extend the base classes! - - // use the appropriate flags to tell SuperCollider what kind of - // thing it is looking at - - if (Integer.class.equals(c)) { - stream.write('i'); - return; - } - if (java.math.BigInteger.class.equals(c)) { - stream.write('h'); - return; - } - if (Float.class.equals(c)) { - stream.write('f'); - return; - } - if (Double.class.equals(c)) { - stream.write('d'); - return; - } - if (String.class.equals(c)) { - stream.write('s'); - return; - } - if (Character.class.equals(c)) { - stream.write('c'); - return; - } - } - - /** - * Creation date: (2/23/2001 2:43:25 AM) - * @param anArray java.lang.Object[] - */ - public void writeTypesArray(Object[] array) { - // A big ol' case statement in a for loop -- what's polymorphism mean, again? - // I really wish I could extend the base classes! - - for (int i = 0; i < array.length; i++) { - if (null == array[i]) - continue; - // if the array at i is a type of array write a [ - // This is used for nested arguments - if (array[i].getClass().isArray()) { - stream.write('['); - // fill the [] with the SuperCollider types corresponding to the object - // (i.e. Object of type String needs -s). - writeTypesArray((Object[]) array[i]); - // close the array - stream.write(']'); - continue; - } - // Create a way to deal with Boolean type objects - if (Boolean.TRUE.equals(array[i])) { - stream.write('T'); - continue; - } - if (Boolean.FALSE.equals(array[i])) { - stream.write('F'); - continue; - } - // go through the array and write the superCollider types as shown in the - // above method. the Classes derived here are used as the arg to the above method - writeType(array[i].getClass()); - } - // align the stream with padded bytes - appendNullCharToAlignStream(); - } - - /** - * Same as writeSuperColliderTypes(Object[]), just that it takes a vector (for jdk1.1 - * compatibility), rather than an array. - * @param vector the collection I am to write out types for - */ - public void writeTypes(Vector vector) { - // A big ol' case statement in a for loop -- what's polymorphism mean, again? - // I really wish I could extend the base classes! - - Enumeration enm = vector.elements(); - Object nextObject; - while (enm.hasMoreElements()) { - nextObject = enm.nextElement(); - if (null == nextObject) - continue; - // if the array at i is a type of array write a [ - // This is used for nested arguments - if (nextObject.getClass().isArray()) { - stream.write('['); - // fill the [] with the SuperCollider types corresponding to the object - // (e.g., Object of type String needs -s). - writeTypesArray((Object[]) nextObject); - // close the array - stream.write(']'); - continue; - } - // Create a way to deal with Boolean type objects - if (Boolean.TRUE.equals(nextObject)) { - stream.write('T'); - continue; - } - if (Boolean.FALSE.equals(nextObject)) { - stream.write('F'); - continue; - } - // go through the array and write the superCollider types as shown in the - // above method. the Classes derived here are used as the arg to the above method - writeType(nextObject.getClass()); - } - // align the stream with padded bytes - appendNullCharToAlignStream(); - } - - /** - * convert an integer to byte array - * - * @param value int - */ - private void writeIntegerToByteArray(int value) { - byte[] intBytes = new byte[4]; - - intBytes[3] = (byte)value; value>>>=8; - intBytes[2] = (byte)value; value>>>=8; - intBytes[1] = (byte)value; value>>>=8; - intBytes[0] = (byte)value; - - try { - stream.write(intBytes); - } catch (IOException e) { - throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); - } - } - - /** - * Line up the BigEnd of the bytes to a 4 byte boundry - * - * @param bytes byte[] - */ - private void writeBigEndToFourByteBoundry(byte[] bytes) { - int mod = bytes.length % 4; - // if the remainder == 0 write the bytes - if (mod == 0) { - try { stream.write(bytes); } catch (IOException e) - { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } - return; - } - // pad the bytes to lineup correctly - int pad = 4 - mod; - byte[] newBytes = new byte[pad + bytes.length]; - System.arraycopy(bytes,0,newBytes,pad,bytes.length); - - try { stream.write(newBytes); } catch (IOException e) - { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } - } - - /** - * Line up the LittleEnd of the bytes to a 4 byte boundry - * - * @param bytes byte[] - */ - private void writeLittleEndToFourByteBoundry(byte[] bytes) { - int mod = bytes.length % 4; - // if the remainder == 0 write the bytes - if (mod == 4) { - try { stream.write(bytes); } catch (IOException e) - { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } - return; - } - // pad the bytes to lineup correctly - int pad = 4 - mod; - byte[] newBytes = new byte[pad + bytes.length]; - System.arraycopy(bytes,0,newBytes,0,bytes.length); - - try { stream.write(newBytes); } catch (IOException e) - { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } - } - -} +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Illposed Software + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * + * OSCJavaToByteArrayConverter is a helper class that translates + * from Java types to the format the OSC spec specifies for those + * types. + * + * This implementation is based on Markus Gaelli and + * Iannis Zannos' OSC implementation in Squeak: + * http://www.emergent.de/Goodies/ + */ + +package com.illposed.osc.utility; + +import java.io.IOException; +import java.io.ByteArrayOutputStream; +import java.math.BigInteger; +import java.util.Enumeration; +import java.util.Vector; + + +public class OSCJavaToByteArrayConverter { + + protected ByteArrayOutputStream stream = new ByteArrayOutputStream(); + private byte[] intBytes = new byte[4]; + + /*public OSCJavaToByteArrayConverter() { + super(); + }*/ + + /** + * Creation date: (2/23/2001 2:43:25 AM) + * @param anArray java.lang.Object[] + * + */ + public void appendNullCharToAlignStream() { + int mod = stream.size() % 4; + int pad = 4 - mod; + for (int i = 0; i < pad; i++) + stream.write(0); + } + + /** + * Creation date: (2/23/2001 2:21:53 AM) + * @return byte[] + */ + public byte[] toByteArray() { + return stream.toByteArray(); + } + + /** + * Creation date: (2/23/2001 2:14:23 AM) + * @param bytes byte[] + */ + public void write(byte[] bytes) { + writeBigEndToFourByteBoundry(bytes); + } + + /** + * Creation date: (2/23/2001 2:21:04 AM) + * @param i int + */ + public void write(int i) { + writeIntegerToByteArray(i); + } + + /** + * Creation date: (2/23/2001 2:03:57 AM) + * @param f java.lang.Float + */ + public void write(Float f) { + writeIntegerToByteArray(Float.floatToIntBits(f.floatValue())); + } + + /** + * Creation date: (2/23/2001 2:08:36 AM) + * @param i java.lang.Integer + */ + public void write(Integer i) { + writeIntegerToByteArray(i.intValue()); + } + + /** + * Creation date: (2/23/2001 1:57:35 AM) + * @param str java.lang.String + */ + public void write(String str) { + writeLittleEndToFourByteBoundry(str.getBytes()); + } + + /** + * Creation date: (2/23/2001 2:08:36 AM) + * @param c char + */ + public void write(char c) { + stream.write(c); + } + + /** + * Creation date: (2/23/2001 2:02:54 AM) + * @param anObject java.lang.Object + */ + public void write(Object anObject) { + // Can't do switch on class + if (null == anObject) + return; + if (anObject instanceof Float) { + write((Float) anObject); + return; + } + if (anObject instanceof String) { + write((String) anObject); + return; + } + if (anObject instanceof Integer) { + write((Integer) anObject); + return; + } + } + + /** + * Creation date: (2/23/2001 2:43:25 AM) + * @param aClass Class + */ + public void writeType(Class c) { + // A big ol' case statement -- what's polymorphism mean, again? + // I really wish I could extend the base classes! + + // use the appropriate flags to tell SuperCollider what kind of + // thing it is looking at + + if (Integer.class.equals(c)) { + stream.write('i'); + return; + } + if (java.math.BigInteger.class.equals(c)) { + stream.write('h'); + return; + } + if (Float.class.equals(c)) { + stream.write('f'); + return; + } + if (Double.class.equals(c)) { + stream.write('d'); + return; + } + if (String.class.equals(c)) { + stream.write('s'); + return; + } + if (Character.class.equals(c)) { + stream.write('c'); + return; + } + } + + /** + * Creation date: (2/23/2001 2:43:25 AM) + * @param anArray java.lang.Object[] + */ + public void writeTypesArray(Object[] array) { + // A big ol' case statement in a for loop -- what's polymorphism mean, again? + // I really wish I could extend the base classes! + + for (int i = 0; i < array.length; i++) { + if (null == array[i]) + continue; + // if the array at i is a type of array write a [ + // This is used for nested arguments + if (array[i].getClass().isArray()) { + stream.write('['); + // fill the [] with the SuperCollider types corresponding to the object + // (i.e. Object of type String needs -s). + writeTypesArray((Object[]) array[i]); + // close the array + stream.write(']'); + continue; + } + // Create a way to deal with Boolean type objects + if (Boolean.TRUE.equals(array[i])) { + stream.write('T'); + continue; + } + if (Boolean.FALSE.equals(array[i])) { + stream.write('F'); + continue; + } + // go through the array and write the superCollider types as shown in the + // above method. the Classes derived here are used as the arg to the above method + writeType(array[i].getClass()); + } + // align the stream with padded bytes + appendNullCharToAlignStream(); + } + + /** + * Same as writeSuperColliderTypes(Object[]), just that it takes a vector (for jdk1.1 + * compatibility), rather than an array. + * @param vector the collection I am to write out types for + */ + public void writeTypes(Vector vector) { + // A big ol' case statement in a for loop -- what's polymorphism mean, again? + // I really wish I could extend the base classes! + + Enumeration enm = vector.elements(); + Object nextObject; + while (enm.hasMoreElements()) { + nextObject = enm.nextElement(); + if (null == nextObject) + continue; + // if the array at i is a type of array write a [ + // This is used for nested arguments + if (nextObject.getClass().isArray()) { + stream.write('['); + // fill the [] with the SuperCollider types corresponding to the object + // (e.g., Object of type String needs -s). + writeTypesArray((Object[]) nextObject); + // close the array + stream.write(']'); + continue; + } + // Create a way to deal with Boolean type objects + if (Boolean.TRUE.equals(nextObject)) { + stream.write('T'); + continue; + } + if (Boolean.FALSE.equals(nextObject)) { + stream.write('F'); + continue; + } + // go through the array and write the superCollider types as shown in the + // above method. the Classes derived here are used as the arg to the above method + writeType(nextObject.getClass()); + } + // align the stream with padded bytes + appendNullCharToAlignStream(); + } + + /** + * convert an integer to byte array + * + * @param value int + */ + private void writeIntegerToByteArray(int value) { + byte[] intBytes = new byte[4]; + + intBytes[3] = (byte)value; value>>>=8; + intBytes[2] = (byte)value; value>>>=8; + intBytes[1] = (byte)value; value>>>=8; + intBytes[0] = (byte)value; + + try { + stream.write(intBytes); + } catch (IOException e) { + throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); + } + } + + /** + * Line up the BigEnd of the bytes to a 4 byte boundry + * + * @param bytes byte[] + */ + private void writeBigEndToFourByteBoundry(byte[] bytes) { + int mod = bytes.length % 4; + // if the remainder == 0 write the bytes + if (mod == 0) { + try { stream.write(bytes); } catch (IOException e) + { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } + return; + } + // pad the bytes to lineup correctly + int pad = 4 - mod; + byte[] newBytes = new byte[pad + bytes.length]; + System.arraycopy(bytes,0,newBytes,pad,bytes.length); + + try { stream.write(newBytes); } catch (IOException e) + { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } + } + + /** + * Line up the LittleEnd of the bytes to a 4 byte boundry + * + * @param bytes byte[] + */ + private void writeLittleEndToFourByteBoundry(byte[] bytes) { + int mod = bytes.length % 4; + // if the remainder == 0 write the bytes + if (mod == 4) { + try { stream.write(bytes); } catch (IOException e) + { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } + return; + } + // pad the bytes to lineup correctly + int pad = 4 - mod; + byte[] newBytes = new byte[pad + bytes.length]; + System.arraycopy(bytes,0,newBytes,0,bytes.length); + + try { stream.write(newBytes); } catch (IOException e) + { throw new RuntimeException("You're screwed: IOException writing to a ByteArrayOutputStream"); } + } + +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCPacketDispatcher.java --- a/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCPacketDispatcher.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/com/illposed/osc/utility/OSCPacketDispatcher.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,77 +1,77 @@ -/* $Id: OSCPacketDispatcher.java,v 1.2 2008/07/01 15:29:46 modin Exp $ - * Created on 28.10.2003 - */ -package com.illposed.osc.utility; - -import com.illposed.osc.*; - -import java.util.Date; -import java.util.Enumeration; -import java.util.Hashtable; - -/** - * @author cramakrishnan - * - * Copyright (C) 2003, C. Ramakrishnan / Auracle - * All rights reserved. - * - * See license.txt (or license.rtf) for license information. - * - * Dispatches OSCMessages to registered listeners. - * - */ - -public class OSCPacketDispatcher { - private Hashtable addressToClassTable = new Hashtable(); - - /** - * - */ - public OSCPacketDispatcher() { - super(); - } - - public void addListener(String address, OSCListener listener) { - addressToClassTable.put(address, listener); - } - - public void dispatchPacket(OSCPacket packet) { - if (packet instanceof OSCBundle) - dispatchBundle((OSCBundle) packet); - else - dispatchMessage((OSCMessage) packet); - } - - public void dispatchPacket(OSCPacket packet, Date timestamp) { - if (packet instanceof OSCBundle) - dispatchBundle((OSCBundle) packet); - else - dispatchMessage((OSCMessage) packet, timestamp); - } - - private void dispatchBundle(OSCBundle bundle) { - Date timestamp = bundle.getTimestamp(); - OSCPacket[] packets = bundle.getPackets(); - for (int i = 0; i < packets.length; i++) { - dispatchPacket(packets[i], timestamp); - } - } - - private void dispatchMessage(OSCMessage message) { - dispatchMessage(message, null); - } - - private void dispatchMessage(OSCMessage message, Date time) { - Enumeration keys = addressToClassTable.keys(); - while (keys.hasMoreElements()) { - String key = (String) keys.nextElement(); - // this supports the OSC regexp facility, but it - // only works in JDK 1.4, so don't support it right now - // if (key.matches(message.getAddress())) { - if (key.equals(message.getAddress())) { - OSCListener listener = (OSCListener) addressToClassTable.get(key); - listener.acceptMessage(time, message); - } - } - } -} +/* $Id: OSCPacketDispatcher.java,v 1.2 2008/07/01 15:29:46 modin Exp $ + * Created on 28.10.2003 + */ +package com.illposed.osc.utility; + +import com.illposed.osc.*; + +import java.util.Date; +import java.util.Enumeration; +import java.util.Hashtable; + +/** + * @author cramakrishnan + * + * Copyright (C) 2003, C. Ramakrishnan / Auracle + * All rights reserved. + * + * See license.txt (or license.rtf) for license information. + * + * Dispatches OSCMessages to registered listeners. + * + */ + +public class OSCPacketDispatcher { + private Hashtable addressToClassTable = new Hashtable(); + + /** + * + */ + public OSCPacketDispatcher() { + super(); + } + + public void addListener(String address, OSCListener listener) { + addressToClassTable.put(address, listener); + } + + public void dispatchPacket(OSCPacket packet) { + if (packet instanceof OSCBundle) + dispatchBundle((OSCBundle) packet); + else + dispatchMessage((OSCMessage) packet); + } + + public void dispatchPacket(OSCPacket packet, Date timestamp) { + if (packet instanceof OSCBundle) + dispatchBundle((OSCBundle) packet); + else + dispatchMessage((OSCMessage) packet, timestamp); + } + + private void dispatchBundle(OSCBundle bundle) { + Date timestamp = bundle.getTimestamp(); + OSCPacket[] packets = bundle.getPackets(); + for (int i = 0; i < packets.length; i++) { + dispatchPacket(packets[i], timestamp); + } + } + + private void dispatchMessage(OSCMessage message) { + dispatchMessage(message, null); + } + + private void dispatchMessage(OSCMessage message, Date time) { + Enumeration keys = addressToClassTable.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + // this supports the OSC regexp facility, but it + // only works in JDK 1.4, so don't support it right now + // if (key.matches(message.getAddress())) { + if (key.equals(message.getAddress())) { + OSCListener listener = (OSCListener) addressToClassTable.get(key); + listener.acceptMessage(time, message); + } + } + } +} diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/compile.bat --- a/front_processing/extern/TUIO_JAVA/src/compile.bat Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/compile.bat Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,5 @@ -javac -O -source 1.5 -target 1.5 -cp . *.java TUIO\*.java com\illposed\osc\*.java -jar cfm ..\TuioDemo.jar manifest.inc *.class TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class -jar cf ..\libTUIO.jar TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class -del *.class TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class +javac -encoding utf-8 -O -source 1.5 -target 1.5 -cp . *.java TUIO\*.java com\illposed\osc\*.java +jar cfm ..\TuioDemo.jar manifest.inc *.class TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class +jar cf ..\libTUIO.jar TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class +del *.class TUIO\*.class com\illposed\osc\*.class com\illposed\osc\utility\*.class +pause \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/compile.sh --- a/front_processing/extern/TUIO_JAVA/src/compile.sh Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/compile.sh Fri Mar 23 16:24:36 2012 +0100 @@ -1,7 +1,7 @@ -#!/bin/sh -cd src -javac -Xlint:unchecked -O -source 1.5 -target 1.5 -cp . *.java TUIO/*.java com/illposed/osc/*.java -jar cfm ../TuioDemo.jar manifest.inc *.class TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class -jar cf ../libTUIO.jar TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class -rm -f *.class TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class -cd .. +#!/bin/sh +cd src +javac -Xlint:unchecked -O -source 1.5 -target 1.5 -cp . *.java TUIO/*.java com/illposed/osc/*.java +jar cfm ../TuioDemo.jar manifest.inc *.class TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class +jar cf ../libTUIO.jar TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class +rm -f *.class TUIO/*.class com/illposed/osc/*.class com/illposed/osc/utility/*.class +cd .. diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/doc.sh --- a/front_processing/extern/TUIO_JAVA/src/doc.sh Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/doc.sh Fri Mar 23 16:24:36 2012 +0100 @@ -1,3 +1,3 @@ -#!/bin/sh -javadoc -d doc -sourcepath src TUIO - +#!/bin/sh +javadoc -d doc -sourcepath src TUIO + diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_JAVA/src/manifest.inc --- a/front_processing/extern/TUIO_JAVA/src/manifest.inc Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_JAVA/src/manifest.inc Fri Mar 23 16:24:36 2012 +0100 @@ -1,3 +1,1 @@ -Main-Class: TuioDemo - - +Main-Class: TuioDemo \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_PROCESSING/src/TUIO/TuioProcessing.java --- a/front_processing/extern/TUIO_PROCESSING/src/TUIO/TuioProcessing.java Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_PROCESSING/src/TUIO/TuioProcessing.java Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* TUIO processing library - part of the reacTIVision project http://reactivision.sourceforge.net/ diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_PROCESSING/src/compile.bat --- a/front_processing/extern/TUIO_PROCESSING/src/compile.bat Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_PROCESSING/src/compile.bat Fri Mar 23 16:24:36 2012 +0100 @@ -1,10 +1,12 @@ -rem javac -O -source 1.4 -target 1.4 -cp TUIO\libTUIO.jar:TUIO\core.jar TUIO\*.java +rem javac -O -source 1.4 -target 1.4 -cp TUIO\libTUIO.jar:TUIO\core.jar TUIO\*.java rem javaw -Dfile.encoding=Cp1252 -classpath C:\Users\bastiena\Documents\processing-1.5.1-windows-expert\processing-1.5.1\lib\core.jar;..\TUIO_JAVA\libTUIO.jar processing.core.PApplet -javac -O -source 1.4 -target 1.4 -cp ..\library\libTUIO.jar;..\..\..\..\..\IDILL\DEV\TUIO_Processing-1.4\TUIO_Processing\library\core.jar TUIO\*.java +javac -encoding utf-8 -O -source 1.4 -target 1.4 -cp ..\library\libTUIO.jar;..\..\..\..\..\IDILL\DEV\TUIO_Processing-1.4\TUIO_Processing\library\core.jar TUIO\*.java jar cfm ..\library\TUIO.jar manifest.inc TUIO\*.class del TUIO\*.class +pause + rem javac -O -source 1.4 -target 1.4 -cp ..\library\libTUIO.jar:core.jar TUIO\*.java rem jar cfm ..\library\libTUIO.jar manifest.inc TUIO\*.class rem del TUIO\*.class \ No newline at end of file diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_PROCESSING/src/compile.sh --- a/front_processing/extern/TUIO_PROCESSING/src/compile.sh Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_PROCESSING/src/compile.sh Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh javac -Xlint:unchecked -O -source 1.4 -target 1.4 -cp ../library/libTUIO.jar:core.jar TUIO/*.java jar cfm ../library/TUIO.jar manifest.inc TUIO/*.class rm -f TUIO/*.class diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/extern/TUIO_PROCESSING/src/manifest.inc --- a/front_processing/extern/TUIO_PROCESSING/src/manifest.inc Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/extern/TUIO_PROCESSING/src/manifest.inc Fri Mar 23 16:24:36 2012 +0100 @@ -1,1 +1,1 @@ -Class-Path: libTUIO.jar +Class-Path: libTUIO.jar diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Fluid_manipulation/Fluid_manipulation.pde --- a/front_processing/src/Fluid_manipulation/Fluid_manipulation.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Fluid_manipulation/Fluid_manipulation.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Fluid_manipulation/TuioFunctions.pde --- a/front_processing/src/Fluid_manipulation/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Fluid_manipulation/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Fluid_manipulation/particle.pde --- a/front_processing/src/Fluid_manipulation/particle.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Fluid_manipulation/particle.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Fluid_manipulation/vbuffer.pde --- a/front_processing/src/Fluid_manipulation/vbuffer.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Fluid_manipulation/vbuffer.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Fluid_manipulation/vsquare.pde --- a/front_processing/src/Fluid_manipulation/vsquare.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Fluid_manipulation/vsquare.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hand_press/Hand_press.pde --- a/front_processing/src/Interaction_examples/Hand_press/Hand_press.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hand_press/Hand_press.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hand_press/TuioFunctions.pde --- a/front_processing/src/Interaction_examples/Hand_press/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hand_press/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hand_signal/Hand_signal.pde --- a/front_processing/src/Interaction_examples/Hand_signal/Hand_signal.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hand_signal/Hand_signal.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde --- a/front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hands_1D/Hands_1D.pde --- a/front_processing/src/Interaction_examples/Hands_1D/Hands_1D.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hands_1D/Hands_1D.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hands_1D/TuioFunctions.pde --- a/front_processing/src/Interaction_examples/Hands_1D/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hands_1D/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hands_2D/Hands_2D.pde --- a/front_processing/src/Interaction_examples/Hands_2D/Hands_2D.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hands_2D/Hands_2D.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Interaction_examples/Hands_2D/TuioFunctions.pde --- a/front_processing/src/Interaction_examples/Hands_2D/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Interaction_examples/Hands_2D/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Smoke_manipulation/Smoke_manipulation.pde --- a/front_processing/src/Smoke_manipulation/Smoke_manipulation.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Smoke_manipulation/Smoke_manipulation.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Smoke_manipulation/TuioFunctions.pde --- a/front_processing/src/Smoke_manipulation/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Smoke_manipulation/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Smoke_manipulation/particle.pde --- a/front_processing/src/Smoke_manipulation/particle.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Smoke_manipulation/particle.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Smoke_manipulation/vbuffer.pde --- a/front_processing/src/Smoke_manipulation/vbuffer.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Smoke_manipulation/vbuffer.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Smoke_manipulation/vsquare.pde --- a/front_processing/src/Smoke_manipulation/vsquare.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Smoke_manipulation/vsquare.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Trakers/Trakers.pde --- a/front_processing/src/Trakers/Trakers.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Trakers/Trakers.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI @@ -22,7 +22,7 @@ /*FONCTION D'INITIALISATION Entrée : -Sortie : Création de la fenêtre et du client TUIO*/ +Sortie : Cr�ation de la fenêtre et du client TUIO*/ void setup() { size (WIDTH, HEIGHT); diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Trakers/TuioFunctions.pde --- a/front_processing/src/Trakers/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Trakers/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI @@ -40,7 +40,7 @@ Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/ void handleOneHand(TuioCursor handCursor) { - TuioPoint pt = handCursor.getPosition();//(TuioPoint)pointList.get(j); + TuioPoint pt = handCursor.getPosition(); fill(0); drawEllipse(pt.getX(), pt.getY(), pt.getZ(), !oneHandLeft); } @@ -54,9 +54,9 @@ TuioCursor handRightCursor = (TuioCursor)tuioCursorList.elementAt(1); TuioPoint pt; - pt = (TuioPoint)handLeftCursor.getPosition();//handLeftPointList.get(j); + pt = (TuioPoint)handLeftCursor.getPosition(); drawEllipse(pt.getX(), pt.getY(), pt.getZ(), true); - pt = (TuioPoint)handRightCursor.getPosition();//handRightPointList.get(k); + pt = (TuioPoint)handRightCursor.getPosition(); drawEllipse(pt.getX(), pt.getY(), pt.getZ(), false); } diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Trakers_gestures/Trakers_gestures.pde --- a/front_processing/src/Trakers_gestures/Trakers_gestures.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Trakers_gestures/Trakers_gestures.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/* +/* * This file is part of the TraKERS\Front Processing package. * * (c) IRI diff -r 0f44b7360c8d -r 925b7ee746e3 front_processing/src/Trakers_gestures/TuioFunctions.pde --- a/front_processing/src/Trakers_gestures/TuioFunctions.pde Thu Mar 22 18:15:53 2012 +0100 +++ b/front_processing/src/Trakers_gestures/TuioFunctions.pde Fri Mar 23 16:24:36 2012 +0100 @@ -1,4 +1,4 @@ -/*FONCTION DE RECEPTION DES MESSAGES OSC +/*FONCTION DE RECEPTION DES MESSAGES OSC Entrée : Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/ void tuioInput()