Problem with Brightness / Contrast dialog in Plug-in

Posted by Vasilescu,Dan on
URL: http://imagej.273.s1.nabble.com/Problem-with-Brightness-Contrast-dialog-in-Plug-in-tp3700193.html

Greetings,
 
I am writing a plug-in where I try to apply the user preferences (Min and Max values) from a previous session to a Brightness / Contrast dialog box.
A simplified version of this would be:
 
     IJ.run("Brightness/Contrast...");
     IJ.getImage().getProcessor().setMinAndMax(Min,Max);

The image is adjusted correctly and the dialog box gets the new settings. The problem is that the controls inside the dialog box (histogram and scrollbars) are not adjusted to reflect the change.
The real problem seems to be that ij.plugin.frame.ContrastAdjuster class was not designed to be used programatically, but only in the context of user/GUI interaction.
 
I have a few solutions, like creating a helper class inside ij.plugin.frame package, or use the java reflection API and override all access control, or even generate a IJ script to mimic user interaction.
However, they feel too much like a hack - and it's very likely that sooner or later some code modification will force me to redo the work all over again.
 
I am rather new to ImageJ and there may be other solutions which I could not think of. Comments from the experts on this forum would be greatly appreciated.
Thank you!
 
 
Dan Vasilescu
Center for Cell Analysis and Modeling, (vcell.org)
University of Connecticut Heath Center
263 Farmington Ave
Farmington, CT 06030