+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.appletgui;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.ColumnSelection;
-import jalview.gui.JvSwingUtils;
import jalview.schemes.AnnotationColourGradient;
import jalview.util.MessageManager;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
import java.util.Iterator;
import java.util.Vector;
-import net.miginfocom.swing.MigLayout;
+//import javax.swing.JPanel;
+
+//import net.miginfocom.swing.MigLayout;
public class AnnotationColumnChooser extends AnnotationRowFilter implements
ActionListener, AdjustmentListener, ItemListener, MouseListener
private BorderLayout borderLayout1 = new BorderLayout();
+ private BorderLayout gBorderLayout = new BorderLayout();
+
+ private BorderLayout ngBorderLayout = new BorderLayout();
+
private Choice threshold = new Choice();
private StructureFilterPanel gStructureFilterPanel;
slider.addAdjustmentListener(this);
slider.addMouseListener(this);
- if (av.getAlignment().getAlignmentAnnotation() == null)
+ AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
+ if (anns == null)
{
return;
}
setOldColumnSelection(av.getColumnSelection());
adjusting = true;
- Vector list = new Vector();
+ Vector<String> list = new Vector<String>();
int index = 1;
- for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
+ for (int i = 0; i < anns.length; i++)
{
- String label = av.getAlignment().getAlignmentAnnotation()[i].label;
+ String label = anns[i].label;
+ if (anns[i].sequenceRef != null)
+ {
+ label = label + "_" + anns[i].sequenceRef.getName();
+ }
if (!list.contains(label))
{
list.addElement(label);
}
populateThresholdComboBox(threshold);
-
+ AnnotationColumnChooser lastChooser = av
+ .getAnnotationColumnSelectionState();
// restore Object state from the previous session if one exists
- if (av.getAnnotationColumnSelectionState() != null)
+ if (lastChooser != null)
{
- currentSearchPanel = av.getAnnotationColumnSelectionState()
+ currentSearchPanel = lastChooser
.getCurrentSearchPanel();
- currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
+ currentStructureFilterPanel = lastChooser
.getCurrentStructureFilterPanel();
- annotations.select(av.getAnnotationColumnSelectionState()
+ annotations.select(lastChooser
.getAnnotations().getSelectedIndex());
- threshold.select(av.getAnnotationColumnSelectionState()
+ threshold.select(lastChooser
.getThreshold().getSelectedIndex());
- actionOption = av.getAnnotationColumnSelectionState()
+ actionOption = lastChooser
.getActionOption();
+ percentThreshold.setState(lastChooser.percentThreshold.getState());
}
try
thresholdValue.setEnabled(false);
thresholdValue.setColumns(7);
+ thresholdValue.setCaretPosition(0);
ok.addActionListener(this);
cancel.addActionListener(this);
slider.setPreferredSize(new Dimension(100, 32));
thresholdPanel.setBackground(Color.white);
- thresholdPanel.setFont(JvSwingUtils.getLabelFont());
- thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
+ // thresholdPanel.setFont(JvSwingUtils.getLabelFont());
+ // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
+
+ percentThreshold.setLabel("As percentage");
+ percentThreshold.addItemListener(this);
actionPanel.setBackground(Color.white);
- actionPanel.setFont(JvSwingUtils.getLabelFont());
+ // actionPanel.setFont(JvSwingUtils.getLabelFont());
- graphFilterView.setLayout(new MigLayout("", "[left][right]", "[][]"));
+ graphFilterView.setLayout(gBorderLayout);
graphFilterView.setBackground(Color.white);
- noGraphFilterView.setLayout(new MigLayout("", "[left][right]", "[][]"));
+ noGraphFilterView.setLayout(ngBorderLayout);
noGraphFilterView.setBackground(Color.white);
annotationComboBoxPanel.setBackground(Color.white);
- annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont());
+ // annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont());
gSearchPanel = new SearchPanel(this);
ngSearchPanel = new SearchPanel(this);
ngStructureFilterPanel = new StructureFilterPanel(this);
thresholdPanel.setTitle("Threshold Filter");
- thresholdPanel.add(getThreshold(), "grow");
- thresholdPanel.add(thresholdValue, "grow, wrap");
- thresholdPanel.add(slider, "grow, span, wrap");
+ thresholdPanel.add(getThreshold());
+ thresholdPanel.add(slider);
+ thresholdPanel.add(thresholdValue);
+ thresholdPanel.add(percentThreshold);
actionPanel.add(ok);
actionPanel.add(cancel);
- graphFilterView.add(gSearchPanel, "grow, span, wrap");
- graphFilterView.add(gStructureFilterPanel, "grow, span, wrap");
- graphFilterView.add(thresholdPanel, "grow, span, wrap");
- graphFilterView.add(gFurtherActionPanel);
+ Panel staticPanel = new Panel();
+ staticPanel.setLayout(new BorderLayout());
+ staticPanel.setBackground(Color.white);
- noGraphFilterView.add(ngSearchPanel, "grow, span, wrap");
- noGraphFilterView.add(ngStructureFilterPanel, "grow, span, wrap");
- noGraphFilterView.add(ngFurtherActionPanel);
+ staticPanel.add(gSearchPanel, java.awt.BorderLayout.NORTH);
+ staticPanel.add(gStructureFilterPanel, java.awt.BorderLayout.SOUTH);
+
+ graphFilterView.add(staticPanel, java.awt.BorderLayout.NORTH);
+ graphFilterView.add(thresholdPanel, java.awt.BorderLayout.CENTER);
+ graphFilterView.add(gFurtherActionPanel, java.awt.BorderLayout.SOUTH);
+
+ noGraphFilterView.add(ngSearchPanel, java.awt.BorderLayout.PAGE_START);
+ noGraphFilterView.add(ngStructureFilterPanel,
+ java.awt.BorderLayout.CENTER);
+ noGraphFilterView.add(ngFurtherActionPanel,
+ java.awt.BorderLayout.CENTER);
annotationComboBoxPanel.add(getAnnotations());
switchableViewsPanel.add(noGraphFilterView,
this.validate();
}
+ @Override
@SuppressWarnings("unchecked")
public void reset()
{
}
+ @Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
if (!adjusting)
{
- thresholdValue.setText((slider.getValue() / 1000f) + "");
+ setThresholdValueText();
valueChanged(!sliderDragging);
}
}
});
}
+ @Override
public void valueChanged(boolean updateAllAnnotation)
{
if (slider.isEnabled())
slider.setEnabled(true);
thresholdValue.setEnabled(true);
+ percentThreshold.setEnabled(true);
if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD)
{
slider.setEnabled(false);
thresholdValue.setEnabled(false);
thresholdValue.setText("");
+ percentThreshold.setEnabled(false);
// build filter params
}
else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD)
slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000));
slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
- thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
+ setThresholdValueText();
// slider.setMajorTickSpacing((int) (range / 10f));
slider.setEnabled(true);
thresholdValue.setEnabled(true);
+ percentThreshold.setEnabled(true);
adjusting = false;
// build filter params
filterParams
.setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD);
- if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH)
+ if (getCurrentAnnotation().isQuantitative())
{
filterParams
.setThresholdValue(getCurrentAnnotation().threshold.value);
{
threshold_actionPerformed(null);
}
+ else if (e.getSource() == percentThreshold)
+ {
+ if (!adjusting)
+ {
+ percentageValue_actionPerformed();
+ }
+
+ }
}
public void selectedAnnotationChanged()
{
String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW;
if (av.getAlignment().getAlignmentAnnotation()[getAnnotations()
- .getSelectedIndex()].graph != AlignmentAnnotation.NO_GRAPH)
+ .getSelectedIndex()].isQuantitative())
{
currentView = AnnotationColumnChooser.GRAPH_VIEW;
}
updateView();
}
- public class FurtherActionPanel extends Panel implements
- ItemListener
+ public class FurtherActionPanel extends Panel implements ItemListener
{
private AnnotationColumnChooser aColChooser;
this.setBackground(Color.white);
this.setTitle("Structure Filter");
- this.setFont(JvSwingUtils.getLabelFont());
+ // this.setFont(JvSwingUtils.getLabelFont());
this.add(all);
this.add(alphaHelix);
});
- displayName.setLabel(MessageManager.getString("label.display_name"));
+ displayName.setLabel(MessageManager.getString("label.label"));
displayName.setEnabled(false);
displayName.addItemListener(this);
description.setEnabled(false);
description.addItemListener(this);
this.setTitle("Search Filter");
- this.setFont(JvSwingUtils.getLabelFont());
+ // this.setFont(JvSwingUtils.getLabelFont());
syncState();
this.add(searchBox);
}
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
- if (evt.getSource() == thresholdValue)
- {
- try
- {
- float f = new Float(thresholdValue.getText()).floatValue();
- slider.setValue((int) (f * 1000));
- adjustmentValueChanged(null);
- } catch (NumberFormatException ex)
- {
- }
- }
- else if (evt.getSource() == ok)
+ if (evt.getSource() == ok)
{
ok_actionPerformed(null);
}