1 /* |
1 /* |
2 TUIO Java Demo - part of the reacTIVision project |
2 TUIO Java Demo - 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 java.applet.*; |
22 import java.applet.*; |
23 import java.awt.*; |
23 import java.awt.*; |
24 import javax.swing.*; |
24 import javax.swing.*; |
25 import java.io.*; |
25 import java.io.*; |
26 import java.net.*; |
26 import java.net.*; |
27 import TUIO.*; |
27 import TUIO.*; |
28 |
28 |
29 public class TuioApplet extends JApplet { |
29 public class TuioApplet extends JApplet { |
30 |
30 |
31 TuioDemoComponent demo; |
31 TuioDemoComponent demo; |
32 TuioClient client; |
32 TuioClient client; |
33 int port = 3333; |
33 int port = 3333; |
34 |
34 |
35 public void init() { |
35 public void init() { |
36 try { |
36 try { |
37 port = Integer.parseInt(getParameter("port")); |
37 port = Integer.parseInt(getParameter("port")); |
38 } catch (Exception e) {} |
38 } catch (Exception e) {} |
39 |
39 |
40 Dimension size = this.getSize(); |
40 Dimension size = this.getSize(); |
41 |
41 |
42 TuioDemoComponent demo = new TuioDemoComponent(); |
42 TuioDemoComponent demo = new TuioDemoComponent(); |
43 demo.setSize(size.width,size.height); |
43 demo.setSize(size.width,size.height); |
44 |
44 |
45 client = new TuioClient(); |
45 client = new TuioClient(); |
46 client.addTuioListener(demo); |
46 client.addTuioListener(demo); |
47 |
47 |
48 add(demo); |
48 add(demo); |
49 repaint(); |
49 repaint(); |
50 } |
50 } |
51 |
51 |
52 public void start() { |
52 public void start() { |
53 if (!client.isConnected()) client.connect(); |
53 if (!client.isConnected()) client.connect(); |
54 } |
54 } |
55 |
55 |
56 public void stop() { |
56 public void stop() { |
57 if (client.isConnected()) client.disconnect(); |
57 if (client.isConnected()) client.disconnect(); |
58 } |
58 } |
59 |
59 |
60 public void destroy() { |
60 public void destroy() { |
61 if (client.isConnected()) client.disconnect(); |
61 if (client.isConnected()) client.disconnect(); |
62 client = null; |
62 client = null; |
63 } |
63 } |
64 |
64 |
65 public void paint( Graphics g ) { |
65 public void paint( Graphics g ) { |
66 } |
66 } |
67 } |
67 } |