We're Hiring!

Full image view in TreeViewer

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Full image view in TreeViewer

Postby ryan » Thu Oct 15, 2009 12:42 pm

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/ImViewerUI.java

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 TreeViewerWin.java.

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. ;)
Last edited by ryan on Fri Oct 23, 2009 6:30 am, edited 1 time in total.
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby jburel » Sat Oct 17, 2009 8:01 am

This will require some work and understanding of the structure.
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: Full image view in TreeViewer

Postby ryan » Mon Oct 19, 2009 5:10 am

I saw that the images are added in TreeViewerWin using the following: view.addComponent(db.getUI());
and they are added mostly from TreeViewerComponent.java.
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 ImViewerComponent.java'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");
f.setVisible(true);


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 ImViewerComponent.java'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.
Last edited by ryan on Wed Oct 21, 2009 5:44 am, edited 4 times in total.
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby ryan » Wed Oct 21, 2009 4:46 am

I also tried another way.
I thought it is necessary to invoke the addComponent(JComponent) method of TreeViewerWin only from the TreeViewerComponent.java, so that i can get the image to TreeViewerComponent.java and call addComponent method.

I tried the same. I passed the image-added-label as a component to TreeViewerComponent (from ImViewerComponent.java'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.
Last edited by ryan on Fri Oct 23, 2009 11:38 am, edited 1 time in total.
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby jburel » Wed Oct 21, 2009 8:33 pm

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.

jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: Full image view in TreeViewer

Postby ryan » Thu Oct 22, 2009 5:23 am

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
Last edited by ryan on Thu Oct 22, 2009 6:11 am, edited 1 time in total.
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby jburel » Thu Oct 22, 2009 5:59 am

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.


jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: Full image view in TreeViewer

Postby ryan » Thu Oct 22, 2009 6:30 am

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 dataBrowser.browser.BrowserControl.java

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

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

4. Now the propertyChange() method is invoked in ImViewerControl.java, 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 imviewer.browser.BrowserModel.java, using the setRenderedImage(), and calls paintMainImage() in imviewer.browser.BrowserUI.java.

6. Finally in paintMainImage() of BrowserUI.java, 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. :!:
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby ryan » Mon Oct 26, 2009 7:50 am

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(
LookupNames.CURRENT_USER_DETAILS);
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. :(
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Re: Full image view in TreeViewer

Postby ryan » Tue Oct 27, 2009 9:46 am

Please someone have a look into this. It is frustrating. :|
ryan
 
Posts: 18
Joined: Thu Oct 15, 2009 12:32 pm

Next

Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests