Skip to content

Commit

Permalink
Merge pull request #36 from automated-ultramicrotomy/window_placement
Browse files Browse the repository at this point in the history
Fix window spacing
  • Loading branch information
K-Meech authored Jul 8, 2024
2 parents bdba192 + c20939e commit 7bf8d34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>crosshair</artifactId>
<url>https://github.com/K-Meech/crosshair</url>
<version>1.0.4</version>
<version>1.0.5</version>
<name>Crosshair</name>
<description>Assisted 3D targeting via an ultramicrotome</description>
<inceptionYear>2020</inceptionYear>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/embl/schwab/crosshair/Crosshair.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void initialiseCrosshair(BdvStackSource bdvStackSource, Image3DUniverse

CrosshairFrame crosshairFrame = new CrosshairFrame(this);

spaceOutWindows( bdvHandle, crosshairFrame, universe );
spaceOutWindows( crosshairFrame, bdvHandle, universe );
}

public BdvHandle getBdvHandle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public TargetingAccuracy ( File beforeTargetingXml, File registeredAfterTargetin
reader.loadSettings( settings, planeManager,
accuracyFrame.getImagesPanel().getImageNameToContent(), accuracyFrame.getOtherPanel() );

spaceOutWindows(beforeStackSource.getBdvHandle(), accuracyFrame, universe);
spaceOutWindows(accuracyFrame, beforeStackSource.getBdvHandle(), universe);

}
}
Expand Down
34 changes: 28 additions & 6 deletions src/main/java/de/embl/schwab/crosshair/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,38 @@ public static int findIndexOfMaxMin (ArrayList<Double> values, String MinMax) {

}

public static void spaceOutWindows( BdvHandle bdvHandle, JFrame frame, Image3DUniverse universe ) {
// Space out windows like here:
// https://github.com/mobie/mobie-viewer-fiji/blob/9f7367902cc0bd01e089f7ce40cdcf0ee0325f1e/src/main/java/de/embl/cba/mobie/ui/viewer/SourcesPanel.java#L369
/**
* Space out the three Crosshair windows, with the JFrame on the left (with controls), big data viewer in the
* middle and the 3D viewer on the right.
* Based on
* https://github.com/mobie/mobie-viewer-fiji/blob/main/src/main/java/org/embl/mobie/ui/WindowArrangementHelper.java
* @param frame JFrame containing controls
* @param bdvHandle bdvHandle of the BigDataViewer window
* @param universe universe of the 3D viewer
*/
public static void spaceOutWindows( JFrame frame, BdvHandle bdvHandle, Image3DUniverse universe ) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Window viewFrame = SwingUtilities.getWindowAncestor(bdvHandle.getViewerPanel());

// Make sure bigdataviewer + 3D viewer aren't taller than the screen
int viewHeight = viewFrame.getHeight();
if (viewHeight > screenSize.getHeight()) {
viewHeight = (int) Math.floor(screenSize.getHeight());
}

// Place the 3D viewer in the top right corner, and set its width to a third of the remaining space
// (after the controls width is taken into account)
int width3DViewer = (int) Math.floor((screenSize.getWidth() - frame.getWidth())/3.0);
universe.setSize(width3DViewer, viewHeight);
universe.getWindow().setLocation((int) Math.floor(screenSize.getWidth() - width3DViewer),
frame.getLocationOnScreen().y);

// Fill any remaining width between the controls and 3D viewer with the bdv window
viewFrame.setLocation(
frame.getLocationOnScreen().x + frame.getWidth(),
frame.getLocationOnScreen().y );

universe.getWindow().setLocation(viewFrame.getLocationOnScreen().x + viewFrame.getWidth(),
viewFrame.getLocation().y);
int newViewWidth = (int) Math.floor(screenSize.width - width3DViewer - frame.getWidth());
viewFrame.setSize(newViewWidth, viewHeight);
}

public static void resetCrossPlatformSwingLookAndFeel() {
Expand Down

0 comments on commit 7bf8d34

Please sign in to comment.