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
{
public boolean predefinedColours = false;
+ public boolean seqAssociated = false;
+
+ IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
+
/**
* Creates a new AnnotationColourGradient object.
*/
bb = maxColour.getBlue() - b1;
}
+ @Override
+ public void alignmentChanged(AnnotatedCollectionI alignment,
+ Map<SequenceI, SequenceCollectionI> hiddenReps)
+ {
+ // TODO Auto-generated method stub
+ super.alignmentChanged(alignment, hiddenReps);
+
+ if (seqAssociated && annotation.getCalcId() != null)
+ {
+ if (seqannot!=null) {
+ seqannot.clear();
+ } else {
+ seqannot=new IdentityHashMap<SequenceI, AlignmentAnnotation>();
+ }
+ 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;
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
return currentColour;
}
+
+ public boolean isSeqAssociated()
+ {
+ return seqAssociated;
+ }
+
+ public void setSeqAssociated(boolean sassoc)
+ {
+ seqAssociated = sassoc;
+ }
}