Posted by
dscho on
URL: http://imagej.273.s1.nabble.com/Advice-for-GUI-plugin-development-tp5001300p5001310.html
Hi Oliver,
On Wed, 2 Jan 2013, Oliver Tills wrote:
> I am very new to writing code etc so I apologise if I have overlooked
> something obvious. I've been learning Java and am starting to get
> comfortable with creating functional swing interfaces, however I'm
> encountering some issues when I try and get these functioning within
> ImageJ (in NetBeans). I have read and been using the Writing Image J
> Plugins Tutorial and this has been a real help.
>
> I am using Image J to develop an educational resource whereby students
> will be presented with a GUI which allows them to choose a treatment,
> this will then call up appropriate images sequences which they then
> perform measurements (size/count) using. These measurements will be
> entered into a table and a plot facility will allow them to visualise
> the results of their experiment. My plan is to achieve this by creating
> Image J plugins, however I have several questions -
>
> Firstly, is what I describe (very briefly) achievable using Image J
> plugins (Image J seems to largely be made up of plugins so I couldn't
> find a reason why this shouldn't be feasible)?
It can be achieved, but it would be hard to do exactly the way you want it
to. The MDI approach (i.e. decorate ImageJ's ImageWindows) did not work
for me, as ImageCanvas does not implement everything for a well-behaved
AWT component. Besides, there are still problems with mixing AWT and Swing
components (ImageJ is almost completely relying on AWT).
> I've been using Swing to create GUI's as I found this creates a nicer
> looking interface (this may well just be my inexperience using AWT),
> however I see that PlugInFrame is AWT based and if I try to bring the
> Swing designed windows into a PlugInFrame this does not work (perhaps
> not surprisingly). Therefore should I be switching to AWT for this
> project or can I continue using Swing and get Image J functions working
> with this? What are the advantages/disadvantages of using the Image J
> PlugInFrame as opposed to my own JFrame?
The common strategy is to use different windows for the Swing stuff and
control the AWT windows containing the images (and control the plugins
working on them) through the code triggered by the Swing components.
> I would also like to embed the Image J image windows within a window to
> provide some control over the layout of various components (i.e. a
> control bar for play/pause/measure options positioned next to the window
> – I was going to hide the main Image J window to provide control over
> the features available). Is this possible and if so what is the best
> way of achieving it?
The current design of ImageJ does not allow that, really. There are hacks
e.g. to make an MDI interface for web applets, but they all have their
shortcomings because the architecture of ImageJ really calls for SDI (i.e.
all windows and control components are in separate windows).
So in the short run, I would suggest to keep your GUI in a window separate
from the images and interact with the images and plugins via the API
provided by ij.IJ and ij.WindowManager.
Ciao,
Johannes
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html