Blame view

js/app/models/PlotObjects/PlotTextObject.js 4.27 KB
a8c54fb9   Benjamin Renard   Add text object p...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Project      : AMDA-NG
 * Name         : PlotTextObject.js
 * @class   amdaPlotObj.PlotTextObject
 * @extends Ext.data.Model
 * @brief   Plot Constant Business Object Definition 
 * @author  Benjamin Renard
 * @version $Id: PlotTextObject.js benjamin $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :01/09/2015: BRE  - file creation
 */
 
 		
Ext.define('amdaPlotObj.PlotTextObject', {
	extend: 'Ext.data.Model',
dbb7bcbe   Benjamin Renard   Add curves defint...
18
	idProperty: 'id',
a8c54fb9   Benjamin Renard   Add text object p...
19
20
21
22
23
24
	
	requires: [
	           'amdaPlotObj.PlotObjectConfig'
	],
	
	fields : [
fd5552a4   Benjamin Renard   Info for plot ele...
25
	          {name: 'id', type: 'int'},
a8c54fb9   Benjamin Renard   Add text object p...
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
	          {name: 'text-value', type: 'string'},
	          {name: 'text-y-axis', type: 'string'},
	          {name: 'text-x-relative', type: 'boolean'},
	          {name: 'text-x-floatvalue', type: 'float'},
	          {name: 'text-x-timevalue', type: 'date',
            	  defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
            	  convert: function(value,rec) {
            		  if (!Ext.isDate(value)) {
            		    var valueString = new String(value);
            		    var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
            		      return date;
            		  }
            		  return value;
            	  }
              },
	          {name: 'text-y-relative', type: 'boolean'},
	          {name: 'text-y-value', type: 'float'},
	          {name: 'text-angle', type: 'float'},
	          {name: 'text-color', type: 'string'},
	          {name: 'text-align', type: 'string'},
	          {name: 'text-font-activated', type: 'boolean'},
              {name: 'text-font-name', type: 'string'},
              {name: 'text-font-size', type: 'int'},
              {name: 'text-font-bold', type: 'boolean'},
              {name: 'text-font-italic', type: 'boolean'}
    ],
    
a971060f   Benjamin Renard   Fix some bugs
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    constructor: function(){
        var me = this;
        me.callParent(arguments);
        if ((arguments.length > 0) && arguments[0])
        {
        }
        else
        {
        	//new object, set default fields values
        	me.setDefaultValues();
        }
        this.dirty = false;
    },
    
a8c54fb9   Benjamin Renard   Add text object p...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    setDefaultValues: function()
    {
    	this.set('text-value', '');
    	this.set('text-y-axis', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.yAxisId);
    	this.set('text-x-relative', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.xRelative);
    	this.set('text-x-floatvalue', 0.);
    	this.set('text-y-relative', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.yRelative);
    	this.set('text-y-value', 0.);
    	this.set('text-angle', 0.);
    	this.set('text-color', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.color);
    	this.set('text-align', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.align);
    	this.set('text-font-activated', false);
    	this.set('text-font-name', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.font.name);
    	this.set('text-font-size', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.font.size);
    	this.set('text-font-bold', false);
    	this.set('text-font-italic', false);
    },
    
    getJsonValues : function() 
    {
    	var textValues  = new Object();
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
89
90
    	textValues['id'] = this.get('id');
    	
a8c54fb9   Benjamin Renard   Add text object p...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    	textValues['text-value'] = this.get('text-value');
    	textValues['text-y-axis'] = this.get('text-y-axis');
    	textValues['text-x-relative'] = this.get('text-x-relative');
    	textValues['text-x-floatvalue'] = this.get('text-x-floatvalue');
    	textValues['text-x-timevalue'] = this.get('text-x-timevalue');
    	textValues['text-y-relative'] = this.get('text-y-relative');
    	textValues['text-y-value'] = this.get('text-y-value');
    	textValues['text-angle'] = this.get('text-angle');
    	textValues['text-color'] = this.get('text-color');
    	textValues['text-align'] = this.get('text-align');
    	textValues['text-font-activated'] = this.get('text-font-activated');
    	textValues['text-font-name'] = this.get('text-font-name');
    	textValues['text-font-size'] = this.get('text-font-size');
    	textValues['text-font-bold'] = this.get('text-font-bold');
    	textValues['text-font-italic'] = this.get('text-font-italic');	
    	
    	return textValues;
    }
});