X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSplitFrame.java;fp=src%2Fjalview%2Fgui%2FSplitFrame.java;h=c23ed7cf92ca06ff09a5b70323ede68963304216;hb=f5fcdd78b748d055053e117e31837861cfc76b89;hp=beb2d628e76cd902d4e60745e13107d1c9ec9d08;hpb=3730ef528b26ad0fc89a591ead2d44b90af86dfa;p=jalview.git diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index beb2d62..c23ed7c 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -201,8 +201,18 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI */ protected void adjustDivider() { - final AlignViewport topViewport = ((AlignFrame) getTopFrame()).viewport; - final AlignViewport bottomViewport = ((AlignFrame) getBottomFrame()).viewport; + AlignFrame topFrame = (AlignFrame) getTopFrame(); + AlignFrame bottomFrame = (AlignFrame) getBottomFrame(); + + /* + * recompute layout of top and bottom panels to reflect their + * actual (rather than requested) height + */ + topFrame.alignPanel.adjustAnnotationHeight(); + bottomFrame.alignPanel.adjustAnnotationHeight(); + + final AlignViewport topViewport = topFrame.viewport; + final AlignViewport bottomViewport = bottomFrame.viewport; final AlignmentI topAlignment = topViewport.getAlignment(); final AlignmentI bottomAlignment = bottomViewport.getAlignment(); boolean topAnnotations = topViewport.isShowAnnotation(); @@ -214,6 +224,33 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI int bottomCharHeight = bottomViewport.getViewStyle().getCharHeight(); /* + * calculate the minimum ratio that leaves at least + * two sequences visible in the top panel + */ + int topPanelHeight = topFrame.getHeight(); + int bottomPanelHeight = bottomFrame.getHeight(); + int topSequencesHeight = topFrame.alignPanel.getSeqPanel().seqCanvas + .getHeight(); + int topPanelMinHeight = topPanelHeight + - Math.max(0, + topSequencesHeight - 2 * topViewport.getCharHeight()); + double totalHeight = (double) topPanelHeight + bottomPanelHeight; + double minRatio = topPanelMinHeight / totalHeight; + + /* + * calculate the maximum ratio that leaves at least + * two sequences visible in the bottom panel + */ + int bottomSequencesHeight = bottomFrame.alignPanel.getSeqPanel().seqCanvas + .getHeight(); + int bottomPanelMinHeight = bottomPanelHeight + - Math.max( + 0, + bottomSequencesHeight - 2 + * bottomViewport.getCharHeight()); + double maxRatio = (totalHeight - bottomPanelMinHeight) / totalHeight; + + /* * estimate ratio of (topFrameContent / bottomFrameContent) */ int insets = Platform.isAMac() ? MAC_INSETS_HEIGHT @@ -223,14 +260,15 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI + (topAnnotations ? topViewport.calcPanelHeight() : 0); int bottomHeight = insets + (3 + bottomCount) * bottomCharHeight + (bottomAnnotations ? bottomViewport.calcPanelHeight() : 0); - double ratio = ((double) topHeight) / (topHeight + bottomHeight); + double ratio = ((double) topHeight) + / (double) (topHeight + bottomHeight); /* - * limit to 0.2 <= ratio <= 0.8 to avoid concealing all sequences + * limit ratio to avoid concealing all sequences */ - ratio = Math.min(ratio, 0.8d); - ratio = Math.max(ratio, 0.2d); - setRelativeDividerLocation(ratio); + ratio = Math.min(ratio, maxRatio); + ratio = Math.max(ratio, minRatio); + // setRelativeDividerLocation(ratio); } /**