From fdebbbbada35176910e5d8d1065c038ca1e143b2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 15 Sep 2017 14:49:05 +0100 Subject: [PATCH] JAL-2728 limit divider to ensure seqs visible (wip!) --- src/jalview/gui/AlignmentPanel.java | 5 ---- src/jalview/gui/SplitFrame.java | 52 ++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 76368ed..c700635 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -243,11 +243,6 @@ public class AlignmentPanel extends GAlignmentPanel implements getIdPanel().getIdCanvas().setPreferredSize(d); hscrollFillerPanel.setPreferredSize(d); - if (this.alignFrame.getSplitViewContainer() != null) - { - ((SplitFrame) this.alignFrame.getSplitViewContainer()).adjustLayout(); - } - repaint(); } diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index beb2d62..d28bb14 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 topSequencesHeight = topFrame.alignPanel.getSeqPanel().seqCanvas + .getHeight(); + int topPanelMinHeight = topPanelHeight + - Math.max(0, + topSequencesHeight - 2 * topViewport.getCharHeight()); + int myHeight = getHeight(); + double minRatio = topPanelMinHeight / (double) myHeight; + + /* + * calculate the maximum ratio that leaves at least + * two sequences visible in the bottom panel + */ + int bottomPanelHeight = bottomFrame.getHeight(); + int bottomSequencesHeight = bottomFrame.alignPanel.getSeqPanel().seqCanvas + .getHeight(); + int bottomPanelMinHeight = bottomPanelHeight + - Math.max( + 0, + bottomSequencesHeight - 2 + * bottomViewport.getCharHeight()); + double maxRatio = (myHeight - bottomPanelMinHeight) / (double) myHeight; + + /* * 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); } /** -- 1.7.10.2