X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=789667e0b2d49296053fa319b45ff933ebf0b319;hb=4944c2f33bb34b4f262fd2f3ae40dcdc2a825557;hp=58256122b6f8cfabdc6c279c933c85636173a2eb;hpb=df227ed4042d4c9fa2affb391fa09b662f3b8a2a;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 5825612..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. @@ -46,8 +70,8 @@ public class AnnotationColourGradient extends ResidueColourScheme aboveAnnotationThreshold = aboveThreshold; - if(aboveThreshold!=NO_THRESHOLD && annotation.graphLines!=null) - annotationThreshold = annotation.getGraphLine(0); + if(aboveThreshold!=NO_THRESHOLD && annotation.threshold!=null) + annotationThreshold = annotation.threshold; r1 = minColour.getRed(); g1 = minColour.getGreen(); @@ -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);