*/
package jalview.schemes;
+import jalview.api.AlignViewportI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
private IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
@Override
- public ColourSchemeI getInstance(AnnotatedCollectionI sg,
- Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+ public ColourSchemeI getInstance(AlignViewportI view,
+ AnnotatedCollectionI sg)
{
AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
getColourScheme(), aboveAnnotationThreshold);
}
else
{
- seqannot = new IdentityHashMap<SequenceI, AlignmentAnnotation>();
+ seqannot = new IdentityHashMap<>();
}
// resolve the context containing all the annotation for the sequence
- AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment
+ AnnotatedCollectionI alcontext = alignment instanceof AlignmentI
+ ? alignment
: alignment.getContext();
boolean f = true, rna = false;
- for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation
- .getCalcId()))
+ for (AlignmentAnnotation alan : alcontext
+ .findAnnotation(annotation.getCalcId()))
{
if (alan.sequenceRef != null
- && (alan.label != null && annotation != null && alan.label
- .equals(annotation.label)))
+ && (alan.label != null && annotation != null
+ && alan.label.equals(annotation.label)))
{
if (!rna && alan.isRNA())
{
public Color getMaxColour()
{
- return new Color(redMin + redRange, greenMin + greenRange, blueMin
- + blueRange);
+ return new Color(redMin + redRange, greenMin + greenRange,
+ blueMin + blueRange);
}
/**
/*
* locate the annotation we are configured to colour by
*/
- AlignmentAnnotation ann = (seqAssociated && seqannot != null ? seqannot
- .get(seq) : this.annotation);
+ AlignmentAnnotation ann = (seqAssociated && seqannot != null
+ ? seqannot.get(seq)
+ : this.annotation);
/*
* if gap or no annotation at position, no colour (White)
*/
if (annotationThreshold != null)
{
- if ((aboveAnnotationThreshold == ABOVE_THRESHOLD && aj.value < annotationThreshold.value)
- || (aboveAnnotationThreshold == BELOW_THRESHOLD && aj.value > annotationThreshold.value))
+ if ((aboveAnnotationThreshold == ABOVE_THRESHOLD
+ && aj.value <= annotationThreshold.value)
+ || (aboveAnnotationThreshold == BELOW_THRESHOLD
+ && aj.value >= annotationThreshold.value))
{
return Color.white;
}
}
else
{
- result = ann.annotations[j].secondaryStructure == 'H' ? AnnotationRenderer.HELIX_COLOUR
- : ann.annotations[j].secondaryStructure == 'E' ? AnnotationRenderer.SHEET_COLOUR
+ result = ann.annotations[j].secondaryStructure == 'H'
+ ? AnnotationRenderer.HELIX_COLOUR
+ : ann.annotations[j].secondaryStructure == 'E'
+ ? AnnotationRenderer.SHEET_COLOUR
: AnnotationRenderer.STEM_COLOUR;
}
}
&& aboveAnnotationThreshold == ABOVE_THRESHOLD
&& value >= ann.threshold.value)
{
- range = (value - ann.threshold.value)
+ range = ann.graphMax == ann.threshold.value ? 1f
+ : (value - ann.threshold.value)
/ (ann.graphMax - ann.threshold.value);
}
else if (thresholdIsMinMax && ann.threshold != null
&& aboveAnnotationThreshold == BELOW_THRESHOLD
&& value <= ann.threshold.value)
{
- range = (value - ann.graphMin) / (ann.threshold.value - ann.graphMin);
+ range = ann.graphMin == ann.threshold.value ? 0f
+ : (value - ann.graphMin)
+ / (ann.threshold.value - ann.graphMin);
}
else
{
@Override
public String getSchemeName()
{
- return "Annotation";
+ return ANNOTATION_COLOUR;
}
@Override