Page 1 of 2

Full image view in TreeViewer

PostPosted: Thu Oct 15, 2009 12:42 pm
by ryan
Hi, i want to see the image expanded in the central pane when i double click on it, instead of showing it in a separate window. I see that the full image view is implemented in : imviewer/

But i dont want a separate window. Please tell me, how i can get the UI and add it to the TreeViewerWin.
I tried using the ImageData.getName() and form an ImageIcon based on it, add it to a JLabel and call addComponent() of

Then the image is shown in the middle pane, but it is added from the local system path. If we delete the image from the path, it is not shown. Can anyone explain how the image is got from the server/database, and shown in a separate window, so that i can get the image and show it in middle pane of treeviewer.

Please advice. ;)

Re: Full image view in TreeViewer

PostPosted: Sat Oct 17, 2009 8:01 am
by jburel
This will require some work and understanding of the structure.

Re: Full image view in TreeViewer

PostPosted: Mon Oct 19, 2009 5:10 am
by ryan
I saw that the images are added in TreeViewerWin using the following: view.addComponent(db.getUI());
and they are added mostly from
I hope, i can add the image to the TreeViewerWin's central pane, using the addComponent() method of it.

Here is what i have tried:

I hope the double clicked image is rendered in's setImage(BufferedImage image), so i have passed this image to a ImageIcon:

Code: Select all
JLabel label = new JLabel(new ImageIcon(image));
JFrame f = new JFrame();
f.add(label); f.setTitle("Test");

Then i got the image in a new frame, after double clicking on it, from the central pane of TreeViewer. ;)
But what iam not able to get is : when i have passed the label as a parameter to the addComponent(JComponent component) method of TreeViewerWin, (after creating an object of TreeViewerWin), in's setImage() method, iam not able to view the image in the central pane, though iam able to get the image in a new frame.

Dont know, where iam missing.

Re: Full image view in TreeViewer

PostPosted: Wed Oct 21, 2009 4:46 am
by ryan
I also tried another way.
I thought it is necessary to invoke the addComponent(JComponent) method of TreeViewerWin only from the, so that i can get the image to and call addComponent method.

I tried the same. I passed the image-added-label as a component to TreeViewerComponent (from's setImage method) :
TreeViewerComponent tvc = new TreeViewerComponent(label);

And in TreeViewerComponent constructor, i called
Code: Select all
public TreeViewerComponent(JComponent comp) {
view = new TreeViewerWin();
view.addComponent(comp);   // add image to working pane

When i called the addComponent(), i was getting the image ( I added the same image to a frame and i can see it), but the problem is that: the workingpane (central pane, where i want the image to be shown) is becoming null. Hence i could not see the image.

Even i tried to reinstantiate it, like: view.workingPane = new JScrollPane(comp);
But it did not work.

Re: Full image view in TreeViewer

PostPosted: Wed Oct 21, 2009 8:33 pm
by jburel
Hi Ryan

it is null b/c you have invoke the initialize method, you should not have to modify the initialization sequence. A TreeViewer is initialized via the factory.


Re: Full image view in TreeViewer

PostPosted: Thu Oct 22, 2009 5:23 am
by ryan
Thanks for the reply. I have tried to call the initialize method, from my TreeViewerComponent constructor above, like:
Code: Select all
view.initialize(controller, model, null);

However, iam getting few error messages like: No model

Re: Full image view in TreeViewer

PostPosted: Thu Oct 22, 2009 5:59 am
by jburel
You should not have to modify the tree viewer as such.
When a image is selected and the user decides to view by either selecting the view menu item or double-click, an event is posted on the event bus to launch the image. That's what you need to modify so you load the rendered image and do what you want with it.


Re: Full image view in TreeViewer

PostPosted: Thu Oct 22, 2009 6:30 am
by ryan
Ok, i understood the complete flow now. This is my understanding of what is happening when we double click on an image: ;)

1. The mouseReleased method is invoked in

2. Then viewDisplay method is invoked in, which gets the imagedata and posts the event to bus.

3. Then the event of view image is handled by handleViewImage method of, which creates the imviewer.

4. Now the propertyChange() method is invoked in, which calls onRndLoaded() of ImViewerComponent, where the components and GUI of ImViewerUI (new window hosting image) are built.

5. Then renderXYPlane() is invoked in ImViewerComponent, which fires the image retrieval, using the fireImageRetrieval() method in ImViewerModel, that sets the rendered image in, using the setRenderedImage(), and calls paintMainImage() in

6. Finally in paintMainImage() of, the createDisplayedImage() of BrowserModel is called, that magnifies the rendered image.

7. The BrowserUI is the view that is returned and is added to a ClosableTabbedPaneComponent in a new window (ImViewerUI).

Now Please tell me, how i can get the rendered image to the working pane of TreeViewer.
As the treeviewer is initialised before the image is double clicked, how can i get the reference of it ?

And as you said that i should not have to modify the tree viewer, how can i transfer the image to TreeViewerWin. :!:

Re: Full image view in TreeViewer

PostPosted: Mon Oct 26, 2009 7:50 am
by ryan
I have modified the TreeViewerAgent and made it to handle the event ViewImage, and i have commented out the code that handles the same event in ImViewerAgent. Now the ImViewer is created from TreeViewerAgent:
view = ImViewerFactory.getImageViewer(image, r, b);

And now i have created the treeviewer once again, in TreeViewerAgent's handleViewImage(ViewImage) method:

ExperimenterData exp = (ExperimenterData) registry.lookup(
GroupData gp = exp.getDefaultGroup();
long id = -1;
if (gp != null) id = gp.getId();
TreeViewer viewer = TreeViewerFactory.getTreeViewer(exp, id);

Is my approach right? I could not get any ideas. Iam stuck here since 1 week. Please help. :(

Re: Full image view in TreeViewer

PostPosted: Tue Oct 27, 2009 9:46 am
by ryan
Please someone have a look into this. It is frustrating. :|