This is a read-only version of, available during the transition to a new site.
Please direct any questions or issues to this Forum thread.
Thank you for your patience as we improve the website!

3D Viewer: Two Canvasses

(Return to the Developer Documentation page)
(Return to the main 3D_Viewer page)

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.