X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fschemes%2FAnnotationColourGradient.java;h=00744c02677398470323cc064fb078a6cdc0e81b;hb=4ecba72bdecb7f685bf7629e7784d2d11c172f9d;hp=c28ea5f7dd727fd6f1af5948a7dd1122f7d7a762;hpb=f4766a7bbcfae845fc95923b01fa14ff83d589ff;p=jalview.git diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index c28ea5f..00744c0 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -36,6 +36,16 @@ import java.util.Map; public class AnnotationColourGradient extends FollowerColourScheme { + /** + * map positional scores to transparency rather than colour + */ + boolean positionToTransparency = true; + + /** + * compute shade based on annotation row score + */ + boolean perLineScore = true; + public static final int NO_THRESHOLD = -1; public static final int BELOW_THRESHOLD = 0; @@ -93,6 +103,8 @@ public class AnnotationColourGradient extends FollowerColourScheme acg.predefinedColours = predefinedColours; acg.seqAssociated = seqAssociated; acg.noGradient = noGradient; + acg.positionToTransparency = positionToTransparency; + acg.perLineScore = perLineScore; return acg; } @@ -185,20 +197,22 @@ public class AnnotationColourGradient extends FollowerColourScheme } else { - seqannot = new IdentityHashMap(); + seqannot = new IdentityHashMap<>(); } // resolve the context containing all the annotation for the sequence AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment : alignment.getContext(); - boolean f = true, rna = false; - for (AlignmentAnnotation alan : alcontext - .findAnnotation(annotation.getCalcId())) + boolean f = true, sf = true, rna = false; + long plcount = 0, ancount = 0; + for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation + .getCalcId())) { if (alan.sequenceRef != null && (alan.label != null && annotation != null && alan.label.equals(annotation.label))) { + ancount++; if (!rna && alan.isRNA()) { rna = true; @@ -213,8 +227,30 @@ public class AnnotationColourGradient extends FollowerColourScheme aamin = alan.graphMin; } f = false; + if (alan.score == alan.score) + { + if (sf || alan.score < plmin) + { + plmin = alan.score; + } + if (sf || alan.score > plmax) + { + plmax = alan.score; + } + sf = false; + plcount++; + } } } + if (plcount > 0 && plcount == ancount) + { + perLineScore = plcount == ancount; + aamax=plmax; + } + else + { + perLineScore = false; + } if (rna) { ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax); @@ -222,7 +258,15 @@ public class AnnotationColourGradient extends FollowerColourScheme } } - float aamin = 0f, aamax = 0f; + /** + * positional annotation max/min + */ + double aamin = 0.0, aamax = 0.0; + + /** + * per line score max/min + */ + double plmin = Double.NaN, plmax = Double.NaN; public AlignmentAnnotation getAnnotation() { @@ -435,11 +479,25 @@ public class AnnotationColourGradient extends FollowerColourScheme } } - int dr = (int) (redRange * range + redMin); - int dg = (int) (greenRange * range + greenMin); - int db = (int) (blueRange * range + blueMin); - - return new Color(dr, dg, db); + // midtr sets the ceiling for bleaching out the shading + int trans = 0, midtr = 239; + if (perLineScore) + { + trans = (int) ((1f - range) * midtr); + range = (float) ((annotation.score - plmin) / (plmax - aamin)); + } + int dr = (int) (redRange * range + redMin), + dg = (int) (greenRange * range + greenMin), + db = (int) (blueRange * range + blueMin); + if (annotation.score == annotation.score && positionToTransparency) + { + return new Color(Math.min(dr + trans, midtr), Math.min(dg + + trans, midtr), Math.min(db + trans, midtr)); + } + else + { + return new Color(dr, dg, db); + } } public boolean isPredefinedColours()