From: gmungoc Date: Wed, 17 Aug 2016 11:30:57 +0000 (+0100) Subject: JAL-2173 don't remove annotation from hidden columns X-Git-Tag: Release_2_10_0~103 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=08c8b9d76f478017bdb4fbd5bc1b4d0e16421de6;p=jalview.git JAL-2173 don't remove annotation from hidden columns --- diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index dd652b1..1a5dc05 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -160,12 +160,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)) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 398f57d..eec1881 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -289,9 +289,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (evt.getActionCommand().equals(REMOVE)) { - for (int sel : av.getColumnSelection().getSelected()) + for (int index : av.getColumnSelection().getSelected()) { - anot[sel] = null; + if (av.getColumnSelection().isVisible(index)) + { + anot[index] = null; + } } } else if (evt.getActionCommand().equals(LABEL)) @@ -423,9 +426,21 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, return; } - private String collectAnnotVals(Annotation[] anot, String label2) + /** + * Returns any existing annotation concatenated as a string. For each + * annotation, takes the description, if any, else the secondary structure + * character (if type is HELIX, SHEET or STEM), else the display character (if + * type is LABEL). + * + * @param anots + * @param type + * @return + */ + private String collectAnnotVals(Annotation[] anots, String type) { - String collatedInput = ""; + // TODO is this method wanted? why? 'last' is not used + + StringBuilder collatedInput = new StringBuilder(64); String last = ""; ColumnSelection viscols = av.getColumnSelection(); // TODO: refactor and save av.getColumnSelection for efficiency @@ -437,22 +452,22 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, continue; } String tlabel = null; - if (anot[index] != null) + if (anots[index] != null) { // LML added stem code - if (label2.equals(HELIX) || label2.equals(SHEET) - || label2.equals(STEM) || label2.equals(LABEL)) + if (type.equals(HELIX) || type.equals(SHEET) + || type.equals(STEM) || type.equals(LABEL)) { - tlabel = anot[index].description; + tlabel = anots[index].description; if (tlabel == null || tlabel.length() < 1) { - if (label2.equals(HELIX) || label2.equals(SHEET) - || label2.equals(STEM)) + if (type.equals(HELIX) || type.equals(SHEET) + || type.equals(STEM)) { - tlabel = "" + anot[index].secondaryStructure; + tlabel = "" + anots[index].secondaryStructure; } else { - tlabel = "" + anot[index].displayCharacter; + tlabel = "" + anots[index].displayCharacter; } } } @@ -460,13 +475,13 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { if (last.length() > 0) { - collatedInput += " "; + collatedInput.append(" "); } - collatedInput += tlabel; + collatedInput.append(tlabel); } } } - return collatedInput; + return collatedInput.toString(); } /**