front_processing/extern/TUIO_JAVA/src/TuioDump.java
changeset 9 0f44b7360c8d
parent 3 92f19af39024
child 10 925b7ee746e3
equal deleted inserted replaced
8:e4e7db2435f8 9:0f44b7360c8d
     1 /*
     1 /*
     2 	TUIO Java Example - part of the reacTIVision project
     2     TUIO Java Example - part of the reacTIVision project
     3 	http://reactivision.sourceforge.net/
     3     http://reactivision.sourceforge.net/
     4 
     4 
     5 	Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
     5     Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
     6 
     6 
     7 	This program is free software;you can redistribute it and/or modify
     7     This program is free software;you can redistribute it and/or modify
     8 	it under the terms of the GNU General Public License as published by
     8     it under the terms of the GNU General Public License as published by
     9 	the Free Software Foundation;either version 2 of the License, or
     9     the Free Software Foundation;either version 2 of the License, or
    10 	(at your option) any later version.
    10     (at your option) any later version.
    11 
    11 
    12 	This program is distributed in the hope that it will be useful,
    12     This program is distributed in the hope that it will be useful,
    13 	but WITHOUT ANY WARRANTY;without even the implied warranty of
    13     but WITHOUT ANY WARRANTY;without even the implied warranty of
    14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    15 	GNU General Public License for more details.
    15     GNU General Public License for more details.
    16 
    16 
    17 	You should have received a copy of the GNU General Public License
    17     You should have received a copy of the GNU General Public License
    18 	along with this program;if not, write to the Free Software
    18     along with this program;if not, write to the Free Software
    19 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    20 */
    20 */
    21 
    21 
    22 import javax.swing.*;
    22 import javax.swing.*;
    23 import java.awt.geom.*;
    23 import java.awt.geom.*;
    24 import java.awt.*;
    24 import java.awt.*;
    25 import java.awt.event.*;
    25 import java.awt.event.*;
    26 import TUIO.*;
    26 import TUIO.*;
    27 
    27 
    28 public class TuioDump implements TuioListener {
    28 public class TuioDump implements TuioListener {
    29 	
    29     
    30 	public void addTuioObject(TuioObject tobj) {
    30     public void addTuioObject(TuioObject tobj) {
    31 		System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle());	
    31         System.out.println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle());    
    32 	}
    32     }
    33 
    33 
    34 	public void updateTuioObject(TuioObject tobj) {
    34     public void updateTuioObject(TuioObject tobj) {
    35 		System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel());
    35         System.out.println("set obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel());
    36 	}
    36     }
    37 	
    37     
    38 	public void removeTuioObject(TuioObject tobj) {
    38     public void removeTuioObject(TuioObject tobj) {
    39 		System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")");	
    39         System.out.println("del obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")");    
    40 	}
    40     }
    41 
    41 
    42 	public void addTuioCursor(TuioCursor tcur) {
    42     public void addTuioCursor(TuioCursor tcur) {
    43 		System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY());	
    43         System.out.println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY());    
    44 	}
    44     }
    45 
    45 
    46 	public void updateTuioCursor(TuioCursor tcur) {
    46     public void updateTuioCursor(TuioCursor tcur) {
    47 		System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel());
    47         System.out.println("set cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+") "+tcur.getX()+" "+tcur.getY()+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel());
    48 	}
    48     }
    49 	
    49     
    50 	public void removeTuioCursor(TuioCursor tcur) {
    50     public void removeTuioCursor(TuioCursor tcur) {
    51 		System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")");	
    51         System.out.println("del cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+")");    
    52 	}
    52     }
    53 	
    53     
    54 	public void addTuioString(TuioString tstr) {
    54     public void addTuioString(TuioString tstr) {
    55 		System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage());	
    55         System.out.println("add str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage());    
    56 	}
    56     }
    57 
    57 
    58 	public void updateTuioString(TuioString tstr) {
    58     public void updateTuioString(TuioString tstr) {
    59 		System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage());
    59         System.out.println("set str "+tstr.getStringID()+" ("+tstr.getSessionID()+") "+tstr.getMessage());
    60 	}
    60     }
    61 	
    61     
    62 	public void removeTuioString(TuioString tstr) {
    62     public void removeTuioString(TuioString tstr) {
    63 		System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")");	
    63         System.out.println("del str "+tstr.getStringID()+" ("+tstr.getSessionID()+")");    
    64 	}
    64     }
    65 	
    65     
    66 	public void refresh(TuioTime frameTime) {
    66     public void refresh(TuioTime frameTime) {
    67 		//System.out.println("refresh "+frameTime.getTotalMilliseconds());
    67         //System.out.println("refresh "+frameTime.getTotalMilliseconds());
    68 	}
    68     }
    69 
    69 
    70 	public static void main(String argv[]) {
    70     public static void main(String argv[]) {
    71 	
    71     
    72 		int port = 3333;
    72         int port = 3333;
    73 
    73 
    74 		if (argv.length==1) {
    74         if (argv.length==1) {
    75 			try { port = Integer.parseInt(argv[0]); }
    75             try { port = Integer.parseInt(argv[0]); }
    76 			catch (Exception e) { System.out.println("usage: java TuioDump [port]"); }
    76             catch (Exception e) { System.out.println("usage: java TuioDump [port]"); }
    77 		}
    77         }
    78 
    78 
    79 		TuioDump demo = new TuioDump();
    79         TuioDump demo = new TuioDump();
    80 		TuioClient client = new TuioClient(port);
    80         TuioClient client = new TuioClient(port);
    81 
    81 
    82 		System.out.println("listening to TUIO messages at port "+port);
    82         System.out.println("listening to TUIO messages at port "+port);
    83 		client.addTuioListener(demo);
    83         client.addTuioListener(demo);
    84 		client.connect();
    84         client.connect();
    85 	}
    85     }
    86 }
    86 }