X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=4a78aa12e6d2be61938ba1d82e4515525a9ed951;hb=d587f1aa61946dc14f6f089cf1dc2a3116cfb773;hp=58256122b6f8cfabdc6c279c933c85636173a2eb;hpb=df227ed4042d4c9fa2affb391fa09b662f3b8a2a;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 5825612..4a78aa1 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -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(); @@ -61,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); @@ -80,7 +128,6 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n) { - System.out.println("AnnotationColourGradient findColour(string)"); return Color.red; } @@ -94,39 +141,45 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n, int j) { + Color 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); + currentColour = applyConservation(currentColour, j); return currentColour; }