tofront() and getCurrentImage()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

tofront() and getCurrentImage()

Colin Poczatek
We've been running into some issues with calling imageWindow.tofront()
not actually bringing the window "above" other windows.  The purpose of
this is to then call WindowManager.getCurrentImage() to get the on
screen pixels of an image.  Playing around things like setVisible() can
bring the window to the front, but we can't figure out how to force the
window to redraw immediately (so we can get the pixels).  Doing
something like:

win.repaint()
thread.sleep(500)

works but is kludgy.  Playing around with awt.EventQueue.invokeAndWait()
to try to flush awt events is something we can't get working either, and
I'm not sure that's a good way to attack it.

Is there a better / more proper way to do this?

I could have sworn there was a thread about this or something similar,
maybe a bug fix or a specific linux issue (we're on Ubuntu + Sun JRE
1.6)?  But I can't find it.

Thanks,
Collin




The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: tofront() and getCurrentImage()

Nathaniel Ryckman
You can use the WindowManager, ImagePlus, and ImageProcessor classes.


You could use these three commands to iterate through the windows:

WindowManager.getWindowCount()
WindowManager.getIDList()
WindowManager.getImage(int imageID)
WindowManager.getImage(String title)

The following is pseudo-code for getting the image once you have selected a window:

ImagePlus imp = WindowManager.getImage(int imageID);
ImageProcessor ip = imp.getImageProcessor();
byte p = ip.pixelValue(x, y);

If you see the window before it gets pushed to the back, you can store a reference of it and use it later. Again, here's some more pseudo-code:

ImageWindow iw = WindowManager.getCurrentImage();
WindowManager.setCurrentWindow(iw);
WindowManager.setWindow(iw); <-- "The specified frame becomes the front window, the one returnd by getFrontWindow()"

I highly recommend creating an imageJ project in Eclipse. It's much more easier to deal with than sifting through documentation online.

http://rsbweb.nih.gov/ij/download/src/