PlotTextObject.js 3.97 KB
/**
 * 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',
	idProperty: 'id',
	
	requires: [
	           'amdaPlotObj.PlotObjectConfig'
	],
	
	fields : [
	          {name: 'id', type: 'int'},
	          {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'}
    ],
    
    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();
    	
    	textValues['id'] = this.get('id');
    	
    	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;
    }
});