From 6d9cb59a547de8c4d73e1ba365fe8b91f91063c6 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 30 Mar 2010 17:46:55 +0000 Subject: [PATCH] bugfix for redraw when AlignPanel partially constructed. group autoannotation and consensus display settings --- src/jalview/gui/AnnotationPanel.java | 36 +++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 281d5dc..b196444 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -141,6 +141,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, { for (int i = 0; i < aa.length; i++) { + if (aa[i]==null) + { + System.err.println("Null annotation row: ignoring."); + continue; + } if (!aa[i].visible) { continue; @@ -177,7 +182,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, } this.setPreferredSize(new Dimension(1, height)); - ap.alabels.validate(); + if (ap!=null) + { + // revalidate only when the alignment panel is fully constructed + ap.validate(); + } return height; } @@ -1300,7 +1309,18 @@ public class AnnotationPanel extends JPanel implements MouseListener, int column; int aaMax = aa.annotations.length - 1; - + boolean renderHistogram = true, renderProfile = true; + if (aa.autoCalculated && aa.label.startsWith("Consensus")) { + // TODO: generalise this to have render styles for consensus/profile data + if (aa.groupRef!=null) + { + renderHistogram = aa.groupRef.isShowConsensusHistogram(); + renderProfile = aa.groupRef.isIncludeAllConsSymbols(); + } else { + renderHistogram = av.isShowConsensusHistogram(); + renderProfile = av.isShowConsensusProfile(); + } + } while (x < eRes - sRes) { column = sRes + x; @@ -1319,7 +1339,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, x++; continue; } - if (aa.annotations[column].colour == null) g.setColor(Color.black); else @@ -1328,7 +1347,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, y1 = y - (int) (((aa.annotations[column].value - min) / (range)) * aa.graphHeight); - if (y1 - y2 > 0) + if (renderHistogram) + { + if (y1 - y2 > 0) { g.fillRect(x * av.charWidth, y2, av.charWidth, y1 - y2); } @@ -1336,8 +1357,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, { g.fillRect(x * av.charWidth, y1, av.charWidth, y2 - y1); } + } // draw profile if available - if (aa.annotations[column].value!=0) + if (aa.annotations[column].value!=0 && renderProfile) { int profl[] = getProfileFor(aa,column); int ht = y1,htn=y2-y1;//aa.graphHeight; @@ -1391,11 +1413,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, private int[] getProfileFor(AlignmentAnnotation aa, int column) { if (aa.autoCalculated && aa.label.startsWith("Consensus")) { - if (aa.groupRef!=null && aa.groupRef.consensusData!=null) { + if (aa.groupRef!=null && aa.groupRef.consensusData!=null && aa.groupRef.isIncludeAllConsSymbols()) { return AAFrequency.extractProfile(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) + if (aa.groupRef==null && aa.sequenceRef==null && av.isShowConsensusProfile()) { return AAFrequency.extractProfile(av.hconsensus[column],av.getIgnoreGapsConsensus()); } -- 1.7.10.2