X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=4b774d60cbab3252eaa0868b182136f0545f6bda;hb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;hp=5b01b9b94222cb190e5bdd51f756c588f31d3b4f;hpb=408b2821c8daf99245bf6358d06760701d90ddd8;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 5b01b9b..4b774d6 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -27,6 +27,7 @@ import jalview.datamodel.Annotation; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.FileFormat; import jalview.io.FormatAdapter; import jalview.util.MessageManager; @@ -219,6 +220,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 +233,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 +252,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 +263,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[i].visible = true; } } + fullRepaint = true; } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { @@ -283,18 +292,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 +326,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", @@ -332,12 +354,20 @@ public class AnnotationLabels extends JPanel implements MouseListener, { getSelectedRow(evt.getY() - getScrollOffset()); oldY = evt.getY(); - if (!evt.isPopupTrigger()) + if (evt.isPopupTrigger()) { - return; + showPopupMenu(evt); } + } + + /** + * Build and show the Pop-up menu at the right-click mouse position + * + * @param evt + */ + void showPopupMenu(MouseEvent evt) + { evt.consume(); - // handle popup menu event final AlignmentAnnotation[] aa = ap.av.getAlignment() .getAlignmentAnnotation(); @@ -390,7 +420,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, // ann.visible = false; // } // } - refresh(); + refresh(true); } }); pop.add(hideType); @@ -452,6 +482,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap); } + ap.alignmentChanged(); } }); pop.add(cbmi); @@ -595,7 +626,6 @@ public class AnnotationLabels extends JPanel implements MouseListener, } } pop.show(this, evt.getX(), evt.getY()); - } /** @@ -607,6 +637,12 @@ public class AnnotationLabels extends JPanel implements MouseListener, @Override public void mouseReleased(MouseEvent evt) { + if (evt.isPopupTrigger()) + { + showPopupMenu(evt); + return; + } + int start = selectedRow; getSelectedRow(evt.getY() - getScrollOffset()); int end = selectedRow; @@ -944,8 +980,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex( hiddenCols); } - String output = new FormatAdapter().formatSequences("Fasta", seqs, - omitHidden, alignmentStartEnd); + String output = new FormatAdapter().formatSequences(FileFormat.Fasta, + seqs, omitHidden, alignmentStartEnd); Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(output), Desktop.instance);