JAL-4071 boring GUI bits - add togglable menu item for show/hide sequence feature...
authorJim Procter <j.procter@dundee.ac.uk>
Thu, 22 Sep 2022 14:48:06 +0000 (15:48 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 22 Sep 2022 14:50:00 +0000 (15:50 +0100)
src/jalview/api/AlignViewportI.java
src/jalview/api/ViewStyleI.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/viewmodel/styles/ViewStyle.java

index d15c5fb..c692844 100644 (file)
  */
 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<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly);
+
+  /**
+   * Show or hide annotation tracks for each type of sequence feature
+   * 
+   * @param selected
+   */
+  void setShowSequenceFeatureCounts(boolean selected);
 }
index a348300..5dc6526 100644 (file)
@@ -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();
+
 }
index e24cbea..6f57d83 100644 (file)
@@ -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.
    * 
index 30ccdbe..a43b89b 100644 (file)
  */
 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!
  * 
index 71b6b9e..ffa586e 100755 (executable)
  */
 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()
   {
   }
index 08af2ec..72eb9c0 100644 (file)
  */
 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()
   {
index 91f2f0c..0a525e2 100644 (file)
  */
 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;
+  }
 }