Right now I have a plugin which measures several unique statistics and adds
them to a ResultsTable. Right now I use ResultsTable.getResultsTable() which gets the table used by Analyze>Measure titled "Results". This has problems however. 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. Oddly, if I first use Measure and then use my plugin, then measure again, results stay, though with the two odd rows I added by using measure. I tried just making my own instance of ResultsTable, but it lacks the ability to truly clear the table (old "deleted" rows reappear when I do another image). This is because only the window gets cleared, not the actual ResultsTable. I see the code in the TextPanel and TextWindow classes actually looks for the "Results" text in the title of the window to determine whether to add the "Clear Results" menu and to provide for selectively clearing rows. Is there a way to have all the functionality of Analyze>Measure's ResultsTable, without having these problems? I tried to subclass ResultsTable, TextPanel and TextWindow to make things work, but it's gotten so messy and it doesn't even work! I think the clearing functionality should be built into an existing class or maybe another class, instead of TextPanel and TextWindow using if(getTitle().equals("Results")). Thanks, Josh D |
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 |
In reply to this post by Josh Doe-2
You might check out my MeasurementTable class as an example of how I
dealt with these problems : http://www.astro.physik.uni-goettingen.de/ ~hessman/ImageJ/Astronomy/ Rick On 3 Jan 2007, at 11:35 pm, Josh D wrote: > Right now I have a plugin which measures several unique statistics > and adds > them to a ResultsTable. Right now I use ResultsTable.getResultsTable > () which > gets the table used by Analyze>Measure titled "Results". This has > problems > however. > > 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. Oddly, if I first use Measure and then use my plugin, then > measure again, results stay, though with the two > odd rows I added by using measure. > > I tried just making my own instance of ResultsTable, but it lacks the > ability to truly clear the table (old "deleted" rows reappear when > I do > another image). This is because only the window gets cleared, not > the actual > ResultsTable. I see the code in the TextPanel and TextWindow classes > actually looks for the "Results" text in the title of the window to > determine whether to add the "Clear Results" menu and to provide for > selectively clearing rows. > > Is there a way to have all the functionality of Analyze>Measure's > ResultsTable, without having these problems? I tried to subclass > ResultsTable, TextPanel and TextWindow to make things work, but > it's gotten > so messy and it doesn't even work! I think the clearing > functionality should > be built into an existing class or maybe another class, instead of > TextPanel > and TextWindow using if(getTitle().equals("Results")). Thanks, > Josh D |
In reply to this post by Josh Doe-2
These bugs are fixed in ImageJ 1.38g, due next week. The
Sine_Cosine_Table plugin at http://rsb.info.nih.gov/ij/plugins/sine-cosine.html demonstrates how a plugin can display values in the Results window. -wayne On Jan 3, 2007, at 5:35 PM, Josh D wrote: > Right now I have a plugin which measures several unique statistics and > adds them to a ResultsTable. Right now I use > ResultsTable.getResultsTable() > which gets the table used by Analyze>Measure titled "Results". This has > problems however. > > 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. Oddly, if I first use Measure and then use my plugin, > then measure again, results stay, though with the two > odd rows I added by using measure. > > I tried just making my own instance of ResultsTable, but it lacks the > ability to truly clear the table (old "deleted" rows reappear when I do > another image). This is because only the window gets cleared, not the > actual ResultsTable. I see the code in the TextPanel and TextWindow > classes actually looks for the "Results" text in the title of the > window to > determine whether to add the "Clear Results" menu and to provide for > selectively clearing rows. > > Is there a way to have all the functionality of Analyze>Measure's > ResultsTable, without having these problems? I tried to subclass > ResultsTable, TextPanel and TextWindow to make things work, but it's > gotten > so messy and it doesn't even work! I think the clearing functionality > should > be built into an existing class or maybe another class, instead of > TextPanel > and TextWindow using if(getTitle().equals("Results")). Thanks, > Josh D > |
Free forum by Nabble | Edit this page |