-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.xml
More file actions
2877 lines (2480 loc) · 81.3 KB
/
Copy pathplot.xml
File metadata and controls
2877 lines (2480 loc) · 81.3 KB
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px"
width="512px" height="512px"
viewBox="-256 -256 512 512"
xml:space="preserve"
contentScriptType="text/javascript"
scriptImplementation="browser"
>
<defs>
<script type="text/javascript" xlink:href="js/test.js" />
<script type="text/javascript">
/********************************************************************
Notes on delete operator
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator
JavaScript basically has two scopes for variables: global and local.
Variables assigned outside of a function are global, and variables
assigned inside of a function, using the var keyword, are local
(not rocket surgery). However, if you leave the var keyword off,
it assigns a global variable, regardless of where it’s declared.
http://opensoul.org/2008/9/4/the-importance-of-var-in-javascript
Trimming a string on JavaScript (TODO)
http://blog.stevenlevithan.com/archives/faster-trim-javascript
********************************************************************/
/********************************************************************
TODO LIST
Fix the rest of TODO
Check to make sure that division doesn't result in:
divide by zero
number too small resulting in zero
Consider tracking how many points we are using per plot and reducing that number (if possible)
Consider reducing quality when plotting or dragging to speed things up
********************************************************************/
/********************************************************************
Constants
********************************************************************/
//Colors
var GREEN = top.GREEN;
var RED = top.RED;
var BLACK = top.BLACK;
var GREY_BACK = top.GREY_BACK;
var LIGHTGREY = top.LIGHTGREY;
var GREY = top.GREY;
var DIMGREY = top.DIMGREY;
// Window size
var WINDOW_WIDTH = 512;
var WINDOW_HEIGHT = 512;
// Initial Zoom and Scale
var INITIAL_SCALE_UNIT = 32;
var INITIAL_EDGE_VALUE = 8;
// Links to namespaces and document
var XMLNS = "http://www.w3.org/2000/svg";
var ROOT = document.documentElement;
//we can't zoom in more than 56 times due to the size limit of the numbers
var MAX_ZOOM_LEVEL = 56;
var TOLERANCE = 0.0000000001
var ROUND_PRECISION = 7;
//var H = .00000000001; //smaller -> more precise
// TODO: One character global var???? perhaps something more descriptive
// Various modes supported
var DRAG_MODE = 0
var INTERSECT_MODE = 1;
var ZERO_MODE = 2;
var MAX_MODE = 3;
var MIN_MODE = 4;
var TRACE_MODE = 5
var TICKS_COUNT = 8;
/***************************************************
switches to enable/disable features
******************************************************/
var ZOOMING_ANIMATION_DEFAULT = true;
var zoomingAnimation = ZOOMING_ANIMATION_DEFAULT;
var TRACE_MULTIPLE_DEFAULT = true;
var traceMultiple = TRACE_MULTIPLE_DEFAULT;
var IZMM_POINT_DEFAULT = true;
var izmmPoint = IZMM_POINT_DEFAULT;
var LAST_POINT_DEFUALT = true;
var lastPoint = LAST_POINT_DEFUALT;
var SHOW_TOOLBAR_DEFAULT = true;
var showToolbar = SHOW_TOOLBAR_DEFAULT;
var SHOW_NAVIGATION_TOOLS_DEFAULT = true;
var showNavigationTools = SHOW_NAVIGATION_TOOLS_DEFAULT;
var SHOW_MOUSE_POSITION_DEFAULT = true;
var showMousePosition = SHOW_MOUSE_POSITION_DEFAULT;
var SHOW_AXIS_NUMBERS_DEFAULT = true;
var showAxisNumbers = SHOW_AXIS_NUMBERS_DEFAULT;
var SHOW_GRIDLINES_DEFAULT = true;
var showGridlines = SHOW_GRIDLINES_DEFAULT;
var SHOW_AXIS_DEFAULT = true;
var showAxis = SHOW_AXIS_DEFAULT;
var LINE_WIDTH_DEFUALT = 1;
var lineWidth = LINE_WIDTH_DEFUALT;
var SHOW_DIALOG_DEFAULT = true;
var dialogShowing = SHOW_DIALOG_DEFAULT;
/********************************************************************
STYLES FOR VARIOUS COMPONENTS
********************************************************************/
// Used when a line is created for plottin (setting color
// is done at a layer leverl and will not over-ride this if set
// here)
var PLOT_LINE_STYLE = {'stroke-width':1};
// Used in resetAllColors()
var GUI_RESET = {fill: LIGHTGREY};
// Used in setMode
var SET_MODE_SELECTED = {fill: DIMGREY};
// used in drawBoxGrab(evt)
var DRAG_BOX_STYLE = {stroke: "black", "stroke-width": 1, "stroke-dasharray": "2,2"};
var INVISIBLE = {"display": "none"};
var VISIBLE = {"display": "inline"};
/********************************************************************
Allows HTML doc access to various internal functions
********************************************************************/
top.graph = graph;
top.unplot = unplot;
top.getCenter = getCenter;
top.moveBox = moveBox;
top.updateColor = updateColor;
top.toggleVisibility = toggleVisibility;
top.getFuncObjs = getFuncObjs;
top.getValueToPixelScale = getValueToPixelScale;
top.plotPointObj = plotPointObj;
top.unplotTable = unplotTable;
top.toggleLayer = toggleLayer;
top.changeLineWidth = changeLineWidth;
top.toggleExtras = toggleExtras;
top.restoreDefaults = restoreDefaults;
top.getOffset = getOffset;
top.setInit = setInit;
top.print = print;
//top.plotPointArray = plotPointArray;
function print() {
toggleLayer('toolbar',false);
toggleLayer('nav_tools',false);
toggleLayer('mouse_pos',false);
assignAttr(ROOT, {
"onmousedown":null,
"onmousemove":null,
"onmouseup":null,
cursor:"default"});
}
function setInit(vArray){
valueToPixelScale = parseFloat(vArray[2]);
pixelToValueScale = parseFloat(1/valueToPixelScale);
offsetX = parseFloat(vArray[3]);
offsetY = parseFloat(vArray[4]);
var x = parseFloat(vArray[0]);
var y = parseFloat(vArray[1]);
setMinMax(x,y);
moveBox(x+offsetX,y+offsetY);
}
//given: centerX in pixel, centerY in pixel, VtoPScale as scale, givenOffsetX in pixel, givenOffsetY in pixel
//return Xmin Ymin Xmax Ymax in value
function setMinMax(x, y) {
curXMin = (x-WINDOW_WIDTH/2+offsetX) / valueToPixelScale;
curXMax = (x+WINDOW_WIDTH/2+offsetX) / valueToPixelScale;
curYMin = -(y+WINDOW_HEIGHT/2+offsetY) / valueToPixelScale;
curYMax = -(y-WINDOW_HEIGHT/2+offsetY) / valueToPixelScale;
}
function getOffset(){
return [offsetX, offsetY];
}
function getValueToPixelScale() {
return valueToPixelScale;
}
function getFuncObjs() {
return curFuncObjs;
}
// TODO THIS IS FOR FIREBUG CONSOLE ONLY (REMOVE ON PRODUCTION)
top.setFBConsole = setFBConsole;
/********************************************************************
Internal Global Variables
********************************************************************/
// TODO REMOVE ON PRODUCTION
var DEBUG_FLAG = false;
// TODO INCREMENT THIS DURING DEBUG ONLY TO KEEP TRACK OF ERROR STATES
var errorCounter = 0;
// Tracking Mouse Dragging
// TODO Initial values?
var dragging;
var lastX;
var lastY;
//addon point storage
var addonLast = [];
// Lower and Upper Bound of Domain (x)
var curXMin = -WINDOW_WIDTH/2; //in value, but we need to adjust by the origin to find the true value
var curXMax = WINDOW_WIDTH/2;
var absXMax = 0;
var absXMin = 0;
var curYMin = -WINDOW_HEIGHT/2;
var curYMax = WINDOW_HEIGHT/2;
var absYMax = 0;
var absYMin = 0;
var offsetX = 0; // for each zoom in, offset to the origin to avoid the limitation in svg canvas
var offsetY = 0;
// Coordinates beyond this limit are not graphed
var SVG_Canvas_Limit = Math.pow(10, 6)-1;
// Contains all the layers. Associative array
var layers = new Array();
//Contains all the children of layers['plots']
//Each element is a group containing a series of Circle
// that represents ONE WHOLE function.
var plots = new Array();
var curFuncObjs = null;
// Collection of GUI elements
var guiElements = new Array();
//number ticks lists
var xNumList = [];
var yNumList = [];
var currentMode = 0;
// Track Scaling (currently affects drawing of circles)
var pixelToValueScale = INITIAL_SCALE_UNIT;
var valueToPixelScale = INITIAL_SCALE_UNIT;
var current_Zoom_Level = 0;
var traceArray = [];
//Used fro animated zooming
var curCenter = new Array();
var animateTimer = 128;
var isZooming = false;
// Used by tableUtil.js
var tablePlots = new Array();
var tableObj = new Array();
/********************************************************************
Entry-point call
********************************************************************/
init(ROOT);
/********************************************************************
Helper
TODO: Adjust zooming
********************************************************************/
// Assigns mouse event attributes to the document
function init(R) {
createLayers();
createGUI();
setMode(0);
var viewBox = ROOT.getAttribute('viewBox');
var viewBoxArray = viewBox.split(' ');
var newCornerX = parseInt(viewBoxArray[0]);
var newCornerY = parseInt(viewBoxArray[1]);
translate(layers['guiElementsLayer'],newCornerX, newCornerY);
// curXMin = -INITIAL_EDGE_VALUE;
// curXMax = INITIAL_EDGE_VALUE;
// curYMin = -INITIAL_EDGE_VALUE;
// curYMax = INITIAL_EDGE_VALUE;
// valueToPixelScale = INITIAL_SCALE_UNIT;
// pixelToValueScale = 1/INITIAL_SCALE_UNIT;
// moveBox(0, 0);
var urlvars = top.getURLVars();
//use url variables or use initial values here;
if(urlvars['w'])
var initialize = urlvars['w'];
else
var initialize = [0,0,32,0,0];
if(urlvars['f0']) {
var j = 0;
for(i in urlvars){
if(i != 'w' && i != 'print' && i != 'sep'){
top.addEquation(urlvars[i]['t']);
var key = urlvars[i]['t']+"_eq"+j;
if(urlvars[i]['t'] == 'polar')
top.toggleTabs(top.document.getElementById('polar'));
if(urlvars[i]['t'] == 'param'){
top.toggleTabs(top.document.getElementById('parametric'));
var fs = urlvars[i]['f'].split(';');
top.document.getElementById(key).value = fs[0];
top.document.getElementById(key+'_y').value = fs[1];
}else{
top.document.getElementById(key).value = urlvars[i]['f'];
}
if(urlvars[i]['t'] != 'fx'){
top.document.getElementById(key+'_start').value = urlvars[i]['s'];
top.document.getElementById(key+'_end').value = urlvars[i]['e'];
}
top.document.getElementById('colorbox'+key).style.backgroundColor = urlvars[i]['c'];
top.changeColor(key,urlvars[i]['c'].substring(1));
if(urlvars[i]['v'] == 'false')
top.toggleVisibilityHandler(key+'_visi');
j++;
}
}
if(!urlvars['sep'])
top.plotSeparate = false;
top.generate_graph();
top.plotSeparate = true;
}
else {
// TODO Something magical
top.addEquation('fx');
top.addEquation('fx');
}
setInit(initialize);
}
/*****************************************************************
SVG tools
******************************************************************/
function objectCopy(oldobj) {
for (myvar in oldobj) {
this[myvar] = oldobj[myvar];
}
}
function translate(elem, xPos, yPos) {
elem.setAttribute('transform', "translate("+xPos+","+yPos+")");
}
function getMouseXValue(evt) {
return pixelToValue(valueToPixel(curXMin) + evt.clientX);
}
function getMouseYValue(evt) {
return pixelToValue(valueToPixel(curYMax) - evt.clientY);
}
//Limits number text 'num' to have 'lim' significant figures if the text of num is longer than 'len'
function limitNumberText(num, len, lim) {
if (num.toString().length > len) {
if (num < 0) {
return num.toExponential(lim-1);
}
if (num > 0) {
return num.toExponential(lim);
}
}
return num;
}
function createLayer(name, appendTo) {
var newLayer = document.createElementNS(XMLNS,"g");
layers[name] = newLayer;
appendTo.appendChild(newLayer);
}
function toggleLayer(name, checked) {
var displayStyle;
if (checked) {
displayStyle = VISIBLE;
}
else {
displayStyle = INVISIBLE;
}
switch (name) {
case 'toolbar':
assignAttr(layers['modeControls'], displayStyle);
break;
case 'nav_tools':
assignAttr(layers['navigationControls'], displayStyle);
break;
case 'mouse_pos':
assignAttr(guiElements['xMouseValue'], displayStyle);
assignAttr(guiElements['yMouseValue'], displayStyle);
break;
case 'labels':
assignAttr(layers['xNumbers'], displayStyle);
assignAttr(layers['yNumbers'], displayStyle);
break;
case 'grid_lines':
assignAttr(guiElements['grids'], displayStyle);
break;
case 'axis':
assignAttr(layers['axisLayer'], displayStyle);
break;
default:
break;
}
}
function createLayers() {
createLayer('backgroundLayer',ROOT);
createLayer('axisLayer',ROOT);
createLayer('plots',ROOT);
createLayer('xNumbers',ROOT);
createLayer('yNumbers',ROOT);
createLayer('addons',ROOT);
createLayer('guiElementsLayer',ROOT);
createLayer('drawBoxLayer',layers['guiElementsLayer']);
createLayer('navigationControls',layers['guiElementsLayer']);
createLayer('modeControls',layers['guiElementsLayer']);
createLayer('modeControlsText',layers['modeControls']);
}
// Creates a layer to graph on
function createPlotLayer(plotID) {
// If the layer exists, removes it
if (plots[plotID] != undefined) {
layers['plots'].removeChild(plots[plotID]);
}
// Create a new layer to work with
plots[plotID] = document.createElementNS(XMLNS, "g");
// User should do "layers['plots'].appendChild(plots[plotID]);"
// Have to append later
return plots[plotID];
}
function removeAllPlots() {
for (var i in curFuncObjs) {
unplot(i);
}
}
function unplot(key) {
// TODO Optimize this - I believe jQuery (whether we use it for SVG or not) has a feature
// that allows you to remove all elements of a type? Maybe worth a look
// TODO MORE CHECKING ON THE KEY
addonRemoveAll();
if (curFuncObjs != null) {
if (curFuncObjs[key] != null) {
if (curFuncObjs[key].fn != "") {
if (key in plots) {
layers['plots'].removeChild(plots[key]);
delete plots[key];
}
}
if (curFuncObjs[key].xFunc != null)
delete curFuncObjs[key].xFunc;
if (curFuncObjs[key].yFunc != null)
delete curFuncObjs[key].yFunc;
delete curFuncObjs[key];
}
}
}
function showDialog(text) {
if (dialogShowing) {
guiElements['guiDialogTextNode'].nodeValue = text;
assignAttr(guiElements['guiDialogText'], VISIBLE);
assignAttr(guiElements['guiDialogBox'], VISIBLE);
}
}
function hideDialog() {
if (dialogShowing) {
assignAttr(guiElements['guiDialogText'], INVISIBLE);
assignAttr(guiElements['guiDialogBox'], INVISIBLE);
}
}
function changeLineWidth(width) {
lineWidth = width;
replot();
}
function toggleExtras(name, checked) {
switch (name) {
case 'zoom_anim':
zoomingAnimation = checked;
break;
case 'multiple_trace':
traceMultiple = checked;
break;
case 'mmzi_point':
izmmPoint = checked;
break;
case 'keep_last_trace':
lastPoint = checked;
addonRemoveAll();
break;
case 'help_dialog':
dialogShowing = checked;
break;
default:
break;
}
}
function restoreDefaults() {
var displayStyle = VISIBLE;
assignAttr(layers['modeControls'], displayStyle);
assignAttr(layers['navigationControls'], displayStyle);
assignAttr(guiElements['xMouseValue'], displayStyle);
assignAttr(guiElements['yMouseValue'], displayStyle);
assignAttr(layers['xNumbers'], displayStyle);
assignAttr(layers['yNumbers'], displayStyle);
assignAttr(guiElements['grids'], displayStyle);
assignAttr(layers['axisLayer'], displayStyle);
zoomingAnimation = ZOOMING_ANIMATION_DEFAULT;
traceMultiple = TRACE_MULTIPLE_DEFAULT;
izmmPoint = IZMM_POINT_DEFAULT;
lastPoint = LAST_POINT_DEFUALT;
showToolbar = SHOW_TOOLBAR_DEFAULT;
showNavigationTools = SHOW_NAVIGATION_TOOLS_DEFAULT;
showMousePosition = SHOW_MOUSE_POSITION_DEFAULT;
showAxisNumbers = SHOW_AXIS_NUMBERS_DEFAULT;
showGridlines = SHOW_GRIDLINES_DEFAULT;
showAxis = SHOW_AXIS_DEFAULT;
dialogShowing = SHOW_DIALOG_DEFAULT;
top.plotSeparate = true;
lineWidth = LINE_WIDTH_DEFUALT;
replot();
top.resetAdvanced();
}
/********************************************************************
Create GUI elements
TODO: Adjust position of X and Y value
********************************************************************/
function createGUI() {
// Create GUI elements
var xAxis = document.createElementNS(XMLNS,"line");
var yAxis = document.createElementNS(XMLNS,"line");
var xMouseValue = document.createElementNS(XMLNS,"text");
var yMouseValue = document.createElementNS(XMLNS,"text");
var guiDialogBox = document.createElementNS(XMLNS,"rect");
var guiDialogText = document.createElementNS(XMLNS,"text");
var guiDialogTextProperties = document.createElementNS(XMLNS,"tspan");
var guiResetBox = document.createElementNS(XMLNS,"rect");
var guiResetText = document.createElementNS(XMLNS,"text");
var guiResetTextProperties = document.createElementNS(XMLNS,"tspan");
var guiOriginBox = document.createElementNS(XMLNS,"rect");
var guiOriginText = document.createElementNS(XMLNS,"text");
var guiOriginTextProperties = document.createElementNS(XMLNS,"tspan");
var guiZoomInBox = document.createElementNS(XMLNS,"rect");
var guiZoomInPlusHoriz = document.createElementNS(XMLNS,"rect");
var guiZoomInPlusVert = document.createElementNS(XMLNS,"rect");
var guiZoomOutBox = document.createElementNS(XMLNS,"rect");
var guiZoomOutMinus = document.createElementNS(XMLNS,"rect");
var guiNavigationTray = document.createElementNS(XMLNS,"rect");
var guiGrabBox = document.createElementNS(XMLNS,"rect");
var guiGrabText = document.createElementNS(XMLNS,"text");
var guiGrabTextProperties = document.createElementNS(XMLNS,"tspan");
var guiIntersectBox = document.createElementNS(XMLNS,"rect");
var guiIntersectText = document.createElementNS(XMLNS,"text");
var guiIntersectTextProperties = document.createElementNS(XMLNS,"tspan");
var guiZeroBox = document.createElementNS(XMLNS,"rect");
var guiZeroText = document.createElementNS(XMLNS,"text");
var guiZeroTextProperties = document.createElementNS(XMLNS,"tspan");
var guiMaxBox = document.createElementNS(XMLNS,"rect");
var guiMaxText = document.createElementNS(XMLNS,"text");
var guiMaxTextProperties = document.createElementNS(XMLNS,"tspan");
var guiMinBox = document.createElementNS(XMLNS,"rect");
var guiMinText = document.createElementNS(XMLNS,"text");
var guiMinTextProperties = document.createElementNS(XMLNS,"tspan");
var guiTraceBox = document.createElementNS(XMLNS,"rect");
var guiTraceText = document.createElementNS(XMLNS,"text");
var guiTraceTextProperties = document.createElementNS(XMLNS,"tspan");
// Assign atrributes
assignAttr(xAxis, { id:"xAxis",
x1:-WINDOW_WIDTH/2,
y1:0,
x2:WINDOW_WIDTH/2,
y2:0,
stroke:DIMGREY,
"stroke-width":2});
assignAttr(yAxis, { id:"yAxis",
x1:0,
y1:-WINDOW_HEIGHT/2,
x2:0,
y2:WINDOW_HEIGHT/2,
stroke:DIMGREY,
"stroke-width":2});
assignAttr(xMouseValue, { id:"xMouseValue",
x:"10",
y:"480",
fill:GREY,
"font-size":13,
"font-family":"sans-serif"});
assignAttr(yMouseValue, { id:"yMouseValue",
x:"10",
y:"500",
fill:GREY,
"font-size":13,
"font-family":"sans-serif"});
assignAttr(guiDialogBox, { id:"guiDialogBox",
x:96,
y:10,
rx:5,
ry:5,
height:20,
width:320,
fill:LIGHTGREY,
display:"none"});
assignAttr(guiDialogText, { id:"guiDialogText",
x:256,
y:24,
"text-anchor":"middle",
"font-size":11,
display:"none"});
assignAttr(guiDialogTextProperties, { id:"guiDialogTextProperties",
"font-family":"sans-serif",
fill:"black"});
assignAttr(guiResetBox, { id:"guiResetBox",
x:10,
y:10,
rx:5,
ry:5,
height:20,
width:40,
fill:GREY,
"onmouseover":"fillBlack(guiElements['guiResetTextProperties']);showDialog('Reset window view')",
"onmouseout":"fillWhite(guiElements['guiResetTextProperties']);hideDialog()",
"onclick":"reset()"});
assignAttr(guiResetText, { id:"guiResetText",
x:13,
y:24,
"font-size":12,
"onmouseover":"fillBlack(guiElements['guiResetTextProperties']);showDialog('Reset window view')",
"onmouseout":"fillWhite(guiElements['guiResetTextProperties']);hideDialog()",
"onclick":"reset()"});
assignAttr(guiResetTextProperties, { id:"guiResetTextProperties",
"font-family":"sans-serif",
"font-weight":"bold",
fill:"white"});
assignAttr(guiOriginBox, { id:"guiOriginBox",
x:10,
y:35,
rx:5,
ry:5,
height:20,
width:40,
fill:GREY,
"onmouseover":"fillBlack(guiElements['guiOriginTextProperties']);showDialog('Center origin')",
"onmouseout":"fillWhite(guiElements['guiOriginTextProperties']);hideDialog()",
"onclick":"moveToOrigin()"});
assignAttr(guiOriginText, { id:"guiOriginText",
x:12,
y:49,
"font-size":12,
"onmouseover":"fillBlack(guiElements['guiOriginTextProperties']);showDialog('Center origin')",
"onmouseout":"fillWhite(guiElements['guiOriginTextProperties']);hideDialog()",
"onclick":"moveToOrigin()"});
assignAttr(guiOriginTextProperties, { id:"guiOriginTextProperties",
"font-family":"sans-serif",
"font-weight":"bold",
fill:"white"});
assignAttr(guiZoomInBox, { id:"guiZoomInBox",
x:20,
y:60,
rx:5,
ry:5,
height:20,
width:20,
fill:GREY,
"onmouseover":"fillBlack(guiElements['guiZoomInPlusHoriz']);fillBlack(guiElements['guiZoomInPlusVert']);showDialog('Zoom in')",
"onmouseout":"fillWhite(guiElements['guiZoomInPlusHoriz']);fillWhite(guiElements['guiZoomInPlusVert']);hideDialog()",
"onclick":"zoomIn()"});
assignAttr(guiZoomInPlusHoriz, { id:"guiZoomInPlusHoriz",
x:24,
y:69,
height:2,
width:12,
fill:"white",
"onmouseover":"fillBlack(guiElements['guiZoomInPlusHoriz']);fillBlack(guiElements['guiZoomInPlusVert']);showDialog('Zoom in')",
"onmouseout":"fillWhite(guiElements['guiZoomInPlusHoriz']);fillWhite(guiElements['guiZoomInPlusVert']);hideDialog()",
"onclick":"zoomIn()"});
assignAttr(guiZoomInPlusVert, { id:"guiZoomInPlusVert",
x:29,
y:64,
height:12,
width:2,
fill:"white",
"onmouseover":"fillBlack(guiElements['guiZoomInPlusHoriz']);fillBlack(guiElements['guiZoomInPlusVert']);showDialog('Zoom in')",
"onmouseout":"fillWhite(guiElements['guiZoomInPlusHoriz']);fillWhite(guiElements['guiZoomInPlusVert']);hideDialog()",
"onclick":"zoomIn()"});
assignAttr(guiZoomOutBox, { id:"guiZoomOutBox",
x:20,
y:85,
rx:5,
ry:5,
height:20,
width:20,
fill:GREY,
"onmouseover":"fillBlack(guiElements['guiZoomOutMinus']);showDialog('Zoom out')",
"onmouseout":"fillWhite(guiElements['guiZoomOutMinus']);hideDialog()",
"onclick":"zoomOut()"});
assignAttr(guiZoomOutMinus, { id:"guiZoomOutMinus",
x:24,
y:94,
height:2,
width:12,
fill:"white",
"onmouseover":"fillBlack(guiElements['guiZoomOutMinus']);showDialog('Zoom out')",
"onmouseout":"fillWhite(guiElements['guiZoomOutMinus']);hideDialog()",
"onclick":"zoomOut()"});
assignAttr(guiNavigationTray, { id:"guiNavigationTray",
x:473,
y:10,
rx:5,
ry:5,
height:178, //increase 4 pixels
width:30,
fill:LIGHTGREY
});
assignAttr(guiGrabBox, { id:"guiGrabBox",
x:474,
y:15,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":"strokeBlack(guiElements['handIcon']);showDialog('Drag the graph to change the current view')",
"onmouseout":"strokeWhite(guiElements['handIcon']);hideDialog()",
onclick:'setMode(0)'
});
assignAttr(guiGrabText, { id:"guiGrabText",
x:469,
y:34,
height:28,
width:28,
'font-size':14
});
assignAttr(guiGrabTextProperties, { id:"guiGrabTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(guiIntersectBox, { id:"guiIntersectBox",
x:474,
y:43,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":"fillBlack(guiElements['intersectIcon']);strokeBlack(guiElements['intersectIcon']);showDialog('Select bounds to find the intersection of the selected equations')",
"onmouseout":"fillWhite(guiElements['intersectIcon']);strokeWhite(guiElements['intersectIcon']);hideDialog()",
onclick:'setMode(1)'
});
assignAttr(guiIntersectText, { id:"guiIntersectText",
x:469,
y:62,
height:28,
width:28,
'font-size':14
});
assignAttr(guiIntersectTextProperties, { id:"guiIntersectTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(guiZeroBox, { id:"guiZeroBox",
x:474,
y:71,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":"fillBlack(guiElements['zeroIcon']);strokeBlack(guiElements['zeroIcon']);showDialog('Select bounds to find the zero of the selected equation')",
"onmouseout":"fillWhite(guiElements['zeroIcon']);strokeWhite(guiElements['zeroIcon']);hideDialog()",
onclick:'setMode(2)'
});
assignAttr(guiZeroText, { id:"guiZeroText",
x:469,
y:90,
height:28,
width:28,
'font-size':14
});
assignAttr(guiZeroTextProperties, { id:"guiZeroTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(guiMaxBox, { id:"guiMaxBox",
x:474,
y:99,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":
"fillBlack(guiElements['maxDot']);strokeBlack(guiElements['maxDot']);strokeBlack(guiElements['maxLine']);showDialog('Select bounds to find the max of the selected equation')",
"onmouseout":
"fillWhite(guiElements['maxDot']);strokeWhite(guiElements['maxDot']);strokeWhite(guiElements['maxLine']);hideDialog()",
onclick:'setMode(3)'
});
assignAttr(guiMaxText, { id:"guiMaxText",
x:469,
y:118,
height:28,
width:28,
'font-size':14
});
assignAttr(guiMaxTextProperties, { id:"guiMaxTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(guiMinBox, { id:"guiMinBox",
x:474,
y:127,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":
"fillBlack(guiElements['minDot']);strokeBlack(guiElements['minDot']);strokeBlack(guiElements['minLine']);showDialog('Select bounds to find the min of the selected equation')",
"onmouseout":
"fillWhite(guiElements['minDot']);strokeWhite(guiElements['minDot']);strokeWhite(guiElements['minLine']);hideDialog()",
onclick:'setMode(4)'
});
assignAttr(guiMinText, { id:"guiMinText",
x:469,
y:146,
height:28,
width:28,
'font-size':14
});
assignAttr(guiMinTextProperties, { id:"guiMinTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(guiTraceBox, { id:"guiTraceBox",
x:474,
y:155,
height:28,
width:28,
fill:LIGHTGREY,
"onmouseover":
"fillBlack(guiElements['traceDot']);strokeBlack(guiElements['traceDot']);strokeBlack(guiElements['traceLine']);showDialog('Click to find the y value of the nearest plot')",
"onmouseout":
"fillWhite(guiElements['traceDot']);strokeWhite(guiElements['traceDot']);strokeWhite(guiElements['traceLine']);hideDialog()",
onclick:'setMode(5)'
});
assignAttr(guiTraceText, { id:"guiTraceText",
x:469,
y:174,
height:28,
width:28,
'font-size':14
});
assignAttr(guiTraceTextProperties, { id:"guiTraceTextProperties",
'font-family':'sans-serif',
'font-weight':'bold',
'text-anchor':'end',
fill:GREY
});
assignAttr(layers['navigationControls'], {
onmouseover:'navigationControlsMouseover()',
onmouseout:'navigationControlsMouseout()'
});
assignAttr(layers['modeControls'], {
onmouseover:'modeControlsMouseover()',
onmouseout:'modeControlsMouseout()'
});
assignAttr(layers['modeControlsText'], INVISIBLE);
var xText = document.createTextNode('x: 0');
xMouseValue.appendChild(xText);
var yText = document.createTextNode('y: 0');
yMouseValue.appendChild(yText);
var guiDialogTextNode = document.createTextNode('Dialog');
guiDialogTextProperties.appendChild(guiDialogTextNode);
guiDialogText.appendChild(guiDialogTextProperties);
var guiResetTextNode = document.createTextNode('Reset');
guiResetTextProperties.appendChild(guiResetTextNode);
guiResetText.appendChild(guiResetTextProperties);
var guiOriginTextNode = document.createTextNode('Origin');
guiOriginTextProperties.appendChild(guiOriginTextNode);
guiOriginText.appendChild(guiOriginTextProperties);
var guiGrabTextNode = document.createTextNode('Drag');
guiGrabTextProperties.appendChild(guiGrabTextNode);
guiGrabText.appendChild(guiGrabTextProperties);
var guiIntersectTextNode = document.createTextNode('Intersect');
guiIntersectTextProperties.appendChild(guiIntersectTextNode);
guiIntersectText.appendChild(guiIntersectTextProperties);
var guiZeroTextNode = document.createTextNode('Zero');
guiZeroTextProperties.appendChild(guiZeroTextNode);
guiZeroText.appendChild(guiZeroTextProperties);