Remove unnecessary panel, also nullFrame created only once
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index d9b8dd3..1bf3d38 100755 (executable)
@@ -51,11 +51,16 @@ public class AnnotationPanel
 \r
   public static int GRAPH_HEIGHT = 40;\r
 \r
+  boolean MAC = false;\r
+\r
   public AnnotationPanel(AlignmentPanel ap)\r
   {\r
+    if (System.getProperty("os.name").startsWith("Mac"))\r
+      MAC = true;\r
+\r
     this.ap = ap;\r
     av = ap.av;\r
-    this.setLayout(null);\r
+    setLayout(null);\r
     adjustPanelHeight();\r
 \r
     addMouseMotionListener(new MouseMotionAdapter()\r
@@ -126,9 +131,6 @@ public class AnnotationPanel
     }\r
 \r
     this.setSize(getSize().width, height);\r
-    if(ap!=null)\r
-       ap.annotationScroller.setSize(getSize().width, height);\r
-\r
 \r
     repaint();\r
 \r
@@ -206,6 +208,8 @@ public class AnnotationPanel
 \r
   public void paint(Graphics g)\r
   {\r
+\r
+\r
     imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;\r
 \r
     if (image == null || imgWidth != image.getWidth(this))\r
@@ -225,6 +229,8 @@ public class AnnotationPanel
     }\r
 \r
     drawComponent(gg, av.startRes, av.endRes + 1);\r
+    g.setColor(Color.white);\r
+    g.fillRect(0, 0, getSize().width, getSize().height);\r
     g.drawImage(image, 0, 0, this);\r
   }\r
 \r
@@ -286,14 +292,14 @@ public class AnnotationPanel
           g.setColor(Color.white);\r
           g.fillRect(0, 0, getSize().width, getSize().height);\r
           g.setColor(Color.black);\r
-          g.drawString("Alignment has no annotations", 20, 15);\r
+          if(av.validCharWidth)\r
+            g.drawString("Alignment has no annotations", 20, 15);\r
 \r
           return;\r
       }\r
 \r
       AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
 \r
-      int j;\r
       int x = 0;\r
       int y = 0;\r
       char lastSS;\r
@@ -356,8 +362,8 @@ public class AnnotationPanel
               x = (column - startRes) * av.charWidth;\r
 \r
 \r
-              if (validRes &&\r
-                      (row.annotations[column].displayCharacter.length() > 0))\r
+              if (av.validCharWidth && validRes &&\r
+                        (row.annotations[column].displayCharacter.length() > 0))\r
               {\r
                 int charOffset = (av.charWidth -\r
                     fm.charWidth(row.annotations[column].displayCharacter.charAt(\r
@@ -391,11 +397,21 @@ public class AnnotationPanel
                       {\r
                       case 'H':\r
                         g.setColor(HELIX_COLOUR);\r
+                        if (MAC)\r
+                        {\r
+                          //Off by 1 offset when drawing rects and ovals\r
+                          //to offscreen image on the MAC\r
+                          g.fillRoundRect(lastSSX, y + 4 + iconOffset,\r
+                                          x - lastSSX, 7, 8, 8);\r
+                          break;\r
+                        }\r
+\r
                         int sCol = (lastSSX / av.charWidth) + startRes;\r
                         int x1 = lastSSX;\r
                         int x2 = x;\r
 \r
-                       if(row.annotations[sCol-1]==null ||\r
+                       if(sCol==0 ||\r
+                          row.annotations[sCol-1]==null ||\r
                           row.annotations[sCol-1].secondaryStructure!='H')\r
                        {\r
                          g.fillArc(lastSSX, y+4+iconOffset, av.charWidth, 8, 90,180) ;\r
@@ -459,12 +475,22 @@ public class AnnotationPanel
               {\r
               case 'H':\r
                 g.setColor(HELIX_COLOUR);\r
+                if (MAC)\r
+                {\r
+                  //Off by 1 offset when drawing rects and ovals\r
+                  //to offscreen image on the MAC\r
+                  g.fillRoundRect(lastSSX, y + 4 + iconOffset,\r
+                                  x - lastSSX, 7, 8, 8);\r
+                  break;\r
+                }\r
+\r
 \r
                 int sCol = (lastSSX / av.charWidth) + startRes;\r
                 int x1 = lastSSX;\r
                 int x2 = x;\r
 \r
-               if(row.annotations[sCol-1]==null ||\r
+               if(sCol==0 ||\r
+                  row.annotations[sCol-1]==null ||\r
                   row.annotations[sCol-1].secondaryStructure!='H')\r
                {\r
                  g.fillArc(lastSSX, y+4+iconOffset, av.charWidth, 8, 90,180) ;\r
@@ -577,7 +603,6 @@ public class AnnotationPanel
       return;\r
 \r
 \r
-    eRes = Math.min(eRes, aa.annotations.length);\r
 \r
     int x = 0;\r
 \r
@@ -585,6 +610,9 @@ public class AnnotationPanel
     if(eRes<av.endRes)\r
       eRes++;\r
 \r
+    eRes = Math.min(eRes, aa.annotations.length);\r
+\r
+\r
     if(sRes==0)\r
     {\r
       sRes++;\r