1 /** 2 * Filter 3 */ 4 wso2vis.f.Filter = function() { 5 this.attr = []; 6 this.dp = null; 7 this.drList = []; 8 wso2vis.environment.filters.push(this); 9 id = wso2vis.environment.filters.length - 1; 10 this.getID = function() {return id;} 11 }; 12 13 wso2vis.f.Filter.prototype.property = function(name) { 14 /* 15 * Define the setter-getter globally 16 */ 17 wso2vis.f.Filter.prototype[name] = function(v) { 18 if (arguments.length) { 19 this.attr[name] = v; 20 return this; 21 } 22 return this.attr[name]; 23 }; 24 25 return this; 26 }; 27 28 wso2vis.f.Filter.prototype.dataProvider = function(dp) { 29 this.dp = dp; 30 this.dp.addDataReceiver(this); 31 return; 32 }; 33 34 wso2vis.f.Filter.prototype.addDataReceiver = function(dr) { 35 this.drList.push(dr); 36 }; 37 38 wso2vis.f.Filter.prototype.pushData = function(data) { 39 var filteredData = this.filterData(data); 40 for (i = 0; i < this.drList.length; i++) { 41 (this.drList[i]).pushData(filteredData); 42 } 43 }; 44 45 wso2vis.f.Filter.prototype.pullData = function() { 46 this.dp.pullData(); 47 }; 48 49 wso2vis.f.Filter.prototype.filterData = function(data) { 50 return data; 51 }; 52 53 wso2vis.f.Filter.prototype.traverseToDataField = function (object, dataFieldArray) { 54 var a = object; 55 for (var i = 0; i < dataFieldArray.length; i++) { 56 a = a[dataFieldArray[i]]; 57 } 58 return a; 59 }; 60