Plot.js
5.11 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
/**
* Project : AMDA-NG
* Name : Plot.js
* @class amdaModel.Plot
* @extends amdaModel.PlotNodeObject
* @brief Plot Request Business Object Definition
* @author Caroline DARMON
* @version $Id: Plot.js 2544 2014-10-03 10:21:56Z elena $
******************************************************************************
* FT Id : Date : Name - Description
******************************************************************************
* : :08/09/2011: CDA - file creation
*/
Ext.define('amdaModel.Plot', {
extend: 'amdaModel.AmdaTimeObject',
fields : [
{name: 'children'},
{name: 'leaf', type: 'boolean', defaultValue: false},
{name: 'outputName', type: 'string'},
{name: 'orientation', type: 'string', defaultValue: 'LANDSCAPE'},
{name: 'format', type: 'string', defaultValue: 'PNG'},
{name: 'title', type: 'string'},
{name: 'description', type: 'string'},
{name: 'charSize', type: 'float', defaultValue: 1.3},
{name: 'thickness', type: 'int', defaultValue: 1},
{name: 'ppp', type: 'int', defaultValue: 3000},
{name: 'forcedLayout', type: 'boolean', defaultValue: false},
{name: 'forcedMulti', type: 'boolean', defaultValue: false},
{name: 'resultId', type: 'string'},
{name: 'resultFolder', type: 'string'},
{name: 'tabId', type: 'string', defaultValue: '1'},
{name: 'xMin', type: 'string'},
{name: 'xMax', type: 'string'}
],
hasMany: {model: 'amdaModel.PlotPanel', name: 'children'},
propertiesToCopy : 'id,name,outputName,orientation,format,ppp,title,description,charSize,thickness,timesrc,startDate,stopDate,children',
constructor: function(configPanel){
this.callParent(arguments);
this.set('leaf',false);
},
getParentPanel : function(paramObject){
// for each panel
for(var i=0;i<this.object.plotPanels().getCount();i++) {
var panel = this.object.plotPanels().getAt(i);
// if there's at least one param
if (panel.plotParams()){
// for each param
for(var j=0;j<panel.plotParams().getCount();j++) {
if (paramObject == panel.plotParams().getAt(j)){
return panel;
}
}
}
}
},
getJsonValues : function(hasId){
var myValues = new Object();
if (hasId) {
myValues.id = this.get('id');
}
if (this.get('resultId')) {
myValues.resultId = this.get('resultId');
}
myValues.name = this.get('name');
// myValues.text = this.get('text');
myValues.tabId = this.get('tabId');
myValues.outputName = this.get('outputName');
myValues.orientation = this.get('orientation');
myValues.format = this.get('format');
myValues.title = this.get('title');
myValues.description = this.get('description');
myValues.charSize = this.get('charSize');
myValues.thickness = this.get('thickness');
myValues.ppp = this.get('ppp');
myValues.forcedLayout = this.get('forcedLayout');
myValues.forcedMulti = this.get('forcedMulti');
var childrenArray = []; //PlotPanel.JsonValues!!!
if (this.childNodes && this.childNodes.length > 0){
// use internal node attribute of NodeInterface to get children
Ext.Array.each(this.childNodes, function(panelItem, panelIndex, allPanelItem) {
childrenArray.push(panelItem.getJsonValues());
});
} else {
// else if a json config has been past to the Plot constructor
childrenArray = this.get('children');
}
myValues.children = childrenArray;
myValues.timesrc = this.get('timesrc');
// if there's at least one timeTable name into 'timeTables' collection
if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
// get complete timeTables collection
var timeTables = this.get('timeTables');
// init an empty array for timeTables
myValues.timeTables=[];
// for each interval record
Ext.Array.each(timeTables, function(item, index, all){
if (!item.$className) {
myValues.timeTables[index] = {timeTableName : item.timeTableName, id : item.id};
}
// get Json simplified value
else {
myValues.timeTables[index] = item.getJsonValues();
}
});
} else {
myValues.startDate = this.get('startDate');
myValues.stopDate = this.get('stopDate');
myValues.durationDay = this.get('durationDay');
myValues.durationHour = this.get('durationHour');
myValues.durationMin = this.get('durationMin');
myValues.durationSec = this.get('durationSec');
}
myValues.leaf = true;
myValues.nodeType = amdaModel.PlotNode.nodeType;
return myValues;
}
});