dif is never used
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 81a3cd2..a4be664 100755 (executable)
@@ -147,7 +147,6 @@ public class AnnotationLabels
    */
   public void actionPerformed(ActionEvent evt)
   {
-    int dif = 0;
     AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
 
     if (evt.getActionCommand().equals(ADDNEW))
@@ -163,10 +162,6 @@ public class AnnotationLabels
 
       ap.av.alignment.addAnnotation(newAnnotation);
       ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
-      if (aa != null)
-      {
-        dif = aa[aa.length - 1].height;
-      }
     }
     else if (evt.getActionCommand().equals(EDITNAME))
     {
@@ -181,21 +176,17 @@ public class AnnotationLabels
       {
         ap.av.quality = null;
       }
-
-      dif = aa[selectedRow].height * -1;
     }
     else if (evt.getActionCommand().equals(DELETE))
     {
       ap.av.alignment.deleteAnnotation(aa[selectedRow]);
-      dif = aa[selectedRow].height * -1;
     }
     else if (evt.getActionCommand().equals(SHOWALL))
     {
       for (int i = 0; i < aa.length; i++)
       {
-        if (!aa[i].visible)
+        if (!aa[i].visible && aa[i].annotations!=null)
         {
-          dif += aa[i].height;
           aa[i].visible = true;
         }
       }
@@ -206,7 +197,7 @@ public class AnnotationLabels
           ap,
           new AlignmentAnnotation[]
           {aa[selectedRow]},
-          null
+          null, null
           );
     }
     else if (evt.getActionCommand().equals(COPYCONS_SEQ))
@@ -245,7 +236,7 @@ public class AnnotationLabels
     annotation.label = dialog.getName();
 
     String text = dialog.getDescription();
-    if (text.length() == 0)
+    if (text!=null && text.length() == 0)
     {
       text = null;
     }
@@ -367,20 +358,33 @@ public class AnnotationLabels
 
     getSelectedRow(evt.getY() - scrollOffset);
 
+
     if (selectedRow > -1
         && ap.av.alignment.getAlignmentAnnotation().length > selectedRow)
     {
-      String desc = ap.av.alignment.
-          getAlignmentAnnotation()[selectedRow].description;
+      AlignmentAnnotation aa = ap.av.alignment.
+          getAlignmentAnnotation()[selectedRow];
+
+      StringBuffer desc = new StringBuffer("<html>");
 
-      if (desc != null && !desc.equals("New description"))
+      if (aa.description != null && !aa.description.equals("New description"))
+      {
+        desc.append(aa.description+"<br>");
+      }
+      if(aa.hasScore())
       {
-        setToolTipText(ap.av.alignment.
-                       getAlignmentAnnotation()[selectedRow].description);
+        desc.append("Score: "+aa.score);
       }
 
+      if(desc.length()!=6)
+      {
+        desc.append("</html>");
+        this.setToolTipText(desc.toString());
+      }
+      else
+        this.setToolTipText(null);
     }
-    repaint();
+
   }
 
   /**
@@ -561,32 +565,36 @@ public class AnnotationLabels
 
     AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
     int fontHeight = g.getFont().getSize();
-    int y = fontHeight;
+    int y = 0;
     int x = 0;
     int graphExtras = 0;
+    int offset =0;
 
     if (aa != null)
     {
       for (int i = 0; i < aa.length; i++)
       {
+        g.setColor(Color.black);
+
         if (!aa[i].visible)
         {
           continue;
         }
 
-        x = width - fm.stringWidth(aa[i].label) - 3;
 
-        if (aa[i].graph > 0 && aa[i].graphHeight > 0)
-        {
-          graphExtras = y;
+        y += aa[i].height;
 
-          y += (aa[i].height / 3);
+        offset = -aa[i].height/2;
 
-          if (aa[i].graphGroup < 0)
-          {
-            graphExtras = y + fontHeight;
-          }
+        if(aa[i].hasText)
+        {
+          offset += fm.getHeight()/2;
+          offset -= fm.getDescent();
         }
+        else
+          offset += fm.getDescent();
+
+        x = width - fm.stringWidth(aa[i].label) - 3;
 
         if (aa[i].graphGroup > -1)
         {
@@ -601,7 +609,7 @@ public class AnnotationLabels
 
           if (groupSize * (fontHeight + 8) < aa[i].height)
           {
-            graphExtras += (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
+            graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
           }
 
           for (int gg = 0; gg < aa.length; gg++)
@@ -609,15 +617,15 @@ public class AnnotationLabels
             if (aa[gg].graphGroup == aa[i].graphGroup)
             {
               x = width - fm.stringWidth(aa[gg].label) - 3;
-              g.drawString(aa[gg].label, x, graphExtras);
+              g.drawString(aa[gg].label, x,y - graphExtras);
               if (aa[gg].annotations[0] != null)
               {
                 g.setColor(aa[gg].annotations[0].colour);
               }
 
-              g.drawLine(x, graphExtras + 3,
+              g.drawLine(x, y - graphExtras - 3,
                          x + fm.stringWidth(aa[gg].label),
-                         graphExtras + 3);
+                         y - graphExtras - 3);
 
               g.setColor(Color.black);
               graphExtras += fontHeight + 8;
@@ -626,38 +634,7 @@ public class AnnotationLabels
         }
         else
         {
-          g.drawString(aa[i].label, x, y);
-        }
-
-        if (aa[i].graph > 0)
-        {
-          /*  if (aa[i].graphLines != null)
-            {
-              for (int gl = 0; gl < aa[i].graphLines.size(); gl++)
-              {
-                 x = width - fm.stringWidth(aa[i].getGraphLine(gl).label) - 3;
-                g.drawString(aa[i].getGraphLine(gl).label, x, graphExtras);
-                g.setColor(aa[i].getGraphLine(gl).colour);
-                Graphics2D g2 = (Graphics2D) g;
-                g2.setStroke(new BasicStroke(1,
-                    BasicStroke.CAP_SQUARE,
-                    BasicStroke.JOIN_ROUND, 3f,
-                    new float[]
-                    {5f, 3f}, 0f));
-
-                graphExtras += 3;
-
-                g.drawLine(x, graphExtras,
-                           x+fm.stringWidth(aa[i].label),
-                           graphExtras);
-                g2.setStroke(new BasicStroke());
-              }
-            }*/
-          y += ( (2 * aa[i].height) / 3);
-        }
-        else
-        {
-          y += aa[i].height;
+          g.drawString(aa[i].label, x, y +offset);
         }
       }
     }