Hi Everyone,
I have a FieldImpl:
RealType x = RealType.getRealType("coordinate");
RealType y = RealType.getRealType("value");
RealType col = RealType.getRealType("color");
RealType z = RealType.getRealType("density");
RealTupleType rxy = new RealTupleType(x,y);
RealTupleType zc = new RealTupleType(z,col);
FunctionType blur = new FunctionType(rxy,zc);
FunctionType ptype = new FunctionType(index, blur);
FieldImpl pfield = new FieldImpl(ptype, index_set);
for (int i=0; i<nrows; i++) {
float[][] locs = new float[2][3*ncoords];
float[][] coldens = new float[2][3*ncoords];
// a bunch of stuff in here that creates locs and coldens
Gridded2DSet set = new Gridded2DSet(rxy, locs, 3, ncoords);
FlatField vals_ff = new FlatField(blur,set);
vals_ff.setSamples( coldens , false );
pfield.setSample(i, vals_ff, false);
}
// tons more code in here
ClassAverage ca = new ClassAverage(pfield, afield);
aveButton.addActionListener(ca);
When a button is pressed, I want to average locs[1][] over several subsets
of values of i, di similar things to coldens, and replace pfield with this
new (much smaller) FieldImpl. So, nrows might be several thousands, but the
new version of pfield may have only a handful of samples. I tried to do this
by creating a new FieldImpl, "afield", that holds the appropriate averages.
Then exchanging the two FieldImpls:
class ClassAverage implements ActionListener {
FieldImpl pfield;
FieldImpl afield;
ClassAverage(FieldImpl pfield, FieldImpl afield){
this.pfield = pfield;
this.afield = afield;
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (cmd.equals("ave")) {
FieldImpl sfield = pfield;
pfield = afield;
afield = sfield;
}
}
}
But nothing happens.
My first question is: how do I get pfield to change in the place where
ClassAverage is used.
My second question is: is there a better/easier/more efficient way to do
this?
Of course, the first question is moot if the answer to the second is "yes",
but right now I'll be delighted if anyone can help me with either!
Thanks
Adele