1 | package sv.filters; |
2 | import java.util.*; import java.awt.*; import sv.kernel.*; |
3 | public class CAddXFilter extends Filter { |
4 | public CAddXFilter()// output data set's dimension is 1 and 1 arg needs |
5 | super(Filter.ONED, 1); label = "Enter the constant c: "; |
6 | } |
7 | public Object performFilter() { |
8 | TimeData1D onetimedata; |
9 | DataSet1D dataSet = (DataSet1D)sources.firstElement(); |
10 | Vector timeDataVec = new Vector(); |
11 | float[] xarr, yarr; |
12 | int points; |
13 | float c = args[0]; |
14 | for (int i=0; i < dataSet.getnoOfTime(); i++) { |
15 | onetimedata = dataSet.getTimeData(i); |
16 | points = onetimedata.getnoOfPoints(); |
17 | xarr = onetimedata.getxArr(); |
18 | yarr = onetimedata.getyArr(); |
19 | for (int j=0; j < points; j++) |
20 | xarr[j] =xarr[j] + c; |
21 | onetimedata = new TimeData1D(dataSet.getTimeArr[i], points, xarr, yarr); |
22 | timeDataVec.addElement(onetimedata); |
23 | } |
24 | return new DataSet1D("x=x+c : " + dataSet.getTitle(), timeDataVec); |
25 | } |
26 | } |