Re: Unique ResultsTable instance with clearing capabilities
Posted by Gabriel Landini on Jan 03, 2007; 11:14pm
URL: http://imagej.273.s1.nabble.com/Unique-ResultsTable-instance-with-clearing-capabilities-tp3700704p3700707.html
On Wednesday 03 January 2007 22:35, Josh D wrote:
> If I use
> my plugin to populate the table with values, and then procede to use
> the Analyze>Measure tool, all of my results get deleted
> without any prompting
> whatsoever.
How do you write to the Table?
Do you use:
rt.incrementCounter();
rt.setValue("Parameter", n, parameter_value);
If not, then you do not have any data in the Table, despite that you see
things printed in it.
For instance, if you use :
IJ.write(parameter_value);
then you are not putting the data in the table, just showing it in there (it
took me some time to realise what is going on).
Also you have to check whether there is any data in the table if you want to
save it before writing to it. If there is data, then you prompt to save.
In one of my plugins I use (this is cut and pasted from several parts, so it
may not make proper sense, and mind the line breaks):
protected ResultsTable rt= ResultsTable.getResultsTable();
[...]
// are there any data?
if (rt.getCounter()>0) {
SaveChangesDialog di = new
SaveChangesDialog(IJ.getInstance(), "Save "+rt.getCounter()+"
measurements?");
if (di.cancelPressed())
return DONE;
else if (di.savePressed())
new MeasurementsWriter().run("");
}
rt.reset(); // resets the table
rt.show("Results");
and then I print the data to it.
at the end I call again
rt.show("Results");
so the screen is updated, but I am not sure this is mandatory.
I hope it helps a bit.
Gabriel