Sort by added to preferences
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 841f929..b1b63b3 100755 (executable)
@@ -41,7 +41,6 @@ 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
@@ -129,7 +128,7 @@ public class SeqCanvas extends JComponent
 \r
             if (value != -1)\r
             {\r
-                int x = LABEL_WEST - fm.stringWidth(value + "");\r
+                int x = LABEL_WEST - fm.stringWidth(String.valueOf(value))-av.charWidth/2;\r
                 g.drawString(value + "", x,\r
                     (ypos + (i * av.charHeight)) - (av.charHeight / 5));\r
             }\r
@@ -171,7 +170,7 @@ public class SeqCanvas extends JComponent
 \r
             if (value != -1)\r
             {\r
-                g.drawString(value + "", 0,\r
+                g.drawString(String.valueOf(value), av.charWidth/2,\r
                     (ypos + (i * av.charHeight)) - (av.charHeight / 5));\r
             }\r
         }\r
@@ -324,17 +323,32 @@ public class SeqCanvas extends JComponent
 \r
         if (av.scaleRightWrapped)\r
         {\r
-            LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000");\r
+            LABEL_EAST = fm.stringWidth(getMask()+"0");\r
         }\r
 \r
         if (av.scaleLeftWrapped)\r
         {\r
-            LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + "");\r
+            LABEL_WEST = fm.stringWidth(getMask());\r
         }\r
 \r
         return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
     }\r
 \r
+\r
+    /**\r
+     * Generates a string of zeroes.\r
+     * @return String\r
+     */\r
+    String getMask()\r
+    {\r
+      String mask = "0";\r
+      for (int i = av.alignment.getWidth(); i > 0; i /= 10)\r
+      {\r
+        mask += "0";\r
+      }\r
+      return mask;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -346,6 +360,7 @@ public class SeqCanvas extends JComponent
     public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight,\r
         int startRes)\r
     {\r
+\r
         AlignmentI al = av.getAlignment();\r
 \r
         FontMetrics fm = getFontMetrics(av.getFont());\r
@@ -354,14 +369,14 @@ public class SeqCanvas extends JComponent
 \r
         if (av.scaleRightWrapped)\r
         {\r
-            LABEL_EAST = fm.stringWidth(al.getWidth() + "000");\r
+            LABEL_EAST = fm.stringWidth(getMask()+"0");\r
         }\r
 \r
         int LABEL_WEST = 0;\r
 \r
         if (av.scaleLeftWrapped)\r
         {\r
-            LABEL_WEST = fm.stringWidth(al.getWidth() + "0");\r
+            LABEL_WEST = fm.stringWidth(getMask());\r
         }\r
 \r
         int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
@@ -383,9 +398,9 @@ public class SeqCanvas extends JComponent
 \r
             if (av.scaleRightWrapped)\r
             {\r
-                g.translate(canvasWidth - LABEL_EAST + av.charWidth, 0);\r
+                g.translate(canvasWidth - LABEL_EAST, 0);\r
                 drawEastScale(g, startRes, endx, ypos);\r
-                g.translate(-(canvasWidth - LABEL_EAST + av.charWidth), 0);\r
+                g.translate(-(canvasWidth - LABEL_EAST), 0);\r
             }\r
 \r
             g.translate(LABEL_WEST, 0);\r
@@ -409,6 +424,11 @@ public class SeqCanvas extends JComponent
                     cWidth * av.charWidth, (int) clip.getBounds().getHeight());\r
             }\r
 \r
+            if(av.alignment.getWidth() >= av.vconsensus.size())\r
+            {\r
+              endx = av.vconsensus.size()-2;\r
+            }\r
+\r
             drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
             g.setClip(clip);\r
             g.translate(-LABEL_WEST, 0);\r