Skip to content

Commit 9b19185

Browse files
committed
fix too large compute pane on small screens but. allow user to resize pane.
1 parent 54bc7a9 commit 9b19185

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

sirius_gui/src/main/java/de/unijena/bioinf/ms/gui/compute/BatchComputeDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class BatchComputeDialog extends JDialog {
5454

5555
public BatchComputeDialog(SiriusGui gui, List<InstanceBean> compoundsToProcess) {
5656
super(gui.getMainFrame(), compoundsToProcess.isEmpty() ? "Edit Presets" : "Compute", true);
57-
setPreferredSize(new Dimension(1150, 970));
5857

5958
gui.getConnectionMonitor().checkConnectionInBackground();
6059
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@@ -114,9 +113,9 @@ public BatchComputeDialog(SiriusGui gui, List<InstanceBean> compoundsToProcess)
114113
Jobs.runEDTLater(() -> SoftwareTourUtils.checkAndInitTour(this, SoftwareTourInfoStore.BatchComputeTourName, SoftwareTourInfoStore.BatchComputeTourKey, gui.getProperties()));
115114

116115
//finalize panel build and make the dialog visible
117-
setResizable(false);
118-
setMaximumSize(GuiUtils.getEffectiveScreenSize(getGraphicsConfiguration()));
116+
setPreferredSize(GuiUtils.getPreferredSizeLimitedByScreenSize(new Dimension(1150, 1024)));
119117
pack();
118+
setResizable(true);
120119
setLocationRelativeTo(getParent());
121120
setVisible(true);
122121
}

sirius_gui/src/main/java/de/unijena/bioinf/ms/gui/dialogs/CompoundFilterOptionsDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public CompoundFilterOptionsDialog(SiriusGui gui, PlaceholderTextField searchFie
367367

368368
add(buttons, BorderLayout.SOUTH);
369369

370-
setMaximumSize(GuiUtils.getEffectiveScreenSize(getGraphicsConfiguration()));
370+
setMaximumSize(GuiUtils.getEffectiveScreenSize());
371371
configureActions();
372372
pack();
373373
setLocationRelativeTo(getParent());

sirius_gui/src/main/java/de/unijena/bioinf/ms/gui/utils/GuiUtils.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,26 @@ public static String formatToolTip(int width, java.util.List<String> lines) {
153153
+ "</p></html>";
154154
}
155155

156-
public static Dimension getEffectiveScreenSize(@NotNull GraphicsConfiguration c) {
157-
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
158-
return new Dimension((int) Math.round(d.width * .8), (int) Math.round(d.height * .8));
156+
public static Dimension getEffectiveScreenSize() {
157+
return getPreferredSizeLimitedByScreenSize(null);
158+
}
159+
160+
public static Dimension getPreferredSizeLimitedByScreenSize(int preferredWidth, int preferredHeight) {
161+
return getPreferredSizeLimitedByScreenSize(new Dimension(preferredWidth, preferredHeight));
162+
}
163+
164+
public static Dimension getPreferredSizeLimitedByScreenSize(@Nullable Dimension preferredSize) {
165+
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
166+
167+
Rectangle screenBounds = ge.getMaximumWindowBounds();
168+
169+
int maxScreenWidth = (int) Math.round(screenBounds.width * .9);
170+
int maxScreenHeight = (int) Math.round(screenBounds.height * .9);
171+
172+
if (preferredSize == null)
173+
return new Dimension(maxScreenWidth, maxScreenHeight);
174+
175+
return new Dimension(Math.min(preferredSize.width, maxScreenWidth), Math.min(preferredSize.height, maxScreenHeight));
159176
}
160177

161178
public static JPanel newNoResultsComputedPanel() {

0 commit comments

Comments
 (0)