From ca5a59c203b85a6c0f26c3d52d7827c5fa9fa4c5 Mon Sep 17 00:00:00 2001 From: Charles Ofoegbu Date: Tue, 20 Jan 2015 15:02:05 +0000 Subject: [PATCH] basic house keeping --- src/jalview/api/AnnotationRowFilterI.java | 16 - .../analysis}/AnnotationFilterParameter.java | 10 +- src/jalview/gui/AnnotationColumnChooser.java | 554 ++++++++++++++++++-- src/jalview/gui/AnnotationRowFilter.java | 14 +- src/jalview/jbgui/FurtherActionPanel.java | 139 ----- src/jalview/jbgui/SearchPanel.java | 182 ------- src/jalview/jbgui/StructureFilterPanel.java | 200 ------- 7 files changed, 513 insertions(+), 602 deletions(-) delete mode 100644 src/jalview/api/AnnotationRowFilterI.java rename src/jalview/{datamodel => api/analysis}/AnnotationFilterParameter.java (89%) delete mode 100644 src/jalview/jbgui/FurtherActionPanel.java delete mode 100644 src/jalview/jbgui/SearchPanel.java delete mode 100644 src/jalview/jbgui/StructureFilterPanel.java diff --git a/src/jalview/api/AnnotationRowFilterI.java b/src/jalview/api/AnnotationRowFilterI.java deleted file mode 100644 index b8d4706..0000000 --- a/src/jalview/api/AnnotationRowFilterI.java +++ /dev/null @@ -1,16 +0,0 @@ -package jalview.api; - -import java.util.Vector; - -public interface AnnotationRowFilterI -{ - public Vector getAnnotationItems(boolean isSeqAssociated); - - public void modelChanged(); - - public void valueChanged(boolean updateAllAnnotation); - - public void updateView(); - - public void reset(); -} diff --git a/src/jalview/datamodel/AnnotationFilterParameter.java b/src/jalview/api/analysis/AnnotationFilterParameter.java similarity index 89% rename from src/jalview/datamodel/AnnotationFilterParameter.java rename to src/jalview/api/analysis/AnnotationFilterParameter.java index cb45c00..c649972 100644 --- a/src/jalview/datamodel/AnnotationFilterParameter.java +++ b/src/jalview/api/analysis/AnnotationFilterParameter.java @@ -1,4 +1,4 @@ -package jalview.datamodel; +package jalview.api.analysis; import java.util.ArrayList; import java.util.List; @@ -12,13 +12,7 @@ public class AnnotationFilterParameter public enum SearchableAnnotationField { - DISPLAY_STRING("Display Character"), DESCRIPTION("Description"); - private String fieldName; - - SearchableAnnotationField(String fieldName) - { - this.fieldName = fieldName; - } + DISPLAY_STRING, DESCRIPTION; } private ThresholdType thresholdType; diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index 3db148d..31b5b64 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -1,11 +1,8 @@ package jalview.gui; +import jalview.api.analysis.AnnotationFilterParameter; import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AnnotationFilterParameter; import jalview.datamodel.ColumnSelection; -import jalview.jbgui.FurtherActionPanel; -import jalview.jbgui.SearchPanel; -import jalview.jbgui.StructureFilterPanel; import jalview.schemes.AnnotationColourGradient; import jalview.util.MessageManager; @@ -19,14 +16,19 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Iterator; +import javax.swing.ButtonGroup; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.JTextField; import javax.swing.border.TitledBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import net.miginfocom.swing.MigLayout; @@ -35,40 +37,38 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ItemListener { - private ColumnSelection oldColumnSelection; - private JComboBox annotations; - JButton ok = new JButton(); + private JButton ok = new JButton(); - JButton cancel = new JButton(); + private JButton cancel = new JButton(); - JPanel actionPanel = new JPanel(); + private JPanel actionPanel = new JPanel(); - JPanel thresholdPanel = new JPanel(); + private JPanel thresholdPanel = new JPanel(); - JPanel switchableViewsPanel = new JPanel(new CardLayout()); + private JPanel switchableViewsPanel = new JPanel(new CardLayout()); - CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel + private CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel .getLayout()); - JPanel noGraphFilterView = new JPanel(); + private JPanel noGraphFilterView = new JPanel(); - JPanel graphFilterView = new JPanel(); + private JPanel graphFilterView = new JPanel(); - JPanel annotationComboBoxPanel = new JPanel(); + private JPanel annotationComboBoxPanel = new JPanel(); - StructureFilterPanel gStructureFilterPanel; + private JLabel annotationLabel = new JLabel(); - StructureFilterPanel ngStructureFilterPanel; + private BorderLayout borderLayout1 = new BorderLayout(); - private StructureFilterPanel currentStructureFilterPanel; + private JComboBox threshold = new JComboBox(); - JLabel annotationLabel = new JLabel(); + private StructureFilterPanel gStructureFilterPanel; - BorderLayout borderLayout1 = new BorderLayout(); + private StructureFilterPanel ngStructureFilterPanel; - private JComboBox threshold = new JComboBox(); + private StructureFilterPanel currentStructureFilterPanel; private SearchPanel currentSearchPanel; @@ -92,6 +92,19 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements private int actionOption = ACTION_OPTION_SELECT; + private ColumnSelection oldColumnSelection; + + public AnnotationColumnChooser() + { + try + { + jbInit(); + } catch (Exception ex) + { + ex.printStackTrace(); + } + } + public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap) { super(av, ap); @@ -115,7 +128,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements setAnnotations(new JComboBox(getAnnotationItems(false))); populateThresholdComboBox(threshold); - // restore the Object state from the previous session if one exists + // restore Object state from the previous session if one exists if (av.getAnnotationColumnSelectionState() != null) { currentSearchPanel = av.getAnnotationColumnSelectionState() @@ -128,7 +141,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements .getThreshold().getSelectedIndex()); actionOption = av.getAnnotationColumnSelectionState() .getActionOption(); - } try @@ -144,17 +156,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements frame.pack(); } - public AnnotationColumnChooser() - { - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - private void jbInit() throws Exception { ok.setOpaque(false); @@ -167,6 +168,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ok_actionPerformed(e); } }); + cancel.setOpaque(false); cancel.setText(MessageManager.getString("action.cancel")); cancel.addActionListener(new ActionListener() @@ -178,8 +180,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } }); - getAnnotations().addItemListener(this); - getThreshold().addActionListener(new ActionListener() + annotations.addItemListener(this); + threshold.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) @@ -188,6 +190,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } }); + thresholdValue.setEnabled(false); + thresholdValue.setColumns(7); thresholdValue.addActionListener(new ActionListener() { @Override @@ -196,14 +200,13 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements thresholdValue_actionPerformed(e); } }); + slider.setPaintLabels(false); slider.setPaintTicks(true); slider.setBackground(Color.white); slider.setEnabled(false); slider.setOpaque(false); slider.setPreferredSize(new Dimension(100, 32)); - thresholdValue.setEnabled(false); - thresholdValue.setColumns(7); annotationLabel.setBackground(Color.white); annotationLabel.setFont(JvSwingUtils.getLabelFont()); @@ -217,7 +220,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements actionPanel.setBackground(Color.white); actionPanel.setFont(JvSwingUtils.getLabelFont()); - this.setLayout(borderLayout1); graphFilterView.setLayout(new MigLayout("", "[left][right]", "[][]")); graphFilterView.setBackground(Color.white); @@ -233,7 +235,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements gStructureFilterPanel = new StructureFilterPanel(this); ngStructureFilterPanel = new StructureFilterPanel(this); - thresholdPanel.add(getThreshold()); thresholdPanel.add(thresholdValue, "wrap"); thresholdPanel.add(slider, "grow, span, wrap"); @@ -256,6 +257,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements switchableViewsPanel.add(graphFilterView, AnnotationColumnChooser.GRAPH_VIEW); + this.setLayout(borderLayout1); this.add(annotationComboBoxPanel, java.awt.BorderLayout.PAGE_START); this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER); this.add(actionPanel, java.awt.BorderLayout.SOUTH); @@ -288,7 +290,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } av.setColumnSelection(oldSelection); } - // ap.alignmentChanged(); ap.paintAlignment(true); } @@ -464,7 +465,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } } - public void select_action(ActionEvent actionEvent) { JRadioButton radioButton = (JRadioButton) actionEvent.getSource(); @@ -485,7 +485,6 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } } - @Override public void itemStateChanged(ItemEvent e) { @@ -500,25 +499,19 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { currentView = AnnotationColumnChooser.GRAPH_VIEW; } - // else{ - // threshold.setSelectedIndex(AlignmentAnnotation.NO_GRAPH); - // } - + gSearchPanel.syncState(); gFurtherActionPanel.syncState(); - gFurtherActionPanel.syncState(); - gFurtherActionPanel.syncState(); + gStructureFilterPanel.syncState(); ngSearchPanel.syncState(); ngFurtherActionPanel.syncState(); ngStructureFilterPanel.syncState(); - ngFurtherActionPanel.syncState(); switchableViewsLayout.show(switchableViewsPanel, currentView); updateView(); } - public FurtherActionPanel getCurrentFutherActionPanel() { return currentFurtherActionPanel; @@ -561,4 +554,463 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements this.currentStructureFilterPanel = currentStructureFilterPanel; } + public class FurtherActionPanel extends JPanel + { + private AnnotationColumnChooser aColChooser; + + private JRadioButton hideOption = new JRadioButton(); + + private JRadioButton selectOption = new JRadioButton(); + + private ButtonGroup optionsGroup = new ButtonGroup(); + + public FurtherActionPanel(AnnotationColumnChooser aColChooser) + { + this.aColChooser = aColChooser; + getSelectOption().setBackground(Color.white); + getSelectOption().setFont(JvSwingUtils.getLabelFont()); + getSelectOption().setText("Select"); + getSelectOption().addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + selectRadioAction(actionEvent); + } + }); + + getHideOption().setBackground(Color.white); + getHideOption().setFont(JvSwingUtils.getLabelFont()); + getHideOption().setText("Hide"); + getHideOption().addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + hideRadioAction(actionEvent); + } + }); + + getOptionsGroup().add(getSelectOption()); + getOptionsGroup().add(getHideOption()); + getOptionsGroup().setSelected(getSelectOption().getModel(), true); + + this.setBackground(Color.white); + this.setFont(JvSwingUtils.getLabelFont()); + syncState(); + + this.add(getSelectOption()); + this.add(getHideOption()); + } + + public void selectRadioAction(ActionEvent actionEvent) + { + aColChooser.setCurrentFutherActionPanel(this); + aColChooser.select_action(actionEvent); + } + + public void hideRadioAction(ActionEvent actionEvent) + { + aColChooser.setCurrentFutherActionPanel(this); + aColChooser.hide_action(actionEvent); + } + + public JRadioButton getHideOption() + { + return hideOption; + } + + public void setHideOption(JRadioButton hideOption) + { + this.hideOption = hideOption; + } + + public JRadioButton getSelectOption() + { + return selectOption; + } + + public void setSelectOption(JRadioButton selectOption) + { + this.selectOption = selectOption; + } + + public ButtonGroup getOptionsGroup() + { + return optionsGroup; + } + + public void setOptionsGroup(ButtonGroup optionsGroup) + { + this.optionsGroup = optionsGroup; + } + + public void syncState() + { + if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) + { + this.getOptionsGroup().setSelected(this.getHideOption().getModel(), + true); + } + else + { + this.getOptionsGroup().setSelected( + this.getSelectOption().getModel(), true); + } + } + } + + public class StructureFilterPanel extends JPanel + { + private AnnotationColumnChooser aColChooser; + + private JCheckBox alphaHelix = new JCheckBox(); + + private JCheckBox betaStrand = new JCheckBox(); + + private JCheckBox turn = new JCheckBox(); + + private JCheckBox all = new JCheckBox(); + + public StructureFilterPanel(AnnotationColumnChooser aColChooser) + { + this.aColChooser = aColChooser; + + alphaHelix.setBackground(Color.white); + alphaHelix.setFont(JvSwingUtils.getLabelFont()); + alphaHelix.setText("Alpha Helix"); + alphaHelix.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + alphaHelix_actionPerformed(); + } + }); + + betaStrand.setBackground(Color.white); + betaStrand.setFont(JvSwingUtils.getLabelFont()); + betaStrand.setText("Beta Strand"); + betaStrand.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + betaStrand_actionPerformed(); + } + }); + + turn.setBackground(Color.white); + turn.setFont(JvSwingUtils.getLabelFont()); + turn.setText("Turn"); + turn.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + turn_actionPerformed(); + } + }); + + all.setBackground(Color.white); + all.setFont(JvSwingUtils.getLabelFont()); + all.setText("Select all"); + all.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + all_actionPerformed(); + } + }); + + this.setBorder(new TitledBorder("Structures Filter")); + this.setBackground(Color.white); + this.setFont(JvSwingUtils.getLabelFont()); + + this.add(all); + this.add(alphaHelix); + this.add(betaStrand); + this.add(turn); + } + + public void alphaHelix_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void betaStrand_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void turn_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void all_actionPerformed() + { + if (all.isSelected()) + { + alphaHelix.setSelected(true); + betaStrand.setSelected(true); + turn.setSelected(true); + } + else + { + alphaHelix.setSelected(false); + betaStrand.setSelected(false); + turn.setSelected(false); + } + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void updateSelectAllState() + { + if (alphaHelix.isSelected() && betaStrand.isSelected() + && turn.isSelected()) + { + all.setSelected(true); + } + else + { + all.setSelected(false); + } + } + + public void syncState() + { + StructureFilterPanel sfp = aColChooser + .getCurrentStructureFilterPanel(); + if (sfp != null) + { + alphaHelix.setSelected(sfp.getAlphaHelix().isSelected()); + betaStrand.setSelected(sfp.getBetaStrand().isSelected()); + turn.setSelected(sfp.getTurn().isSelected()); + if (sfp.getAll().isSelected()) + { + all.setSelected(true); + alphaHelix.setSelected(true); + betaStrand.setSelected(true); + turn.setSelected(true); + } + } + + } + + public JCheckBox getAlphaHelix() + { + return alphaHelix; + } + + public void setAlphaHelix(JCheckBox alphaHelix) + { + this.alphaHelix = alphaHelix; + } + + public JCheckBox getBetaStrand() + { + return betaStrand; + } + + public void setBetaStrand(JCheckBox betaStrand) + { + this.betaStrand = betaStrand; + } + + public JCheckBox getTurn() + { + return turn; + } + + public void setTurn(JCheckBox turn) + { + this.turn = turn; + } + + public JCheckBox getAll() + { + return all; + } + + public void setAll(JCheckBox all) + { + this.all = all; + + } + } + + public class SearchPanel extends JPanel + { + private AnnotationColumnChooser aColChooser; + + private JCheckBox displayName = new JCheckBox(); + + private JCheckBox description = new JCheckBox(); + + private JTextField searchBox = new JTextField(10); + + private JCheckBox structuresFilter = new JCheckBox(); + + public SearchPanel(AnnotationColumnChooser aColChooser) + { + + this.aColChooser = aColChooser; + this.setBorder(new TitledBorder("Search Filter")); + this.setBackground(Color.white); + this.setFont(JvSwingUtils.getLabelFont()); + + getSearchBox().setBackground(Color.white); + getSearchBox().setFont(JvSwingUtils.getLabelFont()); + getSearchBox().getDocument().addDocumentListener( + new DocumentListener() + { + @Override + public void insertUpdate(DocumentEvent e) + { + searchStringAction(); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + searchStringAction(); + } + + @Override + public void changedUpdate(DocumentEvent e) + { + searchStringAction(); + } + }); + + getDisplayName().setBackground(Color.white); + getDisplayName().setFont(JvSwingUtils.getLabelFont()); + getDisplayName().setText("Display Name"); + getDisplayName().setEnabled(false); + getDisplayName().addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + displayNameCheckboxAction(); + } + }); + + getDescription().setBackground(Color.white); + getDescription().setFont(JvSwingUtils.getLabelFont()); + getDescription().setText("Description"); + getDescription().setEnabled(false); + getDescription().addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + discriptionCheckboxAction(); + } + }); + + syncState(); + this.add(getSearchBox()); + this.add(getDisplayName()); + this.add(getDescription()); + } + + public boolean isDescriptionChecked() + { + return getDescription().isSelected(); + } + + public boolean isDisplayNameChecked() + { + return getDisplayName().isSelected(); + } + + public String getSearchString() + { + return getSearchBox().getText(); + } + + public void displayNameCheckboxAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public void discriptionCheckboxAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public void searchStringAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public JCheckBox getDisplayName() + { + return displayName; + } + + public void setDisplayName(JCheckBox displayName) + { + this.displayName = displayName; + } + + public JCheckBox getDescription() + { + return description; + } + + public void setDescription(JCheckBox description) + { + this.description = description; + } + + public JTextField getSearchBox() + { + return searchBox; + } + + public void setSearchBox(JTextField searchBox) + { + this.searchBox = searchBox; + } + + public JCheckBox getStructuresFilter() + { + return structuresFilter; + } + + public void setStructuresFilter(JCheckBox structuresFilter) + { + this.structuresFilter = structuresFilter; + } + + public void syncState() + { + SearchPanel sp = aColChooser.getCurrentSearchPanel(); + if (sp != null) + { + description.setEnabled(sp.getDescription().isEnabled()); + description.setSelected(sp.getDescription().isSelected()); + + displayName.setEnabled(sp.getDisplayName().isEnabled()); + displayName.setSelected(sp.getDisplayName().isSelected()); + + searchBox.setText(sp.getSearchBox().getText()); + } + } + } + } diff --git a/src/jalview/gui/AnnotationRowFilter.java b/src/jalview/gui/AnnotationRowFilter.java index ed59ef6..722ecdc 100644 --- a/src/jalview/gui/AnnotationRowFilter.java +++ b/src/jalview/gui/AnnotationRowFilter.java @@ -1,10 +1,9 @@ package jalview.gui; -import jalview.api.AnnotationRowFilterI; +import jalview.api.analysis.AnnotationFilterParameter; +import jalview.api.analysis.AnnotationFilterParameter.SearchableAnnotationField; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; -import jalview.datamodel.AnnotationFilterParameter; -import jalview.datamodel.AnnotationFilterParameter.SearchableAnnotationField; import jalview.datamodel.ColumnSelection; import jalview.datamodel.GraphLine; import jalview.datamodel.SequenceGroup; @@ -27,8 +26,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @SuppressWarnings("serial") -public abstract class AnnotationRowFilter extends JPanel implements - AnnotationRowFilterI +public abstract class AnnotationRowFilter extends JPanel { protected AlignViewport av; @@ -124,7 +122,6 @@ public abstract class AnnotationRowFilter extends JPanel implements } - @Override public Vector getAnnotationItems(boolean isSeqAssociated) { Vector list = new Vector(); @@ -460,4 +457,9 @@ public abstract class AnnotationRowFilter extends JPanel implements this.currentAnnotation = currentAnnotation; } + public abstract void valueChanged(boolean updateAllAnnotation); + + public abstract void updateView(); + + public abstract void reset(); } diff --git a/src/jalview/jbgui/FurtherActionPanel.java b/src/jalview/jbgui/FurtherActionPanel.java deleted file mode 100644 index 1f91b35..0000000 --- a/src/jalview/jbgui/FurtherActionPanel.java +++ /dev/null @@ -1,139 +0,0 @@ -package jalview.jbgui; - -import jalview.gui.AnnotationColumnChooser; -import jalview.gui.JvSwingUtils; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JRadioButton; - -@SuppressWarnings("serial") -public class FurtherActionPanel extends JPanel -{ - private AnnotationColumnChooser aColChooser; - - private JRadioButton hideOption = new JRadioButton(); - - private JRadioButton selectOption = new JRadioButton(); - - private ButtonGroup optionsGroup = new ButtonGroup(); - - public FurtherActionPanel(AnnotationColumnChooser aColChooser) - { - - this.aColChooser = aColChooser; - - - getSelectOption().setBackground(Color.white); - getSelectOption().setFont(JvSwingUtils.getLabelFont()); - getSelectOption().setText("Select"); - getSelectOption().addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - selectRadioAction(actionEvent); - } - }); - - getHideOption().setBackground(Color.white); - getHideOption().setFont(JvSwingUtils.getLabelFont()); - getHideOption().setText("Hide"); - getHideOption().addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - hideRadioAction(actionEvent); - } - }); - - getOptionsGroup().add(getSelectOption()); - getOptionsGroup().add(getHideOption()); - getOptionsGroup().setSelected(getSelectOption().getModel(), true); - - this.setBackground(Color.white); - this.setFont(JvSwingUtils.getLabelFont()); - syncState(); - - this.add(getSelectOption()); - this.add(getHideOption()); - } - - public void selectRadioAction(ActionEvent actionEvent) - { - aColChooser.setCurrentFutherActionPanel(this); - aColChooser.select_action(actionEvent); - } - - public void hideRadioAction(ActionEvent actionEvent) - { - aColChooser.setCurrentFutherActionPanel(this); - aColChooser.hide_action(actionEvent); - } - - // public abstract void selectRadioAction(ActionEvent actionEvent); - // - // public abstract void hideRadioAction(ActionEvent actionEvent); - - public JRadioButton getHideOption() - { - return hideOption; - } - - public void setHideOption(JRadioButton hideOption) - { - this.hideOption = hideOption; - } - - public JRadioButton getSelectOption() - { - return selectOption; - } - - public void setSelectOption(JRadioButton selectOption) - { - this.selectOption = selectOption; - } - - public ButtonGroup getOptionsGroup() - { - return optionsGroup; - } - - public void setOptionsGroup(ButtonGroup optionsGroup) - { - this.optionsGroup = optionsGroup; - } - - public void syncState() - { - // FurtherActionPanel fap = aColChooser.getCurrentFutherActionPanel(); - // if (fap != null) - // { - // - // // description.setEnabled(sp.getDescription().isEnabled()); - // // description.setSelected(sp.getDescription().isSelected()); - // // - // // displayName.setEnabled(sp.getDisplayName().isEnabled()); - // // displayName.setSelected(sp.getDisplayName().isSelected()); - // // - // // searchBox.setText(sp.getSearchBox().getText()); - // } - - if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) - { - this.getOptionsGroup().setSelected(this.getHideOption().getModel(), - true); - } - else - { - this.getOptionsGroup().setSelected(this.getSelectOption().getModel(), - true); - } - } -} diff --git a/src/jalview/jbgui/SearchPanel.java b/src/jalview/jbgui/SearchPanel.java deleted file mode 100644 index 6a58335..0000000 --- a/src/jalview/jbgui/SearchPanel.java +++ /dev/null @@ -1,182 +0,0 @@ -package jalview.jbgui; - -import jalview.gui.AnnotationColumnChooser; -import jalview.gui.JvSwingUtils; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JCheckBox; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.border.TitledBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -@SuppressWarnings("serial") -public class SearchPanel extends JPanel -{ - - private AnnotationColumnChooser aColChooser; - - private JCheckBox displayName = new JCheckBox(); - - private JCheckBox description = new JCheckBox(); - - private JTextField searchBox = new JTextField(10); - - private JCheckBox structuresFilter = new JCheckBox(); - - public SearchPanel(AnnotationColumnChooser aColChooser) - { - - this.aColChooser = aColChooser; - this.setBorder(new TitledBorder("Search Filter")); - this.setBackground(Color.white); - this.setFont(JvSwingUtils.getLabelFont()); - - - getSearchBox().setBackground(Color.white); - getSearchBox().setFont(JvSwingUtils.getLabelFont()); - getSearchBox().getDocument().addDocumentListener(new DocumentListener() - { - @Override - public void insertUpdate(DocumentEvent e) - { - searchStringAction(); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - searchStringAction(); - } - - @Override - public void changedUpdate(DocumentEvent e) - { - searchStringAction(); - } - }); - - getDisplayName().setBackground(Color.white); - getDisplayName().setFont(JvSwingUtils.getLabelFont()); - getDisplayName().setText("Display Name"); - getDisplayName().setEnabled(false); - getDisplayName().addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - displayNameCheckboxAction(); - } - }); - - getDescription().setBackground(Color.white); - getDescription().setFont(JvSwingUtils.getLabelFont()); - getDescription().setText("Description"); - getDescription().setEnabled(false); - getDescription().addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - discriptionCheckboxAction(); - } - }); - - syncState(); - this.add(getSearchBox()); - this.add(getDisplayName()); - this.add(getDescription()); - } - - public boolean isDescriptionChecked() - { - return getDescription().isSelected(); - } - - public boolean isDisplayNameChecked() - { - return getDisplayName().isSelected(); - } - - public String getSearchString() - { - return getSearchBox().getText(); - } - - public void displayNameCheckboxAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public void discriptionCheckboxAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public void searchStringAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public JCheckBox getDisplayName() - { - return displayName; - } - - public void setDisplayName(JCheckBox displayName) - { - this.displayName = displayName; - } - - public JCheckBox getDescription() - { - return description; - } - - public void setDescription(JCheckBox description) - { - this.description = description; - } - - public JTextField getSearchBox() - { - return searchBox; - } - - public void setSearchBox(JTextField searchBox) - { - this.searchBox = searchBox; - } - - public JCheckBox getStructuresFilter() - { - return structuresFilter; - } - - public void setStructuresFilter(JCheckBox structuresFilter) - { - this.structuresFilter = structuresFilter; - } - - public void syncState() - { - SearchPanel sp = aColChooser.getCurrentSearchPanel(); - if (sp != null) - { - description.setEnabled(sp.getDescription().isEnabled()); - description.setSelected(sp.getDescription().isSelected()); - - displayName.setEnabled(sp.getDisplayName().isEnabled()); - displayName.setSelected(sp.getDisplayName().isSelected()); - - searchBox.setText(sp.getSearchBox().getText()); - } - } -} diff --git a/src/jalview/jbgui/StructureFilterPanel.java b/src/jalview/jbgui/StructureFilterPanel.java deleted file mode 100644 index ae3c161..0000000 --- a/src/jalview/jbgui/StructureFilterPanel.java +++ /dev/null @@ -1,200 +0,0 @@ -package jalview.jbgui; - -import jalview.gui.AnnotationColumnChooser; -import jalview.gui.JvSwingUtils; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JCheckBox; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; - -@SuppressWarnings("serial") -public class StructureFilterPanel extends JPanel -{ - private AnnotationColumnChooser aColChooser; - - private JCheckBox alphaHelix = new JCheckBox(); - - private JCheckBox betaStrand = new JCheckBox(); - - private JCheckBox turn = new JCheckBox(); - - private JCheckBox all = new JCheckBox(); - - public StructureFilterPanel(AnnotationColumnChooser aColChooser) - { - this.aColChooser = aColChooser; - - alphaHelix.setBackground(Color.white); - alphaHelix.setFont(JvSwingUtils.getLabelFont()); - alphaHelix.setText("Alpha Helix"); - alphaHelix.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - alphaHelix_actionPerformed(); - } - }); - - betaStrand.setBackground(Color.white); - betaStrand.setFont(JvSwingUtils.getLabelFont()); - betaStrand.setText("Beta Strand"); - betaStrand.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - betaStrand_actionPerformed(); - } - }); - - turn.setBackground(Color.white); - turn.setFont(JvSwingUtils.getLabelFont()); - turn.setText("Turn"); - turn.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - turn_actionPerformed(); - } - }); - - all.setBackground(Color.white); - all.setFont(JvSwingUtils.getLabelFont()); - all.setText("Select all"); - all.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionEvent) - { - all_actionPerformed(); - } - }); - - this.setBorder(new TitledBorder("Structures Filter")); - this.setBackground(Color.white); - this.setFont(JvSwingUtils.getLabelFont()); - - this.add(all); - this.add(alphaHelix); - this.add(betaStrand); - this.add(turn); - } - - public void alphaHelix_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void betaStrand_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void turn_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void all_actionPerformed() - { - if (all.isSelected()) - { - alphaHelix.setSelected(true); - betaStrand.setSelected(true); - turn.setSelected(true); - } - else - { - alphaHelix.setSelected(false); - betaStrand.setSelected(false); - turn.setSelected(false); - } - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void updateSelectAllState() - { - if (alphaHelix.isSelected() && betaStrand.isSelected() - && turn.isSelected()) - { - all.setSelected(true); - } - else - { - all.setSelected(false); - } - } - - public void syncState() - { - StructureFilterPanel sfp = aColChooser.getCurrentStructureFilterPanel(); - if (sfp != null) - { - alphaHelix.setSelected(sfp.getAlphaHelix().isSelected()); - betaStrand.setSelected(sfp.getBetaStrand().isSelected()); - turn.setSelected(sfp.getTurn().isSelected()); - if (sfp.getAll().isSelected()) - { - all.setSelected(true); - alphaHelix.setSelected(true); - betaStrand.setSelected(true); - turn.setSelected(true); - } - } - - } - - public JCheckBox getAlphaHelix() - { - return alphaHelix; - } - - public void setAlphaHelix(JCheckBox alphaHelix) - { - this.alphaHelix = alphaHelix; - } - - public JCheckBox getBetaStrand() - { - return betaStrand; - } - - public void setBetaStrand(JCheckBox betaStrand) - { - this.betaStrand = betaStrand; - } - - public JCheckBox getTurn() - { - return turn; - } - - public void setTurn(JCheckBox turn) - { - this.turn = turn; - } - - public JCheckBox getAll() - { - return all; - } - - public void setAll(JCheckBox all) - { - this.all = all; - - } -} \ No newline at end of file -- 1.7.10.2