/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
1 by Suren A. Chilingaryan
Initial import
1
function GRAPH(id, selid) {
2
    this.config = null;
3
    this.window = null;
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
4
    this.source = null;
1 by Suren A. Chilingaryan
Initial import
5
    this.exporter = null;
6
    this.selector = document.getElementById(selid);
7
    this.frame = document.getElementById(id);
8
    
9
    this.start_xy = [ 0, 0 ];
10
    this.margins = { left: 0, top: 0, right: 0, bottom: 0 };
11
    this.crop_margins = { left: 0, top: 0, right: 0, bottom: 0 };
12
    this.allWidth = 10;
13
    this.allHeight = 10;
14
    
15
    this.height = 0;
16
    this.width = 0;
233 by Suren A. Chilingaryan
Fix enabling/disabling of vertical cropping
17
    this.plot_mode = -1;
1 by Suren A. Chilingaryan
Initial import
18
    
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
19
    this.idevice = isiDevice();   
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
20
    this.startX = 0; 
21
    this.startY = 0;
22
    this.curX = 0;  
23
    this.curY = 0;
24
    this.startValuesSet = 0;    
25
    this.swiping = 0;
26
    this.fader = 0;
27
    this.throwLeft = 0;
28
    this.test = 0;
29
    this.onlyLegend = 0;
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
30
    
31
    if (this.idevice) {
32
        this.fader = new Animator().addSubject(new NumericalStyleSubject($('graph_image_div'), 'opacity', 1, 0.13));        
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
33
    }
34
    
1 by Suren A. Chilingaryan
Initial import
35
    if (this.frame) {
36
	this.img = this.frame.getElementsByTagName('img')[0];
37
    } else {
38
	this.frame = null;
39
    }
40
    
41
/*    
42
    Event.observe(id,'click',this.MouseStart);
43
    Event.observe(id,'MouseMove', this.MouseStart);
44
    Event.observe(id,'MouseDown', this.MouseStart);
45
*/
46
47
    this.crop = null;
97 by Suren A. Chilingaryan
Suport for custom buttons in JS cropper
48
    this.extraButtons = new Array();
1 by Suren A. Chilingaryan
Initial import
49
50
    if (this.img) {
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
51
	     Event.observe(this.img, 'load', this.Configure.bindAsEventListener(this));	
1 by Suren A. Chilingaryan
Initial import
52
    } else {
53
	if (this.frame) alert('The "img" element is not found within specified block "' + id + '"');
54
	else alert('GRAPH is not able to locate specified ("' + id + '") element');
55
    }
56
57
    this.LegendCloseBind = this.LegendClose.bindAsEventListener( this );
58
    this.LegendCloseHelperBind = eventCanceler.bindAsEventListener();
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
59
60
	// Handling no data cases
61
    if (!isIE()) {
62
	this.img.addEventListener("DOMMouseScroll", this.onLocalScroll(this), false);
63
    }
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
64
    
65
    this.onload_message = 0;
66
    
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
67
    this.img.onmousewheel =  this.onLocalScroll(this);
68
    this.img.ondblclick = this.onLocalDblClick(this);
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
69
    this.img.onload = this.onImageLoad(this);
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
70
71
}
72
73
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
74
GRAPH.prototype.onImageLoad = function(self) {
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
75
    return function() {
76
	adei.SetSuccessStatus(self.onload_message?self.onload_message:translate("Done"));  
77
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
78
	if(self.fader){
79
	    self.AnimatorEffects(self,2);   
80
	} 
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
81
    }
1 by Suren A. Chilingaryan
Initial import
82
}
83
97 by Suren A. Chilingaryan
Suport for custom buttons in JS cropper
84
GRAPH.prototype.RegisterCropperButton = function(info) {
85
    info.onClick = this.onButtonClick(this, info);
86
    this.extraButtons.push(info);
87
}
88
89
1 by Suren A. Chilingaryan
Initial import
90
GRAPH.prototype.AttachConfig = function(config) {
91
    this.config = config;
92
//    config.Register(this);
93
}
94
95
GRAPH.prototype.Clear = function() {
96
    if (this.crop) {
97
	this.crop.clear();
98
    }
99
}
100
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
101
GRAPH.prototype.PointerToY = function(axis_num, pos) {
102
    if (this.ylog[axis_num]) {
103
	var res = (Math.log(this.ymax[axis_num]) - (Math.log(this.ymax[axis_num]) - Math.log(this.ymin[axis_num]))*(pos - this.margins.top) / this.real_height) / Math.LN10;
104
	return Math.pow(10, res);
105
    } else {
106
	var res = this.ymax[axis_num] - (this.ymax[axis_num] - this.ymin[axis_num])*(pos - this.margins.top) / this.real_height;
107
	return res;
108
    }
109
}
1 by Suren A. Chilingaryan
Initial import
110
111
GRAPH.prototype.onEndCrop = function (self) {
112
    return function( coords, dimensions ) {
113
	if (self.window) {
114
	    if ((dimensions.width < self.allWidth)&&(dimensions.height < self.allHeight)) {
143 by Suren A. Chilingaryan
Support for dates prior to Jan 01, 1970
115
		self.window.SetCustomWindow();
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
116
117
		for (var i = 0; i < self.axis.length; i++) {
143 by Suren A. Chilingaryan
Support for dates prior to Jan 01, 1970
118
		    self.window.SetCustomAxis(self.axis[i]);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
119
		}
1 by Suren A. Chilingaryan
Initial import
120
    	    } else if (dimensions.height < self.allHeight) {
121
		var xmin = self.xmin + (self.xmax - self.xmin)*(coords.x1 - self.margins.left) / self.real_width;
122
		var xmax = self.xmin + (self.xmax - self.xmin)*(coords.x2 - self.margins.left) / self.real_width;
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
123
		self.window.SetCustomWindow(xmin, xmax);
124
		
125
		for (var i = 0; i < self.axis.length; i++) {
143 by Suren A. Chilingaryan
Support for dates prior to Jan 01, 1970
126
		    self.window.SetCustomAxis(self.axis[i]);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
127
		}
1 by Suren A. Chilingaryan
Initial import
128
	    } else {
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
129
		for (var i = 0; i < self.axis.length; i++) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
130
		    //var ymin = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(coords.y2 - self.margins.top) / self.real_height;
131
	    	    //var ymax = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(coords.y1 - self.margins.top) / self.real_height;
132
133
		    var ymin = self.PointerToY(i, coords.y2);
134
		    var ymax = self.PointerToY(i, coords.y1);
135
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
136
		    self.window.SetCustomAxis(self.axis[i], ymin, ymax);
137
		}
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
138
139
	        if (dimensions.width >= self.allWidth) {
140
		    var xmin = self.xmin + (self.xmax - self.xmin)*(coords.x1 - self.margins.left) / self.real_width;
141
		    var xmax = self.xmin + (self.xmax - self.xmin)*(coords.x2 - self.margins.left) / self.real_width;
142
		    self.window.SetCustomWindow(xmin, xmax);
143
		}
1 by Suren A. Chilingaryan
Initial import
144
	    }
145
	}
146
    }
147
}
148
149
GRAPH.prototype.onCancelCrop = function (self) {
150
    return function() {
151
	if (self.window) {
143 by Suren A. Chilingaryan
Support for dates prior to Jan 01, 1970
152
	    self.window.SetCustomWindow();
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
153
	    for (var i = 0; i < self.axis.length; i++) {
143 by Suren A. Chilingaryan
Support for dates prior to Jan 01, 1970
154
		self.window.SetCustomAxis(self.axis[i]);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
155
	    }
1 by Suren A. Chilingaryan
Initial import
156
	}
252 by Suren A. Chilingaryan
Better notification mechanism in frontend, provide page geometry in props, allow to set custom properties without triggering update, support onload callback in UpdateDIV call
157
	if (adei.updater) 
158
	    adei.updater.Notify("SelectionCancel");
1 by Suren A. Chilingaryan
Initial import
159
    }
160
}
161
162
GRAPH.prototype.onApply = function (self) {
163
    return function ( coords, dimensions ) {
164
	self.window.Apply();
165
	self.crop.clear();
166
    }
167
}
168
169
GRAPH.prototype.onSave = function (self) {
170
    return function ( coords, dimensions ) {
171
	if (self.exporter) 
172
	    self.exporter.Export(true);
173
	else
174
	    adeiReportError("Data Exporter is not registered", "GRAPH");
175
    }
176
}
177
97 by Suren A. Chilingaryan
Suport for custom buttons in JS cropper
178
GRAPH.prototype.onButtonClick = function(self, info) {
179
    return function (corrds, dimensions) {
180
	var from = self.config.sel_from;
181
	var to = self.config.sel_to;
182
183
	eval('info.object.' + info.callback + '(from, to)');
184
    }
185
}
186
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
187
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
188
189
GRAPH.prototype.GetYAxisNumber = function(mouse_x) {
190
    if (mouse_x > this.margins.left) return 0;
191
    var dist = this.margins.left - mouse_x;
192
    var axis = Math.floor(dist / this.axis_size);
193
    if (axis >= this.axis.length) axis = this.axis.length - 1;
194
    return axis;
195
}
196
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
197
GRAPH.prototype.ProcessMouseScroll = function ( delta, mouse_x, mouse_y ) {
198
	switch (adei.key) {
199
	    case 72:	// h
200
		if (this.source) {
201
		    if (delta > 0)
202
			this.config.history.Back();
203
		    else
204
			this.config.history.Forward();
205
		}
206
	    break;
207
	    case 83:	// s
208
		if (this.source) {
209
		    if (delta > 0)
210
			this.source.NextServer();
211
		    else
212
			this.source.PrevServer();
213
		}
214
	    break;
215
	    case 68:	// d
216
		if (this.source) {
217
		    if (delta > 0)
218
			this.source.NextDatabase();
219
		    else
220
			this.source.PrevDatabase();
221
		}
222
	    break;
223
	    case 71:	// g
224
		if (this.source) {
225
		    if (delta > 0)
226
			this.source.NextGroup();
227
		    else
228
			this.source.PrevGroup();
229
		}
230
	    break;
231
	    case 77:	// m
232
		if (this.source) {
233
		    if (delta > 0)
234
			this.source.NextMask();
235
		    else
236
			this.source.PrevMask();
237
		}
238
	    break;
239
	    case 73:	// i
240
		if (this.source) {
241
		    if (delta > 0)
242
			this.source.NextItem();
243
		    else
244
			this.source.PrevItem();
245
		}
246
	    break;
247
	    case 69:	// e
248
		alert('not supported');
249
		
250
		if (this.experiment) {
251
		    if (delta > 0)
252
			this.experiment.NextItem();
253
		    else
254
			this.experiment.PrevItem();
255
		}
256
	    break;
257
	    case 84:	// t
258
	    case 16:	// Shift
259
		// t - time move
260
		if (delta > 0)
261
		    this.window.MoveLeft();
262
		else if (delta < 0)
263
		    this.window.MoveRight();
264
	    break;
265
	    case 86:	// v
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
266
		if (delta > 0) {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
267
		    this.window.MoveDown();
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
268
		} else if (delta < 0) {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
269
		    this.window.MoveUp();
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
270
		}
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
271
	    break;
272
	    case 87:	// w
273
		if (delta > 0)
274
		    this.window.IncreaseWidth();
275
		else if (delta < 0)
276
		    this.window.DecreaseWidth();
277
		
278
	    break;
279
	    case 89:	// y
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
280
		for (var i = 0; i < this.axis.length; i++) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
281
//		    var y = this.ymax[i] - (this.ymax[i] - this.ymin[i])*(mouse_y - this.margins.top) / this.real_height;
282
		    var y = this.PointerToY(i, mouse_y);
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
283
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
284
		    if (delta > 0)
285
			this.window.YZoomOut(i, y);
286
		    else if (delta < 0)
287
			this.window.YZoomIn(i, y);
288
		}
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
289
		
290
	    break;
291
	    case 67:	// c
292
		if (delta > 0)
293
		    this.window.CenterZoomOut();
294
		else if (delta < 0)
295
		    this.window.CenterZoomIn();
296
		
297
	    break;
298
	    case 76:	// l
299
	    case 90:	// z
300
		x = adeiMathPreciseAdd(this.xmin, this.xsize*(mouse_x - this.margins.left) / this.real_width);
301
302
		if (delta > 0)
303
		    this.window.LocalZoomOut(x);
304
		else if (delta < 0)
305
		    this.window.LocalZoomIn(x);
306
		
307
	    break;
308
	    case false:
309
		if (mouse_y > (this.height - this.margins.bottom)) {
310
		    if (delta > 0)
311
			this.window.MoveLeft();
312
		    else if (delta < 0)
313
			this.window.MoveRight();
314
		} else if (mouse_x < this.margins.left) {
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
315
		    if (this.axis_size) {
316
		        var ai = this.GetYAxisNumber(mouse_x);
317
			if (delta > 0)
318
			    this.window.MoveDown(ai);
319
			else if (delta < 0)
320
			    this.window.MoveUp(ai);
321
		    } else {
322
			for (var ai = 0; ai < this.axis.length; ai++) {
323
			    if (delta > 0)
324
				this.window.MoveDown(ai);
325
			    else if (delta < 0)
326
				this.window.MoveUp(ai);
327
			}
328
		    }
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
329
		} else if ((mouse_y >= this.margins.top)&&(mouse_x <= (this.width - this.margins.right))) {
330
		    var x = adeiMathPreciseAdd(this.xmin, this.xsize*(mouse_x - this.margins.left) / this.real_width);
75 by Suren A. Chilingaryan
Omit from listings groups, databases, and servers what are not cached yet
331
		    
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
332
		    if (delta > 0)
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
333
			this.window.ZoomOut(x);
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
334
		    else if (delta < 0)
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
335
			this.window.ZoomIn(x);
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
336
		}
337
	    break;
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
338
//	    default:
339
//		  if(this.fader) this.fader.reverse();
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
340
	}
341
}
342
1 by Suren A. Chilingaryan
Initial import
343
GRAPH.prototype.onMouseScroll = function (self) {
344
    return function ( delta, point ) {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
345
	self.ProcessMouseScroll(delta, point.x, point.y);
1 by Suren A. Chilingaryan
Initial import
346
//	alert(adei.key);
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
347
//adeiMathPreciseAdd(self.xmin, self.xsize*(point.x - self.margins.left) / self.real_width),	
348
//	alert(mouse_x + "(" + self.real_width + ")");
349
350
    }
351
}
352
353
GRAPH.prototype.onLocalDblClick = function(self) {
354
    return function(ev) {
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
355
	self.window.ResetXY();
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
356
    }
357
}
358
359
GRAPH.prototype.onLocalScroll = function(self) {
360
    return function(ev) {
361
	switch (adei.key) {
362
	    case 83:	// s
363
	    case 68:	// d
364
		var delta = domGetScrollEventDelta(ev);
365
		self.ProcessMouseScroll(delta,0,0);
366
	    break;
367
	    case 71:	// g
368
	    case 67:	// c
369
	    case 76:	// l
370
	    case false:
371
		self.window.CenterZoomOut();
372
		// zoom out
373
	    break;
374
	}
1 by Suren A. Chilingaryan
Initial import
375
    }
376
}
377
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
378
GRAPH.prototype.onMouseMove = function (self) {
379
    return function ( point, dragging, resizing ) {
212 by Suren A. Chilingaryan
Integration of work of students with fixes
380
85 by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only)
381
//	if (self.config.GetModule() != "graph") return;
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
382
    
383
	if ((!point)||((point.x < self.margins.left)||(point.x > (self.width - self.margins.right)))||
384
	    ((point.y < self.margins.top)||(point.y > (self.height - self.margins.bottom)))) {
385
		adei.ClearStatus(self.mousepos_status_id);
386
		return;
387
	}
388
    
389
	var x = adeiMathPreciseAdd(self.xmin, self.xsize*(point.x - self.margins.left) / self.real_width);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
390
391
	var status = translate('Mouse cursor is at time: ') + adeiDateReadableFormat(x, self.xsize) + ", Y: ";
392
393
	for (var i = self.axis.length - 1; i>=0; i--) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
394
//	    var y = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(point.y - self.margins.top) / self.real_height;
395
            var y = self.PointerToY(i, point.y);
431 by Suren A. Chilingaryan
Handle really big but insignificantly changing values on Y-axis
396
397
            var precision = 2;
398
            while ((self.ymax[i].toPrecision(precision) == self.ymin[i].toPrecision(precision))&&(precision < 16)) precision++;
399
400
	    if ((precision > 8)&&(y > Math.pow(10, precision + 1))) y = Math.round(y);
401
	    else y = y.toPrecision(precision + 2);
402
403
	    status += "<span style=\"color: " + self.color[i] + "\">" + y + "</span>";
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
404
	    if (i) status += ", ";
405
	}
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
406
	
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
407
	self.mousepos_status_id = adei.ProposeStatus(status, 0);
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
408
    }
409
}
410
1 by Suren A. Chilingaryan
Initial import
411
412
413
GRAPH.prototype.LegendClose = function(self) {
414
    return function(ev) {
415
	if (self.legend) {
416
	    self.legend.Hide();
417
	    self.legend = null;
418
	}
419
	Event.stop(ev);
420
    }
421
}
422
423
GRAPH.prototype.ShowLegend = function (self, mouse_x, mouse_y) {
424
    return function(transport) {
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
425
/*	if (transport.responseText.charAt(0) == '{') {
1 by Suren A. Chilingaryan
Initial import
426
	    var json = transport.responseText.evalJSON(false);
427
    	    if (json.error) {
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
428
		adeiReportError(json.error);
1 by Suren A. Chilingaryan
Initial import
429
	    } else {
430
		var html = "";//"<h4>Legend</h4>""<div class=\"window_close\"></div><h4>Legend</h4>";
431
		if ((json.legend)&&(json.legend.length>0)) {
432
		    html+="<table><tr><th>ID</th><th>Name</th></tr>";
433
		    for (var i = 0; i < json.legend.length; i++) {
434
			var item = json.legend[i];
435
			html+="<tr><td>" + item.id + "</td><td>" + item.name + "</td></tr>";
436
		    }
437
		    html+="</table>";
438
		} else {
439
		    html+="<p>Nothing selected</p>";
440
		}
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
441
*/
442
		var html = transport.responseText;
1 by Suren A. Chilingaryan
Initial import
443
		
444
		if ((self.legend)&&(self.legend.CheckReusability())) {
445
		    self.legend.AlterContent(html);
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
446
		    adei.SetSuccessStatus("Legend is updated");
1 by Suren A. Chilingaryan
Initial import
447
		} else {
448
		    var legend = new DIALOG(self.LegendClose(self), "Legend", html, "legend");
449
		    legend.Show(self.frame, self.legend, mouse_x, mouse_y);
450
		    self.legend = legend;
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
451
		    
452
		    adei.ClearStatus(self.legend_status_id);
1 by Suren A. Chilingaryan
Initial import
453
		}
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
454
/*
1 by Suren A. Chilingaryan
Initial import
455
	    }
456
	} else {
457
	    // XML
458
	}
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
459
*/
1 by Suren A. Chilingaryan
Initial import
460
    }
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
461
1 by Suren A. Chilingaryan
Initial import
462
}
463
464
GRAPH.prototype.onClick = function (self) {
465
    return function ( ev, point ) {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
466
	if ((point.x < self.margins.left)||(point.x > (self.width - self.margins.right))) return;
467
	if ((point.y < self.margins.top)||(point.y > (self.height - self.margins.bottom))) return;
468
    
469
	var x = adeiMathPreciseAdd(self.xmin, self.xsize*(point.x - self.margins.left) / self.real_width);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
470
	
471
	var y = new Array();
472
	for (var i = 0; i < self.axis.length; i++) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
473
//	    y[i] = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(point.y - self.margins.top) / self.real_height;
474
            y[i] = self.PointerToY(i, point.y);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
475
	}
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
476
477
	switch (adei.key) {
478
	 case 67:	// c
479
	    self.window.Center(x,y);
480
	    return;
481
	 case 90:	// z
482
	    self.window.DeepZoom(x);
483
	    return;
484
	}
485
486
487
//	alert(adeiMathPreciseAdd(self.xmin, self.xsize*(point.x - self.margins.left) / self.real_width));
488
	var params = {
1 by Suren A. Chilingaryan
Initial import
489
	    xmin: self.xmin.toString(),
490
	    xmax: self.xmax.toString(),
491
	    ymin: self.ymin,
492
	    ymax: self.ymax,
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
493
	    x : x,
115 by Suren A. Chilingaryan
Further drawing improvements: legend, gaps, source tree
494
	    y : y,
495
	    xslt: "legend",
496
	    time_format: "text"
1 by Suren A. Chilingaryan
Initial import
497
	};
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
498
499
1 by Suren A. Chilingaryan
Initial import
500
//	alert(self.xmax + " - " + self.xmin + "(" + self.xsize + "): " + point.x + "\n");
501
	
231 by Suren A. Chilingaryan
Finish mergin RRDReader by Riku and few fixes for newer pecl-rrd
502
	if (adei.config.cfg.plot_mode == 0) {
503
	    self.legend_status_id = adei.SetStatus(translate("Loading legend..."), 0);
504
	    new Ajax.Request(adei.GetServiceURL("legend"), 
505
	    {
506
		method: 'post',
507
		requestHeaders: {Accept: 'application/json'},
508
		parameters: { props: self.config.GetJSON(params) },
509
		onSuccess: self.ShowLegend(self, ev.clientX, ev.clientY),
510
		onFailure: function() {
511
		    alert('GetLegend request is failed');
512
		}
513
	    });
514
	}
1 by Suren A. Chilingaryan
Initial import
515
    
516
	//updater.
517
    }
518
}
519
520
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
521
GRAPH.prototype.onDblClick = function(self) {
522
    return function (ev, point) {
523
	if (point.x < self.margins.left) {
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
524
	    if (self.axis_size) {
525
		var ai = self.GetYAxisNumber(point.x);
526
		self.window.ResetY(self.axis[ai]);
527
	    } else {
528
		self.window.ResetY();
529
	    }
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
530
	} else if (point.y > (self.height - self.margins.bottom)) {
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
531
	    self.window.ResetXY();
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
532
	}
533
    }
534
}
535
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
536
/**TouchStart sets startvalues
537
 * Saves the position of users finger
538
 */
539
GRAPH.prototype.onTouchStart = function(self){
540
  return function(e,pos){
541
    if(self.startValuesSet == 0)
542
    {
543
        self.startX = pos.x;
544
        self.startY = pos.y;        
545
        self.startValuesSet = 1;
546
    if(e.touches.length == 1){self.onlyLegend = 1;}
547
    }
548
    if(e.touches.length == 2){self.onlyLegend = 0;}
549
  }
550
}
551
552
/**onTouchMove 
553
 * 
554
 */
555
GRAPH.prototype.onTouchMove = function(self){
556
    return function(e,xpos){
557
      if(e.touches.length == 1)
558
      {
559
         self.swiping = 1;
560
         self.curX = xpos.x;
561
         self.curY = xpos.y;
562
         self.onlyLegend = 0;
563
      }
564
      if(e.touches.length>1){
565
        self.swiping = 0;
566
        self.onlyLegend = 0;
567
      }
568
      
569
      
570
    }
571
}
572
/**onTouchEnd
573
 * Does swipe, or show legend.
574
 */
575
GRAPH.prototype.onTouchEnd = function(self){
576
    return function(e){
577
        e.preventDefault();  
578
579
        self.startValuesSet=0;      
580
        if(self.swiping == 1){//Do swipemoving left & right & up & down
581
            var direction = self.getSwipeDirection(self);
582
            self.swiping = 0;
583
           // alert(direction);
584
            if(direction != 0)
585
            {    
212 by Suren A. Chilingaryan
Integration of work of students with fixes
586
              if(self.fader != 0) {
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
587
                self.AnimatorEffects(self,1);}
212 by Suren A. Chilingaryan
Integration of work of students with fixes
588
                self.window.Swipe(direction);
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
589
              //alert(direction);
590
              //self.window.Apply();
591
              //startValuesSet = 0;
592
            }
593
        }
594
        else if(self.onlyLegend === 1 && self.swiping === 0){
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
595
            var iphone = isiPhone();
596
            if(!iphone) {
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
597
                var x = adeiMathPreciseAdd(self.xmin, self.xsize*(self.startX - self.margins.left) / self.real_width);
598
                var y = new Array();
599
                for (var i = 0; i < self.axis.length; i++) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
600
//                    y[i] = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(self.startY - self.margins.top) / self.real_height;
601
                    y[i] = self.PointerToY(i, self.startY);
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
602
                }
603
                   
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
604
                    var params = {
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
605
                    xmin: self.xmin.toString(),
606
                    xmax: self.xmax.toString(),
607
                    ymin: self.ymin,
608
                    ymax: self.ymax,
609
                    x : x,
610
                    y : y,
611
                    xslt: "legend",
612
                    time_format: "text"
613
                };           
614
                self.legend_status_id = adei.SetStatus(translate("Loading legend..."), 0);
615
                new Ajax.Request(adei.GetServiceURL("legend"), 
616
                {
617
                    method: 'post',
618
                    requestHeaders: {Accept: 'application/json'},
619
                    parameters: { props: self.config.GetJSON(params) },
620
                    onSuccess: self.ShowLegend(self, self.startX, self.startY),
621
                    onFailure: function() {
622
                  alert('GetLegend request is failed');
623
                    }
624
                });
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
625
        	
626
		self.onlyLegend = 0;
627
          }
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
628
        }
629
     }
630
}
631
632
/**onGestureStart
633
 * When 2 fingers touch the screen.
634
 */
635
GRAPH.prototype.onGestureStart = function(self){
636
  return function(e){ 
637
    self.swiping = 0;
638
    self.onlyLegend = 0;
639
  }
640
  
641
}
642
/**onGestureMove
643
 * nothing yet
644
 */
645
GRAPH.prototype.onGestureMove = function(self){
646
  return function(e,scale){
647
648
  }
649
  
650
}
651
652
/**onGestureEnd
653
 * Zoom graph x or y
654
 */
655
GRAPH.prototype.onGestureEnd = function(self){
656
  return function(e,scale,angle){
657
658
      var gestureValues = new Object();
659
      gestureValues.x = adeiMathPreciseAdd(self.xmin, self.xsize*(self.startX - self.margins.left) / self.real_width);
660
     // alert(self.margins.left);
661
      gestureValues.marginsLeft = self.margins.left;
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
662
      gestureValues.device = self.idevice;
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
663
      gestureValues.y = new Array();
664
      for (var i = 0; i < self.axis.length; i++) {
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
665
//        gestureValues.y[i] = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(self.startY - self.margins.top) / self.real_height;        
666
            gestureValues.y[i] = self.PointerToY(i, self.startY);
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
667
      }
668
      if(self.fader != 0){self.AnimatorEffects(self,1);}
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
669
      gestureValues.scale = scale;
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
670
      gestureValues.startX = self.startX;
671
      self.window.PinchZoom(gestureValues);
672
      self.startValuesSet = 0;      
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
673
      self.window.Apply();      
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
674
  } 
675
}
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
676
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
677
GRAPH.prototype.onOrientationChange = function(self){
678
  return function(e){
210.1.1 by Suren A. Chilingaryan
Support of Appled devices by Toni Pirhonen
679
  	if(self.fader != 0){self.AnimatorEffects(self,1);}
680
  	self.window.Apply();
681
  }
682
}
683
684
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
685
/**Gets direction of Swipe gesture
686
 * When user swipes the screen with 1 finger, calculates heading and return an integer.
687
 * Return values:
688
 * 1 = Swipe left
689
 * 2 = Swipe Right
690
 * 3 = Swipe Up
691
 * 4 = Swipe Down 
692
 */
693
GRAPH.prototype.getSwipeDirection = function(self){
694
  var varianceX = 0;
695
  var varianceY = 0;
696
  var leftRight = 0;
697
  var upDown = 0;
698
  var percentX =  (self.real_width)/100;
699
  var percentY = (self.real_height)/100;
700
701
  if(self.startX > self.curX){
702
    varianceX = (self.startX-self.curX)/percentX - 20; 
703
    leftRight = 1;
704
    }
705
  else if(self.startX < self.curX){
706
    varianceX = (self.curX-self.startX)/percentX + 20; 
707
    leftRight = 2;
708
    }
709
  if(self.startY > self.curY){
710
    varianceY = (self.startY-self.curY)/percentY + 20; 
711
    upDown = 3;
712
    }
713
  else if(self.startY < self.curY){
714
    varianceY = (self.curY-self.startY)/percentY + 20;
715
    upDown = 4;
716
    }
717
    
718
  if(varianceX < 30 && varianceY < 30)
719
  {return 0;}  
720
  if(varianceX > varianceY)
721
  {
722
    return leftRight;
723
  }
724
  else if(varianceX < varianceY)
725
  {
726
    return upDown;
727
  }
728
729
  
730
}
731
732
/** Animatoreffects
733
 * Uses animator.js to animate graph opacity.
734
 */
735
GRAPH.prototype.AnimatorEffects = function(self,id){
736
  if(self.fader){
737
    switch(id){
738
      case 1:
739
        self.fader.play();
740
        break;
741
      case 2:
742
        self.fader.reverse();
743
        break;
744
      default:
745
        break;
746
    }
747
  }
748
}
749
750
1 by Suren A. Chilingaryan
Initial import
751
GRAPH.prototype.AttachWindow = function (window) {
752
    this.window = window;
753
    window.RegisterGraph(this);
754
}
755
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
756
GRAPH.prototype.AttachSource = function (source) {
757
    this.source = source;
758
}
759
1 by Suren A. Chilingaryan
Initial import
760
GRAPH.prototype.AttachExporter = function (exporter) {
761
    this.exporter = exporter;
762
}
763
764
GRAPH.prototype.SetMargins = function (l,t,r,b) {
765
    this.margins = { left: l, top: t, right: r, bottom: b };
766
    this.crop_margins = { left: l, top: t, right: r, bottom: b };
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
767
    if (this.crop) this.crop.setMargins(l, t, r, b);
1 by Suren A. Chilingaryan
Initial import
768
}
769
770
GRAPH.prototype.SetAllSizes = function (w,h) {
771
    this.allWidth = w;
772
    this.allHeight = h;
773
}
774
775
GRAPH.prototype.Prepare = function() {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
776
	/* Fixing IE6. Diff is non-zero only in IE6, however certain
777
	CSS settings could bring it to zero even in IE6. For example:
778
	html, body { width: 100%; } */
1 by Suren A. Chilingaryan
Initial import
779
    var diff = document.body.offsetWidth - windowGetWidth();
780
    if (diff > 0) {
781
	var new_size = this.frame.offsetWidth - diff;
782
	if (new_size > 0) {
783
	    this.config.SetupGeometry(new_size, this.frame.offsetHeight);
784
	    return;
785
	}
786
    }
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
787
1 by Suren A. Chilingaryan
Initial import
788
    this.config.SetupGeometry(this.frame);
789
}
790
212 by Suren A. Chilingaryan
Integration of work of students with fixes
791
GRAPH.prototype.ConfigureFunction = function(self) {
792
    return function () {
793
	return self.Configure();
794
    }
795
}
796
1 by Suren A. Chilingaryan
Initial import
797
GRAPH.prototype.Configure = function() {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
798
	    this.real_height = this.img.height - this.margins.top - this.margins.bottom;
799
	    this.real_width = this.img.width - this.margins.left - this.margins.right;
1 by Suren A. Chilingaryan
Initial import
800
	    
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
801
	    if (this.xsize) {
802
		var new_width = this.img.width;
803
		var new_height = this.img.height;
804
		
1 by Suren A. Chilingaryan
Initial import
805
		if (this.crop) {
212 by Suren A. Chilingaryan
Integration of work of students with fixes
806
		  if ((new_width != this.width)||(new_height != this.height)) {
1 by Suren A. Chilingaryan
Initial import
807
			this.width = new_width;
808
			this.height = new_height;
809
			this.crop.setParams();	// DS. this action slows evertything down after several steps
233 by Suren A. Chilingaryan
Fix enabling/disabling of vertical cropping
810
		  } 
811
		  if (adei.config.cfg.plot_mode != this.plot_mode) {
812
		    this.crop.setCropMode(((adei.config.cfg.plot_mode == 0)?true:false));
212 by Suren A. Chilingaryan
Integration of work of students with fixes
813
		  }
1 by Suren A. Chilingaryan
Initial import
814
	        } else {
212 by Suren A. Chilingaryan
Integration of work of students with fixes
815
		  var tooltip;
816
		  if (this.exporter) 
1 by Suren A. Chilingaryan
Initial import
817
			tooltip = " (" + this.exporter.GetTooltip() + ")";
212 by Suren A. Chilingaryan
Integration of work of students with fixes
818
		  else
1 by Suren A. Chilingaryan
Initial import
819
			tooltip = "";
820
212 by Suren A. Chilingaryan
Integration of work of students with fixes
821
		  if(this.idevice) {
822
            		this.crop = new Cropper.Img("graph_image", {
823
	        	    onOrientationChange: this.onOrientationChange(this),
824
    			    onTouchStart: this.onTouchStart(this),
825
	        	    onTouchMove:this.onTouchMove(this),
826
	        	    onTouchEnd:this.onTouchEnd(this),
827
	        	    onGestureStart:this.onGestureStart(this),
828
	        	    onGestureMove:this.onGestureMove(this),
829
	        	    onGestureEnd:this.onGestureEnd(this),   
830
	        	    onApplyClick: this.onApply(this),
831
	        	    onSaveClick: this.onSave(this),
832
	        	    extraButtons: this.extraButtons,
833
			    margins: this.crop_margins,
834
	        	    allWidth: this.allWidth,
835
	        	    allHeight: this.allHeight,
836
	        	    monitorImage: false,
231 by Suren A. Chilingaryan
Finish mergin RRDReader by Riku and few fixes for newer pecl-rrd
837
			    verticalCrop: ((adei.config.cfg.plot_mode == 0)?true:false),
212 by Suren A. Chilingaryan
Integration of work of students with fixes
838
	        	    imageReady: true
839
			});
840
			
841
			this.width = new_width;
842
    	    		this.height = new_height;
843
    		  } else {
1 by Suren A. Chilingaryan
Initial import
844
		    this.crop = new Cropper.Img("graph_image", {
845
    			onEndCrop:  this.onEndCrop(this),
846
			onCancelCrop: this.onCancelCrop(this),
847
			onClick: this.onClick(this),
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
848
			onDblClick: this.onDblClick(this),
849
			onDblSelClick: this.onApply(this),
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
850
  			onMouseScroll: this.onMouseScroll(this),
851
  			onMouseMove: this.onMouseMove(this),
852
  			onApplyClick: this.onApply(this),
853
  			onSaveClick: this.onSave(this),
97 by Suren A. Chilingaryan
Suport for custom buttons in JS cropper
854
			extraButtons: this.extraButtons,
1 by Suren A. Chilingaryan
Initial import
855
			margins: this.crop_margins,
856
			allWidth: this.allWidth,
857
			allHeight: this.allHeight,
858
			monitorImage: false,
231 by Suren A. Chilingaryan
Finish mergin RRDReader by Riku and few fixes for newer pecl-rrd
859
			verticalCrop: ((adei.config.cfg.plot_mode == 0)?true:false),
1 by Suren A. Chilingaryan
Initial import
860
			imageReady: true,
861
			tooltips: new Object({
862
			    'apply': translate('Zoom to the Selection'),
863
			    'save': translate('Export Selected Data') + tooltip
864
			})
865
		    });
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
866
		    this.width = new_width;
867
		    this.height = new_height;
240 by Suren A. Chilingaryan
Fix invalid usage of graph_mode
868
		    this.plot_mode = adei.config.cfg.plot_mode;
1 by Suren A. Chilingaryan
Initial import
869
		}
212 by Suren A. Chilingaryan
Integration of work of students with fixes
870
	      }
871
	      
872
	      if ((this.crop)&&(!this.crop.initialized)) {
873
	        this.crop = null;
874
	        setTimeout(this.ConfigureFunction(this), 1000);
875
	      }
200 by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196
876
		
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
877
	    }
1 by Suren A. Chilingaryan
Initial import
878
}
879
880
881
GRAPH.prototype.Update = function(json, forced) {
882
    if (json.draw) {
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
883
	if (json.nodata) {
884
	    this.img.src = adei.GetServiceURL("getimage", "id=" + json.image);
885
	    
886
	    if (this.crop) {
887
		this.crop.remove();
888
		this.crop = null;
889
	    }
890
	    
891
		// indictating it is not valid window
892
	    this.xsize = 0;
893
	} else if (this.img) {
1 by Suren A. Chilingaryan
Initial import
894
	    var doit = 1;
895
896
	    if (this.crop) {
897
		var crop = this.crop;
898
		if ((crop.selected)||(crop.dragging)||(crop.resizing)||(crop.calcW()>this.allWidth)||(crop.calcH()>this.allHeight)) {
899
		    if (forced) this.crop.clear();
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
900
		    else {
901
			adei.SetStatus(translate("Canceled because of selection"));
902
			doit = 0;
903
		    }
1 by Suren A. Chilingaryan
Initial import
904
		}
905
	    }
906
907
	    if (doit) {
15 by Suren A. Chilingaryan
Provide information in the statusbar, fix of global menu positioning
908
		adei.SetStatus(translate("Loading Image..."));
1 by Suren A. Chilingaryan
Initial import
909
	        this.img.src = adei.GetServiceURL("getimage", "id=" + json.image);
910
911
		this.xmin = parseFloat(json.xmin);
912
		this.xmax = parseFloat(json.xmax);
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
913
		this.imin = parseFloat(json.imin);
914
		this.imax = parseFloat(json.imax);
915
		this.prec = parseFloat(json.precision);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
916
		this.ymin = parseFloatArray(json.ymin);
917
		this.ymax = parseFloatArray(json.ymax);
327 by Suren A. Chilingaryan
Basic support for logarithmic axes
918
		this.ylog = parseFloatArray(json.ylog);
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
919
		this.yzoom = parseIntArray(json.yzoom);
920
		this.axis = parseStringArray(json.axis);
921
		this.color = parseArray(json.color);
922
		this.name = parseArray(json.name);
923
		this.axis_size = parseFloat(json.axis_size);
161 by Suren A. Chilingaryan
Handle the case if there are too many Y-axis
924
		this.onload_message = json.warning;
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
925
		
926
		if (json.margins) {
927
		    this.SetMargins(json.margins[0], json.margins[1], json.margins[2], json.margins[3]);
928
		}
929
		
1 by Suren A. Chilingaryan
Initial import
930
		this.xsize = parseFloat(adeiMathPreciseSubstract(this.xmax, this.xmin));
931
		
118 by Suren A. Chilingaryan
Missing javascript stuff from previous commit
932
		this.ysize = new Object;
933
		for (var i = 0; i < this.axis.length; i++) {
934
	    	    this.ysize[i] = this.ymax[i] - this.ymin[i];
935
		}
936
937
938
		this.window.NewGraph(this, this.xmin, this.xmax);
1 by Suren A. Chilingaryan
Initial import
939
	    }
940
	}
941
    }
942
}
943
944
GRAPH.prototype.SetExportTooltip = function () {
945
    var tooltip = this.exporter.GetTooltip();
946
    if ((this.crop)&&(tooltip)) {
947
	this.crop.setTooltip(new Object({'save': translate("Export Selected Data (%s)", tooltip)}));
948
    }
949
}
950
951
GRAPH.prototype.NotifyExportSettings = function() {
952
    this.SetExportTooltip();
953
}
954
955
//GRAPH.prototype.NotificationExport
956
957
12 by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu
958
GRAPH.prototype.AdjustGeometry = function(width, height, hend, vend) {
959
/*
960
    This was rougher approach
961
    domAdjustGeometry(this.frame, width, height - (this.selector?this.selector.offsetHeight:0), true);
962
*/
85 by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only)
963
    
964
	// otherwise we are probably not on display
965
    if (this.frame.offsetParent) {
966
	var mboffset = domGetNodeOffset(this.frame);
967
	var w = hend - mboffset[0];
968
	var h = vend - mboffset[1] - 1;
969
	domAdjustGeometry(this.frame, w, h, true);
970
    }
1 by Suren A. Chilingaryan
Initial import
971
}
972
973
11 by Suren A. Chilingaryan
Graph navigation: mouse wheel, modifier keys, etc.
974
GRAPH.prototype.GetPrecision = function(min) {
975
    var prec = this.prec;
976
    if (min > prec) prec = min;
977
    
978
    return (this.xsize * prec) / this.real_width;
979
}
980
1 by Suren A. Chilingaryan
Initial import
981
/*
982
GRAPH.prototype.MouseSelection = function(xy) {
983
    alert(this.start_xy[0] - xy[0]);
984
}
985
986
GRAPH.prototype.MouseStart = function(evt) {
987
    var xy = domGetMouseOffset(evt);
988
    this.start_xy = xy;
989
    return false;
990
}
991
992
GRAPH.prototype.MouseDone = function(evt) {
993
    var xy = domGetMouseOffset(evt);
994
    this.MouseSelection(xy);
995
}
996
997
GRAPH.prototype.MouseVisualize = function(evt) {
998
    var xy = domGetMouseOffset(evt);
999
    return false;
1000
}
1001
*/