X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=ceb736dd2d13335bcb436e3ae1e08fcf9e50411f;hb=5ae7fc3b4050c0ed10c9e6ad96f4b5360bce5f84;hp=bbc5c048098a265cd4a3d33b60b1e0a17229b788;hpb=b58df831ace95b2c9ac13331f8e8ea7237cd2ae6;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index bbc5c04..ceb736d 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -40,7 +40,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, static String HIDE = "Hide This Row"; static String DELETE = "Delete This Row"; static String SHOWALL = "Show All Hidden Rows"; - static String OUTPUT_TEXT = "Show Values In Textbox"; + static String OUTPUT_TEXT = "Export Annotation"; boolean resizePanel = false; Image image; AlignmentPanel ap; @@ -113,20 +113,23 @@ public class AnnotationLabels extends JPanel implements MouseListener, int height = 0; AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - for (int i = 0; i < aa.length; i++) + if(aa!=null) { - if (!aa[i].visible) + for (int i = 0; i < aa.length; i++) { - continue; - } + if (!aa[i].visible) + { + continue; + } - height += aa[i].height; + height += aa[i].height; - if (y < height) - { - selectedRow = i; + if (y < height) + { + selectedRow = i; - break; + break; + } } } } @@ -157,7 +160,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, ap.av.alignment.addAnnotation(newAnnotation); ap.av.alignment.setAnnotationIndex(newAnnotation, 0); - dif = aa[aa.length - 1].height; + if (aa != null) + dif = aa[aa.length - 1].height; } else if (evt.getActionCommand().equals(HIDE)) { @@ -198,11 +202,11 @@ public class AnnotationLabels extends JPanel implements MouseListener, } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - Desktop.addInternalFrame(cap, - ap.alignFrame.getTitle() + " - " + aa[selectedRow].label, 500, - 100); - cap.setText(aa[selectedRow].toString()); + new AnnotationExporter().exportAnnotations( + ap, + new AlignmentAnnotation[] + {aa[selectedRow]} + ); } @@ -230,7 +234,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, public void mouseReleased(MouseEvent evt) { int start = selectedRow; - getSelectedRow(evt.getY()); + getSelectedRow(evt.getY() - scrollOffset); int end = selectedRow; if(start!=end) @@ -270,7 +274,13 @@ public class AnnotationLabels extends JPanel implements MouseListener, * @param evt DOCUMENT ME! */ public void mouseExited(MouseEvent evt) - { } + { + if(dragEvent == null) + { + resizePanel = false; + repaint(); + } + } /** * DOCUMENT ME! @@ -407,9 +417,9 @@ public class AnnotationLabels extends JPanel implements MouseListener, public void drawComponent(Graphics g, int width) { if(av.getFont().getSize()<10) - g.setFont(new Font("Arial", Font.PLAIN, av.getFont().getSize()-1)); - else g.setFont(font); + else + g.setFont(av.getFont()); FontMetrics fm = g.getFontMetrics(g.getFont()); g.setColor(Color.white); @@ -517,10 +527,10 @@ public class AnnotationLabels extends JPanel implements MouseListener, { g.drawImage(image, 2, 0 - scrollOffset, this); } - else if (dragEvent != null) + else if (dragEvent != null && aa!=null) { g.setColor(Color.lightGray); - g.drawString(aa[selectedRow].label, dragEvent.getX(), dragEvent.getY()); + g.drawString(aa[selectedRow].label, dragEvent.getX(), dragEvent.getY() - scrollOffset); }