JAL-1264 adding show/hide annotation options to applet
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 891aaf7..a544813 100755 (executable)
  */
 package jalview.gui;
 
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.Annotation;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.io.FormatAdapter;
-import jalview.util.MessageManager;
-
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
@@ -49,6 +40,7 @@ import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.regex.Pattern;
 
 import javax.swing.JCheckBoxMenuItem;
@@ -58,6 +50,16 @@ import javax.swing.JPopupMenu;
 import javax.swing.SwingUtilities;
 import javax.swing.ToolTipManager;
 
+import jalview.analysis.AlignmentUtils;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.io.FormatAdapter;
+import jalview.util.MessageManager;
+
 /**
  * DOCUMENT ME!
  * 
@@ -623,11 +625,11 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     item.addActionListener(this);
     pop.add(item);
     // JAL-1264 hide all sequence-specific annotations of this type
-    final String label = aa[selectedRow].label;
     if (selectedRow < aa.length)
     {
       if (aa[selectedRow].sequenceRef != null)
       {
+        final String label = aa[selectedRow].label;
         JMenuItem hideType = new JMenuItem();
         String text = MessageManager.getString("label.hide_all") + " " + label;
         hideType.setText(text);
@@ -636,15 +638,18 @@ public class AnnotationLabels extends JPanel implements MouseListener,
           @Override
           public void actionPerformed(ActionEvent e)
           {
-            for (AlignmentAnnotation ann : ap.av.getAlignment()
-                    .getAlignmentAnnotation())
-            {
-              if (ann.sequenceRef != null && ann.label != null
-                      && ann.label.equals(label))
-              {
-                ann.visible = false;
-              }
-            }
+            AlignmentUtils.showOrHideSequenceAnnotations(
+                    ap.av.getAlignment(), Collections.singleton(label),
+                    null, false, false);
+            // for (AlignmentAnnotation ann : ap.av.getAlignment()
+            // .getAlignmentAnnotation())
+            // {
+            // if (ann.sequenceRef != null && ann.label != null
+            // && ann.label.equals(label))
+            // {
+            // ann.visible = false;
+            // }
+            // }
             refresh();
           }
         });
@@ -667,6 +672,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     // property methods
     if (selectedRow < aa.length)
     {
+      final String label = aa[selectedRow].label;
       if (!aa[selectedRow].autoCalculated)
       {
         if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)