X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=78e850bacd01ba858e7357ab074005c8d8baa0a2;hb=27d1490bba5753b3f9c8fac0647cfe8148c53310;hp=6c46d0e3c12e3f99dfb43835e7b795b91cf56f13;hpb=a79f9e113c51c032070c670e45ce3eb464691166;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 6c46d0e..78e850b 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -18,10 +18,14 @@ package jalview.schemes; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.GraphLine; +import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; import java.awt.Color; +import java.util.IdentityHashMap; +import java.util.Map; public class AnnotationColourGradient extends ResidueColourScheme { @@ -45,6 +49,10 @@ public class AnnotationColourGradient extends ResidueColourScheme public boolean predefinedColours = false; + public boolean seqAssociated = false; + + IdentityHashMap seqannot = null; + /** * Creates a new AnnotationColourGradient object. */ @@ -94,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; @@ -158,7 +193,11 @@ public class AnnotationColourGradient extends ResidueColourScheme 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 @@ -226,4 +265,14 @@ public class AnnotationColourGradient extends ResidueColourScheme return currentColour; } + + public boolean isSeqAssociated() + { + return seqAssociated; + } + + public void setSeqAssociated(boolean sassoc) + { + seqAssociated = sassoc; + } }