mouse pressed moved to mouseclicked
authoramwaterhouse <Andrew Waterhouse>
Tue, 14 Jun 2005 15:03:02 +0000 (15:03 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 14 Jun 2005 15:03:02 +0000 (15:03 +0000)
src/jalview/gui/AnnotationLabels.java

index 1b9fd8f..9b9e2db 100755 (executable)
@@ -85,21 +85,21 @@ public class AnnotationLabels
 \r
   public void actionPerformed(ActionEvent evt)\r
   {\r
+    int dif = 0;\r
     AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
 \r
     if (evt.getActionCommand().equals(ADDNEW))\r
     {\r
       String label = JOptionPane.showInputDialog(this,\r
                                                  "Label for annotation");\r
-\r
       if (label == null)\r
-      {\r
         label = "";\r
-      }\r
 \r
       ap.av.alignment.addAnnotation(new AlignmentAnnotation(label,\r
           "New description",\r
           new Annotation[ap.av.alignment.getWidth()]));\r
+\r
+      dif = aa[aa.length-1].height;\r
     }\r
     else if (evt.getActionCommand().equals(HIDE))\r
     {\r
@@ -119,16 +119,23 @@ public class AnnotationLabels
       {\r
         ap.av.showIdentity = false;\r
       }\r
+\r
+      dif = aa[selectedRow].height*-1;\r
     }\r
     else if (evt.getActionCommand().equals(DELETE))\r
     {\r
       ap.av.alignment.deleteAnnotation(aa[selectedRow]);\r
+      dif = aa[selectedRow].height*-1;\r
     }\r
     else if (evt.getActionCommand().equals(SHOWALL))\r
     {\r
       for (int i = 0; i < aa.length; i++)\r
       {\r
-        aa[i].visible = true;\r
+        if(!aa[i].visible)\r
+         {\r
+           dif+=aa[i].height;\r
+           aa[i].visible = true;\r
+         }\r
       }\r
     }\r
     else if (evt.getActionCommand().equals(OUTPUT_TEXT))\r
@@ -142,63 +149,20 @@ public class AnnotationLabels
     }\r
 \r
     ap.annotationPanel.adjustPanelHeight();\r
-    ap.repaint();\r
-  }\r
-\r
-  public void mousePressed(MouseEvent evt)\r
-  {\r
-    int y = evt.getY() - scrollOffset;\r
-\r
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
-\r
-    if ( (aa == null) || (aa.length == 0))\r
-    {\r
-      JPopupMenu pop = new JPopupMenu("Annotations");\r
-      JMenuItem item = new JMenuItem(ADDNEW);\r
-      item.addActionListener(this);\r
-      pop.add(item);\r
-      pop.show(this, evt.getX(), evt.getY());\r
-\r
-      return;\r
-    }\r
-\r
-    int height = 0;\r
 \r
-    for (int i = 0; i < aa.length; i++)\r
-    {\r
-      if (!aa[i].visible)\r
-      {\r
-        continue;\r
-      }\r
-\r
-      height += aa[i].height;\r
+    Dimension d = ap.annotationScroller.getPreferredSize();\r
+    ap.annotationScroller.setPreferredSize(new Dimension(d.width, d.height+dif));\r
+    d = ap.annotationSpaceFillerHolder.getPreferredSize();\r
+    ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension(\r
+        d.width, d.height+dif));\r
 \r
-      if (y < height)\r
-      {\r
-        selectedRow = i;\r
+      ap.addNotify();\r
 \r
-        break;\r
-      }\r
-    }\r
 \r
-    JPopupMenu pop = new JPopupMenu("Annotations");\r
-    JMenuItem item = new JMenuItem(ADDNEW);\r
-    item.addActionListener(this);\r
-    pop.add(item);\r
-    item = new JMenuItem(HIDE);\r
-    item.addActionListener(this);\r
-    pop.add(item);\r
-    item = new JMenuItem(DELETE);\r
-    item.addActionListener(this);\r
-    pop.add(item);\r
-    item = new JMenuItem(SHOWALL);\r
-    item.addActionListener(this);\r
-    pop.add(item);\r
-    item = new JMenuItem(OUTPUT_TEXT);\r
-    item.addActionListener(this);\r
-    pop.add(item);\r
-    pop.show(this, evt.getX(), evt.getY());\r
+  }\r
 \r
+  public void mousePressed(MouseEvent evt)\r
+  {\r
     oldY = evt.getY();\r
   }\r
 \r
@@ -249,6 +213,56 @@ public class AnnotationLabels
 \r
   public void mouseClicked(MouseEvent evt)\r
   {\r
+    int y = evt.getY() - scrollOffset;\r
+    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
+\r
+    if ( (aa == null) || (aa.length == 0))\r
+    {\r
+      JPopupMenu pop = new JPopupMenu("Annotations");\r
+      JMenuItem item = new JMenuItem(ADDNEW);\r
+      item.addActionListener(this);\r
+      pop.add(item);\r
+      pop.show(this, evt.getX(), evt.getY());\r
+\r
+      return;\r
+    }\r
+\r
+    int height = 0;\r
+\r
+    for (int i = 0; i < aa.length; i++)\r
+    {\r
+      if (!aa[i].visible)\r
+      {\r
+        continue;\r
+      }\r
+\r
+      height += aa[i].height;\r
+\r
+      if (y < height)\r
+      {\r
+        selectedRow = i;\r
+\r
+        break;\r
+      }\r
+    }\r
+\r
+    JPopupMenu pop = new JPopupMenu("Annotations");\r
+    JMenuItem item = new JMenuItem(ADDNEW);\r
+    item.addActionListener(this);\r
+    pop.add(item);\r
+    item = new JMenuItem(HIDE);\r
+    item.addActionListener(this);\r
+    pop.add(item);\r
+    item = new JMenuItem(DELETE);\r
+    item.addActionListener(this);\r
+    pop.add(item);\r
+    item = new JMenuItem(SHOWALL);\r
+    item.addActionListener(this);\r
+    pop.add(item);\r
+    item = new JMenuItem(OUTPUT_TEXT);\r
+    item.addActionListener(this);\r
+    pop.add(item);\r
+    pop.show(this, evt.getX(), evt.getY());\r
   }\r
 \r
   public void paintComponent(Graphics g1)\r