*/
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();
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
+ (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);
}
/**