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