1
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
|
2
|
<html>
|
3
|
<head>
|
4
|
<title>
|
5
|
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
|
6
|
</title>
|
7
|
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
8
|
<script>
|
9
|
function asd() {
|
10
|
|
11
|
parent.document.title="MovieLoop.js Overview";
|
12
|
|
13
|
}
|
14
|
</script>
|
15
|
</head>
|
16
|
<body bgcolor="white" onload="asd();">
|
17
|
|
18
|
<!-- ========== START OF NAVBAR ========== -->
|
19
|
<a name="navbar_top"><!-- --></a>
|
20
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
21
|
<tr>
|
22
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
23
|
<a name="navbar_top_firstrow"><!-- --></a>
|
24
|
<table border="0" cellpadding="0" cellspacing="3">
|
25
|
<tr align="center" valign="top">
|
26
|
|
27
|
|
28
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
29
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
30
|
|
31
|
|
32
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
33
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
34
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
35
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
36
|
</tr>
|
37
|
</table>
|
38
|
</td>
|
39
|
<td bgcolor="#EEEEFF" align="right" valign="top">
|
40
|
<em>
|
41
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
42
|
</td>
|
43
|
</tr>
|
44
|
|
45
|
<tr>
|
46
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
47
|
PREV
|
48
|
NEXT</font></td>
|
49
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
50
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
51
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
52
|
|
53
|
<script>
|
54
|
<!--
|
55
|
if(window==top) {
|
56
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
57
|
}
|
58
|
//-->
|
59
|
</script>
|
60
|
<noscript>
|
61
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
62
|
</noscript>
|
63
|
</font></td>
|
64
|
</tr>
|
65
|
</table>
|
66
|
<!-- =========== END OF NAVBAR =========== -->
|
67
|
|
68
|
<hr>
|
69
|
<center>
|
70
|
|
71
|
<h2>MovieLoop.js</h2>
|
72
|
|
73
|
</center>
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
<h4>Summary</h4>
|
79
|
<p>
|
80
|
|
81
|
No overview generated for 'MovieLoop.js'<BR/><BR/>
|
82
|
|
83
|
</p>
|
84
|
|
85
|
<hr>
|
86
|
|
87
|
|
88
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
89
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
90
|
<td colspan=2><font size="+2">
|
91
|
|
92
|
<b>Class Summary</b>
|
93
|
|
94
|
</font></td>
|
95
|
</tr>
|
96
|
|
97
|
<tr bgcolor="white" class="TableRowColor">
|
98
|
<td width="15%"><b><a href="MovieLoop.html">MovieLoop</a></b></td>
|
99
|
<td> </td>
|
100
|
</tr>
|
101
|
|
102
|
</table>
|
103
|
<hr/>
|
104
|
|
105
|
|
106
|
<!-- ========== METHOD SUMMARY =========== -->
|
107
|
|
108
|
<!-- ========== END METHOD SUMMARY =========== -->
|
109
|
|
110
|
|
111
|
<pre class="sourceview"><span class="comment">/*
|
112
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
113
|
Dependancies: Context
|
114
|
$Id: MovieLoop.js 3881 2008-02-27 15:41:07Z gjvoosten $
|
115
|
*/</span>
|
116
|
<span class="comment">
|
117
|
// Ensure this object's dependancies are loaded.</span>
|
118
|
mapbuilder.loadScript(baseDir+<span class="literal">"/tool/ToolBase.js"</span>);
|
119
|
|
120
|
<span class="comment">/**
|
121
|
* Controller for a movie loop. Set framesPerSec to control the frame rate
|
122
|
* and frameIncrement (+n/-n) to control the steps through the loop (n is number
|
123
|
* of frames to increment.
|
124
|
* <span class="attrib">@constructor</span>
|
125
|
* <span class="attrib">@base</span> ToolBase
|
126
|
* <span class="attrib">@author</span> Adair
|
127
|
* <span class="attrib">@param</span> toolNode The tool node from the config document for this tool
|
128
|
* <span class="attrib">@param</span> model the model object that contains this tool
|
129
|
*/</span>
|
130
|
<span class="reserved">function</span> MovieLoop(toolNode, model) {
|
131
|
ToolBase.apply(<span class="reserved">this</span>, new Array(toolNode, model));
|
132
|
|
133
|
<span class="reserved">this</span>.frameIncrement = 1;
|
134
|
<span class="reserved">this</span>.model.setParam(<span class="literal">"firstFrame"</span>, 0);
|
135
|
<span class="reserved">this</span>.timestampIndex = 0;
|
136
|
window.movieLoop = <span class="reserved">this</span>;
|
137
|
<span class="reserved">this</span>.isRunning = false;
|
138
|
<span class="reserved">this</span>.frameIsLoading = false;
|
139
|
<span class="comment">
|
140
|
//delay in milliseconds</span>
|
141
|
<span class="reserved">this</span>.delay = 1000/<span class="reserved">this</span>.getProperty(<span class="literal">"mb:framesPerSecond"</span>, 10);
|
142
|
<span class="comment">
|
143
|
//set a limit to the number of frames to be loaded</span>
|
144
|
<span class="reserved">this</span>.maxFrames = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:maxFrames"</span>, 30);
|
145
|
|
146
|
<span class="comment">/**
|
147
|
* Sets the frame to the specified index in the frame array
|
148
|
* <span class="attrib">@param</span> index the 0-based frame index in the frame array
|
149
|
*/</span>
|
150
|
<span class="reserved">this</span>.setFrame = <span class="reserved">function</span>(index) {
|
151
|
var timestampList = <span class="reserved">this</span>.model.timestampList;
|
152
|
var ts;
|
153
|
<span class="reserved">if</span> (<span class="reserved">this</span>.timestampIndex!=null) {
|
154
|
var ts = timestampList.childNodes[<span class="reserved">this</span>.timestampIndex];
|
155
|
<span class="reserved">if</span> (ts) {
|
156
|
ts.setAttribute(<span class="literal">"current"</span>, <span class="literal">"0"</span>);
|
157
|
<span class="reserved">this</span>.model.setParam(<span class="literal">"timestamp"</span>, <span class="reserved">this</span>.timestampIndex);
|
158
|
}
|
159
|
}
|
160
|
var firstFrame = <span class="reserved">this</span>.model.getParam(<span class="literal">"firstFrame"</span>);
|
161
|
var lastFrame = <span class="reserved">this</span>.model.getParam(<span class="literal">"lastFrame"</span>);
|
162
|
<span class="reserved">if</span> (index > lastFrame) index = firstFrame;
|
163
|
<span class="reserved">if</span> (index < firstFrame) index = lastFrame;
|
164
|
<span class="reserved">this</span>.timestampIndex = index;
|
165
|
ts = timestampList.childNodes[<span class="reserved">this</span>.timestampIndex];
|
166
|
ts.setAttribute(<span class="literal">"current"</span>, <span class="literal">"1"</span>);
|
167
|
<span class="reserved">this</span>.model.setParam(<span class="literal">"timestamp"</span>, <span class="reserved">this</span>.timestampIndex);
|
168
|
}
|
169
|
|
170
|
<span class="comment">/**
|
171
|
* Advances the frame array by the frame increment.
|
172
|
*
|
173
|
* <span class="attrib">@param</span> step optional parameter to override default frame increment
|
174
|
*/</span>
|
175
|
<span class="reserved">this</span>.nextFrame = <span class="reserved">function</span>(step) {
|
176
|
var objRef = window.movieLoop;
|
177
|
var increment = objRef.frameIncrement;
|
178
|
<span class="reserved">if</span> (step) increment = step; //arg passed in overrides default
|
179
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.frameIsLoading) {
|
180
|
<span class="comment"> // play() will continue calling nextFrame, so that </span>
|
181
|
<span class="comment"> // nextFrame() will continually be called at a regular interval, until the current frame is loaded </span>
|
182
|
<span class="comment"> // The 'bug' is that if the user clicks the next button rapidly, subsequent requests will be ignored</span>
|
183
|
<span class="comment"> // while the initial frame is loading. This needs to be resolved.</span>
|
184
|
objRef.setFrame(objRef.timestampIndex + increment);
|
185
|
}
|
186
|
}
|
187
|
|
188
|
<span class="comment">/**
|
189
|
* Listener fucntion to set the start and end frames based on the
|
190
|
* firstFrame and maxFrames property values.
|
191
|
* <span class="attrib">@param</span> objRef pointer to this object
|
192
|
*/</span>
|
193
|
<span class="reserved">this</span>.setFrameLimits = <span class="reserved">function</span>(objRef) {
|
194
|
var timestampList = objRef.model.timestampList;
|
195
|
<span class="comment"> //timestampList.firstFrame = objRef.firstFrame; //set these from a widget, or config</span>
|
196
|
var firstFrame = objRef.model.getParam(<span class="literal">"firstFrame"</span>);
|
197
|
var lastFrame = firstFrame+objRef.maxFrames;
|
198
|
<span class="reserved">if</span> (lastFrame > timestampList.childNodes.length) lastFrame = timestampList.childNodes.length-1;
|
199
|
objRef.model.setParam(<span class="literal">"lastFrame"</span>,lastFrame);
|
200
|
timestampList.childNodes[firstFrame].setAttribute(<span class="literal">"current"</span>,<span class="literal">"1"</span>);
|
201
|
}
|
202
|
<span class="reserved">this</span>.model.addFirstListener(<span class="literal">"refresh"</span>,<span class="reserved">this</span>.setFrameLimits,<span class="reserved">this</span>);
|
203
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"firstFrame"</span>,<span class="reserved">this</span>.setFrameLimits,<span class="reserved">this</span>);
|
204
|
|
205
|
<span class="comment">/**
|
206
|
* Resets the frame index to the firstFrame property
|
207
|
* <span class="attrib">@param</span> objRef pointer to this object
|
208
|
*/</span>
|
209
|
<span class="reserved">this</span>.reset = <span class="reserved">function</span>(objRef) {
|
210
|
objRef.pause();
|
211
|
objRef.setFrame(objRef.model.getParam(<span class="literal">"firstFrame"</span>));
|
212
|
}
|
213
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"loadModel"</span>,<span class="reserved">this</span>.reset,<span class="reserved">this</span>);
|
214
|
|
215
|
<span class="comment">/**
|
216
|
* initialize the movie loop. This only happens at the first bbox event,
|
217
|
* which shows us that the map is loaded.
|
218
|
*/</span>
|
219
|
<span class="reserved">this</span>.init = <span class="reserved">function</span>(objRef) {
|
220
|
<span class="comment"> //TBD: this is an ugly workaround because we do not have an event that</span>
|
221
|
<span class="comment"> // tells us when the OL map finished loading. </span>
|
222
|
<span class="reserved">if</span> (!objRef.initialized) {
|
223
|
objRef.initialized = true;
|
224
|
objRef.reset(objRef);
|
225
|
}
|
226
|
}
|
227
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"bbox"</span>, <span class="reserved">this</span>.init, <span class="reserved">this</span>);
|
228
|
|
229
|
<span class="comment">/**
|
230
|
* set the initialized state of the movie loop to false
|
231
|
*/</span>
|
232
|
<span class="reserved">this</span>.uninit = <span class="reserved">function</span>(objRef) {
|
233
|
objRef.initialized = false;
|
234
|
}
|
235
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"newModel"</span>, <span class="reserved">this</span>.uninit, <span class="reserved">this</span>);
|
236
|
|
237
|
<span class="comment">/**
|
238
|
* Starts the movie loop playing by using a JavaScript timer.
|
239
|
*/</span>
|
240
|
<span class="reserved">this</span>.play = <span class="reserved">function</span>() {
|
241
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.isRunning) {
|
242
|
<span class="reserved">this</span>.movieTimer = setInterval(<span class="literal">'window.movieLoop.nextFrame()'</span>,<span class="reserved">this</span>.delay);
|
243
|
<span class="reserved">this</span>.isRunning = true;
|
244
|
}
|
245
|
}
|
246
|
|
247
|
<span class="comment">/**
|
248
|
* Stops the JavaScript movie loop timer.
|
249
|
*/</span>
|
250
|
<span class="reserved">this</span>.pause = <span class="reserved">function</span>() {
|
251
|
<span class="reserved">this</span>.isRunning = false;
|
252
|
clearInterval(<span class="reserved">this</span>.movieTimer);
|
253
|
}
|
254
|
|
255
|
<span class="comment">/**
|
256
|
* Stops the JavaScript movie loop timer and sets the index back to the first
|
257
|
* frame.
|
258
|
*/</span>
|
259
|
<span class="reserved">this</span>.stop = <span class="reserved">function</span>() {
|
260
|
<span class="reserved">this</span>.pause();
|
261
|
<span class="reserved">this</span>.reset(<span class="reserved">this</span>);
|
262
|
}
|
263
|
|
264
|
<span class="comment">/**
|
265
|
* A "stopLoop" event listener to call the stop method
|
266
|
* <span class="attrib">@param</span> objRef pointer to this object
|
267
|
*/</span>
|
268
|
<span class="reserved">this</span>.stopListener = <span class="reserved">function</span>(objRef) {
|
269
|
objRef.stop();
|
270
|
}
|
271
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"stopLoop"</span>,<span class="reserved">this</span>.stopListener,<span class="reserved">this</span>);
|
272
|
|
273
|
|
274
|
}
|
275
|
|
276
|
</pre>
|
277
|
<hr>
|
278
|
|
279
|
|
280
|
|
281
|
<!-- ========== START OF NAVBAR ========== -->
|
282
|
<a name="navbar_top"><!-- --></a>
|
283
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
284
|
<tr>
|
285
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
286
|
<a name="navbar_top_firstrow"><!-- --></a>
|
287
|
<table border="0" cellpadding="0" cellspacing="3">
|
288
|
<tr align="center" valign="top">
|
289
|
|
290
|
|
291
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
292
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
293
|
|
294
|
|
295
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
296
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
297
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
298
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
299
|
</tr>
|
300
|
</table>
|
301
|
</td>
|
302
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
303
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
304
|
</td>
|
305
|
</tr>
|
306
|
|
307
|
<tr>
|
308
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
309
|
PREV
|
310
|
NEXT</font></td>
|
311
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
312
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
313
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
314
|
|
315
|
<script>
|
316
|
<!--
|
317
|
if(window==top) {
|
318
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
319
|
}
|
320
|
//-->
|
321
|
</script>
|
322
|
<noscript>
|
323
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
324
|
</noscript>
|
325
|
</font></td>
|
326
|
</tr>
|
327
|
</table>
|
328
|
<!-- =========== END OF NAVBAR =========== -->
|
329
|
|
330
|
<hr>
|
331
|
<font size="-1">
|
332
|
|
333
|
</font>
|
334
|
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
|
335
|
</body>
|
336
|
</html>
|