set gap char modified
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 83e3a6d..30a8090 100755 (executable)
@@ -7,7 +7,7 @@ import jalview.datamodel.*;
 import jalview.analysis.*;\r
 \r
 \r
-public class SeqCanvas extends JPanel\r
+public class SeqCanvas extends JComponent\r
 {\r
      FeatureRenderer fr;\r
     BufferedImage             img;\r
@@ -122,7 +122,7 @@ public void fastPaint(int horizontal, int vertical)
     gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth,\r
                 -vertical * av.charHeight);\r
 \r
-    int sr = av.startRes, er = av.endRes + 1, ss = av.startSeq, es = av.endSeq,\r
+    int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq,\r
         transX = 0, transY = 0;\r
     if (horizontal > 0) // scrollbar pulled right, image to the left\r
     {\r
@@ -253,7 +253,6 @@ public void fastPaint(int horizontal, int vertical)
       int  endx   = startRes+cWidth-1;\r
       int  ypos  = 2*av.charHeight;\r
 \r
-\r
       while (ypos <= canvasHeight && startRes<av.alignment.getWidth() )\r
       {\r
         g.setColor(Color.black);\r
@@ -272,9 +271,21 @@ public void fastPaint(int horizontal, int vertical)
         if(av.scaleAboveWrapped)\r
           drawNorthScale(g, startRes, endx, ypos);\r
 \r
-        g.setClip(0, 0, cWidth*av.charWidth, getHeight());\r
+\r
+        // When printing we have an extra clipped region,\r
+        // the Printable page which we need to account for here\r
+        Shape clip = g.getClip();\r
+        if(clip==null)\r
+          g.setClip(0, 0, cWidth*av.charWidth, canvasHeight);\r
+        else\r
+          g.setClip(0,\r
+                    (int)clip.getBounds().getY(),\r
+                    cWidth*av.charWidth,\r
+                    (int)clip.getBounds().getHeight()\r
+                    );\r
+\r
         drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
-        g.setClip(null);\r
+        g.setClip(clip);\r
         g.translate(-LABEL_WEST,0);\r
 \r
         ypos += cHeight;\r
@@ -288,7 +299,7 @@ public void fastPaint(int horizontal, int vertical)
   }\r
 \r
 \r
-  public void drawPanel(Graphics g1,int x1,int x2, int y1, int y2,int startx, int starty,int offset) {\r
+  synchronized public void drawPanel(Graphics g1,int x1,int x2, int y1, int y2,int startx, int starty,int offset) {\r
 \r
     Graphics2D g = (Graphics2D)g1;\r
     g.setFont(av.getFont());\r