Remove development code
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 6c2c07b..7f9ee97 100755 (executable)
@@ -41,15 +41,14 @@ public class SeqCanvas extends JComponent
     int imgWidth;\r
     int imgHeight;\r
     AlignViewport av;\r
-    boolean showScores = false;\r
     boolean displaySearch = false;\r
     int[] searchResults = null;\r
-    int chunkHeight;\r
-    int chunkWidth;\r
     boolean fastPaint = false;\r
     int LABEL_WEST;\r
     int LABEL_EAST;\r
 \r
+    boolean isOverview = false;\r
+\r
     /**\r
      * Creates a new SeqCanvas object.\r
      *\r
@@ -185,13 +184,17 @@ public class SeqCanvas extends JComponent
      */\r
     public void fastPaint(int horizontal, int vertical)\r
     {\r
-        if (((horizontal == 0) && (vertical == 0)) || (gg == null))\r
+        if (gg == null)\r
         {\r
             return;\r
         }\r
 \r
-        gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth,\r
-            -vertical * av.charHeight);\r
+        gg.copyArea(horizontal * av.charWidth,\r
+                    vertical * av.charHeight,\r
+                    imgWidth,\r
+                    imgHeight,\r
+                    -horizontal * av.charWidth,\r
+                    -vertical * av.charHeight);\r
 \r
         int sr = av.startRes;\r
         int er = av.endRes;\r
@@ -202,12 +205,13 @@ public class SeqCanvas extends JComponent
 \r
         if (horizontal > 0) // scrollbar pulled right, image to the left\r
         {\r
+            er ++;\r
             transX = (er - sr - horizontal) * av.charWidth;\r
             sr = er - horizontal;\r
         }\r
         else if (horizontal < 0)\r
         {\r
-            er = sr - horizontal;\r
+            er = sr - horizontal-1;\r
         }\r
         else if (vertical > 0) // scroll down\r
         {\r
@@ -233,10 +237,6 @@ public class SeqCanvas extends JComponent
         }\r
 \r
         gg.translate(transX, transY);\r
-\r
-        gg.setColor(Color.white);\r
-        gg.fillRect(0, 0, (er - sr + 1) * av.charWidth,\r
-            (es - ss) * av.charHeight);\r
         drawPanel(gg, sr, er, ss, es, sr, ss, 0);\r
         gg.translate(-transX, -transY);\r
 \r
@@ -258,6 +258,8 @@ public class SeqCanvas extends JComponent
     // Set this to false to force a full panel paint\r
     public void paintComponent(Graphics g)\r
     {\r
+        sr.renderGaps(av.renderGaps);\r
+\r
         if ((img != null) &&\r
                 (fastPaint || (getWidth() != g.getClipBounds().width) ||\r
                 (getHeight() != g.getClipBounds().height)))\r
@@ -280,20 +282,16 @@ public class SeqCanvas extends JComponent
             return;\r
         }\r
 \r
+\r
         img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);\r
         gg = (Graphics2D) img.getGraphics();\r
         gg.setFont(av.getFont());\r
         gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
-            RenderingHints.VALUE_ANTIALIAS_ON);\r
+          RenderingHints.VALUE_ANTIALIAS_ON);\r
 \r
         gg.setColor(Color.white);\r
         gg.fillRect(0, 0, imgWidth, imgHeight);\r
 \r
-        chunkWidth = getWrappedCanvasWidth(getWidth());\r
-        chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-\r
-        av.setChunkHeight(chunkHeight);\r
-        av.setChunkWidth(chunkWidth);\r
 \r
         if (av.getWrapAlignment())\r
         {\r
@@ -380,16 +378,25 @@ public class SeqCanvas extends JComponent
             LABEL_WEST = fm.stringWidth(getMask());\r
         }\r
 \r
+        int hgap = av.charHeight;\r
+        if(av.scaleAboveWrapped)\r
+          hgap += av.charHeight;\r
+\r
         int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
-        int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
+        int cHeight = av.getAlignment().getHeight() * av.charHeight;\r
+\r
+        av.setWrappedWidth(cWidth);\r
 \r
         av.endRes = av.startRes + cWidth;\r
 \r
+\r
         int endx = (startRes + cWidth) - 1;\r
-        int ypos = 2 * av.charHeight;\r
+        int ypos = hgap;\r
+\r
 \r
         while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
         {\r
+            g.setFont(av.getFont());\r
             g.setColor(Color.black);\r
 \r
             if (av.scaleLeftWrapped)\r
@@ -425,11 +432,30 @@ public class SeqCanvas extends JComponent
                     cWidth * av.charWidth, (int) clip.getBounds().getHeight());\r
             }\r
 \r
+            if (av.vconsensus!=null && av.alignment.getWidth() >= av.vconsensus.size())\r
+            {\r
+              endx = av.vconsensus.size() - 2;\r
+            }\r
+\r
+\r
             drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+\r
+            if(av.showAnnotation)\r
+            {\r
+              g.translate(0, cHeight + ypos + 3);\r
+              if(annotations==null)\r
+                annotations = new AnnotationPanel(av);\r
+\r
+              annotations.drawComponent( (Graphics2D) g, startRes, endx + 1);\r
+              g.translate(0, -cHeight - ypos);\r
+            }\r
             g.setClip(clip);\r
             g.translate(-LABEL_WEST, 0);\r
 \r
-            ypos += cHeight;\r
+            ypos += cHeight+getAnnotationHeight()+hgap;\r
+            if(av.showAnnotation)\r
+              ypos -= 3;\r
+\r
             startRes += cWidth;\r
             endx = (startRes + cWidth) - 1;\r
 \r
@@ -440,6 +466,18 @@ public class SeqCanvas extends JComponent
         }\r
     }\r
 \r
+    AnnotationPanel annotations;\r
+    int getAnnotationHeight()\r
+    {\r
+      if(!av.showAnnotation)\r
+        return 0;\r
+\r
+      if(annotations==null)\r
+        annotations = new AnnotationPanel(av);\r
+\r
+      return annotations.adjustPanelHeight();\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -452,25 +490,51 @@ public class SeqCanvas extends JComponent
      * @param starty DOCUMENT ME!\r
      * @param offset DOCUMENT ME!\r
      */\r
+\r
+    float aaRatio = 2f/3f;\r
+    public void increaseAARatio()\r
+    {\r
+      aaRatio += .025;\r
+      if(aaRatio>1)\r
+        aaRatio = 1;\r
+\r
+      repaint();\r
+    }\r
+\r
+    public void decreaseAARation()\r
+    {\r
+      aaRatio -= .025;\r
+      if(aaRatio<0)\r
+        aaRatio = 0;\r
+\r
+      repaint();\r
+    }\r
+\r
     synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1,\r
         int y2, int startx, int starty, int offset)\r
     {\r
         Graphics2D g = (Graphics2D) g1;\r
         g.setFont(av.getFont());\r
-        sr.renderGaps(av.renderGaps);\r
 \r
-        SequenceI nextSeq;\r
+\r
+  SequenceI nextSeq;\r
+\r
 \r
         /// First draw the sequences\r
         /////////////////////////////\r
         for (int i = y1; i < y2; i++)\r
         {\r
             nextSeq = av.alignment.getSequenceAt(i);\r
+            g.setFont(av.getFont());\r
+\r
 \r
             sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq),\r
-                x1, x2, (x1 - startx) * av.charWidth,\r
-                offset + ((i - starty) * av.charHeight), av.charWidth,\r
-                av.charHeight);\r
+                            x1, x2, (x1 - startx) * av.charWidth,\r
+                            offset + ( (i - starty) * av.charHeight), av.charWidth,\r
+                            av.charHeight);\r
+\r
+\r
+\r
 \r
             if (av.showSequenceFeatures)\r
             {\r
@@ -501,7 +565,7 @@ public class SeqCanvas extends JComponent
         }\r
 \r
 \r
-        if (group != null)\r
+        if (group != null && !isOverview)\r
         {\r
             do\r
             {\r
@@ -518,8 +582,12 @@ public class SeqCanvas extends JComponent
                     ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
                         1;\r
 \r
+                    if(sx+ex<0 || sx>imgWidth)\r
+                    {\r
+                      continue;\r
+                    }\r
 \r
-                    if ((sx < (x2-x1)*av.charWidth) &&\r
+                    if ( (sx <= (x2-x1)*av.charWidth) &&\r
                             group.sequences.contains(av.alignment.getSequenceAt(\r
                                     i)))\r
                     {\r
@@ -559,46 +627,75 @@ public class SeqCanvas extends JComponent
                     }\r
                     else\r
                     {\r
-                        if (inGroup)\r
+                      if (inGroup)\r
+                      {\r
+                        if (sx >= 0 && sx < imgWidth)\r
+                          g.drawLine(sx, oldY, sx, sy);\r
+\r
+                        if (sx + ex < imgWidth)\r
+                          g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+                        if (sx < 0)\r
                         {\r
-                            g.drawLine(sx, oldY, sx, sy);\r
-                            g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+                          ex += sx;\r
+                          sx = 0;\r
+                        }\r
 \r
-                            if (top != -1)\r
-                            {\r
-                                g.drawLine(sx, top, sx + ex, top);\r
-                                top = -1;\r
-                            }\r
+                        if (sx + ex > imgWidth)\r
+                          ex = imgWidth;\r
 \r
-                            if (bottom != -1)\r
-                            {\r
-                                g.drawLine(sx, bottom, sx + ex, bottom);\r
-                                bottom = -1;\r
-                            }\r
+                        else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+                          ex = (x2 - x1 + 1) * av.charWidth;\r
 \r
-                            inGroup = false;\r
+                        if (top != -1)\r
+                        {\r
+                          g.drawLine(sx, top, sx + ex, top);\r
+                          top = -1;\r
+                        }\r
+\r
+                        if (bottom != -1)\r
+                        {\r
+                          g.drawLine(sx, bottom, sx + ex, bottom);\r
+                          bottom = -1;\r
+                        }\r
+\r
+                        inGroup = false;\r
                         }\r
                     }\r
                 }\r
 \r
-\r
                 if (inGroup)\r
                 {\r
-                    if (top != -1)\r
-                    {\r
-                        g.drawLine(sx, top, sx + ex, top);\r
-                        top = -1;\r
-                    }\r
-\r
-                    if (bottom != -1)\r
-                    {\r
-                        g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
-                        bottom = -1;\r
-                    }\r
-\r
-                    sy = offset + ((i - starty) * av.charHeight);\r
+                  sy = offset + ( (i - starty) * av.charHeight);\r
+                  if (sx >= 0 && sx < imgWidth)\r
                     g.drawLine(sx, oldY, sx, sy);\r
+\r
+                  if (sx + ex < imgWidth)\r
                     g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+                  if (sx < 0)\r
+                  {\r
+                    ex += sx;\r
+                    sx = 0;\r
+                  }\r
+\r
+                  if (sx + ex > imgWidth)\r
+                    ex = imgWidth;\r
+                  else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+                    ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+                  if (top != -1)\r
+                  {\r
+                    g.drawLine(sx, top, sx + ex, top);\r
+                    top = -1;\r
+                  }\r
+\r
+                  if (bottom != -1)\r
+                  {\r
+                    g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
+                    bottom = -1;\r
+                  }\r
+\r
                     inGroup = false;\r
                 }\r
 \r