public Vector removeRedundancy(float threshold, Vector sel) {\r
Vector del = new Vector();\r
\r
- for (int i=1; i < sel.size(); i++) {\r
- for (int j = 0; j < i; j++) {\r
+ for (int i = 1; i < sel.size(); i++)\r
+ {\r
+ for (int j = 0; j < i; j++)\r
+ {\r
// Only do the comparison if either have not been deleted\r
- if (!del.contains((SequenceI)sel.elementAt(i)) ||\r
- !del.contains((SequenceI)sel.elementAt(j))) {\r
+ if (!del.contains( (SequenceI) sel.elementAt(i)) ||\r
+ !del.contains( (SequenceI) sel.elementAt(j)))\r
+ {\r
\r
- float pid = Comparison.compare((SequenceI)sel.elementAt(j),\r
- (SequenceI)sel.elementAt(i));\r
+ float pid = Comparison.compare( (SequenceI) sel.elementAt(j),\r
+ (SequenceI) sel.elementAt(i));\r
\r
- if (pid >= threshold) {\r
+ if (pid >= threshold)\r
+ {\r
// Delete the shortest one\r
- if (((SequenceI)sel.elementAt(j)).getSequence().length() >\r
- ((SequenceI)sel.elementAt(i)).getSequence().length()) {\r
+ if ( ( (SequenceI) sel.elementAt(j)).getSequence().length() >\r
+ ( (SequenceI) sel.elementAt(i)).getSequence().length())\r
del.addElement(sel.elementAt(i));\r
- System.out.println("Deleting sequence " + ((SequenceI)sel.elementAt(i)).getName());\r
- } else {\r
+ else\r
del.addElement(sel.elementAt(i));\r
- System.out.println("Deleting sequence " + ((SequenceI)sel.elementAt(i)).getName());\r
- }\r
}\r
}\r
}\r
}\r
\r
// Now delete the sequences\r
- for (int i=0; i < del.size(); i++) {\r
- System.out.println("Deleting sequence " + ((SequenceI)del.elementAt(i)).getName());\r
+ for (int i=0; i < del.size(); i++)\r
deleteSequence((SequenceI)del.elementAt(i));\r
- }\r
\r
return del;\r
}\r
frame.setContentPane(sp);\r
Desktop.addInternalFrame(frame, "Conservation Colour Increment", 400, 90);\r
frame.setMaximizable(false);\r
+ frame.setResizable(false);\r
}\r
}\r
\r
frame.setContentPane(sp);\r
Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400, 90);\r
frame.setMaximizable(false);\r
+ frame.setResizable(false);\r
}\r
}\r
\r
\r
public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ RedundancyPanel sp = new RedundancyPanel(alignPanel);\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(sp);\r
+ Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100);\r
+ frame.setMaximizable(false);\r
+ frame.setResizable(false);\r
\r
}\r
\r
--- /dev/null
+package jalview.gui;\r
+\r
+import jalview.jbgui.*;\r
+import jalview.datamodel.*;\r
+import java.awt.event.*;\r
+import java.util.*;\r
+import javax.swing.event.*;\r
+\r
+public class RedundancyPanel extends GSliderPanel\r
+{\r
+ AlignmentPanel ap;\r
+\r
+ SequenceI[] oldAlignment;\r
+\r
+\r
+ public RedundancyPanel(AlignmentPanel ap)\r
+ {\r
+ this.ap = ap;\r
+\r
+ label.setText("Enter the redundancy threshold");\r
+\r
+ slider.addChangeListener(new ChangeListener()\r
+ {\r
+ public void stateChanged(ChangeEvent evt)\r
+ {\r
+ valueField.setText( slider.getValue()+"" );\r
+ }\r
+ });\r
+\r
+ slider.setMinimum(0);\r
+ slider.setMaximum(100);\r
+ slider.setValue(100 );\r
+\r
+ }\r
+\r
+ public void applyButton_actionPerformed(ActionEvent e)\r
+ {\r
+ float threshold = slider.getValue();\r
+ Vector del;\r
+\r
+ oldAlignment = new SequenceI[ap.av.alignment.getHeight()];\r
+ for (int i = 0; i < ap.av.alignment.getHeight(); i++)\r
+ {\r
+ oldAlignment[i] = new Sequence(ap.av.alignment.getSequenceAt(i).getName(),\r
+ ap.av.alignment.getSequenceAt(i).\r
+ getSequence());\r
+ }\r
+\r
+ undoButton.setEnabled(true);\r
+\r
+ if (ap.av.sel != null && ap.av.sel.size() > 1)\r
+ {\r
+\r
+ del = ap.av.alignment.removeRedundancy(threshold, ap.av.sel.asVector());\r
+ for (int i = 0; i < del.size(); i++)\r
+ if (ap.av.sel.contains( (SequenceI) del.elementAt(i)))\r
+ ap.av.sel.removeElement( (SequenceI) del.elementAt(i));\r
+\r
+ }\r
+ else\r
+ {\r
+ Vector s = new Vector();\r
+ int i=0;\r
+ while(i < ap.av.alignment.getHeight())\r
+ {\r
+ s.addElement( ap.av.alignment.getSequenceAt(i) );\r
+ i++;\r
+ }\r
+ del = ap.av.alignment.removeRedundancy(threshold,s);\r
+ for (int j=0; j < del.size(); j++)\r
+ {\r
+ if (ap.av.sel.contains((SequenceI)del.elementAt(j)))\r
+ ap.av.sel.removeElement((SequenceI)del.elementAt(j));\r
+\r
+ }\r
+ }\r
+\r
+ ap.RefreshPanels();\r
+\r
+ }\r
+\r
+ public void undoButton_actionPerformed(ActionEvent e)\r
+ {\r
+ undoButton.setEnabled(false);\r
+ ap.av.setAlignment( new Alignment(oldAlignment) );\r
+ oldAlignment = null;\r
+ ap.RefreshPanels();\r
+ }\r
+\r
+\r
+ public void valueField_actionPerformed(ActionEvent e)\r
+ {\r
+ try{\r
+ int i = Integer.parseInt(valueField.getText());\r
+ slider.setValue(i);\r
+ }\r
+ catch(Exception ex)\r
+ {\r
+ valueField.setText( slider.getValue()+"" );\r
+ }\r
+ }\r
+}\r
public class GSliderPanel extends JPanel
{
+ // this is used for conservation colours, PID colours and redundancy threshold
protected JSlider slider = new JSlider();
protected JTextField valueField = new JTextField();
protected JLabel label = new JLabel();
JPanel jPanel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
GridLayout gridLayout1 = new GridLayout();
+ JPanel jPanel2 = new JPanel();
+ protected JButton applyButton = new JButton();
+ protected JButton undoButton = new JButton();
+ FlowLayout flowLayout1 = new FlowLayout();
public GSliderPanel()
{
{
this.setLayout(gridLayout1);
slider.setMajorTickSpacing(10);
- slider.setMaximum(50);
slider.setMinorTickSpacing(1);
slider.setPaintTicks(true);
- slider.setBackground(new Color(212, 208, 236));
+ slider.setBackground(new Color(177, 177, 217));
slider.setFont(new java.awt.Font("Verdana", 0, 11));
valueField.setFont(new java.awt.Font("Verdana", 0, 11));
valueField.setMinimumSize(new Dimension(6, 21));
valueField.setPreferredSize(new Dimension(60, 21));
valueField.setText("");
+ valueField.setHorizontalAlignment(SwingConstants.CENTER);
valueField.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
valueField_actionPerformed(e);
}
});
- label.setBackground(new Color(212, 208, 236));
+ label.setBackground(new Color(177, 177, 217));
label.setFont(new java.awt.Font("Verdana", 0, 11));
label.setOpaque(true);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setText("set this label text");
jPanel1.setLayout(borderLayout1);
gridLayout1.setRows(2);
- this.add(label, null);
- this.add(jPanel1, null);
+ jPanel2.setLayout(flowLayout1);
+ applyButton.setBackground(new Color(177, 177, 217));
+ applyButton.setText("Apply");
+ applyButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ applyButton_actionPerformed(e);
+ }
+ });
+ undoButton.setBackground(new Color(177, 177, 217));
+ undoButton.setEnabled(false);
+ undoButton.setText("Undo");
+ undoButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ undoButton_actionPerformed(e);
+ }
+ });
+ jPanel2.setBackground(new Color(177, 177, 217));
+ this.add(jPanel2, null);
+ jPanel2.add(label, null);
+ jPanel2.add(applyButton, null);
+ jPanel2.add(undoButton, null);this.add(jPanel1, null);
jPanel1.add(valueField, BorderLayout.EAST);
jPanel1.add(slider, BorderLayout.CENTER);
+
}
protected void valueField_actionPerformed(ActionEvent e)
}
+ protected void applyButton_actionPerformed(ActionEvent e)
+ {
+
+ }
+
+ protected void undoButton_actionPerformed(ActionEvent e)
+ {
+
+ }
+
}