Hi,
I'm developing an application which implements the ImageJ PlugIn interface and has its own user interface. That user interface is a JFrame and the application is launched like any other ImageJ plugin. What I want to do is to show an image inside my user interface but continuing to have all the ImageJ functionalities to process this image. Is that possible? I know I can put an ImageCanvas inside a JFrame and then I can show an image. But by doing that I lost all the ImageJ functionalities because my ImageJ instance does not know there's an image open. Could I "tell" ImageJ the image in my user interface is also its image so that I can process the image with ImageJ user interface? Thank you. []s -- Anderson Vinícius Alves Ferreira Intern at Lafarge Centre de Recherche 95 rue du Montmurier - 38291 St Quentin-Fallavier - France |
Hi Anderson,
as far as I can say, you need to write a subclass of ImageWindow (which is a subclass of Frame). The WindowManager of ImageJ accesses the getImagePlus() method of an ImageWindow to get the ImagePlus for processing. A few more relevant methods: WindowManager.addWindow to get it into the list and WindowManager.setCurrentWindow(ImageWindow win) makes it the foreground window. I don't see much chance with a JFrame for a seamless integration -- there is no multiple inheritance in Java. It also seems to me that WindowManager.setTempCurrentImage is no workaround for your needs, because you can set it only for a thread that is known in advance. ImageJ commands from the menu (or shortcuts) create their own threads. There might be an awful workaround of very limited use using the Macro Interpreter, but it may become invalid with any version change, as soon as the Macro Interpreter becomes more multithreading-aware. But maybe someone else has a solution? If this is a common problem, maybe it would be worth to add an interface to ImageJ, say 'ImagePlusContainer' ? ImagePlusContainer would be implemented by ImageWindow. Various getImagePlus() calls in WindowManager would then use the ImagePlusContainer interface, not the ImageWindow. Michael ________________________________________________________________ On 23 Jun 2010, at 16:45, Anderson Vinícius wrote: > Hi, > > I'm developing an application which implements the ImageJ PlugIn > interface > and has its own user interface. That user interface is a JFrame and > the > application is launched like any other ImageJ plugin. > > What I want to do is to show an image inside my user interface but > continuing to have all the ImageJ functionalities to process this > image. Is > that possible? > I know I can put an ImageCanvas inside a JFrame and then I can show an > image. But by doing that I lost all the ImageJ functionalities > because my > ImageJ instance does not know there's an image open. > Could I "tell" ImageJ the image in my user interface is also its > image so > that I can process the image with ImageJ user interface? > > Thank you. > > []s |
Hi Michael,
Thank you for your answer. I had already tried to extend the ImageWindow class but as the ImageWindow() constructor is set as private I can't do it. I've also tried a workaround that would be to add my user interface as a JPanel component into an ImageWindow object. Despite that it works in terms that I get access to the image, it turns out that the user interface gets ugly, limited and doesn't work properly (sometimes the components doesn't show up, other times they start to blink as I move the mouse over the image). I don't know to say if these dysfunctions have something to do with Windows 7 issues. Another workaround I have tried it would be to have my user interface and an ImageWindow (set as non visible but set as the current window) instance running with the same ImageCanvas. But it didn't work. I've also tried to use the WindowManager.setTempCurrentImage method but once again it didn't work. I'm starting to think about changing my approach. But, has someone else already had the same problem? []s -- Anderson On 24 June 2010 18:54, Michael Schmid <[hidden email]> wrote: > Hi Anderson, > > as far as I can say, you need to write a subclass of ImageWindow (which is > a subclass of Frame). The WindowManager of ImageJ accesses the > getImagePlus() method of an ImageWindow to get the ImagePlus for processing. > > A few more relevant methods: > WindowManager.addWindow > to get it into the list and > WindowManager.setCurrentWindow(ImageWindow win) > makes it the foreground window. > > I don't see much chance with a JFrame for a seamless integration -- there > is no multiple inheritance in Java. > > It also seems to me that WindowManager.setTempCurrentImage is no workaround > for your needs, because you can set it only for a thread that is known in > advance. ImageJ commands from the menu (or shortcuts) create their own > threads. > > There might be an awful workaround of very limited use using the Macro > Interpreter, but it may become invalid with any version change, as soon as > the Macro Interpreter becomes more multithreading-aware. > > But maybe someone else has a solution? > > If this is a common problem, maybe it would be worth to add an interface to > ImageJ, say 'ImagePlusContainer' ? > ImagePlusContainer would be implemented by ImageWindow. > Various getImagePlus() calls in WindowManager would then use the > ImagePlusContainer interface, not the ImageWindow. > > Michael > ________________________________________________________________ > > > On 23 Jun 2010, at 16:45, Anderson Vinícius wrote: > > Hi, >> >> I'm developing an application which implements the ImageJ PlugIn interface >> and has its own user interface. That user interface is a JFrame and the >> application is launched like any other ImageJ plugin. >> >> What I want to do is to show an image inside my user interface but >> continuing to have all the ImageJ functionalities to process this image. >> Is >> that possible? >> I know I can put an ImageCanvas inside a JFrame and then I can show an >> image. But by doing that I lost all the ImageJ functionalities because my >> ImageJ instance does not know there's an image open. >> Could I "tell" ImageJ the image in my user interface is also its image so >> that I can process the image with ImageJ user interface? >> >> Thank you. >> >> []s > > |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hello, I did this several times. If you want you can download http://www.mri.cnrs.fr/mriwiki/uploads/mri-cia/mri-cia-source.zip and have a look at /MRI Cell Image Analyzer/src/tools/multipleImageWindow/ or at /MRI Cell Image Analyzer/src/objectModelingWorkbench/ I think it usually didn't work without using some private code somewhere, by either copying it or calling it via reflection, which risks to get broken sometimes. So a clean way to do this would indeed be very nice. > I had already tried to extend the ImageWindow class but as the ImageWindow() > constructor is set as private I can't do it. Which ImageJ version is this? In the ImageJ version I have at hand (1.43s) I see no ImageWindow constructor without arguments and since other constructors exist the default constructor does not exist anymore. Can't you use the public constructor ImageWindow(String title) ? Volker -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwkcswACgkQ0gXPLVKexCczbwCfQFWPh3xVBJJskXaZecyoCjN0 5IkAn1QNZHlPza9bHxpQzmGXsCmYDdCv =eIBc -----END PGP SIGNATURE----- -- passerelle antivirus du campus CNRS de Montpellier -- |
Hi Volker,
Thank you very much for your answer. This is really going to help me. > I had already tried to extend the ImageWindow class but as the ImageWindow() > constructor is set as private I can't do it. >> Which ImageJ version is this? In the ImageJ version I have at hand >> (1.43s) I see no ImageWindow constructor without arguments and since >> other constructors exist the default constructor does not exist anymore. >> Can't you use the public constructor ImageWindow(String title) ? I don't know why at home my Netbeans was saying that, but I couldn't do it. Nonetheless, here at work I tested to extend the ImageWindow class and it worked. I've done a little test project and it works fine. (As far as I get home, I'll test it again.) Another example I've found that does what I wanted to do is the Yawi_2D plugin. Finally, the key points are to extend the ImageWindow class and to add the necessary listeners to the window. []s -- Anderson. On 25 June 2010 11:11, Volker Baecker <[hidden email]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello, > I did this several times. If you want you can download > http://www.mri.cnrs.fr/mriwiki/uploads/mri-cia/mri-cia-source.zip > and have a look at > /MRI Cell Image Analyzer/src/tools/multipleImageWindow/ > or at > /MRI Cell Image Analyzer/src/objectModelingWorkbench/ > I think it usually didn't work without using some private code > somewhere, by either copying it or calling it via reflection, which > risks to get broken sometimes. So a clean way to do this would indeed be > very nice. > > > I had already tried to extend the ImageWindow class but as the > ImageWindow() > > constructor is set as private I can't do it. > Which ImageJ version is this? In the ImageJ version I have at hand > (1.43s) I see no ImageWindow constructor without arguments and since > other constructors exist the default constructor does not exist anymore. > Can't you use the public constructor ImageWindow(String title) ? > > Volker > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkwkcswACgkQ0gXPLVKexCczbwCfQFWPh3xVBJJskXaZecyoCjN0 > 5IkAn1QNZHlPza9bHxpQzmGXsCmYDdCv > =eIBc > -----END PGP SIGNATURE----- > > -- > passerelle antivirus du campus CNRS de Montpellier > -- > |
This post was updated on .
In reply to this post by Anderson Vinícius
it is possible to make that, it is just like an image doc management plugin that can display image in an user interface and then process image.
|
Free forum by Nabble | Edit this page |