JAL-1807 test
[jalviewjs.git] / bin / jalview / appletgui / AnnotationRowFilter.js
1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "$.Button", "$.Checkbox", "$.Scrollbar", "$.TextField"], "jalview.appletgui.AnnotationRowFilter", ["jalview.util.MessageManager", "java.lang.Float", "java.util.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.av = null;
5 this.ap = null;
6 this.annmap = null;
7 this.enableSeqAss = false;
8 this.currentAnnotation = null;
9 this.adjusting = false;
10 this.currentColours = null;
11 this.minColour = null;
12 this.maxColour = null;
13 this.seqAssociated = null;
14 this.thresholdIsMin = null;
15 this.slider = null;
16 this.thresholdValue = null;
17 this.frame = null;
18 this.ok = null;
19 this.cancel = null;
20 this.sliderDragging = false;
21 Clazz.instantialize (this, arguments);
22 }, jalview.appletgui, "AnnotationRowFilter", awt2swing.Panel);
23 Clazz.prepareFields (c$, function () {
24 this.currentColours =  new awt2swing.Checkbox ();
25 this.minColour =  new awt2swing.Panel ();
26 this.maxColour =  new awt2swing.Panel ();
27 this.seqAssociated =  new awt2swing.Checkbox ();
28 this.thresholdIsMin =  new awt2swing.Checkbox ();
29 this.slider =  new awt2swing.Scrollbar (0);
30 this.thresholdValue =  new awt2swing.TextField (20);
31 this.ok =  new awt2swing.Button ();
32 this.cancel =  new awt2swing.Button ();
33 });
34 Clazz.makeConstructor (c$, 
35 function (av, ap) {
36 Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []);
37 this.av = av;
38 this.ap = ap;
39 }, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel");
40 Clazz.makeConstructor (c$, 
41 function () {
42 Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []);
43 });
44 Clazz.defineMethod (c$, "getAnnotationItems", 
45 function (isSeqAssociated) {
46 var list =  new java.util.Vector ();
47 var index = 1;
48 var anmap =  Clazz.newIntArray (this.av.getAlignment ().getAlignmentAnnotation ().length, 0);
49 for (var i = 0; i < this.av.getAlignment ().getAlignmentAnnotation ().length; i++) {
50 if (this.av.getAlignment ().getAlignmentAnnotation ()[i].sequenceRef == null) {
51 if (isSeqAssociated) {
52 continue;
53 }} else {
54 this.enableSeqAss = true;
55 }var label = this.av.getAlignment ().getAlignmentAnnotation ()[i].label;
56 if (!list.contains (label)) {
57 anmap[list.size ()] = i;
58 list.add (label);
59 } else {
60 if (!isSeqAssociated) {
61 anmap[list.size ()] = i;
62 list.add (label + "_" + (index++));
63 }}}
64 this.annmap =  Clazz.newIntArray (list.size (), 0);
65 System.arraycopy (anmap, 0, this.annmap, 0, this.annmap.length);
66 return list;
67 }, "~B");
68 Clazz.defineMethod (c$, "getSelectedThresholdItem", 
69 function (indexValue) {
70 var selectedThresholdItem = -1;
71 if (indexValue == 1) {
72 selectedThresholdItem = 1;
73 } else if (indexValue == 2) {
74 selectedThresholdItem = 0;
75 }return selectedThresholdItem;
76 }, "~N");
77 Clazz.defineMethod (c$, "modelChanged", 
78 function () {
79 this.seqAssociated.setEnabled (this.enableSeqAss);
80 });
81 Clazz.defineMethod (c$, "ok_actionPerformed", 
82 function (e) {
83 this.updateView ();
84 this.frame.setVisible (false);
85 }, "java.awt.event.ActionEvent");
86 Clazz.defineMethod (c$, "cancel_actionPerformed", 
87 function (e) {
88 this.reset ();
89 this.ap.paintAlignment (true);
90 this.frame.setVisible (false);
91 }, "java.awt.event.ActionEvent");
92 Clazz.defineMethod (c$, "thresholdCheck_actionPerformed", 
93 function (e) {
94 this.updateView ();
95 }, "java.awt.event.ActionEvent");
96 Clazz.defineMethod (c$, "annotations_actionPerformed", 
97 function (e) {
98 this.updateView ();
99 }, "java.awt.event.ActionEvent");
100 Clazz.defineMethod (c$, "threshold_actionPerformed", 
101 function (e) {
102 this.updateView ();
103 }, "java.awt.event.ActionEvent");
104 Clazz.defineMethod (c$, "thresholdValue_actionPerformed", 
105 function (e) {
106 try {
107 var f = Float.parseFloat (this.thresholdValue.getText ());
108 this.slider.setValue (Clazz.floatToInt (f * 1000));
109 this.updateView ();
110 } catch (ex) {
111 if (Clazz.exceptionOf (ex, NumberFormatException)) {
112 } else {
113 throw ex;
114 }
115 }
116 }, "java.awt.event.ActionEvent");
117 Clazz.defineMethod (c$, "populateThresholdComboBox", 
118 function (threshold) {
119 threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold"));
120 threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold"));
121 threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold"));
122 }, "awt2swing.Choice");
123 Clazz.defineMethod (c$, "getCurrentAnnotation", 
124 function () {
125 return this.currentAnnotation;
126 });
127 Clazz.defineMethod (c$, "setCurrentAnnotation", 
128 function (currentAnnotation) {
129 this.currentAnnotation = currentAnnotation;
130 }, "jalview.datamodel.AlignmentAnnotation");
131 });