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