X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=20b08857c757ec16f291d6962d625118173f2762;hb=2e699d341f8e64868e3c279f9c02af617c4e9b44;hp=58256122b6f8cfabdc6c279c933c85636173a2eb;hpb=df227ed4042d4c9fa2affb391fa09b662f3b8a2a;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 5825612..20b0885 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); @@ -78,9 +126,8 @@ public class AnnotationColourGradient extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n) + public Color findColour(char c) { - System.out.println("AnnotationColourGradient findColour(string)"); return Color.red; } @@ -92,41 +139,47 @@ public class AnnotationColourGradient extends ResidueColourScheme * * @return DOCUMENT ME! */ - public Color findColour(String n, int j) + public Color findColour(char c, int j) { - if ((threshold == 0) || aboveThreshold(n, j)) + Color currentColour = Color.white; + + if ((threshold == 0) || aboveThreshold(c, 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(c, 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; }