Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.appletgui

File AnnotationColumnChooser.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

106
327
51
4
950
745
108
0.33
6.41
12.75
2.12

Classes

Class Line # Actions
AnnotationColumnChooser 55 223 75
0.00%
AnnotationColumnChooser.FurtherActionPanel 606 15 5
0.00%
AnnotationColumnChooser.StructureFilterPanel 657 58 18
0.00%
AnnotationColumnChooser.SearchPanel 794 31 10
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.appletgui;
22   
23    import java.awt.BorderLayout;
24    import java.awt.CardLayout;
25    import java.awt.Checkbox;
26    import java.awt.Choice;
27    import java.awt.Color;
28    import java.awt.Dimension;
29    import java.awt.Frame;
30    import java.awt.Panel;
31    import java.awt.TextField;
32    import java.awt.event.ActionEvent;
33    import java.awt.event.ActionListener;
34    import java.awt.event.AdjustmentEvent;
35    import java.awt.event.AdjustmentListener;
36    import java.awt.event.ItemEvent;
37    import java.awt.event.ItemListener;
38    import java.awt.event.MouseAdapter;
39    import java.awt.event.MouseEvent;
40    import java.awt.event.MouseListener;
41    import java.awt.event.TextEvent;
42    import java.awt.event.TextListener;
43    import java.util.Vector;
44   
45    import jalview.datamodel.AlignmentAnnotation;
46    import jalview.datamodel.HiddenColumns;
47    import jalview.schemes.AnnotationColourGradient;
48    import jalview.util.MessageManager;
49    import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
50   
51    //import javax.swing.JPanel;
52   
53    //import net.miginfocom.swing.MigLayout;
54   
 
55    public class AnnotationColumnChooser extends AnnotationRowFilter implements
56    ActionListener, AdjustmentListener, ItemListener, MouseListener
57    {
58   
59    private Choice annotations = new Choice();
60   
61    private Panel actionPanel = new Panel();
62   
63    private TitledPanel thresholdPanel = new TitledPanel();
64   
65    private Panel switchableViewsPanel = new Panel(new CardLayout());
66   
67    private CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel
68    .getLayout());
69   
70    private Panel noGraphFilterView = new Panel();
71   
72    private Panel graphFilterView = new Panel();
73   
74    private Panel annotationComboBoxPanel = new Panel();
75   
76    private BorderLayout borderLayout1 = new BorderLayout();
77   
78    private BorderLayout gBorderLayout = new BorderLayout();
79   
80    private BorderLayout ngBorderLayout = new BorderLayout();
81   
82    private Choice threshold = new Choice();
83   
84    private StructureFilterPanel gStructureFilterPanel;
85   
86    private StructureFilterPanel ngStructureFilterPanel;
87   
88    private StructureFilterPanel currentStructureFilterPanel;
89   
90    private SearchPanel currentSearchPanel;
91   
92    private SearchPanel gSearchPanel;
93   
94    private SearchPanel ngSearchPanel;
95   
96    private FurtherActionPanel currentFurtherActionPanel;
97   
98    private FurtherActionPanel gFurtherActionPanel;
99   
100    private FurtherActionPanel ngFurtherActionPanel;
101   
102    public static final int ACTION_OPTION_SELECT = 1;
103   
104    public static int ACTION_OPTION_HIDE = 2;
105   
106    public static String NO_GRAPH_VIEW = "0";
107   
108    public static String GRAPH_VIEW = "1";
109   
110    private int actionOption = ACTION_OPTION_SELECT;
111   
112    private HiddenColumns oldHiddenColumns;
113   
 
114  0 toggle public AnnotationColumnChooser()
115    {
116  0 try
117    {
118  0 jbInit();
119    } catch (Exception ex)
120    {
121  0 ex.printStackTrace();
122    }
123    }
124   
 
125  0 toggle public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap)
126    {
127  0 super(av, ap);
128  0 frame = new Frame();
129  0 frame.add(this);
130  0 jalview.bin.JalviewLite.addFrame(frame,
131    MessageManager.getString("label.select_by_annotation"), 520,
132    215);
133   
134  0 slider.addAdjustmentListener(this);
135  0 slider.addMouseListener(this);
136   
137  0 AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
138  0 if (anns == null)
139    {
140  0 return;
141    }
142  0 setOldHiddenColumns(av.getAlignment().getHiddenColumns());
143  0 adjusting = true;
144  0 Vector<String> list = new Vector<>();
145  0 int index = 1;
146  0 for (int i = 0; i < anns.length; i++)
147    {
148  0 String label = anns[i].label;
149  0 if (anns[i].sequenceRef != null)
150    {
151  0 label = label + "_" + anns[i].sequenceRef.getName();
152    }
153  0 if (!list.contains(label))
154    {
155  0 list.addElement(label);
156    }
157    else
158    {
159  0 list.addElement(label + "_" + (index++));
160    }
161    }
162   
163  0 for (int i = 0; i < list.size(); i++)
164    {
165  0 annotations.addItem(list.elementAt(i).toString());
166    }
167   
168  0 populateThresholdComboBox(threshold);
169  0 AnnotationColumnChooser lastChooser = av
170    .getAnnotationColumnSelectionState();
171    // restore Object state from the previous session if one exists
172  0 if (lastChooser != null)
173    {
174  0 currentSearchPanel = lastChooser.getCurrentSearchPanel();
175  0 currentStructureFilterPanel = lastChooser
176    .getCurrentStructureFilterPanel();
177  0 annotations.select(lastChooser.getAnnotations().getSelectedIndex());
178  0 threshold.select(lastChooser.getThreshold().getSelectedIndex());
179  0 actionOption = lastChooser.getActionOption();
180  0 percentThreshold.setState(lastChooser.percentThreshold.getState());
181    }
182   
183  0 try
184    {
185  0 jbInit();
186    } catch (Exception ex)
187    {
188    }
189  0 adjusting = false;
190   
191  0 updateView();
192  0 frame.invalidate();
193  0 frame.pack();
194    }
195   
 
196  0 toggle private void jbInit() throws Exception
197    {
198  0 ok.setLabel(MessageManager.getString("action.ok"));
199   
200  0 cancel.setLabel(MessageManager.getString("action.cancel"));
201   
202  0 thresholdValue.setEnabled(false);
203  0 thresholdValue.setColumns(7);
204  0 thresholdValue.setCaretPosition(0);
205   
206  0 ok.addActionListener(this);
207  0 cancel.addActionListener(this);
208  0 annotations.addItemListener(this);
209  0 thresholdValue.addActionListener(this);
210  0 threshold.addItemListener(this);
211   
212  0 slider.setBackground(Color.white);
213  0 slider.setEnabled(false);
214  0 slider.setPreferredSize(new Dimension(100, 32));
215   
216  0 thresholdPanel.setBackground(Color.white);
217    // thresholdPanel.setFont(JvSwingUtils.getLabelFont());
218    // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
219   
220  0 percentThreshold.setLabel("As percentage");
221  0 percentThreshold.addItemListener(this);
222   
223  0 actionPanel.setBackground(Color.white);
224    // actionPanel.setFont(JvSwingUtils.getLabelFont());
225   
226  0 graphFilterView.setLayout(gBorderLayout);
227  0 graphFilterView.setBackground(Color.white);
228   
229  0 noGraphFilterView.setLayout(ngBorderLayout);
230  0 noGraphFilterView.setBackground(Color.white);
231   
232  0 annotationComboBoxPanel.setBackground(Color.white);
233    // annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont());
234   
235  0 gSearchPanel = new SearchPanel(this);
236  0 ngSearchPanel = new SearchPanel(this);
237  0 gFurtherActionPanel = new FurtherActionPanel(this);
238  0 ngFurtherActionPanel = new FurtherActionPanel(this);
239  0 gStructureFilterPanel = new StructureFilterPanel(this);
240  0 ngStructureFilterPanel = new StructureFilterPanel(this);
241   
242  0 thresholdPanel.setTitle("Threshold Filter");
243  0 thresholdPanel.add(getThreshold());
244  0 thresholdPanel.add(slider);
245  0 thresholdPanel.add(thresholdValue);
246  0 thresholdPanel.add(percentThreshold);
247   
248  0 actionPanel.add(ok);
249  0 actionPanel.add(cancel);
250   
251  0 Panel staticPanel = new Panel();
252  0 staticPanel.setLayout(new BorderLayout());
253  0 staticPanel.setBackground(Color.white);
254   
255  0 staticPanel.add(gSearchPanel, java.awt.BorderLayout.NORTH);
256  0 staticPanel.add(gStructureFilterPanel, java.awt.BorderLayout.SOUTH);
257   
258  0 graphFilterView.add(staticPanel, java.awt.BorderLayout.NORTH);
259  0 graphFilterView.add(thresholdPanel, java.awt.BorderLayout.CENTER);
260  0 graphFilterView.add(gFurtherActionPanel, java.awt.BorderLayout.SOUTH);
261   
262  0 noGraphFilterView.add(ngSearchPanel, java.awt.BorderLayout.PAGE_START);
263  0 noGraphFilterView.add(ngStructureFilterPanel,
264    java.awt.BorderLayout.CENTER);
265  0 noGraphFilterView.add(ngFurtherActionPanel,
266    java.awt.BorderLayout.CENTER);
267   
268  0 annotationComboBoxPanel.add(getAnnotations());
269  0 switchableViewsPanel.add(noGraphFilterView,
270    AnnotationColumnChooser.NO_GRAPH_VIEW);
271  0 switchableViewsPanel.add(graphFilterView,
272    AnnotationColumnChooser.GRAPH_VIEW);
273   
274  0 this.setLayout(borderLayout1);
275  0 this.add(annotationComboBoxPanel, java.awt.BorderLayout.PAGE_START);
276  0 this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER);
277  0 this.add(actionPanel, java.awt.BorderLayout.SOUTH);
278   
279  0 selectedAnnotationChanged();
280  0 this.validate();
281    }
282   
 
283  0 toggle @Override
284    @SuppressWarnings("unchecked")
285    public void reset()
286    {
287  0 if (this.getOldHiddenColumns() != null)
288    {
289  0 av.getColumnSelection().clear();
290   
291  0 if (av.getAnnotationColumnSelectionState() != null)
292    {
293  0 HiddenColumns oldHidden = av.getAnnotationColumnSelectionState()
294    .getOldHiddenColumns();
295  0 av.getAlignment().setHiddenColumns(oldHidden);
296    }
297  0 av.sendSelection();
298  0 ap.paintAlignment(true, true);
299    }
300   
301    }
302   
 
303  0 toggle @Override
304    public void adjustmentValueChanged(AdjustmentEvent evt)
305    {
306  0 if (!adjusting)
307    {
308  0 setThresholdValueText();
309  0 valueChanged(!sliderDragging);
310    }
311    }
312   
 
313  0 toggle protected void addSliderMouseListeners()
314    {
315   
316  0 slider.addMouseListener(new MouseAdapter()
317    {
 
318  0 toggle @Override
319    public void mousePressed(MouseEvent e)
320    {
321  0 sliderDragging = true;
322  0 super.mousePressed(e);
323    }
324   
 
325  0 toggle @Override
326    public void mouseDragged(MouseEvent e)
327    {
328  0 sliderDragging = true;
329  0 super.mouseDragged(e);
330    }
331   
 
332  0 toggle @Override
333    public void mouseReleased(MouseEvent evt)
334    {
335  0 if (sliderDragging)
336    {
337  0 sliderDragging = false;
338  0 valueChanged(true);
339    }
340  0 ap.paintAlignment(true, true);
341    }
342    });
343    }
344   
 
345  0 toggle @Override
346    public void valueChanged(boolean updateAllAnnotation)
347    {
348  0 if (slider.isEnabled())
349    {
350  0 getCurrentAnnotation().threshold.value = slider.getValue() / 1000f;
351  0 updateView(); // this also calls paintAlignment(true,true)
352    }
353    }
354   
 
355  0 toggle public Choice getThreshold()
356    {
357  0 return threshold;
358    }
359   
 
360  0 toggle public void setThreshold(Choice threshold)
361    {
362  0 this.threshold = threshold;
363    }
364   
 
365  0 toggle public Choice getAnnotations()
366    {
367  0 return annotations;
368    }
369   
 
370  0 toggle public void setAnnotations(Choice annotations)
371    {
372  0 this.annotations = annotations;
373    }
374   
 
375  0 toggle @Override
376    public void updateView()
377    {
378    // Check if combobox is still adjusting
379  0 if (adjusting)
380    {
381  0 return;
382    }
383   
384  0 AnnotationFilterParameter filterParams = new AnnotationFilterParameter();
385  0 setCurrentAnnotation(av.getAlignment()
386    .getAlignmentAnnotation()[getAnnotations().getSelectedIndex()]);
387   
388  0 int selectedThresholdItem = getSelectedThresholdItem(
389    getThreshold().getSelectedIndex());
390   
391  0 slider.setEnabled(true);
392  0 thresholdValue.setEnabled(true);
393  0 percentThreshold.setEnabled(true);
394   
395  0 if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD)
396    {
397  0 slider.setEnabled(false);
398  0 thresholdValue.setEnabled(false);
399  0 thresholdValue.setText("");
400  0 percentThreshold.setEnabled(false);
401    // build filter params
402    }
403  0 else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD)
404    {
405  0 if (getCurrentAnnotation().threshold == null)
406    {
407  0 getCurrentAnnotation().setThreshold(new jalview.datamodel.GraphLine(
408    (getCurrentAnnotation().graphMax
409    - getCurrentAnnotation().graphMin) / 2f,
410    "Threshold", Color.black));
411    }
412   
413  0 adjusting = true;
414    // float range = getCurrentAnnotation().graphMax * 1000
415    // - getCurrentAnnotation().graphMin * 1000;
416   
417  0 slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000));
418  0 slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
419  0 slider.setValue(
420    (int) (getCurrentAnnotation().threshold.value * 1000));
421  0 setThresholdValueText();
422    // slider.setMajorTickSpacing((int) (range / 10f));
423  0 slider.setEnabled(true);
424  0 thresholdValue.setEnabled(true);
425  0 percentThreshold.setEnabled(true);
426  0 adjusting = false;
427   
428    // build filter params
429  0 filterParams.setThresholdType(
430    AnnotationFilterParameter.ThresholdType.NO_THRESHOLD);
431  0 if (getCurrentAnnotation().isQuantitative())
432    {
433  0 filterParams
434    .setThresholdValue(getCurrentAnnotation().threshold.value);
435   
436  0 if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD)
437    {
438  0 filterParams.setThresholdType(
439    AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD);
440    }
441  0 else if (selectedThresholdItem == AnnotationColourGradient.BELOW_THRESHOLD)
442    {
443  0 filterParams.setThresholdType(
444    AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD);
445    }
446    }
447    }
448   
449  0 if (currentStructureFilterPanel != null)
450    {
451  0 if (currentStructureFilterPanel.alphaHelix.getState())
452    {
453  0 filterParams.setFilterAlphaHelix(true);
454    }
455  0 if (currentStructureFilterPanel.betaStrand.getState())
456    {
457  0 filterParams.setFilterBetaSheet(true);
458    }
459  0 if (currentStructureFilterPanel.turn.getState())
460    {
461  0 filterParams.setFilterTurn(true);
462    }
463    }
464   
465  0 if (currentSearchPanel != null)
466    {
467   
468  0 if (!currentSearchPanel.searchBox.getText().isEmpty())
469    {
470  0 currentSearchPanel.description.setEnabled(true);
471  0 currentSearchPanel.displayName.setEnabled(true);
472  0 filterParams.setRegexString(currentSearchPanel.searchBox.getText());
473  0 if (currentSearchPanel.displayName.getState())
474    {
475  0 filterParams.addRegexSearchField(
476    AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING);
477    }
478  0 if (currentSearchPanel.description.getState())
479    {
480  0 filterParams.addRegexSearchField(
481    AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION);
482    }
483    }
484    else
485    {
486  0 currentSearchPanel.description.setEnabled(false);
487  0 currentSearchPanel.displayName.setEnabled(false);
488    }
489    }
490   
491    // show hidden columns here, before changing the column selection in
492    // filterAnnotations, because showing hidden columns has the side effect of
493    // adding them to the selection
494  0 av.showAllHiddenColumns();
495  0 av.getColumnSelection().filterAnnotations(getCurrentAnnotation(),
496    filterParams);
497   
498  0 if (getActionOption() == ACTION_OPTION_HIDE)
499    {
500  0 av.hideSelectedColumns();
501    }
502   
503  0 filterParams = null;
504  0 av.setAnnotationColumnSelectionState(this);
505  0 av.sendSelection();
506  0 ap.paintAlignment(true, true);
507    }
508   
 
509  0 toggle public HiddenColumns getOldHiddenColumns()
510    {
511  0 return oldHiddenColumns;
512    }
513   
 
514  0 toggle public void setOldHiddenColumns(HiddenColumns currentHiddenColumns)
515    {
516  0 if (currentHiddenColumns != null)
517    {
518  0 this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns);
519    }
520    }
521   
 
522  0 toggle public FurtherActionPanel getCurrentFutherActionPanel()
523    {
524  0 return currentFurtherActionPanel;
525    }
526   
 
527  0 toggle public void setCurrentFutherActionPanel(
528    FurtherActionPanel currentFutherActionPanel)
529    {
530  0 this.currentFurtherActionPanel = currentFutherActionPanel;
531    }
532   
 
533  0 toggle public SearchPanel getCurrentSearchPanel()
534    {
535  0 return currentSearchPanel;
536    }
537   
 
538  0 toggle public void setCurrentSearchPanel(SearchPanel currentSearchPanel)
539    {
540  0 this.currentSearchPanel = currentSearchPanel;
541    }
542   
 
543  0 toggle public int getActionOption()
544    {
545  0 return actionOption;
546    }
547   
 
548  0 toggle public void setActionOption(int actionOption)
549    {
550  0 this.actionOption = actionOption;
551    }
552   
 
553  0 toggle public StructureFilterPanel getCurrentStructureFilterPanel()
554    {
555  0 return currentStructureFilterPanel;
556    }
557   
 
558  0 toggle public void setCurrentStructureFilterPanel(
559    StructureFilterPanel currentStructureFilterPanel)
560    {
561  0 this.currentStructureFilterPanel = currentStructureFilterPanel;
562    }
563   
 
564  0 toggle @Override
565    public void itemStateChanged(ItemEvent e)
566    {
567  0 if (e.getSource() == annotations)
568    {
569  0 selectedAnnotationChanged();
570    }
571  0 else if (e.getSource() == threshold)
572    {
573  0 threshold_actionPerformed(null);
574    }
575  0 else if (e.getSource() == percentThreshold)
576    {
577  0 if (!adjusting)
578    {
579  0 percentageValue_actionPerformed();
580    }
581   
582    }
583    }
584   
 
585  0 toggle public void selectedAnnotationChanged()
586    {
587  0 String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW;
588  0 if (av.getAlignment().getAlignmentAnnotation()[getAnnotations()
589    .getSelectedIndex()].isQuantitative())
590    {
591  0 currentView = AnnotationColumnChooser.GRAPH_VIEW;
592    }
593   
594  0 gSearchPanel.syncState();
595  0 gFurtherActionPanel.syncState();
596  0 gStructureFilterPanel.syncState();
597   
598  0 ngSearchPanel.syncState();
599  0 ngFurtherActionPanel.syncState();
600  0 ngStructureFilterPanel.syncState();
601   
602  0 switchableViewsLayout.show(switchableViewsPanel, currentView);
603  0 updateView();
604    }
605   
 
606    public class FurtherActionPanel extends Panel implements ItemListener
607    {
608    private AnnotationColumnChooser aColChooser;
609   
610    private Choice furtherAction = new Choice();
611   
 
612  0 toggle public FurtherActionPanel(AnnotationColumnChooser aColChooser)
613    {
614  0 this.aColChooser = aColChooser;
615  0 furtherAction.addItem("Select");
616  0 furtherAction.addItem("Hide");
617  0 furtherAction.addItemListener(this);
618  0 syncState();
619   
620    // this.setTitle("Filter Actions");
621    // this.setFont(JvSwingUtils.getLabelFont());
622   
623  0 this.add(furtherAction);
624    }
625   
 
626  0 toggle public void syncState()
627    {
628  0 if (aColChooser
629    .getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE)
630    {
631  0 furtherAction.select("Hide");
632    }
633    else
634    {
635  0 furtherAction.select("Select");
636    }
637    }
638   
 
639  0 toggle @Override
640    public void itemStateChanged(ItemEvent e)
641    {
642  0 aColChooser.setCurrentFutherActionPanel(this);
643  0 if (furtherAction.getSelectedItem().equalsIgnoreCase("Select"))
644    {
645  0 setActionOption(ACTION_OPTION_SELECT);
646  0 updateView();
647    }
648    else
649    {
650  0 setActionOption(ACTION_OPTION_HIDE);
651  0 updateView();
652    }
653   
654    }
655    }
656   
 
657    public class StructureFilterPanel extends TitledPanel
658    implements ItemListener
659    {
660    private AnnotationColumnChooser aColChooser;
661   
662    private Checkbox alphaHelix = new Checkbox();
663   
664    private Checkbox betaStrand = new Checkbox();
665   
666    private Checkbox turn = new Checkbox();
667   
668    private Checkbox all = new Checkbox();
669   
 
670  0 toggle public StructureFilterPanel(AnnotationColumnChooser aColChooser)
671    {
672  0 this.aColChooser = aColChooser;
673   
674  0 alphaHelix.setLabel(MessageManager.getString("label.alpha_helix"));
675  0 alphaHelix.setBackground(Color.white);
676   
677  0 alphaHelix.addItemListener(this);
678   
679  0 betaStrand.setLabel(MessageManager.getString("label.beta_strand"));
680  0 betaStrand.setBackground(Color.white);
681  0 betaStrand.addItemListener(this);
682   
683  0 turn.setLabel(MessageManager.getString("label.turn"));
684  0 turn.setBackground(Color.white);
685  0 turn.addItemListener(this);
686   
687  0 all.setLabel(MessageManager.getString("label.select_all"));
688  0 all.setBackground(Color.white);
689  0 all.addItemListener(this);
690   
691  0 this.setBackground(Color.white);
692  0 this.setTitle("Structure Filter");
693    // this.setFont(JvSwingUtils.getLabelFont());
694   
695  0 this.add(all);
696  0 this.add(alphaHelix);
697  0 this.add(betaStrand);
698  0 this.add(turn);
699    }
700   
 
701  0 toggle public void alphaHelix_actionPerformed()
702    {
703  0 updateSelectAllState();
704  0 aColChooser.setCurrentStructureFilterPanel(this);
705  0 aColChooser.updateView();
706    }
707   
 
708  0 toggle public void betaStrand_actionPerformed()
709    {
710  0 updateSelectAllState();
711  0 aColChooser.setCurrentStructureFilterPanel(this);
712  0 aColChooser.updateView();
713    }
714   
 
715  0 toggle public void turn_actionPerformed()
716    {
717  0 updateSelectAllState();
718  0 aColChooser.setCurrentStructureFilterPanel(this);
719  0 aColChooser.updateView();
720    }
721   
 
722  0 toggle public void all_actionPerformed()
723    {
724  0 if (all.getState())
725    {
726  0 alphaHelix.setState(true);
727  0 betaStrand.setState(true);
728  0 turn.setState(true);
729    }
730    else
731    {
732  0 alphaHelix.setState(false);
733  0 betaStrand.setState(false);
734  0 turn.setState(false);
735    }
736  0 aColChooser.setCurrentStructureFilterPanel(this);
737  0 aColChooser.updateView();
738    }
739   
 
740  0 toggle public void updateSelectAllState()
741    {
742  0 if (alphaHelix.getState() && betaStrand.getState() && turn.getState())
743    {
744  0 all.setState(true);
745    }
746    else
747    {
748  0 all.setState(false);
749    }
750    }
751   
 
752  0 toggle public void syncState()
753    {
754  0 StructureFilterPanel sfp = aColChooser
755    .getCurrentStructureFilterPanel();
756  0 if (sfp != null)
757    {
758  0 alphaHelix.setState(sfp.alphaHelix.getState());
759  0 betaStrand.setState(sfp.betaStrand.getState());
760  0 turn.setState(sfp.turn.getState());
761  0 if (sfp.all.getState())
762    {
763  0 all.setState(true);
764  0 alphaHelix.setState(true);
765  0 betaStrand.setState(true);
766  0 turn.setState(true);
767    }
768    }
769   
770    }
771   
 
772  0 toggle @Override
773    public void itemStateChanged(ItemEvent e)
774    {
775  0 if (e.getSource() == alphaHelix)
776    {
777  0 alphaHelix_actionPerformed();
778    }
779  0 else if (e.getSource() == betaStrand)
780    {
781  0 betaStrand_actionPerformed();
782    }
783  0 else if (e.getSource() == turn)
784    {
785  0 turn_actionPerformed();
786    }
787  0 else if (e.getSource() == all)
788    {
789  0 all_actionPerformed();
790    }
791    }
792    }
793   
 
794    public class SearchPanel extends TitledPanel implements ItemListener
795    {
796    private AnnotationColumnChooser aColChooser;
797   
798    private Checkbox displayName = new Checkbox();
799   
800    private Checkbox description = new Checkbox();
801   
802    private TextField searchBox = new TextField(10);
803   
 
804  0 toggle public SearchPanel(AnnotationColumnChooser aColChooser)
805    {
806   
807  0 this.aColChooser = aColChooser;
808  0 searchBox.addTextListener(new TextListener()
809    {
810   
 
811  0 toggle @Override
812    public void textValueChanged(TextEvent e)
813    {
814  0 searchStringAction();
815   
816    }
817   
818    });
819   
820  0 displayName.setLabel(MessageManager.getString("label.label"));
821  0 displayName.setEnabled(false);
822  0 displayName.addItemListener(this);
823   
824  0 description.setLabel(MessageManager.getString("label.description"));
825  0 description.setEnabled(false);
826  0 description.addItemListener(this);
827  0 this.setTitle("Search Filter");
828    // this.setFont(JvSwingUtils.getLabelFont());
829   
830  0 syncState();
831  0 this.add(searchBox);
832  0 this.add(displayName);
833  0 this.add(description);
834    }
835   
 
836  0 toggle public void displayNameCheckboxAction()
837    {
838  0 aColChooser.setCurrentSearchPanel(this);
839  0 aColChooser.updateView();
840    }
841   
 
842  0 toggle public void discriptionCheckboxAction()
843    {
844  0 aColChooser.setCurrentSearchPanel(this);
845  0 aColChooser.updateView();
846    }
847   
 
848  0 toggle public void searchStringAction()
849    {
850  0 aColChooser.setCurrentSearchPanel(this);
851  0 aColChooser.updateView();
852    }
853   
 
854  0 toggle public void syncState()
855    {
856  0 SearchPanel sp = aColChooser.getCurrentSearchPanel();
857  0 if (sp != null)
858    {
859  0 description.setEnabled(sp.description.isEnabled());
860  0 description.setState(sp.description.getState());
861   
862  0 displayName.setEnabled(sp.displayName.isEnabled());
863  0 displayName.setState(sp.displayName.getState());
864   
865  0 searchBox.setText(sp.searchBox.getText());
866    }
867    }
868   
 
869  0 toggle @Override
870    public void itemStateChanged(ItemEvent e)
871    {
872  0 if (e.getSource() == displayName)
873    {
874  0 displayNameCheckboxAction();
875    }
876  0 else if (e.getSource() == description)
877    {
878  0 discriptionCheckboxAction();
879    }
880   
881    }
882    }
883   
 
884  0 toggle @Override
885    public void actionPerformed(ActionEvent evt)
886    {
887   
888  0 if (evt.getSource() == ok)
889    {
890  0 ok_actionPerformed(null);
891    }
892  0 else if (evt.getSource() == cancel)
893    {
894  0 cancel_actionPerformed(null);
895    }
896  0 else if (evt.getSource() == thresholdValue)
897    {
898  0 thresholdValue_actionPerformed(null);
899    }
900    else
901    {
902  0 updateView();
903    }
904    }
905   
 
906  0 toggle @Override
907    public void mouseClicked(MouseEvent e)
908    {
909    // TODO Auto-generated method stub
910   
911    }
912   
 
913  0 toggle @Override
914    public void mousePressed(MouseEvent e)
915    {
916  0 if (e.getSource() == slider)
917    {
918  0 updateView();
919    }
920   
921    }
922   
 
923  0 toggle @Override
924    public void mouseReleased(MouseEvent e)
925    {
926  0 if (e.getSource() == slider)
927    {
928  0 updateView();
929    }
930    }
931   
 
932  0 toggle @Override
933    public void mouseEntered(MouseEvent e)
934    {
935  0 if (e.getSource() == slider)
936    {
937  0 updateView();
938    }
939    }
940   
 
941  0 toggle @Override
942    public void mouseExited(MouseEvent e)
943    {
944  0 if (e.getSource() == slider)
945    {
946  0 updateView();
947    }
948    }
949   
950    }