X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=75a07b98eb9e424455c412d1ad38d1d35afb7673;hb=16d109024847af92482237e43f99b82fd997451a;hp=220d3ab84f3ddcf6846ac6869f0305ae5287cb42;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 220d3ab..75a07b9 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; @@ -76,8 +77,8 @@ public class AnnotationColourGradient extends FollowerColourScheme private IdentityHashMap seqannot = null; @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, - Map hiddenRepSequences) + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg) { AnnotationColourGradient acg = new AnnotationColourGradient(annotation, getColourScheme(), aboveAnnotationThreshold); @@ -185,18 +186,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 +254,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 +289,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 +319,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 +359,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 +415,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 { @@ -469,7 +479,7 @@ public class AnnotationColourGradient extends FollowerColourScheme @Override public String getSchemeName() { - return "Annotation"; + return ANNOTATION_COLOUR; } @Override