3 import jalview.jbgui.*;
\r
4 import jalview.datamodel.*;
\r
5 import java.awt.event.*;
\r
7 import javax.swing.event.*;
\r
9 public class RedundancyPanel
\r
10 extends GSliderPanel
\r
14 Stack historyList = new Stack(); // simpler than synching with alignFrame.
\r
16 public RedundancyPanel(AlignmentPanel ap, AlignFrame af)
\r
20 label.setText("Enter the redundancy threshold");
\r
22 slider.addChangeListener(new ChangeListener()
\r
24 public void stateChanged(ChangeEvent evt)
\r
26 valueField.setText(slider.getValue() + "");
\r
30 slider.setMinimum(0);
\r
31 slider.setMaximum(100);
\r
32 slider.setValue(100);
\r
36 public void applyButton_actionPerformed(ActionEvent e)
\r
38 float threshold = slider.getValue();
\r
41 historyList.push(it=new HistoryItem("Remove redundancy",
\r
42 ap.av.alignment, HistoryItem.HIDE));
\r
43 if (historyList.size()==1
\r
44 || !af.historyList.contains(historyList.firstElement())) {
\r
45 af.addHistoryItem((HistoryItem) historyList.firstElement());
\r
46 af.updateEditMenuBar();
\r
48 undoButton.setEnabled(true);
\r
49 SequenceGroup sg = ap.av.getSelectionGroup();
\r
50 if (sg != null && sg.getSize() >= 1)
\r
53 del = ap.av.alignment.removeRedundancy(threshold, sg.sequences);
\r
54 for (int i = 0; i < del.size(); i++)
\r
56 if (sg.sequences.contains( (SequenceI) del.elementAt(i)))
\r
58 sg.deleteSequence( (SequenceI) del.elementAt(i));
\r
65 Vector s = new Vector();
\r
67 while (i < ap.av.alignment.getHeight())
\r
69 s.addElement(ap.av.alignment.getSequenceAt(i));
\r
72 del = ap.av.alignment.removeRedundancy(threshold, s);
\r
75 // This has to be done before the restoreHistoryItem method of alignFrame will
\r
76 // actually restore these sequences.
\r
79 for (int i=0,j=del.size(); i<j; i++) {
\r
80 SequenceI sq = (SequenceI) del.elementAt(i);
\r
81 sq.deleteChars(0,sq.getLength());
\r
84 ap.av.firePropertyChange("alignment", null,
\r
85 ap.av.getAlignment().getSequences());
\r
86 ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight());
\r
87 if (ap.av.getAlignment().getHeight() < 1)
\r
93 catch (Exception ex)
\r
96 ap.av.updateConservation();
\r
97 ap.av.updateConsensus();
\r
98 af.updateEditMenuBar();
\r
103 public void undoButton_actionPerformed(ActionEvent e)
\r
105 HistoryItem hi = (HistoryItem) historyList.pop();
\r
106 af.restoreHistoryItem(hi);
\r
107 if (historyList.size() == 0)
\r
109 undoButton.setEnabled(false);
\r
110 if (af.historyList.contains(hi))
\r
112 af.historyList.remove(hi);
\r
113 af.updateEditMenuBar();
\r
117 public void valueField_actionPerformed(ActionEvent e)
\r
121 int i = Integer.parseInt(valueField.getText());
\r
122 slider.setValue(i);
\r
124 catch (Exception ex)
\r
126 valueField.setText(slider.getValue() + "");
\r