X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;fp=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=5f4e9fa85764a103f2d2f67eeaad142b18f577fc;hp=b6967df1763c5f11b8dedcf8611d0fdf4f50ef6c;hb=fab0afc9e1e7a5ca460f0cbd48545536f989a435;hpb=b7e521af667bdc18f9071075d1face56367eab69 diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index b6967df..5f4e9fa 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -31,6 +31,7 @@ import jalview.renderer.AwtRenderPanelI; import jalview.schemes.ResidueProperties; import jalview.util.Comparison; import jalview.util.MessageManager; +import jalview.util.Platform; import jalview.viewmodel.ViewportListenerI; import jalview.viewmodel.ViewportRanges; @@ -211,7 +212,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, @Override public Dimension getPreferredScrollableViewportSize() { - return getPreferredSize(); + Dimension ps = getPreferredSize(); + return new Dimension(ps.width, adjustForAlignFrame(false, ps.height)); } @Override @@ -1266,4 +1268,49 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, repaint(); } } + + /** + * computes the visible height of the annotation panel + * + * @param adjustPanelHeight + * - when false, just adjust existing height according to other + * windows + * @param annotationHeight + * @return height to use for the ScrollerPreferredVisibleSize + */ + public int adjustForAlignFrame(boolean adjustPanelHeight, + int annotationHeight) + { + /* + * Estimate available height in the AlignFrame for alignment + + * annotations. Deduct an estimate for title bar, menu bar, scale panel, + * hscroll, status bar, insets. + */ + int stuff = (ap.getViewName() != null ? 30 : 0) + + (Platform.isAMac() ? 120 : 140); + int availableHeight = ap.alignFrame.getHeight() - stuff; + int rowHeight = av.getCharHeight(); + + if (adjustPanelHeight) + { + int alignmentHeight = rowHeight * av.getAlignment().getHeight(); + + /* + * If not enough vertical space, maximize annotation height while keeping + * at least two rows of alignment visible + */ + if (annotationHeight + alignmentHeight > availableHeight) + { + annotationHeight = Math.min(annotationHeight, + availableHeight - 2 * rowHeight); + } + } + else + { + // maintain same window layout whilst updating sliders + annotationHeight = Math.min(ap.annotationScroller.getSize().height, + availableHeight - 2 * rowHeight); + } + return annotationHeight; + } }