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