Zoom/Unzoom in Image Canvas without an Image Window?

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

Zoom/Unzoom in Image Canvas without an Image Window?

NateR124
Hey, I'm a new programmer using ImageJ, and I'm having trouble using the "unzoom();" and "zoom100Percent();" features with my program. I've created a gui using Java AWT/Swing that has an ImageCanvas as one of the objects in the JFrame, but because I have not put it inside a specific ImageWindow, the default unzoom() and zoom100Percent() methods throw a null pointer error. After looking at the source code, I see that the methods depend on variables like "initial magnification" that are stored within the ImageWindow. Is there a way to use these methods without an ImageWindow, or do I need to find someway to implement the ImageWindow within my JFrame? Thanks for your help!
Reply | Threaded
Open this post in threaded view
|

Re: Zoom/Unzoom in Image Canvas without an Image Window?

NateR124
Just a heads up, for anyone else with this problem - I found the solution! Essentially you DO end up creating an ImageWindow, but you still place the actual Canvas in your JFrame and just create a custom ImageWindow with the show method overwritten to be blank (also with setVisible(false) in the constructor). Just make sure whenever your code calls for an image change, that you update the same ImageCanvas and same ImagePlus that the window is currently using, or else there will be a disparity between the two and it will no longer work.

This guy explains it perfectly, even though there were issues for him (works for me!).
http://osdir.com/ml/java-imagej/2009-09/msg00290.html