X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=359c500eb91a9d258eb9a301c5ea8be6ce4daeef;hb=a45774ee31d9f35d4eff46d54d7deab719afb092;hp=638a1c998765c5fd1dc5fd32f22c60f44180df80;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 638a1c9..359c500 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/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, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -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; @@ -175,19 +193,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, height += aa[i].height; } } - if (height==0) + if (height == 0) { // 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; } @@ -200,7 +210,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, public void actionPerformed(ActionEvent evt) { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - if (aa==null) + if (aa == null) { return; } @@ -919,9 +929,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (v == column) { - g - .fillRect(x * av.charWidth, y, av.charWidth, - av.charHeight); + g.fillRect(x * av.charWidth, y, av.charWidth, av.charHeight); } } } @@ -1096,9 +1104,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (sCol == 0 || row.annotations[sCol - 1] == null || row.annotations[sCol - 1].secondaryStructure != 'H') { - g - .fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, - 90, 180); + g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180); x1 += av.charWidth / 2; } @@ -1380,7 +1386,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } // draw profile if available - if (aa.annotations[column].value != 0 && renderProfile) + if (renderProfile && aa.annotations[column].value != 0) { int profl[] = getProfileFor(aa, column); int ht = y1, htn = y2 - y1;// aa.graphHeight; @@ -1416,8 +1422,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, // group(aa.groupRef.cs==null) // ? av.textColour2 : // cs.findColour(dc)); - g.drawChars(dc, 0, 1, x * av.charWidth, (int) (ht + lm - .getHeight())); + g.drawChars(dc, 0, 1, x * av.charWidth, + (int) (ht + lm.getHeight())); // ht+=g.getFontMetrics().getAscent()-g.getFontMetrics().getDescent(); } } @@ -1447,16 +1453,16 @@ public class AnnotationPanel extends JPanel implements MouseListener, && aa.groupRef.isShowSequenceLogo()) { return AAFrequency.extractProfile( - aa.groupRef.consensusData[column], aa.groupRef - .getIgnoreGapsConsensus()); + aa.groupRef.consensusData[column], + aa.groupRef.getIgnoreGapsConsensus()); } // TODO extend annotation row to enable dynamic and static profile data to // be stored if (aa.groupRef == null && aa.sequenceRef == null && av.isShowSequenceLogo()) { - return AAFrequency.extractProfile(av.hconsensus[column], av - .getIgnoreGapsConsensus()); + return AAFrequency.extractProfile(av.hconsensus[column], + av.getIgnoreGapsConsensus()); } } return null;