Posted by
Mike Myerburg on
May 16, 2008; 2:16am
URL: http://imagej.273.s1.nabble.com/Collate-PlotWindows-into-a-stack-tp3696195p3696197.html
Albert Cardona wrote:
> Mike,
>
>
>> My plugin generates numerous plotWindows that eventually take over the
>> screen. Is there an easy way to have each new plotWindow placed into
>> a stack?
>
>
> PlotWindow is an extended ImageWindow, thus you can call
> getImagePlus().getProcessor() on it. So to make a stack:
>
>
> PlotWindow[] pw = ....
>
> ImageProcessor ip = pw[0].getImagePlus().getProcessor();
> int w = ip.getWidth();
> int h = ip.getHeight();
>
> ImageStack stack = new ImageStack(w, h);
> stack.addSlice("plotwindow 1", ip); // the first one
>
> // start at the second one, index 1
> for (int i=1; i<pw.length; i++) {
> stack.addSlice("plotwindow" + (i+1),
> pw[i].getImagePlus().getProcessor());
> }
>
>
> new ImagePlus("All PlotWindows", stack).show();
>
>
Thank you for the help. However, I dont think this way will work for
me, because the plots are not generated all at once. The following
class is in the plugin and is used to plot the results. As I use the
plugin multiple times I wind up with numerous "PSD Sum" windows, but
they are not all generated at one time.
public void PSDPlot(float[] PSD){
float[] frequency = new float[PSD.length];
for (int i=0; i<frequency.length; i++) frequency[i] =
frequency(i,frequency.length);
PlotWindow psdSumPlot = new PlotWindow("PSD Sum","CBF","PSD",
frequency, PSD);
psdSumPlot.draw();
}
I am pretty new with java and have been hacking my way through... I
appreciate the help, Mike