package sv.filters; |
import java.util.*; import java.awt.*; import sv.kernel.*; |
public class CAddXFilter extends Filter { |
public CAddXFilter()// output data set's dimension is 1 and 1 arg needs |
super(Filter.ONED, 1); label = "Enter the constant c: "; |
} |
public Object performFilter() { |
TimeData1D onetimedata; |
DataSet1D dataSet = (DataSet1D)sources.firstElement(); |
Vector timeDataVec = new Vector(); |
float[] xarr, yarr; |
int points; |
float c = args[0]; |
for (int i=0; i < dataSet.getnoOfTime(); i++) { |
onetimedata = dataSet.getTimeData(i); |
points = onetimedata.getnoOfPoints(); |
xarr = onetimedata.getxArr(); |
yarr = onetimedata.getyArr(); |
for (int j=0; j < points; j++) |
xarr[j] =xarr[j] + c; |
onetimedata = new TimeData1D(dataSet.getTimeArr[i], points, xarr, yarr); |
timeDataVec.addElement(onetimedata); |
} |
return new DataSet1D("x=x+c : " + dataSet.getTitle(), timeDataVec); |
} |
} |