From e9b0f1619b7b33b9d2ebb3f64d7cefe563c24db8 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 22 Sep 2022 15:48:06 +0100 Subject: [PATCH] JAL-4071 boring GUI bits - add togglable menu item for show/hide sequence feature counts and viewModel/viewStyleI methods --- src/jalview/api/AlignViewportI.java | 21 ++++++++---- src/jalview/api/ViewStyleI.java | 12 +++++++ src/jalview/gui/AlignFrame.java | 18 ++++++++-- src/jalview/gui/AlignViewport.java | 22 ++++++------ src/jalview/jbgui/GAlignFrame.java | 44 +++++++++++++++++------- src/jalview/viewmodel/AlignmentViewport.java | 46 +++++++++++++++++++------- src/jalview/viewmodel/styles/ViewStyle.java | 22 ++++++++++-- 7 files changed, 139 insertions(+), 46 deletions(-) diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index d15c5fb..c692844 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -20,6 +20,13 @@ */ package jalview.api; +import java.awt.Color; +import java.awt.Font; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import jalview.analysis.Conservation; import jalview.analysis.TreeModel; import jalview.datamodel.AlignmentAnnotation; @@ -36,13 +43,6 @@ import jalview.renderer.ResidueShaderI; import jalview.schemes.ColourSchemeI; import jalview.viewmodel.ViewportRanges; -import java.awt.Color; -import java.awt.Font; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - /** * @author jimp * @@ -552,4 +552,11 @@ public interface AlignViewportI extends ViewStyleI * @return */ Iterator getViewAsVisibleContigs(boolean selectedRegionOnly); + + /** + * Show or hide annotation tracks for each type of sequence feature + * + * @param selected + */ + void setShowSequenceFeatureCounts(boolean selected); } diff --git a/src/jalview/api/ViewStyleI.java b/src/jalview/api/ViewStyleI.java index a348300..5dc6526 100644 --- a/src/jalview/api/ViewStyleI.java +++ b/src/jalview/api/ViewStyleI.java @@ -278,4 +278,16 @@ public interface ViewStyleI * @return */ void setProteinFontAsCdna(boolean b); + + /** + * Set the flag indicating that feature count annotation tracks are to be + * displayed + */ + void setShowSequenceFeatureCounts(boolean show); + + /** + * @return true if feature count annotation tracks are to be displayed + */ + boolean isShowSequenceFeatureCounts(); + } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e24cbea..6f57d83 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -20,8 +20,6 @@ */ package jalview.gui; -import java.util.Locale; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -59,6 +57,7 @@ import java.util.Deque; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import java.util.Vector; import javax.swing.ButtonGroup; @@ -3358,6 +3357,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** + * Set or clear 'Show Sequence Feature Counts' + * + * @param evt + * DOCUMENT ME! + */ + @Override + protected void showSeqFeatureCounts_actionPerformed( + ActionEvent actionEvent) + { + viewport.setShowSequenceFeatureCounts( + showSeqFeatureCounts.isSelected()); + alignPanel.paintAlignment(true, true); + } + + /** * Action on toggle of the 'Show annotations' menu item. This shows or hides * the annotations panel as a whole. * diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 30ccdbe..a43b89b 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -20,6 +20,17 @@ */ package jalview.gui; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import javax.swing.JInternalFrame; + import jalview.analysis.AlignmentUtils; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.api.AlignViewportI; @@ -53,17 +64,6 @@ import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.AutoCalcSetting; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -import javax.swing.JInternalFrame; - /** * DOCUMENT ME! * diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 71b6b9e..ffa586e 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -20,18 +20,6 @@ */ package jalview.jbgui; -import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; -import jalview.analysis.GeneticCodeI; -import jalview.analysis.GeneticCodes; -import jalview.api.SplitContainerI; -import jalview.bin.Cache; -import jalview.gui.JvSwingUtils; -import jalview.gui.Preferences; -import jalview.io.FileFormats; -import jalview.schemes.ResidueColourScheme; -import jalview.util.MessageManager; -import jalview.util.Platform; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; @@ -61,6 +49,18 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.GeneticCodeI; +import jalview.analysis.GeneticCodes; +import jalview.api.SplitContainerI; +import jalview.bin.Cache; +import jalview.gui.JvSwingUtils; +import jalview.gui.Preferences; +import jalview.io.FileFormats; +import jalview.schemes.ResidueColourScheme; +import jalview.util.MessageManager; +import jalview.util.Platform; + @SuppressWarnings("serial") public class GAlignFrame extends JInternalFrame { @@ -102,6 +102,8 @@ public class GAlignFrame extends JInternalFrame public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem showSeqFeatureCounts = new JCheckBoxMenuItem(); + JMenuItem copy = new JMenuItem(); JMenuItem cut = new JMenuItem(); @@ -803,6 +805,16 @@ public class GAlignFrame extends JInternalFrame showSeqFeatures_actionPerformed(actionEvent); } }); + showSeqFeatureCounts.setText( + MessageManager.getString("label.show_sequence_feature_counts")); + showSeqFeatureCounts.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent actionEvent) + { + showSeqFeatureCounts_actionPerformed(actionEvent); + } + }); /* * showSeqFeaturesHeight.setText("Vary Sequence Feature Height"); * showSeqFeaturesHeight.addActionListener(new ActionListener() { public @@ -1863,6 +1875,7 @@ public class GAlignFrame extends JInternalFrame autoAnnMenu.add(showAutoFirst); autoAnnMenu.add(showAutoLast); autoAnnMenu.addSeparator(); + autoAnnMenu.add(showSeqFeatureCounts); autoAnnMenu.add(applyAutoAnnotationSettings); autoAnnMenu.add(showConsensusHistogram); autoAnnMenu.add(showSequenceLogo); @@ -1951,6 +1964,13 @@ public class GAlignFrame extends JInternalFrame // selectMenu.add(listenToViewSelections); } + protected void showSeqFeatureCounts_actionPerformed( + ActionEvent actionEvent) + { + // TODO Auto-generated method stub + + } + protected void loadVcf_actionPerformed() { } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 08af2ec..72eb9c0 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -20,6 +20,18 @@ */ package jalview.viewmodel; +import java.awt.Color; +import java.beans.PropertyChangeSupport; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Deque; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.Conservation; import jalview.analysis.TreeModel; @@ -61,18 +73,6 @@ import jalview.workers.ComplementConsensusThread; import jalview.workers.ConsensusThread; import jalview.workers.StrucConsensusThread; -import java.awt.Color; -import java.beans.PropertyChangeSupport; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Deque; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - /** * base class holding visualization and analysis attributes and common logic for * an active alignment view displayed in the GUI @@ -571,6 +571,28 @@ public abstract class AlignmentViewport viewStyle.setSeqNameItalics(default1); } + /** + * Set the flag indicating that feature count annotation tracks are to be + * displayed + * + * @see jalview.api.ViewStyleI#setShowSequenceFeatureCounts(boolean) + */ + @Override + public void setShowSequenceFeatureCounts(boolean show) + { + viewStyle.setShowSequenceFeatureCounts(show); + } + + /** + * @return true if feature count annotation tracks are to be displayed + * @see jalview.api.ViewStyleI#isShowSequenceFeatureCounts() + */ + @Override + public boolean isShowSequenceFeatureCounts() + { + return viewStyle.isShowSequenceFeatureCounts(); + } + @Override public AlignmentI getAlignment() { diff --git a/src/jalview/viewmodel/styles/ViewStyle.java b/src/jalview/viewmodel/styles/ViewStyle.java index 91f2f0c..0a525e2 100644 --- a/src/jalview/viewmodel/styles/ViewStyle.java +++ b/src/jalview/viewmodel/styles/ViewStyle.java @@ -20,10 +20,10 @@ */ package jalview.viewmodel.styles; -import jalview.api.ViewStyleI; - import java.awt.Color; +import jalview.api.ViewStyleI; + /** * A container for holding alignment view properties. View properties are * data-independent, which means they can be safely copied between views @@ -124,6 +124,12 @@ public class ViewStyle implements ViewStyleI boolean showSequenceFeatures = false; /** + * display setting for showing/hiding annotation tracks reporting sequence + * feature counts in columns of alignment view + */ + boolean showSequenceFeatureCounts = false; + + /** * display sequence symbols */ boolean showText = true; @@ -1144,4 +1150,16 @@ public class ViewStyle implements ViewStyleI { return showComplementFeaturesOnTop; } + + @Override + public void setShowSequenceFeatureCounts(boolean show) + { + showSequenceFeatureCounts = show; + } + + @Override + public boolean isShowSequenceFeatureCounts() + { + return showSequenceFeatureCounts; + } } -- 1.7.10.2