Commit 339866c461447ac75a53867e7535c8726ddab57c
1 parent
94abdb37
Exists in
master
and in
111 other branches
Add text legend definition
Showing
9 changed files
with
220 additions
and
10 deletions
Show diff stats
... | ... | @@ -0,0 +1,61 @@ |
1 | +/** | |
2 | + * Project : AMDA-NG | |
3 | + * Name : PlotLegendTextObject.js | |
4 | + * @class amdaPlotObj.PlotLegendTextObject | |
5 | + * @extends Ext.data.Model | |
6 | + * @brief Plot Text Legend Business Object Definition | |
7 | + * @author Benjamin Renard | |
8 | + * @version $Id: PlotLegendTextObject.js benjamin $ | |
9 | + ****************************************************************************** | |
10 | + * FT Id : Date : Name - Description | |
11 | + ****************************************************************************** | |
12 | + * : :01/09/2015: BRE - file creation | |
13 | + */ | |
14 | + | |
15 | + | |
16 | +Ext.define('amdaPlotObj.PlotLegendTextObject', { | |
17 | + extend: 'Ext.data.Model', | |
18 | + | |
19 | + requires: [ | |
20 | + 'amdaPlotObj.PlotObjectConfig' | |
21 | + ], | |
22 | + | |
23 | + fields : [ | |
24 | + {name: 'legend-text-value', type: 'string'}, | |
25 | + {name: 'legend-text-position', type: 'string'}, | |
26 | + {name: 'legend-text-color', type: 'string'}, | |
27 | + {name: 'legend-text-font-activated', type: 'boolean'}, | |
28 | + {name: 'legend-text-font-name', type: 'string'}, | |
29 | + {name: 'legend-text-font-size', type: 'int'}, | |
30 | + {name: 'legend-text-font-bold', type: 'boolean'}, | |
31 | + {name: 'legend-text-font-italic', type: 'boolean'} | |
32 | + ], | |
33 | + | |
34 | + setDefaultValues: function() | |
35 | + { | |
36 | + this.set('legend-text-value', ''); | |
37 | + this.set('legend-text-position', amdaPlotObj.PlotObjectConfig.defaultValues.legends.text.position); | |
38 | + this.set('legend-text-color', amdaPlotObj.PlotObjectConfig.defaultValues.legends.text.color); | |
39 | + this.set('legend-text-font-activated', false); | |
40 | + this.set('legend-text-font-name', amdaPlotObj.PlotObjectConfig.defaultValues.legends.text.font.name); | |
41 | + this.set('legend-text-font-size', amdaPlotObj.PlotObjectConfig.defaultValues.legends.text.font.size); | |
42 | + this.set('legend-text-font-bold', false); | |
43 | + this.set('legend-text-font-italic', false); | |
44 | + }, | |
45 | + | |
46 | + getJsonValues : function() | |
47 | + { | |
48 | + var legendValues = new Object(); | |
49 | + | |
50 | + legendValues['legend-text-value'] = this.get('legend-text-value'); | |
51 | + legendValues['legend-text-position'] = this.get('legend-text-position'); | |
52 | + legendValues['legend-text-color'] = this.get('legend-text-color'); | |
53 | + legendValues['legend-text-font-activated'] = this.get('legend-text-font-activated'); | |
54 | + legendValues['legend-text-font-name'] = this.get('legend-text-font-name'); | |
55 | + legendValues['legend-text-font-size'] = this.get('legend-text-font-size'); | |
56 | + legendValues['legend-text-font-bold'] = this.get('legend-text-font-bold'); | |
57 | + legendValues['legend-text-font-italic'] = this.get('legend-text-font-italic'); | |
58 | + | |
59 | + return legendValues; | |
60 | + } | |
61 | +}); | |
0 | 62 | \ No newline at end of file | ... | ... |
js/app/models/PlotObjects/PlotObjectConfig.js
... | ... | @@ -131,6 +131,14 @@ Ext.define('amdaPlotObj.PlotObjectConfig', { |
131 | 131 | name : 'sans-serif', |
132 | 132 | size: '12' |
133 | 133 | } |
134 | + }, | |
135 | + text : { | |
136 | + position : 'left', | |
137 | + color : '#000000', | |
138 | + font : { | |
139 | + name : 'sans-serif', | |
140 | + size: '12' | |
141 | + } | |
134 | 142 | } |
135 | 143 | } |
136 | 144 | }, |
... | ... | @@ -308,5 +316,12 @@ Ext.define('amdaPlotObj.PlotObjectConfig', { |
308 | 316 | availableLegendSeriesIntervalInfoTypes : [ |
309 | 317 | {'key' : 'index', 'value' : 'Interval Index'}, |
310 | 318 | {'key' : 'start-stop', 'value' : 'Interval Start/Stop'} |
319 | + ], | |
320 | + | |
321 | + availableLegendTextPositions : [ | |
322 | + {'key' : 'right', 'value' : 'Right'}, | |
323 | + {'key' : 'left', 'value' : 'Left'}, | |
324 | + {'key' : 'top', 'value' : 'Top'}, | |
325 | + {'key' : 'bottom', 'value' : 'Bottom'} | |
311 | 326 | ] |
312 | 327 | }); |
313 | 328 | \ No newline at end of file | ... | ... |
js/app/models/PlotObjects/PlotPanelObject.js
... | ... | @@ -17,12 +17,14 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
17 | 17 | extend: 'Ext.data.Model', |
18 | 18 | |
19 | 19 | lastParamId : 0, |
20 | + lastTextLegendId : 0, | |
20 | 21 | |
21 | 22 | requires: [ |
22 | 23 | 'amdaPlotObj.PlotObjectConfig', |
23 | 24 | 'amdaPlotObj.PlotAxisObject', |
24 | 25 | 'amdaPlotObj.PlotParamObject', |
25 | - 'amdaPlotObj.PlotLegendSeriesObject' | |
26 | + 'amdaPlotObj.PlotLegendSeriesObject', | |
27 | + 'amdaPlotObj.PlotLegendTextObject' | |
26 | 28 | ], |
27 | 29 | |
28 | 30 | fields : [ |
... | ... | @@ -90,6 +92,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
90 | 92 | name : 'params' |
91 | 93 | }, |
92 | 94 | { |
95 | + type : 'hasMany', | |
96 | + model : 'amdaPlotObj.PlotLegendTextObject', | |
97 | + name : 'textLegends' | |
98 | + }, | |
99 | + { | |
93 | 100 | type : 'belongsTo', |
94 | 101 | model : 'amdaPlotObj.PlotTabObject' |
95 | 102 | } |
... | ... | @@ -104,6 +111,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
104 | 111 | me.loadAxes(arguments[0].axes); |
105 | 112 | if (arguments[0].params) |
106 | 113 | me.loadParams(arguments[0].params); |
114 | + if (arguments[0].textLegends) | |
115 | + me.loadTextLegends(arguments[0].textLegends); | |
107 | 116 | } |
108 | 117 | else |
109 | 118 | { |
... | ... | @@ -122,6 +131,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
122 | 131 | this.params().loadData(params); |
123 | 132 | }, |
124 | 133 | |
134 | + loadTextLegends: function(textLegends) | |
135 | + { | |
136 | + this.textLegends().loadData(textLegends); | |
137 | + }, | |
138 | + | |
125 | 139 | initAxes : function() |
126 | 140 | { |
127 | 141 | this.axes().removeAll(); |
... | ... | @@ -206,6 +220,22 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
206 | 220 | return true; |
207 | 221 | }, |
208 | 222 | |
223 | + createNewTextLegend: function() { | |
224 | + var recs = this.textLegends().add({id : this.get('id')+'-legend-text-'+this.lastTextLegendId}); | |
225 | + ++this.lastTextLegendId; | |
226 | + recs[0].setDefaultValues(); | |
227 | + return recs[0]; | |
228 | + }, | |
229 | + | |
230 | + removeTextLegendById: function(legendId) { | |
231 | + //Retrieve text legend record | |
232 | + var textLegendRecord = this.textLegends().getById(legendId); | |
233 | + if (textLegendRecord == null) | |
234 | + return false; | |
235 | + this.textLegends().remove(textLegendRecord); | |
236 | + return true; | |
237 | + }, | |
238 | + | |
209 | 239 | updatePlotType: function(plotType, forceUpdate) { |
210 | 240 | forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false; |
211 | 241 | |
... | ... | @@ -238,7 +268,10 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
238 | 268 | } |
239 | 269 | } |
240 | 270 | else |
271 | + { | |
241 | 272 | this.set('panel-legend-series', null); |
273 | + this.textLegends().removeAll(); | |
274 | + } | |
242 | 275 | }, |
243 | 276 | |
244 | 277 | setDefaultValues: function() |
... | ... | @@ -339,6 +372,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
339 | 372 | if ((this.get('panel-legend-series') != null) && this.get('panel-legend-series').get('legend-series-activated')) |
340 | 373 | panelValues['panel-series-legend'] = this.get('panel-legend-series').getJsonValues(); |
341 | 374 | |
375 | + panelValues['text-legends'] = []; | |
376 | + | |
377 | + this.textLegends().each(function (legend, index) { | |
378 | + panelValues['text-legends'][index] = legend.getJsonValues(); | |
379 | + }); | |
380 | + | |
342 | 381 | panelValues['axes'] = []; |
343 | 382 | |
344 | 383 | this.axes().each(function (axe, index) { | ... | ... |
js/app/models/PlotObjects/PlotTreeNode.js
js/app/views/PlotComponents/PlotElementPanel.js
... | ... | @@ -20,7 +20,9 @@ Ext.define('amdaPlotComp.PlotElementPanel', { |
20 | 20 | 'amdaPlotComp.PlotColorAxisForm', |
21 | 21 | 'amdaPlotComp.PlotParamForm', |
22 | 22 | 'amdaPlotComp.PlotLayoutForm', |
23 | - 'amdaPlotComp.PlotLegendSeriesForm' | |
23 | + 'amdaPlotComp.PlotLegendSeriesForm', | |
24 | + 'amdaPlotComp.PlotLegendTextForm', | |
25 | + 'amdaPlotComp.PlotLegendsTextForm' | |
24 | 26 | ], |
25 | 27 | |
26 | 28 | elementFormsManager : new Ext.AbstractManager(), |
... | ... | @@ -90,6 +92,12 @@ Ext.define('amdaPlotComp.PlotElementPanel', { |
90 | 92 | case 'series-legend' : |
91 | 93 | this.elementFormsManager.register(new amdaPlotComp.PlotLegendSeriesForm({id : formId})); |
92 | 94 | break; |
95 | + case 'text-legend' : | |
96 | + this.elementFormsManager.register(new amdaPlotComp.PlotLegendTextForm({id : formId})); | |
97 | + break; | |
98 | + case 'text-legends' : | |
99 | + this.elementFormsManager.register(new amdaPlotComp.PlotLegendsTextForm({id : formId})); | |
100 | + break; | |
93 | 101 | case '' : |
94 | 102 | this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element to the tree to show options'})); |
95 | 103 | break; | ... | ... |
... | ... | @@ -0,0 +1,28 @@ |
1 | +/** | |
2 | + * Project : AMDA-NG | |
3 | + * Name : PlotLegendTextForm.js | |
4 | + * @class amdaPlotComp.PlotLegendTextForm | |
5 | + * @extends amdaPlotComp.PlotStandardForm | |
6 | + * @brief Form to define specifics Text legend options | |
7 | + * @author Benjamin Renard | |
8 | + * @version $Id: PlotLegendTextForm.js benjamin $ | |
9 | + */ | |
10 | + | |
11 | +Ext.define('amdaPlotComp.PlotLegendTextForm', { | |
12 | + extend: 'amdaPlotComp.PlotStandardForm', | |
13 | + | |
14 | + setObject : function(object) { | |
15 | + this.object = object; | |
16 | + if (this.object != null) | |
17 | + this.loadRecord(this.object); | |
18 | + }, | |
19 | + | |
20 | + getFormItems: function() { | |
21 | + return [ | |
22 | + this.addStandardText('legend-text-value', 'Text'), | |
23 | + this.addStandardColor('legend-text-color', 'Color', amdaPlotObj.PlotObjectConfig.availableColors), | |
24 | + this.addStandardCombo('legend-text-position', 'Position', amdaPlotObj.PlotObjectConfig.availableLegendTextPositions), | |
25 | + this.addStandardFont('legend-text-font') | |
26 | + ]; | |
27 | + } | |
28 | +}); | |
0 | 29 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +/** | |
2 | + * Project : AMDA-NG | |
3 | + * Name : PlotLegendsTextForm.js | |
4 | + * @class amdaPlotComp.PlotLegendsTextForm | |
5 | + * @extends amdaPlotComp.PlotStandardForm | |
6 | + * @brief Form to define a list of text legends | |
7 | + * @author Benjamin Renard | |
8 | + * @version $Id: PlotLegendsTextForm.js benjamin $ | |
9 | + */ | |
10 | + | |
11 | +Ext.define('amdaPlotComp.PlotLegendsTextForm', { | |
12 | + extend: 'amdaPlotComp.PlotStandardForm', | |
13 | + | |
14 | + setObject : function(object) { | |
15 | + this.object = object; | |
16 | + if (this.object != null) | |
17 | + this.loadRecord(this.object); | |
18 | + }, | |
19 | + | |
20 | + getFormItems: function() { | |
21 | + var me = this; | |
22 | + return [ | |
23 | + { | |
24 | + xtype: 'button', | |
25 | + text: 'Add new text legend', | |
26 | + iconCls: 'icon-add', | |
27 | + handler : function() { | |
28 | + var textLegendObject = me.object.createNewTextLegend(); | |
29 | + me.crtTree.buildPanelAdditionalObjectsNode(me.object, textLegendObject.get('id')); | |
30 | + } | |
31 | + } | |
32 | + ]; | |
33 | + } | |
34 | +}); | |
0 | 35 | \ No newline at end of file | ... | ... |
js/app/views/PlotComponents/PlotTree.js
... | ... | @@ -162,7 +162,9 @@ Ext.define('amdaPlotComp.PlotTree', { |
162 | 162 | this.getSelectionModel().select(selectedParamNode); |
163 | 163 | }, |
164 | 164 | |
165 | - buildPanelAdditionalObjectsNode: function(panelObject) { | |
165 | + buildPanelAdditionalObjectsNode: function(panelObject, selectedObjectId) { | |
166 | + selectedObjectId = (typeof selectedObjectId !== 'undefined') ? selectedObjectId : ''; | |
167 | + | |
166 | 168 | var objectsNode = null; |
167 | 169 | |
168 | 170 | var me = this; |
... | ... | @@ -176,9 +178,6 @@ Ext.define('amdaPlotComp.PlotTree', { |
176 | 178 | { |
177 | 179 | //create additional objects node |
178 | 180 | objectsNode = panelNode.appendChild(new amdaPlotObj.PlotAdditionalObjectsTreeNode({object : panelObject})); |
179 | - | |
180 | - //create legends node | |
181 | - me.buildPanelLegendsNode(panelObject, objectsNode); | |
182 | 181 | } |
183 | 182 | return; |
184 | 183 | } |
... | ... | @@ -187,15 +186,30 @@ Ext.define('amdaPlotComp.PlotTree', { |
187 | 186 | if (objectsNode == null) |
188 | 187 | return; |
189 | 188 | |
190 | - this.getView().refresh(); | |
189 | + //Remove old objects nodes | |
190 | + objectsNode.removeAll(); | |
191 | + | |
192 | + //create legends node | |
193 | + this.buildPanelLegendsNode(panelObject, objectsNode, selectedObjectId); | |
191 | 194 | }, |
192 | 195 | |
193 | - buildPanelLegendsNode: function(panelObject, objectsNode) { | |
196 | + buildPanelLegendsNode: function(panelObject, objectsNode, selectedObjectId) { | |
194 | 197 | var legendsNode = objectsNode.appendChild(new amdaPlotObj.PlotLegendsTreeNode({object : panelObject})); |
195 | 198 | |
196 | 199 | legendsNode.appendChild(new amdaPlotObj.PlotSeriesLegendTreeNode({object : panelObject})); |
197 | 200 | |
198 | - legendsNode.appendChild(new amdaPlotObj.PlotTextLegendsTreeNode({object : panelObject})); | |
201 | + var textLegendsNode = legendsNode.appendChild(new amdaPlotObj.PlotTextLegendsTreeNode({object : panelObject})); | |
202 | + | |
203 | + var selectedTextLegendNode = null; | |
204 | + panelObject.textLegends().each(function (legendObject) { | |
205 | + var textLegendNode = textLegendsNode.appendChild(new amdaPlotObj.PlotTextLegendTreeNode({object : legendObject})); | |
206 | + if (legendObject.get('id') == selectedObjectId) | |
207 | + selectedTextLegendNode = textLegendNode; | |
208 | + }); | |
209 | + | |
210 | + this.getView().refresh(); | |
211 | + if (selectedTextLegendNode) | |
212 | + this.getSelectionModel().select(selectedTextLegendNode); | |
199 | 213 | }, |
200 | 214 | |
201 | 215 | addPanelNode: function(panelObject) { |
... | ... | @@ -312,6 +326,15 @@ Ext.define('amdaPlotComp.PlotTree', { |
312 | 326 | if (panelObject.removeParamById(record.object.get('id'))) |
313 | 327 | this.buildPanelsNode(); |
314 | 328 | break; |
329 | + case 'text-legend' : | |
330 | + var panelObject = null; | |
331 | + if (!this.isSimplifiedView) | |
332 | + panelObject = record.parentNode.parentNode.object; | |
333 | + else | |
334 | + panelObject = record.parentNode.object; | |
335 | + if (panelObject.removeTextLegendById(record.object.get('id'))) | |
336 | + this.buildPanelAdditionalObjectsNode(panelObject); | |
337 | + break; | |
315 | 338 | } |
316 | 339 | } |
317 | 340 | }, | ... | ... |
js/resources/images/16x16/plot_legends.png deleted
155 Bytes