X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=c74fdbc62f83ce0dd089217dd817b08685d37483;hb=424648b2e57e45eaa21c006b44828d8fca418581;hp=220d3ab84f3ddcf6846ac6869f0305ae5287cb42;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 220d3ab..c74fdbc 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -185,18 +185,19 @@ public class AnnotationColourGradient extends FollowerColourScheme } else { - seqannot = new IdentityHashMap(); + 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()) { @@ -252,8 +253,8 @@ public class AnnotationColourGradient extends FollowerColourScheme public Color getMaxColour() { - return new Color(redMin + redRange, greenMin + greenRange, blueMin - + blueRange); + return new Color(redMin + redRange, greenMin + greenRange, + blueMin + blueRange); } /** @@ -287,8 +288,9 @@ public class AnnotationColourGradient extends FollowerColourScheme /* * 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) @@ -316,8 +318,10 @@ public class AnnotationColourGradient extends FollowerColourScheme */ 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; } @@ -354,8 +358,10 @@ public class AnnotationColourGradient extends FollowerColourScheme } 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; } } @@ -408,14 +414,17 @@ public class AnnotationColourGradient extends FollowerColourScheme && 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 {