From: gmungoc Date: Fri, 12 Aug 2016 09:51:48 +0000 (+0100) Subject: JAL-2171 default SS symbol to existing (if present) X-Git-Tag: Release_2_10_0~70^2~11 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ba66677097af3b383a2b3a01228d374dc7a4b1f9;p=jalview.git JAL-2171 default SS symbol to existing (if present) --- diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index dd652b1..823bbfd 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -241,9 +241,11 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, else if (evt.getActionCommand().equals(STEM)) { type = 'S'; - symbol = "\u03C3"; + symbol = "(";// "\u03C3"; sigma } + symbol = getCurrentAnnotationCharacter(anot, symbol); + if (!aa[activeRow].hasIcons) { aa[activeRow].hasIcons = true; @@ -346,7 +348,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK && activeRow != -1) { - if (av.getColumnSelection() == null) + if (av.getColumnSelection() == null + || av.getColumnSelection().isEmpty()) { return; } @@ -354,10 +357,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, PopupMenu pop = new PopupMenu( MessageManager.getString("label.structure_type")); MenuItem item; - /* - * Just display the needed structure options - */ - if (av.getAlignment().isNucleotide() == true) + + if (av.getAlignment().isNucleotide()) { item = new MenuItem(STEM); item.addActionListener(this); @@ -724,4 +725,38 @@ 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; + } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 398f57d..91d4a5c 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -355,7 +355,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // HELIX, SHEET or STEM { char type = 0; - String symbol = "\u03B1"; + String symbol = "\u03B1"; // alpha if (evt.getActionCommand().equals(HELIX)) { @@ -364,14 +364,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, else if (evt.getActionCommand().equals(SHEET)) { type = 'E'; - symbol = "\u03B2"; + symbol = "\u03B2"; // beta } // Added by LML to color stems else if (evt.getActionCommand().equals(STEM)) { type = 'S'; - symbol = "\u03C3"; + symbol = "(";// "\u03C3"; // sigma } if (!aa[activeRow].hasIcons) @@ -379,6 +379,8 @@ 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); @@ -423,6 +425,40 @@ 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 = ""; @@ -514,7 +550,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (evt.isPopupTrigger() && activeRow != -1) { - if (av.getColumnSelection() == null) + if (av.getColumnSelection() == null + || av.getColumnSelection().isEmpty()) { return; } @@ -525,7 +562,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, /* * Just display the needed structure options */ - if (av.getAlignment().isNucleotide() == true) + if (av.getAlignment().isNucleotide()) { item = new JMenuItem(STEM); item.addActionListener(this); @@ -554,11 +591,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, return; } - if (aa == null) - { - return; - } - ap.getScalePanel().mousePressed(evt); }