8 * The TuioCursor class encapsulates /tuio/_siP TUIO strings. |
8 * The TuioCursor class encapsulates /tuio/_siP TUIO strings. |
9 * |
9 * |
10 */ |
10 */ |
11 public class TuioString { |
11 public class TuioString { |
12 |
12 |
13 /** |
13 /** |
14 * The unique session ID number that is assigned to each TUIO string. |
14 * The unique session ID number that is assigned to each TUIO string. |
15 */ |
15 */ |
16 protected long session_id; |
16 protected long session_id; |
17 |
17 |
18 /** |
18 /** |
19 * The individual string ID number that is assigned to each TuioString. |
19 * The individual string ID number that is assigned to each TuioString. |
20 */ |
20 */ |
21 protected int string_id; |
21 protected int string_id; |
22 |
22 |
23 /** |
23 /** |
24 * The individual string message that is assigned to each TuioString. |
24 * The individual string message that is assigned to each TuioString. |
25 */ |
25 */ |
26 protected String message; |
26 protected String message; |
27 |
27 |
28 /** |
28 /** |
29 * The time stamp of the last update represented as TuioTime (time since session start) |
29 * The time stamp of the last update represented as TuioTime (time since session start) |
30 */ |
30 */ |
31 protected TuioTime currentTime; |
31 protected TuioTime currentTime; |
32 /** |
32 /** |
33 * The creation time of this TuioString represented as TuioTime (time since session start) |
33 * The creation time of this TuioString represented as TuioTime (time since session start) |
34 */ |
34 */ |
35 protected TuioTime startTime; |
35 protected TuioTime startTime; |
36 |
36 |
37 /** |
37 /** |
38 * Defines the ADDED state. |
38 * Defines the ADDED state. |
39 */ |
39 */ |
40 public static final int TUIO_ADDED = 0; |
40 public static final int TUIO_ADDED = 0; |
41 /** |
41 /** |
42 * Defines the REMOVED state. |
42 * Defines the REMOVED state. |
43 */ |
43 */ |
44 public static final int TUIO_REMOVED = 4; |
44 public static final int TUIO_REMOVED = 4; |
45 /** |
45 /** |
46 * Reflects the current state of the TuioString |
46 * Reflects the current state of the TuioString |
47 */ |
47 */ |
48 protected int state; |
48 protected int state; |
49 |
49 |
50 /** |
50 /** |
51 * This constructor takes a TuioTime argument and assigns it along with the provided |
51 * This constructor takes a TuioTime argument and assigns it along with the provided |
52 * Session ID, String ID and a message to the newly created TuioString. |
52 * Session ID, String ID and a message to the newly created TuioString. |
53 * |
53 * |
54 * @param ttime the TuioTime to assign |
54 * @param ttime the TuioTime to assign |
55 * @param si the Session ID to assign |
55 * @param si the Session ID to assign |
56 * @param sti the String ID to assign |
56 * @param sti the String ID to assign |
57 * @param msg the message to assign |
57 * @param msg the message to assign |
58 */ |
58 */ |
59 public TuioString (TuioTime ttime, long si, int sti, String msg) { |
59 public TuioString (TuioTime ttime, long si, int sti, String msg) { |
60 this.session_id = si; |
60 this.session_id = si; |
61 this.string_id = sti; |
61 this.string_id = sti; |
62 this.message = msg; |
62 this.message = msg; |
63 currentTime = new TuioTime(ttime); |
63 currentTime = new TuioTime(ttime); |
64 startTime = new TuioTime(currentTime); |
64 startTime = new TuioTime(currentTime); |
65 } |
65 } |
66 |
66 |
67 /** |
67 /** |
68 * This constructor takes the provided Session ID, String ID and message |
68 * This constructor takes the provided Session ID, String ID and message |
69 * and assigs these values to the newly created TuioString. |
69 * and assigs these values to the newly created TuioString. |
70 * |
70 * |
71 * @param si the Session ID to assign |
71 * @param si the Session ID to assign |
72 * @param sti the String ID to assign |
72 * @param sti the String ID to assign |
73 * @param msg the message to assign |
73 * @param msg the message to assign |
74 */ |
74 */ |
75 public TuioString (long si, int sti, String msg) { |
75 public TuioString (long si, int sti, String msg) { |
76 this.session_id = si; |
76 this.session_id = si; |
77 this.string_id = sti; |
77 this.string_id = sti; |
78 this.message = msg; |
78 this.message = msg; |
79 currentTime = TuioTime.getSessionTime(); |
79 currentTime = TuioTime.getSessionTime(); |
80 startTime = new TuioTime(currentTime); |
80 startTime = new TuioTime(currentTime); |
81 } |
81 } |
82 |
82 |
83 /** |
83 /** |
84 * This constructor takes the atttibutes of the provided TuioCursor |
84 * This constructor takes the atttibutes of the provided TuioCursor |
85 * and assigs these values to the newly created TuioCursor. |
85 * and assigs these values to the newly created TuioCursor. |
86 * |
86 * |
87 * @param tcur the TuioCursor to assign |
87 * @param tcur the TuioCursor to assign |
88 */ |
88 */ |
89 public TuioString (TuioString tstr) { |
89 public TuioString (TuioString tstr) { |
90 this.session_id = tstr.getSessionID(); |
90 this.session_id = tstr.getSessionID(); |
91 this.string_id = tstr.getStringID(); |
91 this.string_id = tstr.getStringID(); |
92 this.message = tstr.getMessage(); |
92 this.message = tstr.getMessage(); |
93 currentTime = new TuioTime(tstr.getCurrentTime()); |
93 currentTime = new TuioTime(tstr.getCurrentTime()); |
94 startTime = new TuioTime(currentTime); |
94 startTime = new TuioTime(currentTime); |
95 } |
95 } |
96 |
96 |
97 /** |
97 /** |
98 * Takes a TuioTime argument and assigns it along with the provided |
98 * Takes a TuioTime argument and assigns it along with the provided |
99 * message to the private TuioString attributes. |
99 * message to the private TuioString attributes. |
100 * The speed and accleration values are calculated accordingly. |
100 * The speed and accleration values are calculated accordingly. |
101 * |
101 * |
102 * @param ttime the TuioTime to assign |
102 * @param ttime the TuioTime to assign |
103 * @param message2 the message to assign |
103 * @param message2 the message to assign |
104 */ |
104 */ |
105 public void update(TuioTime ttime, String message2) { |
105 public void update(TuioTime ttime, String message2) { |
106 currentTime = new TuioTime(ttime); |
106 currentTime = new TuioTime(ttime); |
107 message = message2; |
107 message = message2; |
108 } |
108 } |
109 |
109 |
110 /** |
110 /** |
111 * This method is used to update the TuioTime of a TuioString while keeping the same * * * message. |
111 * This method is used to update the TuioTime of a TuioString while keeping the same * * * message. |
112 */ |
112 */ |
113 public void stop(TuioTime ttime) { |
113 public void stop(TuioTime ttime) { |
114 update(ttime,message); |
114 update(ttime,message); |
115 } |
115 } |
116 |
116 |
117 /** |
117 /** |
118 * Takes the atttibutes of the provided TuioString |
118 * Takes the atttibutes of the provided TuioString |
119 * and assigs these values to this TuioString. |
119 * and assigs these values to this TuioString. |
120 * The TuioTime time stamp of this TuioString remains unchanged. |
120 * The TuioTime time stamp of this TuioString remains unchanged. |
121 * |
121 * |
122 * @param tstr the TuioString to assign |
122 * @param tstr the TuioString to assign |
123 */ |
123 */ |
124 public void update (TuioString tstr) { |
124 public void update (TuioString tstr) { |
125 message = tstr.getMessage(); |
125 message = tstr.getMessage(); |
126 } |
126 } |
127 |
127 |
128 /** |
128 /** |
129 * Takes the message provided |
129 * Takes the message provided |
130 * and assigs its value to this TuioString. |
130 * and assigs its value to this TuioString. |
131 * The TuioTime time stamp of this TuioString remains unchanged. |
131 * The TuioTime time stamp of this TuioString remains unchanged. |
132 * |
132 * |
133 * @param msg the message to assign |
133 * @param msg the message to assign |
134 */ |
134 */ |
135 public void update (String msg) { |
135 public void update (String msg) { |
136 message = msg; |
136 message = msg; |
137 } |
137 } |
138 |
138 |
139 /** |
139 /** |
140 * Assigns the REMOVE state to this TuioString and sets |
140 * Assigns the REMOVE state to this TuioString and sets |
141 * its TuioTime time stamp to the provided TuioTime argument. |
141 * its TuioTime time stamp to the provided TuioTime argument. |
142 * |
142 * |
143 * @param ttime the TuioTime to assign |
143 * @param ttime the TuioTime to assign |
144 */ |
144 */ |
145 public void remove(TuioTime ttime) { |
145 public void remove(TuioTime ttime) { |
146 currentTime = new TuioTime(ttime); |
146 currentTime = new TuioTime(ttime); |
147 state = TUIO_REMOVED; |
147 state = TUIO_REMOVED; |
148 } |
148 } |
149 |
149 |
150 /** |
150 /** |
151 * Returns the Session ID of this TuioString. |
151 * Returns the Session ID of this TuioString. |
152 * @return the Session ID of this TuioString |
152 * @return the Session ID of this TuioString |
153 */ |
153 */ |
154 public long getSessionID() { |
154 public long getSessionID() { |
155 return session_id; |
155 return session_id; |
156 } |
156 } |
157 |
157 |
158 /** |
158 /** |
159 * Returns the String ID of this TuioString. |
159 * Returns the String ID of this TuioString. |
160 * @return the String ID of this TuioString |
160 * @return the String ID of this TuioString |
161 */ |
161 */ |
162 public int getStringID() { |
162 public int getStringID() { |
163 return string_id; |
163 return string_id; |
164 } |
164 } |
165 |
165 |
166 /** |
166 /** |
167 * Returns the Message of this TuioString. |
167 * Returns the Message of this TuioString. |
168 * @return the Message of this TuioString |
168 * @return the Message of this TuioString |
169 */ |
169 */ |
170 public String getMessage() { |
170 public String getMessage() { |
171 return message; |
171 return message; |
172 } |
172 } |
173 |
173 |
174 /** |
174 /** |
175 * Returns the Current Time of this TuioString. |
175 * Returns the Current Time of this TuioString. |
176 * @return the Current Time of this TuioString |
176 * @return the Current Time of this TuioString |
177 */ |
177 */ |
178 public TuioTime getCurrentTime() { |
178 public TuioTime getCurrentTime() { |
179 return currentTime; |
179 return currentTime; |
180 } |
180 } |
181 |
181 |
182 /** |
182 /** |
183 * Returns the TUIO state of this TuioString. |
183 * Returns the TUIO state of this TuioString. |
184 * @return the TUIO state of this TuioString |
184 * @return the TUIO state of this TuioString |
185 */ |
185 */ |
186 public int getTuioState() { |
186 public int getTuioState() { |
187 return state; |
187 return state; |
188 } |
188 } |
189 } |
189 } |