sequences are private in SequenceGroup
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index bf1372e..b0027a8 100755 (executable)
@@ -671,8 +671,8 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
         AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
 \r
-        int x = 0;\r
-        int y = 0;\r
+        int x = 0, y = 0;\r
+        int column=0;\r
         char lastSS;\r
         int lastSSX;\r
         int iconOffset = av.charHeight / 2;\r
@@ -694,7 +694,6 @@ public class AnnotationPanel extends JPanel implements MouseListener,
             lastSS = ' ';\r
             lastSSX = 0;\r
 \r
-\r
             if (row.graph>0)\r
             {\r
                 if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] )\r
@@ -718,18 +717,20 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                 iconOffset = 0;\r
             }\r
 \r
-            int column = startRes;\r
-\r
-            while (column < endRes)\r
+            x = 0;\r
+            while (x < endRes-startRes)\r
             {\r
               if (av.hasHiddenColumns)\r
               {\r
-                column = av.getColumnSelection().adjustForHiddenColumns(column);\r
+                column = av.getColumnSelection().adjustForHiddenColumns(startRes+x);\r
                 if (column > row.annotations.length-1)\r
                 {\r
                   break;\r
                 }\r
               }\r
+              else\r
+                column = startRes+x;\r
+\r
 \r
                 if ((row.annotations.length <= column) ||\r
                         (row.annotations[column] == null))\r
@@ -741,7 +742,6 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                     validRes = true;\r
                 }\r
 \r
-                x = (column - startRes) * av.charWidth;\r
 \r
                 if (activeRow == i)\r
                 {\r
@@ -755,7 +755,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
                             if (v == column)\r
                             {\r
-                                g.fillRect((column - startRes) * av.charWidth, y,\r
+                                g.fillRect(x * av.charWidth, y,\r
                                     av.charWidth, row.height);\r
                             }\r
                         }\r
@@ -773,7 +773,8 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
                     if (column == 0 || row.graph>0)\r
                     {\r
-                        g.drawString(row.annotations[column].displayCharacter, x+charOffset,\r
+                        g.drawString(row.annotations[column].displayCharacter,\r
+                                     x*av.charWidth+charOffset,\r
                             y + iconOffset + 3);\r
                     }\r
                     else if (\r
@@ -784,8 +785,9 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                   (row.annotations[column].displayCharacter.length() <2 &&\r
                    row.annotations[column].secondaryStructure==' ')))\r
                     {\r
-                        g.drawString(row.annotations[column].displayCharacter, x+charOffset,\r
-                            y + iconOffset + 3);\r
+                        g.drawString(row.annotations[column].displayCharacter,\r
+                                     x*av.charWidth+charOffset,\r
+                                     y + iconOffset + 3);\r
                     }\r
                 }\r
 \r
@@ -803,13 +805,13 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                               //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
+                                              x*av.charWidth - lastSSX, 7, 8, 8);\r
                               break;\r
                             }\r
 \r
                             int sCol = (lastSSX / av.charWidth) + startRes;\r
                             int x1 = lastSSX;\r
-                            int x2 = x;\r
+                            int x2 = x*av.charWidth;\r
 \r
                            if(sCol==0 ||\r
                               row.annotations[sCol-1]==null ||\r
@@ -822,7 +824,10 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                             if(row.annotations[column]==null ||\r
                                row.annotations[column].secondaryStructure!='H')\r
                             {\r
-                              g.fillArc(x-av.charWidth, y+4+iconOffset, av.charWidth, 7, 270,180);\r
+                              g.fillArc(x*av.charWidth-av.charWidth,\r
+                                        y+4+iconOffset,\r
+                                        av.charWidth,\r
+                                        7, 270,180);\r
                               x2 -= av.charWidth/2;\r
                             }\r
 \r
@@ -832,8 +837,10 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                         case 'E':\r
                             g.setColor(SHEET_COLOUR);\r
                             g.fillRect(lastSSX, y + 4 + iconOffset,\r
-                                x - lastSSX - 4, 7);\r
-                            g.fillPolygon(new int[] { x - 5, x - 5, x },\r
+                                x*av.charWidth - lastSSX - 4, 7);\r
+                            g.fillPolygon(new int[] { x*av.charWidth - 5,\r
+                                          x*av.charWidth - 5,\r
+                                          x*av.charWidth },\r
                                 new int[]\r
                                 {\r
                                     y + iconOffset, y + 14 + iconOffset,\r
@@ -846,7 +853,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                         default:\r
                             g.setColor(Color.gray);\r
                             g.fillRect(lastSSX, y + 6 + iconOffset,\r
-                                x - lastSSX, 2);\r
+                                x*av.charWidth - lastSSX, 2);\r
 \r
                             break;\r
                         }\r
@@ -860,17 +867,17 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                             lastSS = ' ';\r
                         }\r
 \r
-                        lastSSX = x;\r
+                        lastSSX = x*av.charWidth;\r
                     }\r
                 }\r
-\r
                 column++;\r
+                x++;\r
             }\r
 \r
             if(column>=row.annotations.length)\r
               column = row.annotations.length-1;\r
 \r
-            x += av.charWidth;\r
+            x ++;\r
 \r
             if (row.hasIcons)\r
             {\r
@@ -883,7 +890,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                     //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
+                                    x*av.charWidth - lastSSX, 7, 8, 8);\r
                     break;\r
                   }\r
 \r
@@ -918,9 +925,11 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                         || row.annotations[endRes].secondaryStructure != 'E')\r
                     {\r
                       g.fillRect(lastSSX, y + 4 + iconOffset,\r
-                                 x - lastSSX - 4, 7);\r
+                                 x*av.charWidth - lastSSX - 4, 7);\r
                       g.fillPolygon(new int[]\r
-                                    {x - 5, x - 5, x},\r
+                                    {x*av.charWidth - 5,\r
+                                    x*av.charWidth - 5,\r
+                                    x*av.charWidth},\r
                                     new int[]\r
                                     {\r
                                     y + iconOffset, y + 14 + iconOffset,\r
@@ -929,7 +938,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                     }\r
                     else\r
                       g.fillRect(lastSSX, y + 4 + iconOffset,\r
-                                 x - lastSSX, 7);\r
+                                 x*av.charWidth - lastSSX, 7);\r
 \r
                     break;\r
 \r
@@ -937,7 +946,8 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                 default:\r
                     g.setColor(Color.gray);\r
                     if(!av.wrapAlignment || endRes==av.endRes)\r
-                      g.fillRect(lastSSX, y + 6 + iconOffset, x - lastSSX, 2);\r
+                      g.fillRect(lastSSX, y + 6 + iconOffset,\r
+                                 x*av.charWidth - lastSSX, 2);\r
 \r
                     break;\r
                 }\r
@@ -1033,24 +1043,25 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
       eRes = Math.min(eRes, aa.annotations.length);\r
 \r
-      int column = sRes;\r
+      int column;\r
       int aaMax = aa.annotations.length-1;\r
 \r
-      while( column < eRes )\r
+      while( x < eRes - sRes )\r
       {\r
+        column = sRes + x;\r
         if(av.hasHiddenColumns)\r
         {\r
           column = av.getColumnSelection().adjustForHiddenColumns(column);\r
-          if(column > aaMax)\r
-          {\r
-            break;\r
-          }\r
+        }\r
+\r
+        if (column > aaMax)\r
+        {\r
+          break;\r
         }\r
 \r
         if(aa.annotations[column]==null || aa.annotations[column-1]==null)\r
         {\r
-          x+=av.charWidth;\r
-          column ++;\r
+          x++;\r
           continue;\r
         }\r
 \r
@@ -1059,12 +1070,10 @@ public class AnnotationPanel extends JPanel implements MouseListener,
           y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight);\r
           y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight);\r
 \r
-          g.drawLine(x-av.charWidth/2, y1, x+av.charWidth/2, y2);\r
-          x += av.charWidth;\r
-\r
-          column++;\r
-\r
+          g.drawLine(x*av.charWidth-av.charWidth/2, y1, x*av.charWidth+av.charWidth/2, y2);\r
+          x ++;\r
        }\r
+\r
        if(aa.threshold!=null)\r
        {\r
            g.setColor(aa.threshold.colour);\r
@@ -1090,12 +1099,10 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
       eRes = Math.min(eRes, aa.annotations.length);\r
 \r
-      int x=0, y1, y2;\r
+      int x=0, y1=y, y2=y;\r
 \r
       float range = max - min;\r
 \r
-      y1 = y2 = y;\r
-\r
       if(min<0)\r
         y2 = y - (int)((0-min / (range))*aa.graphHeight);\r
 \r
@@ -1103,25 +1110,25 @@ public class AnnotationPanel extends JPanel implements MouseListener,
 \r
       g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2);\r
 \r
-\r
-      int column = sRes;\r
+      int column;\r
       int aaMax = aa.annotations.length-1;\r
 \r
-      while( column < eRes )\r
+      while( x < eRes-sRes )\r
       {\r
+        column = sRes + x;\r
         if(av.hasHiddenColumns)\r
         {\r
           column = av.getColumnSelection().adjustForHiddenColumns(column);\r
-          if(column > aaMax)\r
-          {\r
+        }\r
+\r
+        if(column > aaMax)\r
+        {\r
             break;\r
-          }\r
         }\r
 \r
         if (aa.annotations[column] == null)\r
         {\r
-          x += av.charWidth;\r
-          column ++;\r
+          x ++;\r
           continue;\r
         }\r
 \r
@@ -1129,12 +1136,11 @@ public class AnnotationPanel extends JPanel implements MouseListener,
           y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight);\r
 \r
           if(y1-y2>0)\r
-            g.fillRect(x, y2, av.charWidth, y1-y2 );\r
+            g.fillRect(x*av.charWidth, y2, av.charWidth, y1-y2 );\r
           else\r
-            g.fillRect(x, y1, av.charWidth, y2-y1 );\r
+            g.fillRect(x*av.charWidth, y1, av.charWidth, y2-y1 );\r
 \r
-          x += av.charWidth;\r
-          column ++;\r
+          x ++ ;\r
 \r
       }\r
       if(aa.threshold!=null)\r
@@ -1155,6 +1161,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
     // used by overview window\r
     public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes)\r
     {\r
+      eRes = Math.min(eRes, aa.annotations.length);\r
       g.setColor(Color.white);\r
       g.fillRect(0, 0, width, y);\r
       g.setColor(new Color(0, 0, 180));\r