From bfe1649e4ae368be307dc423c84eb3bf00cb3cce Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 21 Apr 2011 14:49:48 +0000 Subject: [PATCH] separated alignment annotation height calculation from panel height adjustment --- src/jalview/gui/AlignmentPanel.java | 23 +++++++++++++++++------ src/jalview/gui/AnnotationPanel.java | 26 ++++++++++++++++++-------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index e50b522..3ea6496 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -393,9 +393,17 @@ public class AlignmentPanel extends GAlignmentPanel implements { System.out.println("NEEDS FIXING"); } - + validateAnnotationDimensions(true); + addNotify(); + repaint(); + } + /** + * calculate the annotation dimensions and refresh slider values accordingly. + * need to do repaints/notifys afterwards. + */ + protected void validateAnnotationDimensions(boolean adjustPanelHeight) { int height = annotationPanel.adjustPanelHeight(); - + if (hscroll.isVisible()) { height += hscroll.getPreferredSize().height; @@ -404,17 +412,20 @@ public class AlignmentPanel extends GAlignmentPanel implements { height = alignFrame.getHeight() / 2; } - + if (!adjustPanelHeight) + { + // maintain same window layout whilst updating sliders + height=annotationScroller.getSize().height; + } hscroll.addNotify(); - + annotationScroller.setPreferredSize(new Dimension(annotationScroller .getWidth(), height)); annotationSpaceFillerHolder.setPreferredSize(new Dimension( annotationSpaceFillerHolder.getWidth(), height)); annotationScroller.validate();// repaint(); - addNotify(); - repaint(); + annotationScroller.addNotify(); } /** diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 01c933a..8a93f79 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -132,6 +132,24 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public int adjustPanelHeight() { + int height=calcPanelHeight(); + this.setPreferredSize(new Dimension(1, height)); + if (ap != null) + { + // revalidate only when the alignment panel is fully constructed + ap.validate(); + } + + 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; @@ -180,14 +198,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, // set minimum height = 20; } - - this.setPreferredSize(new Dimension(1, height)); - if (ap != null) - { - // revalidate only when the alignment panel is fully constructed - ap.validate(); - } - return height; } -- 1.7.10.2