Skip to content

Commit

Permalink
3D Viewer: split Image3DUniverse.show() into init() and show().
Browse files Browse the repository at this point in the history
Allows for using third-party ImageWindow3D instances.
  • Loading branch information
acardona committed Oct 12, 2011
1 parent 766b161 commit 31ebfe1
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src-plugins/3D_Viewer/ij3d/Image3DUniverse.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,37 @@ public void mouseClicked(MouseEvent e) {
*/
@Override
public void show() {
init(new ImageWindow3D("ImageJ 3D Viewer", this));
win.pack();
win.setVisible(true);
}

/**
* It is assumed that the {@param window} already displays the {@link Canvas3D}
* as obtained from calling {@link Image3DUniverse#getCanvas()}.
* If the {@link DefaultUniverse} obtained from {@link ImageWindow3D#getUniverse()}
* is not exactly this universe, a {@link RuntimeException} is thrown.
*
* This method acts as an initialization of the ImageWindow3D,
* by adding the menubar to it as well as initializing the {@link PointListDialog}
* and adding a {@link WindowAdapter} to the {@param window} that does cleanup.
*
* The {@param window} is not shown, that is, {@link ImageWindow3D#pack()}
* and {@link ImageWindow3D#setVisible()} are not called.
*
*/
public void init(ImageWindow3D window) {
if (window.getUniverse() != this) {
throw new RuntimeException("Incompatible universes! Go rethink the multiverse!");
}
this.win = window;
// Java 1.6.0_12 fixes the issues occurring when mixing
// AWT heavyweight and Swing lightweight components.
// Unfortunately, not everything is working so far, so
// comment out the check for the Java version.
// if(System.getProperty("java.version").compareTo("1.6.0_12") < 0)
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
win = new ImageWindow3D("ImageJ 3D Viewer", this);
plDialog = new PointListDialog(win);
plDialog = new PointListDialog(this.win);
plDialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
hideAllLandmarks();
Expand All @@ -208,9 +231,6 @@ public void windowClosing(WindowEvent e) {
menubar = new Image3DMenubar(this);
registrationMenubar = new RegistrationMenubar(this);
setMenubar(menubar);

win.pack();
win.setVisible(true);
}

/**
Expand Down

0 comments on commit 31ebfe1

Please sign in to comment.