|
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 |
|
54 public void refresh(TuioTime frameTime) { |
|
55 //System.out.println("refresh "+frameTime.getTotalMilliseconds()); |
|
56 } |
|
57 |
|
58 public static void main(String argv[]) { |
|
59 |
|
60 int port = 3333; |
|
61 |
|
62 if (argv.length==1) { |
|
63 try { port = Integer.parseInt(argv[0]); } |
|
64 catch (Exception e) { System.out.println("usage: java TuioDump [port]"); } |
|
65 } |
|
66 |
|
67 TuioDump demo = new TuioDump(); |
|
68 TuioClient client = new TuioClient(port); |
|
69 |
|
70 System.out.println("listening to TUIO messages at port "+port); |
|
71 client.addTuioListener(demo); |
|
72 client.connect(); |
|
73 } |
|
74 } |