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(); + } + } + + + } +}