X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fappletgui%2FAnnotationColourChooser.js;fp=site%2Fj2s%2Fjalview%2Fappletgui%2FAnnotationColourChooser.js;h=0e34c10328606b363f956f2ceac379b6679c35df;hp=cd1dff3e992ac37bb49a16020a7116cef3dbcfd7;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/appletgui/AnnotationColourChooser.js b/site/j2s/jalview/appletgui/AnnotationColourChooser.js index cd1dff3..0e34c10 100644 --- a/site/j2s/jalview/appletgui/AnnotationColourChooser.js +++ b/site/j2s/jalview/appletgui/AnnotationColourChooser.js @@ -1,348 +1,348 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.AnnotationColourChooser", ["awt2swing.Frame", "jalview.appletgui.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.datamodel.GraphLine", "jalview.schemes.AnnotationColourGradient", "$.ColourSchemeI", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.Font", "java.lang.Error", "$.Float", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.frame = null; -this.av = null; -this.ap = null; -this.oldcs = null; -this.oldgroupColours = null; -this.currentAnnotation = null; -this.adjusting = false; -this.annotations = null; -this.minColour = null; -this.maxColour = null; -this.ok = null; -this.cancel = null; -this.defColours = null; -this.jPanel1 = null; -this.jPanel2 = null; -this.threshold = null; -this.flowLayout1 = null; -this.jPanel3 = null; -this.slider = null; -this.thresholdValue = null; -this.currentColours = null; -this.borderLayout1 = null; -this.thresholdIsMin = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.annotations = new awt2swing.Choice (); -this.minColour = new awt2swing.Button (); -this.maxColour = new awt2swing.Button (); -this.ok = new awt2swing.Button (); -this.cancel = new awt2swing.Button (); -this.defColours = new awt2swing.Button (); -this.jPanel1 = new awt2swing.Panel (); -this.jPanel2 = new awt2swing.Panel (); -this.threshold = new awt2swing.Choice (); -this.flowLayout1 = new java.awt.FlowLayout (); -this.jPanel3 = new awt2swing.Panel (); -this.slider = new awt2swing.Scrollbar (0); -this.thresholdValue = new awt2swing.TextField (20); -this.currentColours = new awt2swing.Checkbox (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.thresholdIsMin = new awt2swing.Checkbox (); -}); -Clazz.makeConstructor (c$, -function (av, ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -this.oldcs = av.getGlobalColourScheme (); -if (av.getAlignment ().getGroups () != null) { -this.oldgroupColours = new java.util.Hashtable (); -for (var sg, $sg = ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs != null) { -this.oldgroupColours.put (sg, sg.cs); -} else { -this.oldgroupColours.put (sg, "null"); -}} -}this.av = av; -this.ap = ap; -this.slider.addAdjustmentListener (this); -this.slider.addMouseListener (this); -if (av.getAlignment ().getAlignmentAnnotation () == null) { -return; -}this.setDefaultMinMax (); -this.adjusting = true; -if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { -var acg = this.oldcs; -this.currentColours.setState (acg.isPredefinedColours () || acg.getBaseColour () != null); -if (!acg.isPredefinedColours () && acg.getBaseColour () == null) { -this.minColour.setBackground (acg.getMinColour ()); -this.maxColour.setBackground (acg.getMaxColour ()); -}}var list = new java.util.Vector (); -var index = 1; -for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { -var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; -if (!list.contains (label)) { -list.addElement (label); -} else { -list.addElement (label + "_" + (index++)); -}} -for (var i = 0; i < list.size (); i++) { -this.annotations.addItem (list.elementAt (i).toString ()); -} -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); -if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { -var acg = this.oldcs; -this.annotations.select (acg.getAnnotation ()); -switch (acg.getAboveThreshold ()) { -case -1: -this.threshold.select (new Integer (0)); -break; -case 1: -this.threshold.select (new Integer (1)); -break; -case 0: -this.threshold.select (new Integer (1)); -break; -default: -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); -} -this.thresholdIsMin.setState (acg.thresholdIsMinMax); -this.thresholdValue.setText ("" + acg.getAnnotationThreshold ()); -}this.adjusting = false; -this.changeColour (); -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.colour_by_annotation"), 560, 175); -this.validate (); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "setDefaultMinMax", - function () { -this.minColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MIN", java.awt.Color.orange)); -this.maxColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MAX", java.awt.Color.red)); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "jbInit", - function () { -this.minColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.minColour.setLabel (jalview.util.MessageManager.getString ("label.min_colour")); -this.minColour.addActionListener (this); -this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.maxColour.setLabel (jalview.util.MessageManager.getString ("label.max_colour")); -this.maxColour.addActionListener (this); -this.thresholdIsMin.addItemListener (this); -this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); -this.ok.addActionListener (this); -this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); -this.cancel.addActionListener (this); -this.defColours.setLabel (jalview.util.MessageManager.getString ("action.set_defaults")); -this.defColours.addActionListener (this); -this.annotations.addItemListener (this); -this.thresholdValue.addActionListener (this); -this.slider.setBackground (java.awt.Color.white); -this.slider.setPreferredSize ( new java.awt.Dimension (193, 21)); -this.slider.setEnabled (false); -this.thresholdValue.setPreferredSize ( new java.awt.Dimension (79, 22)); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setColumns (5); -this.currentColours.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.currentColours.setLabel (jalview.util.MessageManager.getString ("label.use_original_colours")); -this.currentColours.addItemListener (this); -this.thresholdIsMin.setBackground (java.awt.Color.white); -this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); -this.setLayout (this.borderLayout1); -this.jPanel1.setBackground (java.awt.Color.white); -this.jPanel2.setLayout ( new java.awt.FlowLayout ()); -this.jPanel2.setBackground (java.awt.Color.white); -this.threshold.addItemListener (this); -this.jPanel3.setLayout ( new java.awt.FlowLayout ()); -this.jPanel3.setBackground (java.awt.Color.white); -var jPanel4 = new awt2swing.Panel (); -jPanel4.setLayout ( new java.awt.BorderLayout ()); -jPanel4.setBackground (java.awt.Color.white); -this.jPanel1.add (this.ok); -this.jPanel1.add (this.cancel); -this.jPanel2.add (this.annotations); -this.jPanel2.add (this.currentColours); -this.jPanel2.add (this.minColour); -this.jPanel2.add (this.maxColour); -jPanel4.add (this.thresholdIsMin, "West"); -jPanel4.add (this.slider, "Center"); -jPanel4.add (this.thresholdValue, "East"); -var jPanel34 = new awt2swing.Panel (); -jPanel34.setLayout ( new java.awt.BorderLayout ()); -jPanel34.setBackground (java.awt.Color.white); -jPanel34.add (this.jPanel2, "North"); -jPanel34.add (this.threshold, "West"); -this.jPanel3.add (this.defColours); -jPanel34.add (this.jPanel3, "East"); -jPanel34.add (jPanel4, "South"); -this.add (jPanel34, "Center"); -this.add (this.jPanel1, "South"); -}); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.thresholdValue) { -try { -var f = new Float (this.thresholdValue.getText ()).floatValue (); -this.slider.setValue (Clazz.floatToInt (f * 1000)); -this.adjustmentValueChanged (null); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -} else if (evt.getSource () === this.minColour) { -this.minColour_actionPerformed (null); -} else if (evt.getSource () === this.maxColour) { -this.maxColour_actionPerformed (null); -} else if (evt.getSource () === this.defColours) { -this.defColour_actionPerformed (); -} else if (evt.getSource () === this.ok) { -this.changeColour (); -this.frame.setVisible (false); -} else if (evt.getSource () === this.cancel) { -this.reset (); -this.ap.paintAlignment (true); -this.frame.setVisible (false); -} else { -this.changeColour (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -if (evt.getSource () === this.currentColours) { -if (this.currentColours.getState ()) { -this.reset (); -}this.maxColour.setEnabled (!this.currentColours.getState ()); -this.minColour.setEnabled (!this.currentColours.getState ()); -}this.changeColour (); -}, "java.awt.event.ItemEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (!this.adjusting) { -this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); -if (this.currentColours.getState () && !(Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.AnnotationColourGradient))) { -this.changeColour (); -}this.currentAnnotation.threshold.value = this.slider.getValue () / 1000; -this.ap.paintAlignment (false); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "minColour_actionPerformed", -function (newCol) { -if (newCol != null) { -this.minColour.setBackground (newCol); -this.minColour.repaint (); -this.changeColour (); -} else { - new jalview.appletgui.UserDefinedColours (this, "Min Colour", this.minColour.getBackground ()); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "maxColour_actionPerformed", -function (newCol) { -if (newCol != null) { -this.maxColour.setBackground (newCol); -this.maxColour.repaint (); -this.changeColour (); -} else { - new jalview.appletgui.UserDefinedColours (this, "Max Colour", this.maxColour.getBackground ()); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "defColour_actionPerformed", -function () { -this.setDefaultMinMax (); -this.minColour.repaint (); -this.maxColour.repaint (); -this.changeColour (); -}); -Clazz.defineMethod (c$, "changeColour", -function () { -if (this.adjusting) { -return; -}this.currentAnnotation = this.av.getAlignment ().getAlignmentAnnotation ()[this.annotations.getSelectedIndex ()]; -var aboveThreshold = -1; -if (this.threshold.getSelectedIndex () == 1) { -aboveThreshold = 1; -} else if (this.threshold.getSelectedIndex () == 2) { -aboveThreshold = 0; -}this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.thresholdIsMin.setEnabled (true); -if (aboveThreshold == -1) { -this.slider.setEnabled (false); -this.thresholdValue.setEnabled (false); -this.thresholdIsMin.setEnabled (false); -this.thresholdValue.setText (""); -} else if (aboveThreshold != -1 && this.currentAnnotation.threshold == null) { -this.currentAnnotation.setThreshold ( new jalview.datamodel.GraphLine ((this.currentAnnotation.graphMax - this.currentAnnotation.graphMin) / 2, "Threshold", java.awt.Color.black)); -}if (aboveThreshold != -1) { -this.adjusting = true; -this.slider.setMinimum (Clazz.floatToInt (this.currentAnnotation.graphMin * 1000)); -this.slider.setMaximum (Clazz.floatToInt (this.currentAnnotation.graphMax * 1000)); -this.slider.setValue (Clazz.floatToInt (this.currentAnnotation.threshold.value * 1000)); -this.thresholdValue.setText (this.currentAnnotation.threshold.value + ""); -this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.adjusting = false; -}var acg = null; -if (this.currentColours.getState ()) { -acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.av.getGlobalColourScheme (), aboveThreshold); -} else { -acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); -}if (this.currentAnnotation.graphMin == 0 && this.currentAnnotation.graphMax == 0) { -acg.setPredefinedColours (true); -}acg.thresholdIsMinMax = this.thresholdIsMin.getState (); -this.av.setGlobalColourScheme (acg); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs == null) { -continue; -}if (this.currentColours.getState ()) { -sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, sg.cs, aboveThreshold); -} else { -sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); -}} -}this.ap.alignmentChanged (); -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "reset", -function () { -this.av.setGlobalColourScheme (this.oldcs); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -var cs = this.oldgroupColours.get (sg); -if (Clazz.instanceOf (cs, jalview.schemes.ColourSchemeI)) { -sg.cs = cs; -} else { -sg.cs = null; -}} -}this.ap.paintAlignment (true); -}); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.ap.paintAlignment (true); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.AnnotationColourChooser", ["awt2swing.Frame", "jalview.appletgui.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.datamodel.GraphLine", "jalview.schemes.AnnotationColourGradient", "$.ColourSchemeI", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.Font", "java.lang.Error", "$.Float", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.frame = null; +this.av = null; +this.ap = null; +this.oldcs = null; +this.oldgroupColours = null; +this.currentAnnotation = null; +this.adjusting = false; +this.annotations = null; +this.minColour = null; +this.maxColour = null; +this.ok = null; +this.cancel = null; +this.defColours = null; +this.jPanel1 = null; +this.jPanel2 = null; +this.threshold = null; +this.flowLayout1 = null; +this.jPanel3 = null; +this.slider = null; +this.thresholdValue = null; +this.currentColours = null; +this.borderLayout1 = null; +this.thresholdIsMin = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.annotations = new awt2swing.Choice (); +this.minColour = new awt2swing.Button (); +this.maxColour = new awt2swing.Button (); +this.ok = new awt2swing.Button (); +this.cancel = new awt2swing.Button (); +this.defColours = new awt2swing.Button (); +this.jPanel1 = new awt2swing.Panel (); +this.jPanel2 = new awt2swing.Panel (); +this.threshold = new awt2swing.Choice (); +this.flowLayout1 = new java.awt.FlowLayout (); +this.jPanel3 = new awt2swing.Panel (); +this.slider = new awt2swing.Scrollbar (0); +this.thresholdValue = new awt2swing.TextField (20); +this.currentColours = new awt2swing.Checkbox (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.thresholdIsMin = new awt2swing.Checkbox (); +}); +Clazz.makeConstructor (c$, +function (av, ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +this.oldcs = av.getGlobalColourScheme (); +if (av.getAlignment ().getGroups () != null) { +this.oldgroupColours = new java.util.Hashtable (); +for (var sg, $sg = ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs != null) { +this.oldgroupColours.put (sg, sg.cs); +} else { +this.oldgroupColours.put (sg, "null"); +}} +}this.av = av; +this.ap = ap; +this.slider.addAdjustmentListener (this); +this.slider.addMouseListener (this); +if (av.getAlignment ().getAlignmentAnnotation () == null) { +return; +}this.setDefaultMinMax (); +this.adjusting = true; +if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { +var acg = this.oldcs; +this.currentColours.setState (acg.isPredefinedColours () || acg.getBaseColour () != null); +if (!acg.isPredefinedColours () && acg.getBaseColour () == null) { +this.minColour.setBackground (acg.getMinColour ()); +this.maxColour.setBackground (acg.getMaxColour ()); +}}var list = new java.util.Vector (); +var index = 1; +for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { +var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; +if (!list.contains (label)) { +list.addElement (label); +} else { +list.addElement (label + "_" + (index++)); +}} +for (var i = 0; i < list.size (); i++) { +this.annotations.addItem (list.elementAt (i).toString ()); +} +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); +if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { +var acg = this.oldcs; +this.annotations.select (acg.getAnnotation ()); +switch (acg.getAboveThreshold ()) { +case -1: +this.threshold.select (new Integer (0)); +break; +case 1: +this.threshold.select (new Integer (1)); +break; +case 0: +this.threshold.select (new Integer (1)); +break; +default: +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); +} +this.thresholdIsMin.setState (acg.thresholdIsMinMax); +this.thresholdValue.setText ("" + acg.getAnnotationThreshold ()); +}this.adjusting = false; +this.changeColour (); +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.colour_by_annotation"), 560, 175); +this.validate (); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "setDefaultMinMax", + function () { +this.minColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MIN", java.awt.Color.orange)); +this.maxColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MAX", java.awt.Color.red)); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "jbInit", + function () { +this.minColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.minColour.setLabel (jalview.util.MessageManager.getString ("label.min_colour")); +this.minColour.addActionListener (this); +this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.maxColour.setLabel (jalview.util.MessageManager.getString ("label.max_colour")); +this.maxColour.addActionListener (this); +this.thresholdIsMin.addItemListener (this); +this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); +this.ok.addActionListener (this); +this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); +this.cancel.addActionListener (this); +this.defColours.setLabel (jalview.util.MessageManager.getString ("action.set_defaults")); +this.defColours.addActionListener (this); +this.annotations.addItemListener (this); +this.thresholdValue.addActionListener (this); +this.slider.setBackground (java.awt.Color.white); +this.slider.setPreferredSize ( new java.awt.Dimension (193, 21)); +this.slider.setEnabled (false); +this.thresholdValue.setPreferredSize ( new java.awt.Dimension (79, 22)); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setColumns (5); +this.currentColours.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.currentColours.setLabel (jalview.util.MessageManager.getString ("label.use_original_colours")); +this.currentColours.addItemListener (this); +this.thresholdIsMin.setBackground (java.awt.Color.white); +this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); +this.setLayout (this.borderLayout1); +this.jPanel1.setBackground (java.awt.Color.white); +this.jPanel2.setLayout ( new java.awt.FlowLayout ()); +this.jPanel2.setBackground (java.awt.Color.white); +this.threshold.addItemListener (this); +this.jPanel3.setLayout ( new java.awt.FlowLayout ()); +this.jPanel3.setBackground (java.awt.Color.white); +var jPanel4 = new awt2swing.Panel (); +jPanel4.setLayout ( new java.awt.BorderLayout ()); +jPanel4.setBackground (java.awt.Color.white); +this.jPanel1.add (this.ok); +this.jPanel1.add (this.cancel); +this.jPanel2.add (this.annotations); +this.jPanel2.add (this.currentColours); +this.jPanel2.add (this.minColour); +this.jPanel2.add (this.maxColour); +jPanel4.add (this.thresholdIsMin, "West"); +jPanel4.add (this.slider, "Center"); +jPanel4.add (this.thresholdValue, "East"); +var jPanel34 = new awt2swing.Panel (); +jPanel34.setLayout ( new java.awt.BorderLayout ()); +jPanel34.setBackground (java.awt.Color.white); +jPanel34.add (this.jPanel2, "North"); +jPanel34.add (this.threshold, "West"); +this.jPanel3.add (this.defColours); +jPanel34.add (this.jPanel3, "East"); +jPanel34.add (jPanel4, "South"); +this.add (jPanel34, "Center"); +this.add (this.jPanel1, "South"); +}); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.thresholdValue) { +try { +var f = new Float (this.thresholdValue.getText ()).floatValue (); +this.slider.setValue (Clazz.floatToInt (f * 1000)); +this.adjustmentValueChanged (null); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +} else if (evt.getSource () === this.minColour) { +this.minColour_actionPerformed (null); +} else if (evt.getSource () === this.maxColour) { +this.maxColour_actionPerformed (null); +} else if (evt.getSource () === this.defColours) { +this.defColour_actionPerformed (); +} else if (evt.getSource () === this.ok) { +this.changeColour (); +this.frame.setVisible (false); +} else if (evt.getSource () === this.cancel) { +this.reset (); +this.ap.paintAlignment (true); +this.frame.setVisible (false); +} else { +this.changeColour (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +if (evt.getSource () === this.currentColours) { +if (this.currentColours.getState ()) { +this.reset (); +}this.maxColour.setEnabled (!this.currentColours.getState ()); +this.minColour.setEnabled (!this.currentColours.getState ()); +}this.changeColour (); +}, "java.awt.event.ItemEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (!this.adjusting) { +this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); +if (this.currentColours.getState () && !(Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.AnnotationColourGradient))) { +this.changeColour (); +}this.currentAnnotation.threshold.value = this.slider.getValue () / 1000; +this.ap.paintAlignment (false); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "minColour_actionPerformed", +function (newCol) { +if (newCol != null) { +this.minColour.setBackground (newCol); +this.minColour.repaint (); +this.changeColour (); +} else { + new jalview.appletgui.UserDefinedColours (this, "Min Colour", this.minColour.getBackground ()); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "maxColour_actionPerformed", +function (newCol) { +if (newCol != null) { +this.maxColour.setBackground (newCol); +this.maxColour.repaint (); +this.changeColour (); +} else { + new jalview.appletgui.UserDefinedColours (this, "Max Colour", this.maxColour.getBackground ()); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "defColour_actionPerformed", +function () { +this.setDefaultMinMax (); +this.minColour.repaint (); +this.maxColour.repaint (); +this.changeColour (); +}); +Clazz.defineMethod (c$, "changeColour", +function () { +if (this.adjusting) { +return; +}this.currentAnnotation = this.av.getAlignment ().getAlignmentAnnotation ()[this.annotations.getSelectedIndex ()]; +var aboveThreshold = -1; +if (this.threshold.getSelectedIndex () == 1) { +aboveThreshold = 1; +} else if (this.threshold.getSelectedIndex () == 2) { +aboveThreshold = 0; +}this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.thresholdIsMin.setEnabled (true); +if (aboveThreshold == -1) { +this.slider.setEnabled (false); +this.thresholdValue.setEnabled (false); +this.thresholdIsMin.setEnabled (false); +this.thresholdValue.setText (""); +} else if (aboveThreshold != -1 && this.currentAnnotation.threshold == null) { +this.currentAnnotation.setThreshold ( new jalview.datamodel.GraphLine ((this.currentAnnotation.graphMax - this.currentAnnotation.graphMin) / 2, "Threshold", java.awt.Color.black)); +}if (aboveThreshold != -1) { +this.adjusting = true; +this.slider.setMinimum (Clazz.floatToInt (this.currentAnnotation.graphMin * 1000)); +this.slider.setMaximum (Clazz.floatToInt (this.currentAnnotation.graphMax * 1000)); +this.slider.setValue (Clazz.floatToInt (this.currentAnnotation.threshold.value * 1000)); +this.thresholdValue.setText (this.currentAnnotation.threshold.value + ""); +this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.adjusting = false; +}var acg = null; +if (this.currentColours.getState ()) { +acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.av.getGlobalColourScheme (), aboveThreshold); +} else { +acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); +}if (this.currentAnnotation.graphMin == 0 && this.currentAnnotation.graphMax == 0) { +acg.setPredefinedColours (true); +}acg.thresholdIsMinMax = this.thresholdIsMin.getState (); +this.av.setGlobalColourScheme (acg); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs == null) { +continue; +}if (this.currentColours.getState ()) { +sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, sg.cs, aboveThreshold); +} else { +sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); +}} +}this.ap.alignmentChanged (); +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "reset", +function () { +this.av.setGlobalColourScheme (this.oldcs); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +var cs = this.oldgroupColours.get (sg); +if (Clazz.instanceOf (cs, jalview.schemes.ColourSchemeI)) { +sg.cs = cs; +} else { +sg.cs = null; +}} +}this.ap.paintAlignment (true); +}); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.ap.paintAlignment (true); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +});