X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FAnnotationColumnChooser.java;h=3a7188ea47d3aa8966a830ed9032bec812a17ad1;hb=613818a08b858e3fe0dd778c738a362b3a4a0882;hp=0375de247676a04af22853f8bb2a3b3602c60ab6;hpb=65a810f2dd78c44eef0f06bc0afbe3ad3e891848;p=jalview.git
diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java
index 0375de2..3a7188e 100644
--- a/src/jalview/appletgui/AnnotationColumnChooser.java
+++ b/src/jalview/appletgui/AnnotationColumnChooser.java
@@ -1,7 +1,27 @@
+/*
+ * 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 .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.appletgui;
import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.schemes.AnnotationColourGradient;
import jalview.util.MessageManager;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
@@ -26,10 +46,10 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
-import java.util.Iterator;
+import java.util.ArrayList;
import java.util.Vector;
-import javax.swing.JPanel;
+//import javax.swing.JPanel;
//import net.miginfocom.swing.MigLayout;
@@ -90,7 +110,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
private int actionOption = ACTION_OPTION_SELECT;
- private ColumnSelection oldColumnSelection;
+ private HiddenColumns oldHiddenColumns;
public AnnotationColumnChooser()
{
@@ -115,17 +135,22 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
slider.addAdjustmentListener(this);
slider.addMouseListener(this);
- if (av.getAlignment().getAlignmentAnnotation() == null)
+ AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
+ if (anns == null)
{
return;
}
- setOldColumnSelection(av.getColumnSelection());
+ setOldHiddenColumns(av.getAlignment().getHiddenColumns());
adjusting = true;
- Vector list = new Vector();
+ Vector list = new Vector<>();
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);
@@ -142,20 +167,22 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
}
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
@@ -179,6 +206,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
thresholdValue.setEnabled(false);
thresholdValue.setColumns(7);
+ thresholdValue.setCaretPosition(0);
ok.addActionListener(this);
cancel.addActionListener(this);
@@ -194,6 +222,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
// 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());
@@ -217,11 +248,12 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
thresholdPanel.add(getThreshold());
thresholdPanel.add(slider);
thresholdPanel.add(thresholdValue);
+ thresholdPanel.add(percentThreshold);
actionPanel.add(ok);
actionPanel.add(cancel);
- JPanel staticPanel = new JPanel();
+ Panel staticPanel = new Panel();
staticPanel.setLayout(new BorderLayout());
staticPanel.setBackground(Color.white);
@@ -253,40 +285,43 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
this.validate();
}
+ @Override
@SuppressWarnings("unchecked")
public void reset()
{
- if (this.getOldColumnSelection() != null)
+ if (this.getOldHiddenColumns() != null)
{
av.getColumnSelection().clear();
if (av.getAnnotationColumnSelectionState() != null)
{
- ColumnSelection oldSelection = av
+ HiddenColumns oldHidden = av
.getAnnotationColumnSelectionState()
- .getOldColumnSelection();
- if (oldSelection != null && oldSelection.getHiddenColumns() != null
- && !oldSelection.getHiddenColumns().isEmpty())
+ .getOldHiddenColumns();
+ if (oldHidden != null)
{
- for (Iterator itr = oldSelection.getHiddenColumns()
- .iterator(); itr.hasNext();)
+ ArrayList regions = oldHidden.getHiddenColumnsCopy();
+ for (int[] positions : regions)
{
- int positions[] = itr.next();
av.hideColumns(positions[0], positions[1]);
}
}
- av.setColumnSelection(oldSelection);
+ // TODO not clear why we need to hide all the columns (above) if we are
+ // going to copy the hidden columns over wholesale anyway
+ av.getAlignment().setHiddenColumns(oldHidden);
}
+ av.sendSelection();
ap.paintAlignment(true);
}
}
+ @Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
if (!adjusting)
{
- thresholdValue.setText((slider.getValue() / 1000f) + "");
+ setThresholdValueText();
valueChanged(!sliderDragging);
}
}
@@ -323,6 +358,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
});
}
+ @Override
public void valueChanged(boolean updateAllAnnotation)
{
if (slider.isEnabled())
@@ -371,12 +407,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
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)
@@ -391,22 +429,23 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
}
adjusting = true;
- float range = getCurrentAnnotation().graphMax * 1000
- - getCurrentAnnotation().graphMin * 1000;
+ // float range = getCurrentAnnotation().graphMax * 1000
+ // - getCurrentAnnotation().graphMin * 1000;
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);
@@ -466,10 +505,13 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
}
}
+ // show hidden columns here, before changing the column selection in
+ // filterAnnotations, because showing hidden columns has the side effect of
+ // adding them to the selection
+ av.showAllHiddenColumns();
av.getColumnSelection().filterAnnotations(
getCurrentAnnotation().annotations, filterParams);
- av.showAllHiddenColumns();
if (getActionOption() == ACTION_OPTION_HIDE)
{
av.hideSelectedColumns();
@@ -477,19 +519,20 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
filterParams = null;
av.setAnnotationColumnSelectionState(this);
+ av.sendSelection();
ap.paintAlignment(true);
}
- public ColumnSelection getOldColumnSelection()
+ public HiddenColumns getOldHiddenColumns()
{
- return oldColumnSelection;
+ return oldHiddenColumns;
}
- public void setOldColumnSelection(ColumnSelection currentColumnSelection)
+ public void setOldHiddenColumns(HiddenColumns currentHiddenColumns)
{
- if (currentColumnSelection != null)
+ if (currentHiddenColumns != null)
{
- this.oldColumnSelection = new ColumnSelection(currentColumnSelection);
+ this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns);
}
}
@@ -546,13 +589,21 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
{
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;
}
@@ -569,8 +620,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
updateView();
}
- public class FurtherActionPanel extends Panel implements
- ItemListener
+ public class FurtherActionPanel extends Panel implements ItemListener
{
private AnnotationColumnChooser aColChooser;
@@ -783,7 +833,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
});
- displayName.setLabel(MessageManager.getString("label.display_name"));
+ displayName.setLabel(MessageManager.getString("label.label"));
displayName.setEnabled(false);
displayName.addItemListener(this);
@@ -847,21 +897,11 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
}
}
+ @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);
}