X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSplitFrame.java;h=a6c7bb8fa283b2b818028cacc340e25b8ddbb725;hb=57dd16688caa6dacaeaf465bab3ee8b6126e1a51;hp=4e2187e068523a7656f3319b7df81121bd23632b;hpb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;p=jalview.git diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 4e2187e..a6c7bb8 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -26,6 +26,7 @@ import jalview.datamodel.AlignmentI; import jalview.jbgui.GAlignFrame; import jalview.jbgui.GSplitFrame; import jalview.structure.StructureSelectionManager; +import jalview.util.Platform; import jalview.viewmodel.AlignmentViewport; import java.awt.Component; @@ -37,12 +38,15 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.beans.PropertyVetoException; import java.util.Map.Entry; +import java.util.Set; import javax.swing.AbstractAction; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JMenuItem; import javax.swing.KeyStroke; +import javax.swing.UIDefaults; +import javax.swing.UIManager; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; @@ -81,12 +85,24 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI ((AlignFrame) getTopFrame()).getViewport().setCodingComplement( ((AlignFrame) getBottomFrame()).getViewport()); - int width = ((AlignFrame) getTopFrame()).getWidth(); - // about 50 pixels for the SplitFrame's title bar etc + /* + * estimate width and height of SplitFrame; this.getInsets() doesn't seem to + * give the full additional size (a few pixels short) + */ + UIDefaults defaults = UIManager.getDefaults(); + Set keySet = defaults.keySet(); + for (Object key : keySet) + { + System.out.println(key.toString() + " = " + + UIManager.get(key).toString()); + } + int widthFudge = Platform.isAMac() ? 28 : 28; // Windows tbc + int heightFudge = Platform.isAMac() ? 50 : 50; // tbc + int width = ((AlignFrame) getTopFrame()).getWidth() + widthFudge; int height = ((AlignFrame) getTopFrame()).getHeight() - + ((AlignFrame) getBottomFrame()).getHeight() + 50; - // about 65 pixels for Desktop decorators on Windows - height = Math.min(height, Desktop.instance.getHeight() - 65); + + ((AlignFrame) getBottomFrame()).getHeight() + DIVIDER_SIZE + + heightFudge; + height = fitHeightToDesktop(height); setSize(width, height); adjustLayout(); @@ -101,6 +117,27 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI } /** + * Reduce the height if too large to fit in the Desktop. Also adjust the + * divider location in proportion. + * + * @param height + * in pixels + * @return original or reduced height + */ + public int fitHeightToDesktop(int height) + { + // allow about 65 pixels for Desktop decorators on Windows + + int newHeight = Math.min(height, Desktop.instance.getHeight() - 65); + if (newHeight != height) + { + int oldDividerLocation = getDividerLocation(); + setDividerLocation(oldDividerLocation * newHeight / height); + } + return newHeight; + } + + /** * Set the top and bottom frames to listen to each others Commands (e.g. Edit, * Order). */