JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index 823bbfd..6012c1a 100755 (executable)
@@ -25,8 +25,10 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.AnnotationRenderer;
 import jalview.renderer.AwtRenderPanelI;
+import jalview.schemes.ResidueProperties;
 import jalview.util.Comparison;
 import jalview.util.MessageManager;
+import jalview.util.Platform;
 
 import java.awt.Color;
 import java.awt.Dimension;
@@ -100,7 +102,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
 
   public AnnotationPanel(AlignmentPanel ap)
   {
-    MAC = new jalview.util.Platform().isAMac();
+    new jalview.util.Platform();
+    MAC = Platform.isAMac();
     this.ap = ap;
     av = ap.av;
     setLayout(null);
@@ -160,12 +163,12 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
 
     if (evt.getActionCommand().equals(REMOVE))
     {
-      for (int sel : av.getColumnSelection().getSelected())
+      for (int index : av.getColumnSelection().getSelected())
       {
-        // TODO: JAL-2001 check if applet has faulty 'REMOVE' selected columns
-        // of
-        // annotation if selection includes hidden columns
-        anot[sel] = null;
+        if (av.getColumnSelection().isVisible(index))
+        {
+          anot[index] = null;
+        }
       }
     }
     else if (evt.getActionCommand().equals(LABEL))
@@ -241,11 +244,10 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
       else if (evt.getActionCommand().equals(STEM))
       {
         type = 'S';
-        symbol = "(";// "\u03C3"; sigma
+        int column = av.getColumnSelection().getSelectedRanges().get(0)[0];
+        symbol = aa[activeRow].getDefaultRnaHelixSymbol(column);
       }
 
-      symbol = getCurrentAnnotationCharacter(anot, symbol);
-
       if (!aa[activeRow].hasIcons)
       {
         aa[activeRow].hasIcons = true;
@@ -473,9 +475,10 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
       StringBuilder text = new StringBuilder();
       text.append(MessageManager.getString("label.column")).append(" ")
               .append(column + 1);
-      if (aa[row].annotations[column].description != null)
+      String description = aa[row].annotations[column].description;
+      if (description != null && description.length() > 0)
       {
-        text.append("  ").append(aa[row].annotations[column].description);
+        text.append("  ").append(description);
       }
 
       /*
@@ -494,9 +497,28 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
           char residue = seqref.getCharAt(column);
           if (!Comparison.isGap(residue))
           {
+            text.append(" ");
+            String name;
+            if (av.getAlignment().isNucleotide())
+            {
+              name = ResidueProperties.nucleotideName.get(String
+                      .valueOf(residue));
+              text.append(" Nucleotide: ").append(
+                      name != null ? name : residue);
+            }
+            else
+            {
+              name = 'X' == residue ? "X" : ('*' == residue ? "STOP"
+                      : ResidueProperties.aa2Triplet.get(String
+                              .valueOf(residue)));
+              text.append(" Residue: ").append(
+                      name != null ? name : residue);
+            }
             int residuePos = seqref.findPosition(column);
-            text.append(": ").append(residue).append(" (")
-                    .append(residuePos).append(")");
+            text.append(" (").append(residuePos).append(")");
+            // int residuePos = seqref.findPosition(column);
+            // text.append(residue).append(" (")
+            // .append(residuePos).append(")");
           }
         }
       }
@@ -725,38 +747,4 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
       return null;
     }
   }
-
-  /**
-   * Returns the current annotation symbol (if any) within the visible selected
-   * columns (first symbol found left to right in selection). If none is found,
-   * the supplied default value is returned.
-   * 
-   * @param annotations
-   * @param defaultValue
-   * @return
-   */
-  String getCurrentAnnotationCharacter(Annotation[] annotations,
-          String defaultValue)
-  {
-    String result = defaultValue;
-    for (int index : av.getColumnSelection().getSelected())
-    {
-      if (!av.getColumnSelection().isVisible(index))
-      {
-        continue;
-      }
-  
-      Annotation annotation = annotations[index];
-      if (annotation != null)
-      {
-        String displayed = annotation.displayCharacter;
-        if (displayed != null && displayed.length() > 0)
-        {
-          result = displayed.substring(0, 1);
-          break;
-        }
-      }
-    }
-    return result;
-  }
 }