X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationPanel.java;h=d4fcf979ac994dbae1117357d34420d2e11c134a;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=11a957ab40bf5683cf30febd5e9fa322f09340bd;hpb=4fcca76a6c1460d492469ace09a728925b733bfe;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 11a957a..d4fcf97 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -81,7 +81,7 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, av = ap.av; setLayout(null); int height = adjustPanelHeight(); - ap.apvscroll.setValues(0, getHeight(), 0, height); + ap.apvscroll.setValues(0, getSize().height, 0, height); addMouseMotionListener(this); @@ -355,7 +355,7 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0; } graphStretchY = evt.getY(); - adjustPanelHeight(); + calcPanelHeight(); needValidating = true; ap.paintAlignment(true); } @@ -426,7 +426,21 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, public int adjustPanelHeight(boolean repaint) { - + int height = calcPanelHeight(); + this.setSize(new Dimension(getSize().width, height)); + if (repaint) + { + repaint(); + } + return height; + } + /** + * calculate the height for visible annotation, revalidating bounds where necessary + * ABSTRACT GUI METHOD + * @return total height of annotation + */ + public int calcPanelHeight() + { // setHeight of panels AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int height = 0; @@ -469,11 +483,6 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, { height = 20; } - this.setPreferredSize(new Dimension(getSize().width, height)); - if (repaint) - { - repaint(); - } return height; @@ -516,13 +525,16 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, public void paint(Graphics g) { - - imgWidth = getSize().width; + Dimension d = getSize(); + imgWidth = d.width; // (av.endRes - av.startRes + 1) * av.charWidth; - - if (image == null || imgWidth != image.getWidth(this)) + if (imgWidth<1 || d.height<1) + { + return; + } + if (image == null || imgWidth != image.getWidth(this) || d.height != image.getHeight(this)) { - image = createImage(imgWidth, ap.annotationPanel.getSize().height); + image = createImage(imgWidth, d.height); gg = image.getGraphics(); gg.setFont(av.getFont()); fm = gg.getFontMetrics();