JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / jalview / appletgui / RedundancyPanel.js
1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["jalview.appletgui.SliderPanel", "java.awt.event.WindowListener", "java.util.Stack"], "jalview.appletgui.RedundancyPanel", ["awt2swing.Frame", "jalview.analysis.AlignSeq", "jalview.appletgui.PaintRefresher", "jalview.bin.JalviewLite", "jalview.commands.EditCommand", "jalview.util.MessageManager", "java.awt.event.AdjustmentListener", "java.lang.Thread", "java.util.ArrayList", "$.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.historyList = null;
5 this.redundancy = null;
6 this.originalSequences = null;
7 this.frame = null;
8 this.redundantSeqs = null;
9 Clazz.instantialize (this, arguments);
10 }, jalview.appletgui, "RedundancyPanel", jalview.appletgui.SliderPanel, [Runnable, java.awt.event.WindowListener]);
11 Clazz.prepareFields (c$, function () {
12 this.historyList =  new java.util.Stack ();
13 });
14 Clazz.makeConstructor (c$, 
15 function (ap) {
16 Clazz.superConstructor (this, jalview.appletgui.RedundancyPanel, [ap, 0, false, null]);
17 this.redundantSeqs =  new java.util.Vector ();
18 this.ap = ap;
19 this.undoButton.setVisible (true);
20 this.applyButton.setVisible (true);
21 this.allGroupsCheck.setVisible (false);
22 this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold"));
23 this.valueField.setText ("100");
24 this.slider.setVisibleAmount (1);
25 this.slider.setMinimum (0);
26 this.slider.setMaximum (100 + this.slider.getVisibleAmount ());
27 this.slider.setValue (100);
28 this.slider.addAdjustmentListener (((Clazz.isClassDefined ("jalview.appletgui.RedundancyPanel$1") ? 0 : jalview.appletgui.RedundancyPanel.$RedundancyPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.RedundancyPanel$1, this, null)));
29 this.frame =  new awt2swing.Frame ();
30 this.frame.add (this);
31 jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.redundancy_threshold_selection"), 400, 100);
32 this.frame.addWindowListener (this);
33 var worker =  new Thread (this);
34 worker.start ();
35 }, "jalview.appletgui.AlignmentPanel");
36 Clazz.overrideMethod (c$, "run", 
37 function () {
38 this.label.setText (jalview.util.MessageManager.getString ("label.calculating"));
39 this.slider.setVisible (false);
40 this.applyButton.setEnabled (false);
41 this.valueField.setVisible (false);
42 this.validate ();
43 var omitHidden = null;
44 var sg = this.ap.av.getSelectionGroup ();
45 var height;
46 var start;
47 var end;
48 if ((sg != null) && (sg.getSize () >= 1)) {
49 this.originalSequences = sg.getSequencesInOrder (this.ap.av.getAlignment ());
50 start = sg.getStartRes ();
51 end = sg.getEndRes ();
52 } else {
53 this.originalSequences = this.ap.av.getAlignment ().getSequencesArray ();
54 start = 0;
55 end = this.ap.av.getAlignment ().getWidth ();
56 }height = this.originalSequences.length;
57 this.redundancy = jalview.analysis.AlignSeq.computeRedundancyMatrix (this.originalSequences, omitHidden, start, end, false);
58 this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold"));
59 this.slider.setVisible (true);
60 this.applyButton.setEnabled (true);
61 this.valueField.setVisible (true);
62 this.validate ();
63 this.sliderValueChanged ();
64 });
65 Clazz.defineMethod (c$, "sliderValueChanged", 
66 function () {
67 if (this.redundancy == null) {
68 return;
69 }var value = this.slider.getValue ();
70 var redundantSequences =  new java.util.ArrayList ();
71 for (var i = 0; i < this.redundancy.length; i++) {
72 if (value <= this.redundancy[i]) {
73 redundantSequences.add (this.originalSequences[i]);
74 }}
75 this.ap.idPanel.idCanvas.setHighlighted (redundantSequences);
76 jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true);
77 });
78 Clazz.overrideMethod (c$, "applyButton_actionPerformed", 
79 function () {
80 var del =  new java.util.Vector ();
81 this.undoButton.setEnabled (true);
82 var value = this.slider.getValue ();
83 var sg = this.ap.av.getSelectionGroup ();
84 for (var i = 0; i < this.redundancy.length; i++) {
85 if (value <= this.redundancy[i]) {
86 del.addElement (this.originalSequences[i]);
87 }}
88 if (del.size () > 0) {
89 var deleted =  new Array (del.size ());
90 var width = 0;
91 for (var i = 0; i < del.size (); i++) {
92 deleted[i] = del.elementAt (i);
93 if (deleted[i].getLength () > width) {
94 width = deleted[i].getLength ();
95 }}
96 var cut =  new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.remove_redundancy"), jalview.commands.EditCommand.Action.CUT, deleted, 0, width, this.ap.av.getAlignment ());
97 var alignment = this.ap.av.getAlignment ();
98 for (var i = 0; i < del.size (); i++) {
99 alignment.deleteSequence (deleted[i]);
100 if (sg != null) {
101 sg.deleteSequence (deleted[i], false);
102 }}
103 this.historyList.push (cut);
104 this.ap.alignFrame.addHistoryItem (cut);
105 jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true);
106 this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());
107 }});
108 Clazz.overrideMethod (c$, "undoButton_actionPerformed", 
109 function () {
110 var command = this.historyList.pop ();
111 command.undoCommand (null);
112 if (this.ap.av.getHistoryList ().contains (command)) {
113 this.ap.av.getHistoryList ().remove (command);
114 this.ap.alignFrame.updateEditMenuBar ();
115 this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());
116 }this.ap.paintAlignment (true);
117 if (this.historyList.size () == 0) {
118 this.undoButton.setEnabled (false);
119 }});
120 Clazz.defineMethod (c$, "valueField_actionPerformed", 
121 function (e) {
122 try {
123 var i = Integer.parseInt (this.valueField.getText ());
124 this.slider.setValue (i);
125 } catch (ex) {
126 if (Clazz.exceptionOf (ex, Exception)) {
127 this.valueField.setText (this.slider.getValue () + "");
128 } else {
129 throw ex;
130 }
131 }
132 }, "java.awt.event.ActionEvent");
133 Clazz.overrideMethod (c$, "windowOpened", 
134 function (evt) {
135 }, "java.awt.event.WindowEvent");
136 Clazz.overrideMethod (c$, "windowClosing", 
137 function (evt) {
138 this.ap.idPanel.idCanvas.setHighlighted (null);
139 }, "java.awt.event.WindowEvent");
140 Clazz.overrideMethod (c$, "windowClosed", 
141 function (evt) {
142 }, "java.awt.event.WindowEvent");
143 Clazz.overrideMethod (c$, "windowActivated", 
144 function (evt) {
145 }, "java.awt.event.WindowEvent");
146 Clazz.overrideMethod (c$, "windowDeactivated", 
147 function (evt) {
148 }, "java.awt.event.WindowEvent");
149 Clazz.overrideMethod (c$, "windowIconified", 
150 function (evt) {
151 }, "java.awt.event.WindowEvent");
152 Clazz.overrideMethod (c$, "windowDeiconified", 
153 function (evt) {
154 }, "java.awt.event.WindowEvent");
155 c$.$RedundancyPanel$1$ = function () {
156 Clazz.pu$h ();
157 c$ = Clazz.declareAnonymous (jalview.appletgui, "RedundancyPanel$1", null, java.awt.event.AdjustmentListener);
158 Clazz.overrideMethod (c$, "adjustmentValueChanged", 
159 function (evt) {
160 this.b$["jalview.appletgui.RedundancyPanel"].valueField.setText (this.b$["jalview.appletgui.RedundancyPanel"].slider.getValue () + "");
161 this.b$["jalview.appletgui.RedundancyPanel"].sliderValueChanged ();
162 }, "java.awt.event.AdjustmentEvent");
163 c$ = Clazz.p0p ();
164 };
165 });