- // NOTE: this logic is different in the applet. Need a better algorithm to
- // define behaviour
- // try and set height according to alignment
- if (ascaling > 0 && sscaling < 0.5)
- {
- // if the alignment is too big then
- // default is 0.5 split
- height = alignFrame.getHeight() / 2;
- }
- else
+ int rowHeight = av.getCharHeight();
+ int alignmentHeight = rowHeight * av.getAlignment().getHeight();
+
+ /*
+ * Estimate available height in the AlignFrame for alignment +
+ * annotations. Deduct an estimate for title bar, menu bar, scale panel,
+ * hscroll, status bar (as these are not laid out we can't inspect their
+ * actual heights). Insets gives frame borders.
+ */
+ int stuff = Platform.isAMac() ? 80 : 100;
+ Insets insets = alignFrame.getInsets();
+ int availableHeight = alignFrame.getHeight() - stuff - insets.top
+ - insets.bottom;
+
+ /*
+ * If not enough vertical space, maximize annotation height while keeping
+ * at least two rows of alignment visible
+ */
+ if (annotationHeight + alignmentHeight > availableHeight)