X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationColumnChooser.java;h=f1f78fa1d4fa450e9e7956f9e9ddeb5ad0f7c9fe;hb=HEAD;hp=8b66b8e540f48cffad5d6a72c02e756bfb37c1c9;hpb=6b13a606027284408286d1cd2833470d1f9b9bfe;p=jalview.git diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index 8b66b8e..f1f78fa 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -21,14 +21,6 @@ package jalview.gui; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.HiddenColumns; -import jalview.io.cache.JvCacheableInputBox; -import jalview.schemes.AnnotationColourGradient; -import jalview.util.MessageManager; -import jalview.util.Platform; -import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; - import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -50,6 +42,14 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.border.TitledBorder; +import jalview.bin.Console; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.HiddenColumns; +import jalview.io.cache.JvCacheableInputBox; +import jalview.schemes.AnnotationColourGradient; +import jalview.util.MessageManager; +import jalview.util.Platform; +import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; import net.miginfocom.swing.MigLayout; @SuppressWarnings("serial") @@ -91,18 +91,25 @@ public class AnnotationColumnChooser extends AnnotationRowFilter private HiddenColumns oldHiddenColumns; protected static int MIN_WIDTH = (Platform.isJS() ? 370 : 420); + protected static int MIN_HEIGHT = (Platform.isJS() ? 370 : 430); public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap) { + this(av, ap, null); + } + + public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap, + AlignmentAnnotation selectedAnnotation) + { super(av, ap); frame = new JInternalFrame(); + frame.setFrameIcon(null); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, - MessageManager.getString("label.select_by_annotation"), 0, - 0); - // BH note: MIGLayout ignores this completely, + MessageManager.getString("label.select_by_annotation"), 0, 0); + // BH note: MIGLayout ignores this completely, // possibly creating a frame smaller than specified: frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); @@ -134,6 +141,18 @@ public class AnnotationColumnChooser extends AnnotationRowFilter percentThreshold .setSelected(lastChooser.percentThreshold.isSelected()); } + if (selectedAnnotation != null) + { + try + { + setCurrentAnnotation(selectedAnnotation); + annotations.setSelectedItem( + getAnnotationMenuLabel(selectedAnnotation)); + } catch (Exception x) + { + Console.error("Couldn't select annotation in column chooser", x); + } + } try { @@ -158,7 +177,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter MessageManager.getString("label.threshold_filter"))); thresholdPanel.setBackground(Color.white); thresholdPanel.setFont(JvSwingUtils.getLabelFont()); - thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]") ); + thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); percentThreshold.setBackground(Color.white); percentThreshold.setFont(JvSwingUtils.getLabelFont()); @@ -300,15 +319,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter if (currentAnnotation.threshold == null) { currentAnnotation.setThreshold(new jalview.datamodel.GraphLine( - (currentAnnotation.graphMax - - currentAnnotation.graphMin) / 2f, + (currentAnnotation.graphMax - currentAnnotation.graphMin) + / 2f, "Threshold", Color.black)); } adjusting = true; - setSliderModel(currentAnnotation.graphMin, - currentAnnotation.graphMax, + setSliderModel(currentAnnotation.graphMin, currentAnnotation.graphMax, currentAnnotation.threshold.value); setThresholdValueText(); @@ -322,8 +340,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); if (currentAnnotation.isQuantitative()) { - filterParams - .setThresholdValue(currentAnnotation.threshold.value); + filterParams.setThresholdValue(currentAnnotation.threshold.value); if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD) { @@ -378,8 +395,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter // filterAnnotations, because showing hidden columns has the side effect of // adding them to the selection av.showAllHiddenColumns(); - av.getColumnSelection().filterAnnotations( - currentAnnotation.annotations, filterParams); + av.getColumnSelection().filterAnnotations(currentAnnotation, + filterParams); boolean hideCols = getActionOption() == ACTION_OPTION_HIDE; if (hideCols) @@ -495,7 +512,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter CardLayout switchableViewsLayout = (CardLayout) switchableViewsPanel .getLayout(); - switchableViewsLayout.show(switchableViewsPanel, currentView); + switchableViewsLayout.show(switchableViewsPanel, currentView); updateView(); } @@ -732,17 +749,17 @@ public class AnnotationColumnChooser extends AnnotationRowFilter searchBox.getComponent().setToolTipText( MessageManager.getString("info.enter_search_text_here")); searchBox.addKeyListener(new java.awt.event.KeyAdapter() - { - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - { - e.consume(); - searchStringAction(); - } - } - }); + { + @Override + public void keyPressed(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_ENTER) + { + e.consume(); + searchStringAction(); + } + } + }); searchBox.addFocusListener(new FocusAdapter() { @Override @@ -852,4 +869,11 @@ public class AnnotationColumnChooser extends AnnotationRowFilter gSearchPanel.searchBox.updateCache(); ngSearchPanel.searchBox.updateCache(); } + + public static void displayFor(AlignViewport av, AlignmentPanel ap, + AlignmentAnnotation alignmentAnnotation) + { + AnnotationColumnChooser colchooser = new AnnotationColumnChooser(av, ap, + alignmentAnnotation); + } }