Page history Edit this page How do I edit this website?

3D Viewer › Two Canvasses

How to create two canvasses displaying the same universe

You can download example source code for this HowTo here.

This howto shows how to create two windows showing the same universe:

// Open a hyperstack  
String path = "/home/bene/PhD/brains/template.tif";  
ImagePlus imp = IJ.openImage(path);

// Create a universe and show it  
Image3DUniverse univ = new Image3DUniverse();  

// retrieve some info about the 1st canvas  
int w = univ.getCanvas().getWidth();  
int h = univ.getCanvas().getHeight();

// Create a new canvas and add it  
ImageCanvas3D canvas2 = new ImageCanvas3D(w, h);  

// create a new window, add the canvas and show it  
Frame f = new Frame();  

After creating the universe as usual, a new ImageCanvas3D is created. To make it display the existing universe, it has to be registered with it. This is done with univ.getViewer().getView().addCanvas3D(...).

All what is left to do is to create a new frame, add the canvas to it and finally show it.