First, I am very new to Java and my programming in general is rusty. So I might have missed something very simple.
The error:
cannot find symbol
symbol : method setMethod(java.lang.String)
location: class ij.plugin.Thresholder
Thresholder.setMethod("Mean");
Some code snippets: This part is third party code. I would like to avoid modifying this as much as possible
public class Thresholder implements PlugIn, Measurements, ItemListener {
private static String staticMethod = methods[0];
public static void setMethod(String method) {
staticMethod = method;
}
}
My code (well, some relevant parts)
import ij.plugin.Thresholder;
public class CASA_ implements PlugInFilter,Measurements {
public void run(ImageProcessor ip) {
track(imp, minSize, maxSize, maxVelocity);
}
public void track(ImagePlus imp, float minSize, float maxSize, float maxVelocity) {
Thresholder.setMethod("Mean"); <-- This is the line the compiler hates
}
}
Why is the compiler looking for a setMethod method with a return of something other than void?
Thanks
As Makoto correctly states, you can't call Thresholder.setMethod("Mean")
in the class declaration.
In a class implementing PlugInFilter
, you have to define a run(ImageProcessor ip)
and a setup(String arg, ImagePlus imp)
method, so why don't you set the thresholding method during setup of your plugin filter:
import ij.IJ;
import ij.ImagePlus;
import ij.measure.Measurements;
import ij.plugin.Thresholder;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class CASA_ implements PlugInFilter,Measurements {
// define instance variables:
ImagePlus imp;
/**
* implement interface methods
*/
public int setup(String arg, ImagePlus imp) {
this.imp = imp;
Thresholder.setMethod("Mean");
IJ.log("Setup done.");
return DOES_ALL;
}
public void run(ImageProcessor ip) {
// do your processing here
}
}
Have a look at the ImageJ plugin writing tutorial or at Fiji's script editor and its templates (Templates > Java > Bare PlugInFilter) as a starting point.