From: gmungoc Date: Mon, 19 Sep 2016 13:10:36 +0000 (+0100) Subject: JAL-2118 reorder annotations after add/delete/hide/change name X-Git-Tag: Release_2_10_0~39^2~28^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ab4e8d6988969d68d972d308c4159e9b9eb51e84;p=jalview.git JAL-2118 reorder annotations after add/delete/hide/change name --- diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 92c6dc6..f995c60 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -219,6 +219,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, AlignmentAnnotation[] aa = ap.av.getAlignment() .getAlignmentAnnotation(); + boolean fullRepaint = false; if (evt.getActionCommand().equals(ADDNEW)) { AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null, @@ -231,11 +232,16 @@ public class AnnotationLabels extends JPanel implements MouseListener, ap.av.getAlignment().addAnnotation(newAnnotation); ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0); + fullRepaint = true; } else if (evt.getActionCommand().equals(EDITNAME)) { + String name = aa[selectedRow].label; editLabelDescription(aa[selectedRow]); - repaint(); + if (!name.equalsIgnoreCase(aa[selectedRow].label)) + { + fullRepaint = true; + } } else if (evt.getActionCommand().equals(HIDE)) { @@ -245,6 +251,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { ap.av.getAlignment().deleteAnnotation(aa[selectedRow]); ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]); + fullRepaint = true; } else if (evt.getActionCommand().equals(SHOWALL)) { @@ -255,6 +262,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[i].visible = true; } } + fullRepaint = true; } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { @@ -283,18 +291,30 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel; } - refresh(); + refresh(fullRepaint); } /** * Redraw sensibly. + * + * @adjustHeight if true, try to recalculate panel height for visible + * annotations */ - protected void refresh() + protected void refresh(boolean adjustHeight) { - ap.validateAnnotationDimensions(false); + ap.validateAnnotationDimensions(adjustHeight); ap.addNotify(); - ap.repaint(); + if (adjustHeight) + { + // sort, repaint, update overview + ap.paintAlignment(true); + } + else + { + // lightweight repaint + ap.repaint(); + } } /** @@ -305,6 +325,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, */ boolean editLabelDescription(AlignmentAnnotation annotation) { + // TODO i18n EditNameDialog dialog = new EditNameDialog(annotation.label, annotation.description, " Annotation Name ", "Annotation Description ", "Edit Annotation Name/Description", @@ -398,7 +419,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, // ann.visible = false; // } // } - refresh(); + refresh(true); } }); pop.add(hideType);