X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=78e850bacd01ba858e7357ab074005c8d8baa0a2;hb=bce28a70c870ff1283a8dd2720a7da69203039f0;hp=36c1f958e3a3a055a6a42c096d9683d1000ea81a;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 36c1f95..78e850b 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.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. * @@ -17,9 +17,15 @@ */ package jalview.schemes; -import java.awt.*; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.GraphLine; +import jalview.datamodel.SequenceCollectionI; +import jalview.datamodel.SequenceI; -import jalview.datamodel.*; +import java.awt.Color; +import java.util.IdentityHashMap; +import java.util.Map; public class AnnotationColourGradient extends ResidueColourScheme { @@ -43,6 +49,10 @@ public class AnnotationColourGradient extends ResidueColourScheme public boolean predefinedColours = false; + public boolean seqAssociated = false; + + IdentityHashMap seqannot = null; + /** * Creates a new AnnotationColourGradient object. */ @@ -92,6 +102,33 @@ public class AnnotationColourGradient extends ResidueColourScheme bb = maxColour.getBlue() - b1; } + @Override + public void alignmentChanged(AnnotatedCollectionI alignment, + Map hiddenReps) + { + // TODO Auto-generated method stub + super.alignmentChanged(alignment, hiddenReps); + + if (seqAssociated && annotation.getCalcId() != null) + { + if (seqannot!=null) { + seqannot.clear(); + } else { + seqannot=new IdentityHashMap(); + } + for (AlignmentAnnotation alan : alignment.findAnnotation(annotation + .getCalcId())) + { + if (alan.sequenceRef != null + && (alan.label != null && annotation != null && alan.label + .equals(annotation.label))) + { + seqannot.put(alan.sequenceRef, alan); + } + } + } + } + public String getAnnotation() { return annotation.label; @@ -152,10 +189,15 @@ public class AnnotationColourGradient extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(char c, int j) + @Override + public Color findColour(char c, int j, SequenceI seq) { Color currentColour = Color.white; - + AlignmentAnnotation annotation=(seqAssociated ? seqannot.get(seq):this.annotation); + if (annotation==null) + { + return currentColour; + } if ((threshold == 0) || aboveThreshold(c, j)) { if (j < annotation.annotations.length @@ -202,7 +244,7 @@ public class AnnotationColourGradient extends ResidueColourScheme if (colourScheme != null) { - currentColour = colourScheme.findColour(c, j); + currentColour = colourScheme.findColour(c, j, seq); } else if (range != 0) { @@ -223,4 +265,14 @@ public class AnnotationColourGradient extends ResidueColourScheme return currentColour; } + + public boolean isSeqAssociated() + { + return seqAssociated; + } + + public void setSeqAssociated(boolean sassoc) + { + seqAssociated = sassoc; + } }