X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=ac88d96b81898a2467db6bdfb7d6f6e22d73f62b;hb=52fd681e0f239e20df19fd7560d4b999104ba222;hp=bc4455958425dd83439cbca9bf273bf928606081;hpb=1c1f44c47bfd8151d846928eda2d95aeff6f8e92;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index bc44559..ac88d96 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -24,22 +24,55 @@ import jalview.datamodel.*; public class AnnotationColourGradient extends ResidueColourScheme { + public static int NO_THRESHOLD = -1; + public static int BELOW_THRESHOLD = 0; + public static int ABOVE_THRESHOLD = 1; + AlignmentAnnotation annotation; - boolean aboveAnnotationThreshold = false; + int aboveAnnotationThreshold = -1; + + 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. */ public AnnotationColourGradient(AlignmentAnnotation annotation, - Color minColour, Color maxColour, boolean aboveThreshold) + Color minColour, Color maxColour, int aboveThreshold) { this.annotation = annotation; aboveAnnotationThreshold = aboveThreshold; + if(aboveThreshold!=NO_THRESHOLD && annotation.threshold!=null) + annotationThreshold = annotation.threshold; + r1 = minColour.getRed(); g1 = minColour.getGreen(); b1 = minColour.getBlue(); @@ -52,6 +85,30 @@ public class AnnotationColourGradient extends ResidueColourScheme } + + public String getAnnotation() + { + return annotation.label; + } + + public int getAboveThreshold() + { + return aboveAnnotationThreshold; + } + + public float getAnnotationThreshold() + { + if(annotationThreshold==null) + return 0; + else + return annotationThreshold.value; + } + + public ColourSchemeI getBaseColour() + { + return colourScheme; + } + public Color getMinColour() { return new Color( (int) r1, (int) g1, (int) b1); @@ -71,7 +128,6 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n) { - System.out.println("AnnotationColourGradient findColour(string)"); return Color.red; } @@ -85,35 +141,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=annotation.getGraphLine(0).value)) + if( aboveAnnotationThreshold==NO_THRESHOLD + || (annotationThreshold!=null && aboveAnnotationThreshold==ABOVE_THRESHOLD && annotation.annotations[j].value>=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);