X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fschemes%2FAnnotationColourGradient.js;fp=site%2Fj2s%2Fjalview%2Fschemes%2FAnnotationColourGradient.js;h=a1b8db65fd05d67845dc2cda388db4e873ce9a10;hp=adfb4f6fab40a8c59e41e31b6bc478a1f8a7b395;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/schemes/AnnotationColourGradient.js b/site/j2s/jalview/schemes/AnnotationColourGradient.js index adfb4f6..a1b8db6 100644 --- a/site/j2s/jalview/schemes/AnnotationColourGradient.js +++ b/site/j2s/jalview/schemes/AnnotationColourGradient.js @@ -1,200 +1,200 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.FollowerColourScheme"], "jalview.schemes.AnnotationColourGradient", ["jalview.datamodel.AlignmentI", "$.GraphLine", "jalview.renderer.AnnotationRenderer", "jalview.schemes.ColourSchemeProperty", "jalview.util.Comparison", "java.awt.Color", "java.util.IdentityHashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.annotation = null; -this.aboveAnnotationThreshold = -1; -this.thresholdIsMinMax = false; -this.annotationThreshold = null; -this.r1 = 0; -this.g1 = 0; -this.b1 = 0; -this.rr = 0; -this.gg = 0; -this.bb = 0; -this.predefinedColours = false; -this.seqAssociated = false; -this.noGradient = false; -this.seqannot = null; -this.aamin = 0; -this.aamax = 0; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "AnnotationColourGradient", jalview.schemes.FollowerColourScheme); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -var acg = new jalview.schemes.AnnotationColourGradient (this.annotation, this.colourScheme, this.aboveAnnotationThreshold); -acg.thresholdIsMinMax = this.thresholdIsMinMax; -acg.annotationThreshold = (this.annotationThreshold == null) ? null : new jalview.datamodel.GraphLine (this.annotationThreshold); -acg.r1 = this.r1; -acg.g1 = this.g1; -acg.b1 = this.b1; -acg.rr = this.rr; -acg.gg = this.gg; -acg.bb = this.bb; -acg.predefinedColours = this.predefinedColours; -acg.seqAssociated = this.seqAssociated; -acg.noGradient = this.noGradient; -return acg; -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.makeConstructor (c$, -function (annotation, originalColour, aboveThreshold) { -Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); -if (Clazz.instanceOf (originalColour, jalview.schemes.AnnotationColourGradient)) { -this.colourScheme = (originalColour).colourScheme; -} else { -this.colourScheme = originalColour; -}this.annotation = annotation; -this.aboveAnnotationThreshold = aboveThreshold; -if (aboveThreshold != -1 && annotation.threshold != null) { -this.annotationThreshold = annotation.threshold; -}this.r1 = 254; -this.g1 = 254; -this.b1 = 254; -this.rr = 0; -this.gg = 0; -this.bb = 0; -this.noGradient = true; -}, "jalview.datamodel.AlignmentAnnotation,jalview.schemes.ColourSchemeI,~N"); -Clazz.makeConstructor (c$, -function (annotation, minColour, maxColour, aboveThreshold) { -Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); -this.annotation = annotation; -this.aboveAnnotationThreshold = aboveThreshold; -if (aboveThreshold != -1 && annotation.threshold != null) { -this.annotationThreshold = annotation.threshold; -}this.r1 = minColour.getRed (); -this.g1 = minColour.getGreen (); -this.b1 = minColour.getBlue (); -this.rr = maxColour.getRed () - this.r1; -this.gg = maxColour.getGreen () - this.g1; -this.bb = maxColour.getBlue () - this.b1; -this.noGradient = false; -this.aamax = annotation.graphMax; -this.aamin = annotation.graphMin; -if (annotation.isRNA ()) { -jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); -}}, "jalview.datamodel.AlignmentAnnotation,java.awt.Color,java.awt.Color,~N"); -Clazz.defineMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -Clazz.superCall (this, jalview.schemes.AnnotationColourGradient, "alignmentChanged", [alignment, hiddenReps]); -if (this.seqAssociated && this.annotation.getCalcId () != null) { -if (this.seqannot != null) { -this.seqannot.clear (); -} else { -this.seqannot = new java.util.IdentityHashMap (); -}var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); -var f = true; -var rna = false; -for (var alan, $alan = alcontext.findAnnotation (this.annotation.getCalcId ()).iterator (); $alan.hasNext () && ((alan = $alan.next ()) || true);) { -if (alan.sequenceRef != null && (alan.label != null && this.annotation != null && alan.label.equals (this.annotation.label))) { -if (!rna && alan.isRNA ()) { -rna = true; -}this.seqannot.put (alan.sequenceRef, alan); -if (f || alan.graphMax > this.aamax) { -this.aamax = alan.graphMax; -}if (f || alan.graphMin < this.aamin) { -this.aamin = alan.graphMin; -}f = false; -}} -if (rna) { -jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); -}}}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineMethod (c$, "getAnnotation", -function () { -return this.annotation.label; -}); -Clazz.defineMethod (c$, "getAboveThreshold", -function () { -return this.aboveAnnotationThreshold; -}); -Clazz.defineMethod (c$, "getAnnotationThreshold", -function () { -if (this.annotationThreshold == null) { -return 0; -} else { -return this.annotationThreshold.value; -}}); -Clazz.defineMethod (c$, "getMinColour", -function () { -return new java.awt.Color (Clazz.floatToInt (this.r1), Clazz.floatToInt (this.g1), Clazz.floatToInt (this.b1)); -}); -Clazz.defineMethod (c$, "getMaxColour", -function () { -return new java.awt.Color (Clazz.floatToInt (this.r1 + this.rr), Clazz.floatToInt (this.g1 + this.gg), Clazz.floatToInt (this.b1 + this.bb)); -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return java.awt.Color.red; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour = java.awt.Color.white; -var annotation = (this.seqAssociated && this.seqannot != null ? this.seqannot.get (seq) : this.annotation); -if (annotation == null) { -return currentColour; -}if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -if (annotation.annotations != null && j < annotation.annotations.length && annotation.annotations[j] != null && !jalview.util.Comparison.isGap (c)) { -var aj = annotation.annotations[j]; -if (this.aboveAnnotationThreshold == -1 || (this.annotationThreshold != null && (this.aboveAnnotationThreshold == 1 ? aj.value >= this.annotationThreshold.value : aj.value <= this.annotationThreshold.value))) { -if (this.predefinedColours && aj.colour != null && !aj.colour.equals (java.awt.Color.black)) { -currentColour = aj.colour; -} else if (annotation.hasIcons && annotation.graph == 0) { -if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.' && aj.secondaryStructure != '-') { -if (this.colourScheme != null) { -currentColour = this.colourScheme.findColour (c, j, seq); -} else { -if (annotation.isRNA ()) { -currentColour = jalview.schemes.ColourSchemeProperty.rnaHelices[Clazz.floatToInt (aj.value)]; -} else { -currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR : jalview.renderer.AnnotationRenderer.STEM_COLOUR; -}}} else { -return java.awt.Color.white; -}} else if (this.noGradient) { -if (this.colourScheme != null) { -currentColour = this.colourScheme.findColour (c, j, seq); -} else { -if (aj.colour != null) { -currentColour = aj.colour; -}}} else { -currentColour = this.shadeCalculation (annotation, j); -}}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}}}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "shadeCalculation", - function (annotation, j) { -var range = 1; -if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 1 && annotation.annotations[j].value >= annotation.threshold.value) { -range = (annotation.annotations[j].value - annotation.threshold.value) / (annotation.graphMax - annotation.threshold.value); -} else if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 0 && annotation.annotations[j].value >= annotation.graphMin) { -range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.threshold.value - annotation.graphMin); -} else { -if (annotation.graphMax != annotation.graphMin) { -range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.graphMax - annotation.graphMin); -} else { -range = 0; -}}var dr = Clazz.floatToInt (this.rr * range + this.r1); -var dg = Clazz.floatToInt (this.gg * range + this.g1); -var db = Clazz.floatToInt (this.bb * range + this.b1); -return new java.awt.Color (dr, dg, db); -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "isPredefinedColours", -function () { -return this.predefinedColours; -}); -Clazz.defineMethod (c$, "setPredefinedColours", -function (predefinedColours) { -this.predefinedColours = predefinedColours; -}, "~B"); -Clazz.defineMethod (c$, "isSeqAssociated", -function () { -return this.seqAssociated; -}); -Clazz.defineMethod (c$, "setSeqAssociated", -function (sassoc) { -this.seqAssociated = sassoc; -}, "~B"); -Clazz.defineStatics (c$, -"NO_THRESHOLD", -1, -"BELOW_THRESHOLD", 0, -"ABOVE_THRESHOLD", 1); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.FollowerColourScheme"], "jalview.schemes.AnnotationColourGradient", ["jalview.datamodel.AlignmentI", "$.GraphLine", "jalview.renderer.AnnotationRenderer", "jalview.schemes.ColourSchemeProperty", "jalview.util.Comparison", "java.awt.Color", "java.util.IdentityHashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.annotation = null; +this.aboveAnnotationThreshold = -1; +this.thresholdIsMinMax = false; +this.annotationThreshold = null; +this.r1 = 0; +this.g1 = 0; +this.b1 = 0; +this.rr = 0; +this.gg = 0; +this.bb = 0; +this.predefinedColours = false; +this.seqAssociated = false; +this.noGradient = false; +this.seqannot = null; +this.aamin = 0; +this.aamax = 0; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "AnnotationColourGradient", jalview.schemes.FollowerColourScheme); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +var acg = new jalview.schemes.AnnotationColourGradient (this.annotation, this.colourScheme, this.aboveAnnotationThreshold); +acg.thresholdIsMinMax = this.thresholdIsMinMax; +acg.annotationThreshold = (this.annotationThreshold == null) ? null : new jalview.datamodel.GraphLine (this.annotationThreshold); +acg.r1 = this.r1; +acg.g1 = this.g1; +acg.b1 = this.b1; +acg.rr = this.rr; +acg.gg = this.gg; +acg.bb = this.bb; +acg.predefinedColours = this.predefinedColours; +acg.seqAssociated = this.seqAssociated; +acg.noGradient = this.noGradient; +return acg; +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.makeConstructor (c$, +function (annotation, originalColour, aboveThreshold) { +Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); +if (Clazz.instanceOf (originalColour, jalview.schemes.AnnotationColourGradient)) { +this.colourScheme = (originalColour).colourScheme; +} else { +this.colourScheme = originalColour; +}this.annotation = annotation; +this.aboveAnnotationThreshold = aboveThreshold; +if (aboveThreshold != -1 && annotation.threshold != null) { +this.annotationThreshold = annotation.threshold; +}this.r1 = 254; +this.g1 = 254; +this.b1 = 254; +this.rr = 0; +this.gg = 0; +this.bb = 0; +this.noGradient = true; +}, "jalview.datamodel.AlignmentAnnotation,jalview.schemes.ColourSchemeI,~N"); +Clazz.makeConstructor (c$, +function (annotation, minColour, maxColour, aboveThreshold) { +Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); +this.annotation = annotation; +this.aboveAnnotationThreshold = aboveThreshold; +if (aboveThreshold != -1 && annotation.threshold != null) { +this.annotationThreshold = annotation.threshold; +}this.r1 = minColour.getRed (); +this.g1 = minColour.getGreen (); +this.b1 = minColour.getBlue (); +this.rr = maxColour.getRed () - this.r1; +this.gg = maxColour.getGreen () - this.g1; +this.bb = maxColour.getBlue () - this.b1; +this.noGradient = false; +this.aamax = annotation.graphMax; +this.aamin = annotation.graphMin; +if (annotation.isRNA ()) { +jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); +}}, "jalview.datamodel.AlignmentAnnotation,java.awt.Color,java.awt.Color,~N"); +Clazz.defineMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +Clazz.superCall (this, jalview.schemes.AnnotationColourGradient, "alignmentChanged", [alignment, hiddenReps]); +if (this.seqAssociated && this.annotation.getCalcId () != null) { +if (this.seqannot != null) { +this.seqannot.clear (); +} else { +this.seqannot = new java.util.IdentityHashMap (); +}var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); +var f = true; +var rna = false; +for (var alan, $alan = alcontext.findAnnotation (this.annotation.getCalcId ()).iterator (); $alan.hasNext () && ((alan = $alan.next ()) || true);) { +if (alan.sequenceRef != null && (alan.label != null && this.annotation != null && alan.label.equals (this.annotation.label))) { +if (!rna && alan.isRNA ()) { +rna = true; +}this.seqannot.put (alan.sequenceRef, alan); +if (f || alan.graphMax > this.aamax) { +this.aamax = alan.graphMax; +}if (f || alan.graphMin < this.aamin) { +this.aamin = alan.graphMin; +}f = false; +}} +if (rna) { +jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); +}}}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineMethod (c$, "getAnnotation", +function () { +return this.annotation.label; +}); +Clazz.defineMethod (c$, "getAboveThreshold", +function () { +return this.aboveAnnotationThreshold; +}); +Clazz.defineMethod (c$, "getAnnotationThreshold", +function () { +if (this.annotationThreshold == null) { +return 0; +} else { +return this.annotationThreshold.value; +}}); +Clazz.defineMethod (c$, "getMinColour", +function () { +return new java.awt.Color (Clazz.floatToInt (this.r1), Clazz.floatToInt (this.g1), Clazz.floatToInt (this.b1)); +}); +Clazz.defineMethod (c$, "getMaxColour", +function () { +return new java.awt.Color (Clazz.floatToInt (this.r1 + this.rr), Clazz.floatToInt (this.g1 + this.gg), Clazz.floatToInt (this.b1 + this.bb)); +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return java.awt.Color.red; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour = java.awt.Color.white; +var annotation = (this.seqAssociated && this.seqannot != null ? this.seqannot.get (seq) : this.annotation); +if (annotation == null) { +return currentColour; +}if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +if (annotation.annotations != null && j < annotation.annotations.length && annotation.annotations[j] != null && !jalview.util.Comparison.isGap (c)) { +var aj = annotation.annotations[j]; +if (this.aboveAnnotationThreshold == -1 || (this.annotationThreshold != null && (this.aboveAnnotationThreshold == 1 ? aj.value >= this.annotationThreshold.value : aj.value <= this.annotationThreshold.value))) { +if (this.predefinedColours && aj.colour != null && !aj.colour.equals (java.awt.Color.black)) { +currentColour = aj.colour; +} else if (annotation.hasIcons && annotation.graph == 0) { +if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.' && aj.secondaryStructure != '-') { +if (this.colourScheme != null) { +currentColour = this.colourScheme.findColour (c, j, seq); +} else { +if (annotation.isRNA ()) { +currentColour = jalview.schemes.ColourSchemeProperty.rnaHelices[Clazz.floatToInt (aj.value)]; +} else { +currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR : jalview.renderer.AnnotationRenderer.STEM_COLOUR; +}}} else { +return java.awt.Color.white; +}} else if (this.noGradient) { +if (this.colourScheme != null) { +currentColour = this.colourScheme.findColour (c, j, seq); +} else { +if (aj.colour != null) { +currentColour = aj.colour; +}}} else { +currentColour = this.shadeCalculation (annotation, j); +}}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}}}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "shadeCalculation", + function (annotation, j) { +var range = 1; +if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 1 && annotation.annotations[j].value >= annotation.threshold.value) { +range = (annotation.annotations[j].value - annotation.threshold.value) / (annotation.graphMax - annotation.threshold.value); +} else if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 0 && annotation.annotations[j].value >= annotation.graphMin) { +range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.threshold.value - annotation.graphMin); +} else { +if (annotation.graphMax != annotation.graphMin) { +range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.graphMax - annotation.graphMin); +} else { +range = 0; +}}var dr = Clazz.floatToInt (this.rr * range + this.r1); +var dg = Clazz.floatToInt (this.gg * range + this.g1); +var db = Clazz.floatToInt (this.bb * range + this.b1); +return new java.awt.Color (dr, dg, db); +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "isPredefinedColours", +function () { +return this.predefinedColours; +}); +Clazz.defineMethod (c$, "setPredefinedColours", +function (predefinedColours) { +this.predefinedColours = predefinedColours; +}, "~B"); +Clazz.defineMethod (c$, "isSeqAssociated", +function () { +return this.seqAssociated; +}); +Clazz.defineMethod (c$, "setSeqAssociated", +function (sassoc) { +this.seqAssociated = sassoc; +}, "~B"); +Clazz.defineStatics (c$, +"NO_THRESHOLD", -1, +"BELOW_THRESHOLD", 0, +"ABOVE_THRESHOLD", 1); +});