JAL-2171 matching bracket default character for rna SS entry
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index 91d4a5c..61a3f8c 100755 (executable)
@@ -287,14 +287,15 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       aa[activeRow].annotations = anot;
     }
 
-    if (evt.getActionCommand().equals(REMOVE))
+    String action = evt.getActionCommand();
+    if (action.equals(REMOVE))
     {
       for (int sel : av.getColumnSelection().getSelected())
       {
         anot[sel] = null;
       }
     }
-    else if (evt.getActionCommand().equals(LABEL))
+    else if (action.equals(LABEL))
     {
       String exMesg = collectAnnotVals(anot, LABEL);
       String label = JOptionPane.showInputDialog(this,
@@ -319,10 +320,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
 
         if (anot[index] == null)
         {
-          anot[index] = new Annotation(label, "", ' ', 0); // TODO: verify that
-          // null exceptions
-          // aren't raised
-          // elsewhere.
+          anot[index] = new Annotation(label, "", ' ', 0);
         }
         else
         {
@@ -330,7 +328,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
         }
       }
     }
-    else if (evt.getActionCommand().equals(COLOUR))
+    else if (action.equals(COLOUR))
     {
       Color col = JColorChooser.showDialog(this,
               MessageManager.getString("label.select_foreground_colour"),
@@ -357,21 +355,22 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       char type = 0;
       String symbol = "\u03B1"; // alpha
 
-      if (evt.getActionCommand().equals(HELIX))
+      if (action.equals(HELIX))
       {
         type = 'H';
       }
-      else if (evt.getActionCommand().equals(SHEET))
+      else if (action.equals(SHEET))
       {
         type = 'E';
         symbol = "\u03B2"; // beta
       }
 
       // Added by LML to color stems
-      else if (evt.getActionCommand().equals(STEM))
+      else if (action.equals(STEM))
       {
         type = 'S';
-        symbol = "(";// "\u03C3"; // sigma
+        int column = av.getColumnSelection().getSelectedRanges().get(0)[0];
+        symbol = aa[activeRow].getDefaultRnaHelixSymbol(column);
       }
 
       if (!aa[activeRow].hasIcons)
@@ -379,8 +378,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
         aa[activeRow].hasIcons = true;
       }
 
-      symbol = getCurrentAnnotationCharacter(anot, symbol);
-
       String label = JOptionPane.showInputDialog(MessageManager
               .getString("label.enter_label_for_the_structure"), symbol);
 
@@ -392,7 +389,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       if ((label.length() > 0) && !aa[activeRow].hasText)
       {
         aa[activeRow].hasText = true;
-        if (evt.getActionCommand().equals(STEM))
+        if (action.equals(STEM))
         {
           aa[activeRow].showAllColLabels = true;
         }
@@ -425,40 +422,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     return;
   }
 
-  /**
-   * 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;
-  }
-
   private String collectAnnotVals(Annotation[] anot, String label2)
   {
     String collatedInput = "";