-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsgl.js
13331 lines (10816 loc) · 376 KB
/
jsgl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @fileOverview Declaration of JSGL package namespaces.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @namespace Root namespace for JSGL.
*/
jsgl={
/**
* @namespace Holds functionality related to JSGL elements.
*/
elements: {
/**
* @namespace Holds DOM presenters for JSGL elements.
*/
dom: {}
},
/**
* @namespace Classes related to <code>Panel</code> object.
*/
panel: {},
path: {},
/**
* @namespace Classes related to stroke manipulation and rendering.
*/
stroke: {},
/**
* @namespace Claases related to filling, i.e. manipulating and rendering of fill.
*/
fill:{},
/**
* @namespace Utility classes and useful sugar code.
*/
util: {}
};;/**
* @fileOverview Detect information about user's web browser.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* Table of properties capturing information about user's web browser.
* @class
* @constant
* @memberOf jsgl.util
*/
jsgl.util.BrowserInfo=(function() {
__browserinfo=0;
document.write("<!--[if vml]><script type='text/javascript'>__browserinfo++;</script><![endif]-->");
if(document.implementation&&(document.implementation.hasFeature("org.w3c.svg", "1.0") ||
document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG", "1.1") ||
document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))) __browserinfo+=2;
document.write("<!--[if IE]><script type='text/javascript'>__browserinfo+=4;</script><![endif]-->");
document.write("<!--[if IE 5.5000]><script type='text/javascript'>__browserinfo+=8;</script><![endif]-->");
document.write("<!--[if lte IE 6]><script type='text/javascript'>__browserinfo+=32;</script><![endif]-->");
document.write("<!--[if lte IE 7]><script type='text/javascript'>__browserinfo+=64;</script><![endif]-->");
if(typeof(window.event)!="undefined") __browserinfo+=16;
/**
* Determines whether the browser support Vector Markup Language (VML).
* @type boolean
*/
this.supportsVml=!!(__browserinfo & 1);
/**
* Determines whether the browser support Scalable Vector Graphics (SVG).
* @type boolean
*/
this.supportsSvg=!!(__browserinfo & 2);
/**
* Determines whether the browser is MSIE.
* @type boolean
*/
this.isMSIE=!!(__browserinfo & 4);
/**
* Determines whether the browser is MSIE 5.5.
* @type boolean
*/
this.isMSIE55=!!(__browserinfo & 8);
/**
* Determines whether the browser supports window.event
* @type boolean
*/
this.usesWindowEvent=!!(__browserinfo & 16);
/**
* Determines whether the browser is MSIE <= 6.
* @type boolean
*/
this.isMSIElte6 = !!(__browserinfo & 32);
/**
* Determines whether the browser is MSIE <= 7.
* @type boolean
*/
this.isMSIElte7 = !!(__browserinfo && 64);
/**
* Determines whether the browser is Opera-like.
* @type boolean
*/
this.isOpera = !this.isMSIE && this.usesWindowEvent;
return this;
})();;/**
* @fileOverview Sugar code for object inheritance, cloning, and working with
* functions.
* @author Tomas Rehorek
* @since version 1.0
*/
Function.prototype.jsglExtend = function(ancestor) {
function F() {};
F.prototype = ancestor.prototype;
this.prototype = new F();
this.prototype.constructor=this;
this.base = F.prototype;
this.base.constructor = ancestor;
}
Number.prototype.jsglVmlize = function() {
return Math.round(this*1000);
}
jsgl.util.delegate = function(object, method) {
return function() {
return method.apply(object, arguments);
}
}
/**
* @deprecated
*/
jsgl.cloneObject=function(obj) {
if(obj == null || typeof(obj) != 'object')
return obj;
var temp = new obj.constructor();
for(var key in obj)
temp[key] = jsgl.cloneObject(obj[key]);
return temp;
}
jsgl.util.clone=function(obj)
{
if(obj == null || typeof(obj) != "object")
{
return obj;
}
var temp = new obj.constructor();
for(var key in obj)
{
temp[key] = jsgl.util.clone(obj[key]);
}
return temp;
}
if(navigator.userAgent.indexOf("MSIE 5.0") > 0)
{
Function.prototype.call = function(obj)
{
obj.__fnc = this;
var __args = "";
for(var i=1;i<arguments.length;i++)
{
__args += (i == 1 ? "" : ",") + "arguments[" + i + "]";
}
return eval("obj.__fnc(" + __args + ")");
}
Function.prototype.apply = function(obj,args)
{
obj.__fnc = this;
var __args = "";
for(var i=0;i<args.length;i++)
{
__args += (i == 0 ? "" : ",") + "args[" + i + "]"
};
return eval("obj.__fnc(" + __args + ")");
}
};/**
* @fileOverview Implementation of <code>jsgl.util.ArrayList</code>.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @class Simple ArrayList implementation.
* @constructor
* @description Creates an instance of <code>jsgl.util.ArrayList</code>.
* @since version 1.0
*/
jsgl.util.ArrayList = function() {
/**
* The internal javascript array object to hold the elements.
* @type array
* @private
*/
this.items = [];
/**
* Internal size counter.
* @type number
* @private
*/
this.count = 0;
}
/**
* @description Appends an item at the end of the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} item The item to be appended.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.add = function(item) {
if(typeof(item)=='undefined') return;
this.insertAt(item,this.count);
}
/**
* @description Removes items in the ArrayList with respect to provided filter
* function. If no filter function is provided, all the elements are removed
* from the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {function} filter The filtering function. The item is removed from
* the list if filter(item) is truthy.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.clear = function(filter)
{
var f = filter || jsgl.util.ArrayList.DEFAULT_CLEAR_FILTER;
var j = 0;
for(var i=0; i<this.count; i++)
{
if(f(this.items[i])) delete this.items[i];
else
{
if(i!=j)
{
this.items[j] = this.items[i];
delete this.items[i];
}
j++;
}
}
this.count = j;
}
/**
* @description Tests whether a given item is present in the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} item The item to be tested for presence.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.contains = function(item) {
for(var i=0; i<this.count; i++)
{
if(this.items[i]===item) return true;
}
return false;
}
/**
* @description Gets the number of items that are currently contained in the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @returns {number}
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.getCount = function() {
return this.count;
}
/**
* @description Default filter function to be used by the <code>clear()</code>
* method if no filter is provided.
* @private
* @static
* @field
* @memberOf jsgl.util.ArrayList
* @since version 1.0
*/
jsgl.util.ArrayList.DEFAULT_CLEAR_FILTER = function() {
return true;
}
/**
* @description Gets an item present at the specified index in the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {number} index Index of the item to be returned, starting from 0.
* @returns {value}
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.get = function(index) {
if((index >= 0) && (index < this.count)) return this.items[index];
else return null;
}
/**
* @description Sets an item at specified index. If any item is already present
* at the index, it will be replaced.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} item The item to be placed at the index.
* @param {number} index Index of the item to be set.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.setAt = function(item, index) {
if(typeof(item)=='undefined' || index<0) return;
this.items[index] = item;
if(index >= this.count) this.count = index + 1;
}
/**
* @description Inserts and item at the specified index. All the elements starting
* at the index up to the end of the list are shifted right.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} item The item to be inserted into the list.
* @param {number} index Index where the item shall be inserted at.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.insertAt = function(item, index) {
if(typeof(item)=='undefined' || index<0) return;
for(var i=this.count; i>index; i--)
{
this.items[i] = this.items[i-1];
}
for(var i=this.count; i<index; i++)
{
this.items[i] = null;
}
this.items[index] = item;
if(index > this.count) this.count = index + 1;
else this.count ++;
}
/**
* @description Removes an item at the specified index from the list. The rest
* of the list is shifted left after the element is removed.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} index The index of the item to be removed.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.removeAt = function(index) {
if(index<0 || index>=this.count) return;
for(var i=index+1;i<this.count;i++)
{
this.items[i-1] = this.items[i];
}
this.items[this.count-1]=null;
this.count--;
}
/**
* @description Removes all the items that are equal to <code>item</code> from
* the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {value} item The item whose all occurances will be removed from the list.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.remove = function(item) {
this.clear(function(_item) { return _item === item });
}
/**
* @description Reverses the ordering of items in the list.
* @public
* @methodOf jsgl.util.ArrayList#
* @since version 2.0
*/
jsgl.util.ArrayList.prototype.reverse = function() {
this.items.reverse();
}
/**
* @description Sorts the list according to a given comparator function. If no
* comparator is given, default comparison is used.
* @public
* @methodOf jsgl.util.ArrayList#
* @param {function(a,b)} The comparator function to be used for sorting.
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.sort = function(comparator)
{
var cmp = function(a,b)
{
var result = (comparator || jsgl.util.ArrayList.DEFAULT_COMPARATOR)(a,b);
return (typeof(result) == "number" ? result : 0)
}
var c = true;
while(c)
{
c = false;
for(var i=1;i<this.count;i++)
{
if(cmp(this.items[i-1],this.items[i]) < 0)
{
c = true;
var temp = this.items[i-1];
this.items[i-1] = this.items[i];
this.items[i] = temp;
}
}
}
}
/**
* @description Default comparator function to be used by the <code>sort()</code>
* method if no comparator is provided.
* @private
* @static
* @field
* @memberOf jsgl.util.ArrayList
* @since version 1.0
*/
jsgl.util.ArrayList.DEFAULT_COMPARATOR = function(a,b) {
return b - a;
}
/**
* @description Returns the ArrayList as string.
* @public
* @methodOf jsgl.util.ArrayList#
* @returns string
* @since version 1.0
*/
jsgl.util.ArrayList.prototype.toString = function(index) {
var itemsStr = "";
for(var i=0; i<this.count; i++)
{
if(i!=0) itemsStr += ",";
itemsStr += i + ":" + this.items[i];
}
return "ArrayList(count=" + this.count + ",items=[" + itemsStr + "])";
}
;jsgl.util.SortedList=function(comparator)
{
if(comparator) this.comparator = comparator;
this.items=[];
this.count=0;
}
/* Default comparator. */
jsgl.util.SortedList.prototype.comparator = function(a,b)
{
if(b > a) return 1;
if(b < a) return -1;
return 0;
}
jsgl.util.SortedList.prototype.setComparator = function(comparator)
{
if(comparator)
{
this.comparator = comparator;
}
else
{
delete this.comparator;
}
}
// prepsat na binarni hledani!
jsgl.util.SortedList.prototype.add = function(item)
{
var pos;
if(this.count == 0)
{
pos = 0;
}
else
{
var i=this.count;
while((i > 0) && (this.comparator(this.items[i-1], item) < 0))
{
i--;
}
pos = i;
for(var i=this.count; i>=pos; i--)
{
this.items[i+1] = this.items[i];
}
}
this.items[pos] = item;
this.count++;
}
jsgl.util.SortedList.prototype.contains = function(item)
{
for(var i=0; i<this.count; i++)
{
if(this.items[i]==item) return true;
}
return false;
}
jsgl.util.SortedList.prototype.get = function(index)
{
return this.items[index];
}
jsgl.util.SortedList.prototype.getCount = function()
{
return this.count;
}
jsgl.util.SortedList.prototype.remove = function(obj)
{
if(this.count==0) return;
for(var i=0; i<this.count; i++)
{
if(this.items[i] == obj)
{
for(var j=i; j<this.count-1; j++)
{
this.items[j]=this.items[j+1];
}
this.items[this.count-1] = null;
this.count--;
break; // remove one element at most
}
}
}
jsgl.util.SortedList.prototype.removeAt = function(index)
{
if(index < 0 || index >= this.count) return;
for(var i=index; i<this.count-1; i++)
{
this.items[i]=this.items[i+1];
}
this.items[this.count-1] = null;
this.count--;
}
jsgl.util.SortedList.prototype.toString = function()
{
var itemsString = "";
for(var i=0;i<this.count;i++)
{
if(i!=0) itemsString += ",";
itemsString += this.items[i];
}
return "SortedList(count=" + this.count + ",items=[" + itemsString + "])";
}
;/**
* @fileOverview <code>jsgl.util.Queue</code> class implementation.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @class Simple FIFO structure implementation.
* @constructor
* @description Creates new instance of <code>jsgl.util.Queue</code>.
* @since version 1.0
*/
jsgl.util.Queue = function() {
/**
* Head element of the queue.
* @type value
* @private
*/
this.first = null;
/**
* Tailing element of the queue.
* @type value
* @private
*/
this.last = null;
/**
* Number of elements in the queue.
* @type number
* @private
*/
this.count = 0;
}
/**
* @description Adds an item to the end of the queue.
* @methodOf jsgl.util.Queue#
* @param {value} item The item to enqueued.
* @since version 1.0
*/
jsgl.util.Queue.prototype.enqueue = function(item) {
if(this.first == null) {
this.first = this.last = { item : item, next : null };
}
else this.last.next = this.last = { item : item, next : null };
this.count ++;
}
/**
* @description Removes and returns the first element from the head of the queue.
* If the queue is empty, <code>null</code> is returned.
* @methodOf jsgl.util.Queue#
* @returns value
* @since version 1.0
*/
jsgl.util.Queue.prototype.dequeue = function() {
var result = this.first && this.first.item;
if(this.first != null) {
if(this.last == this.first) this.last = null;
this.first = this.first.next;
this.count --;
}
return result;
}
/**
* @description Returns the first element from the head of the queue, keeping
* the item in the queue. If there are no elements in the Queue,
* <code>null</code> is returned.
* @methodOf jsgl.util.Queue#
* @returns value
* @since version 1.0
*/
jsgl.util.Queue.prototype.peek = function() {
return this.first && this.first.item;
}
/**
* @description Gets the number of elements that are currently present in the queue.
* @methodOf jsgl.util.Queue#
* @returns number
* @since version 1.0
*/
jsgl.util.Queue.prototype.getCount = function() {
return this.count;
}
/**
* @description Returns string representation of the queue.
* @methodOf jsgl.util.Queue#
* @returns string
* @since version 1.0
*/
jsgl.util.Queue.prototype.toString = function() {
var itemsStr = "";
obj = this.first;
while(obj)
{
if(obj != this.first) itemsStr += ",";
itemsStr += obj.item;
obj = obj.next;
}
return "Queue(count=" + this.getCount() + ",items=[" + itemsStr + "])";
}
;/**
* @fileOverview <code>jsgl.util.CommandQueue</code> class implementation.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @class Simple command queue implementation. Command queues are important for
* handling events. The command queue prevents hazardeous states by executing
* update operations invoked by individual events in FIFO manner. If an event
* leads to changes in the list of listeners, it will not happen so before all
* peer listeners have been executed.
* @extends jsgl.util.Queue
* @constructor
* @description Creates new instance of <code>jsgl.util.CommandQueue</code>
* @since version 1.0
*/
jsgl.util.CommandQueue = function() {
jsgl.util.Queue.call(this);
/**
* Determines whether the command queue is currently stopped.
* @type boolean
* @private
*/
this.stopped = false;
}
jsgl.util.CommandQueue.jsglExtend(jsgl.util.Queue);
/**
* @description Stops the command queue.
* @methodOf jsgl.util.CommandQueue#
* @since version 1.0
*/
jsgl.util.CommandQueue.prototype.stop = function() {
this.stopped = true;
}
/**
* @description Runs the command queue.
* @methodOf jsgl.util.CommandQueue#
* @since version 1.0
*/
jsgl.util.CommandQueue.prototype.go = function() {
while(this.peek() != null) {
this.dequeue();
}
this.stopped = false;
}
/**
* @description Adds new subroutine at the end of the command queue.
* @methodOf jsgl.util.CommandQueue#
* @param {function()} item The subroutine to be added at the end of the queue.
* @since version 1.0
*/
jsgl.util.CommandQueue.prototype.enqueue = function(item) {
if(this.stopped) jsgl.util.Queue.prototype.enqueue.call(this,item);
else item();
}
/**
* @description Executes the first subroutine at the head of the command queue
* and removes it from the queue.
* @methodOf jsgl.util.CommandQueue#
* @since version 1.0
*/
jsgl.util.CommandQueue.prototype.dequeue = function() {
jsgl.util.Queue.prototype.dequeue.call(this)();
}
;/**
* @fileOverview Implementation of <code>jsgl.util.EventRaiser</code> class.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @class EventRaiser class for MVC architecture.
* @constructor
* @description Instantiates new <code>jsgl.util.EventRaiser</code>.
* @since version 1.0
*/
jsgl.util.EventRaiser=function() {
/**
* The ArrayList of registered listeners.
* @type jsgl.util.ArrayList
* @private
*/
this.listeners = new jsgl.util.ArrayList();
/**
* CommandQueue used for executing listeners. It avoids potential problems
* caused by registering/unregistering during sequential execution of listeners.
* @type jsgl.util.CommandQueue
* @private
*/
this.commandQueue = new jsgl.util.CommandQueue();
}
/**
* @description Registers a function listening to the event.
* @public
* @methodOf jsgl.util.EventRaiser#
* @param {function} listener The listener function. {@link jsgl.util.delegate}
* may be used to provide method of a specific object.
* @since version 1.0
*/
jsgl.util.EventRaiser.prototype.registerListener = function(listener) {
if(!listener) return;
this.commandQueue.enqueue(jsgl.util.delegate(this,function()
{
this.listeners.add(listener);
}));
}
/**
* @description Unregisters a function listening to the event.
* @public
* @methodOf jsgl.util.EventRaiser#
* @param {function} listener The function that is currently listening to events
* and shall not listen anymore.
* @since version 1.0
*/
jsgl.util.EventRaiser.prototype.unregisterListener = function(listener) {
if(!listener) return;
this.commandQueue.enqueue(jsgl.util.delegate(this,function()
{
this.listeners.remove(listener);
}));
}
/**
* @description Raises an event. This results in sequential execution of all
* the registered listeners.
* @public
* @methodOf jsgl.util.EventRaiser#
* @param {value} eventAtgs Event arguments that shall be passed to the listeners.
* @since version 1.0
*/
jsgl.util.EventRaiser.prototype.raiseEvent = function(eventArgs) {
this.commandQueue.enqueue(jsgl.util.delegate(this,function()
{
this.commandQueue.stop();
for(var i=0;i<this.listeners.getCount();i++)
{
this.listeners.get(i)(eventArgs);
}
this.commandQueue.go();
}));
}
;/**
* @fileOverview Sugar class <code>jsgl.util.Property</code> implementation.
* @author Tomas Rehorek
* @since version 1.0
*/
/**
* @class Sugar property-wrapping class for simplification of MVC architecture
* building.
* @constructor
* @param {value} value The initial value of the property.
* @description Creates new instance of <code>jsgl.elements.Property</code>.
* @since version 1.0
*/
jsgl.util.Property=function(value) {
/**
* The value to be stored by the Property object.
* @type value
* @private
*/
this.value = value;
/**
* The event raiser object to inform listening objects about value changes.
* @type jsgl.util.EventRaiser
* @private
*/
this.eventRaiser=new jsgl.util.EventRaiser();
}
/**
* @description Sets the value and informs the listeners about new value.
* @methodOf jsgl.util.Property#
* @param {value} value The new value.
* @since version 1.0
*/
jsgl.util.Property.prototype.setValue=function(value) {
if(this.value != value)
{
this.value = value;
this.eventRaiser.raiseEvent(value);
}
}
/**
* @description Gets the current value.
* @methodOf jsgl.util.Property#
* @returns value
* @since version 1.0
*/
jsgl.util.Property.prototype.getValue=function() {
return this.value;
}
/**
* @description Register new listener to be informed about value changes.
* @methodOf jsgl.util.Property#
* @param {function(value)} listener The new listener to be added to the chain.
* @since version 1.0
*/
jsgl.util.Property.prototype.registerChangeListener=function(listener) {
this.eventRaiser.registerListener(listener);
}
/**
* @description Unregister already-present listener from listening to Property's
* value changes.
* @methodOf jsgl.util.Property#
* @param {function(value)} listener The listener to be removed from the chain.
* @since version 1.0
*/
jsgl.util.Property.prototype.unregisterChangeListener=function(listener) {
this.eventRaiser.unregisterListener(listener);
};jsgl.util.StructuredProperty=function(value)
{
/* parent constructor call */
jsgl.util.Property.call(this,value);
this.internalChangeListener=jsgl.util.delegate(this.eventRaiser,this.eventRaiser.raiseEvent);
}
jsgl.util.StructuredProperty.jsglExtend(jsgl.util.Property);
jsgl.util.StructuredProperty.prototype.getInternalChangeListener=function()
{
return this.internalChangeListener;
};jsgl.util.singletonInstanceGetter=function()
{
if(!this.instance)
{
this.instance=new this();
}
return this.instance;
};/**
* @fileOverview Implementation of <code>jsgl.util.Animator</code> utility class.
* @author Tomas Rehorek
* @since version 2.0
*/
/**
* @class Utility class for creating animations. Although it is especially useful
* for programming graphics, its scope goes beyond graphics applications.
* @constructor
* @description Creates new instance of <code>jsgl.util.Animator</code> class.
* @since version 2.0
*/
jsgl.util.Animator = function() {
/**
* The start value of the animation's control parameter.
* @type number
* @private
*/
this.startValue = 0;