3 import jalview.gui.AnnotationColumnChooser;
4 import jalview.gui.JvSwingUtils;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
10 import javax.swing.JCheckBox;
11 import javax.swing.JPanel;
12 import javax.swing.border.TitledBorder;
14 @SuppressWarnings("serial")
15 public class StructureFilterPanel extends JPanel
17 private AnnotationColumnChooser aColChooser;
19 private JCheckBox alphaHelix = new JCheckBox();
21 private JCheckBox betaStrand = new JCheckBox();
23 private JCheckBox turn = new JCheckBox();
25 private JCheckBox all = new JCheckBox();
27 public StructureFilterPanel(AnnotationColumnChooser aColChooser)
29 this.aColChooser = aColChooser;
31 alphaHelix.setBackground(Color.white);
32 alphaHelix.setFont(JvSwingUtils.getLabelFont());
33 alphaHelix.setText("Alpha Helix");
34 alphaHelix.addActionListener(new ActionListener()
37 public void actionPerformed(ActionEvent actionEvent)
39 alphaHelix_actionPerformed();
43 betaStrand.setBackground(Color.white);
44 betaStrand.setFont(JvSwingUtils.getLabelFont());
45 betaStrand.setText("Beta Strand");
46 betaStrand.addActionListener(new ActionListener()
49 public void actionPerformed(ActionEvent actionEvent)
51 betaStrand_actionPerformed();
55 turn.setBackground(Color.white);
56 turn.setFont(JvSwingUtils.getLabelFont());
58 turn.addActionListener(new ActionListener()
61 public void actionPerformed(ActionEvent actionEvent)
63 turn_actionPerformed();
67 all.setBackground(Color.white);
68 all.setFont(JvSwingUtils.getLabelFont());
69 all.setText("Select all");
70 all.addActionListener(new ActionListener()
73 public void actionPerformed(ActionEvent actionEvent)
75 all_actionPerformed();
79 this.setBorder(new TitledBorder("Structures Filter"));
80 this.setBackground(Color.white);
81 this.setFont(JvSwingUtils.getLabelFont());
89 public void alphaHelix_actionPerformed()
91 updateSelectAllState();
92 aColChooser.setCurrentStructureFilterPanel(this);
93 aColChooser.updateView();
96 public void betaStrand_actionPerformed()
98 updateSelectAllState();
99 aColChooser.setCurrentStructureFilterPanel(this);
100 aColChooser.updateView();
103 public void turn_actionPerformed()
105 updateSelectAllState();
106 aColChooser.setCurrentStructureFilterPanel(this);
107 aColChooser.updateView();
110 public void all_actionPerformed()
112 if (all.isSelected())
114 alphaHelix.setSelected(true);
115 betaStrand.setSelected(true);
116 turn.setSelected(true);
120 alphaHelix.setSelected(false);
121 betaStrand.setSelected(false);
122 turn.setSelected(false);
124 aColChooser.setCurrentStructureFilterPanel(this);
125 aColChooser.updateView();
128 public void updateSelectAllState()
130 if (alphaHelix.isSelected() && betaStrand.isSelected()
131 && turn.isSelected())
133 all.setSelected(true);
137 all.setSelected(false);
141 public void syncState()
143 StructureFilterPanel sfp = aColChooser.getCurrentStructureFilterPanel();
146 alphaHelix.setSelected(sfp.getAlphaHelix().isSelected());
147 betaStrand.setSelected(sfp.getBetaStrand().isSelected());
148 turn.setSelected(sfp.getTurn().isSelected());
149 if (sfp.getAll().isSelected())
151 all.setSelected(true);
152 alphaHelix.setSelected(true);
153 betaStrand.setSelected(true);
154 turn.setSelected(true);
160 public JCheckBox getAlphaHelix()
165 public void setAlphaHelix(JCheckBox alphaHelix)
167 this.alphaHelix = alphaHelix;
170 public JCheckBox getBetaStrand()
175 public void setBetaStrand(JCheckBox betaStrand)
177 this.betaStrand = betaStrand;
180 public JCheckBox getTurn()
185 public void setTurn(JCheckBox turn)
190 public JCheckBox getAll()
195 public void setAll(JCheckBox all)