X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=789667e0b2d49296053fa319b45ff933ebf0b319;hb=0125a426aecc7065538a13f48236dc1e8d268044;hp=433af79e0be514b600ff4043963115c8f3aa1755;hpb=9b2d0f1f47d3a073c91f354775bea6a274812709;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 433af79..789667e 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -34,7 +34,31 @@ public class AnnotationColourGradient extends ResidueColourScheme GraphLine annotationThreshold; float r1, g1, b1, rr, gg, bb, dr, dg, db; - float range; + float range = 0; + + ColourSchemeI colourScheme; + + /** + * Creates a new AnnotationColourGradient object. + */ + public AnnotationColourGradient(AlignmentAnnotation annotation, + ColourSchemeI originalColour, + int aboveThreshold) + { + if(originalColour instanceof AnnotationColourGradient) + { + colourScheme = ((AnnotationColourGradient)originalColour).colourScheme; + } + else + colourScheme = originalColour; + + this.annotation = annotation; + + aboveAnnotationThreshold = aboveThreshold; + + if(aboveThreshold!=NO_THRESHOLD && annotation.threshold!=null) + annotationThreshold = annotation.threshold; + } /** * Creates a new AnnotationColourGradient object. @@ -80,7 +104,6 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n) { - System.out.println("AnnotationColourGradient findColour(string)"); return Color.red; } @@ -94,36 +117,42 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n, int j) { + currentColour = Color.white; + if ((threshold == 0) || aboveThreshold(n, j)) { - if( j+1>annotation.annotations.length || annotation.annotations[j]==null) - currentColour = Color.white; - else + if( j=annotationThreshold.value) || (annotationThreshold!=null && aboveAnnotationThreshold==BELOW_THRESHOLD && annotation.annotations[j].value<=annotationThreshold.value)) { + if(colourScheme!=null) + { + currentColour = colourScheme.findColour(n, j); + } + else if(range!=0) + { dr = rr * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +r1; + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + r1; dg = gg * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +g1; + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + g1; db = bb * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +b1; + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + b1; - currentColour = new Color( (int) dr, (int) dg, (int) db); + currentColour = new Color( (int) dr, (int) dg, (int) db); + } } - else - currentColour = Color.white; } } - else - { - return Color.white; - } if(conservationColouring) applyConservation(j);