JAL-2600 Add in IdCanvas and checks for 0 size images
[jalview.git] / src / jalview / gui / SeqCanvas.java
index e8f9c5b..f1b473c 100755 (executable)
@@ -303,16 +303,27 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
       imgWidth -= (imgWidth % charWidth);
       imgHeight -= (imgHeight % charHeight);
 
-      BufferedImage newimg = new BufferedImage(imgWidth, imgHeight,
-              BufferedImage.TYPE_INT_ARGB);
+      if ((imgWidth > 0) && (imgHeight > 0))
+      {
+        BufferedImage newimg = new BufferedImage(imgWidth, imgHeight,
+                BufferedImage.TYPE_INT_ARGB);
 
-      gg = (Graphics2D) newimg.getGraphics();
-      gg.setFont(av.getFont());
-      gg.drawImage(img, null, 0, 0);
-      img = newimg;
+        gg = (Graphics2D) newimg.getGraphics();
+        gg.setFont(av.getFont());
+        gg.drawImage(img, null, 0, 0);
+        img = newimg;
 
-      transX = (er - horizontal - sr) * charWidth;
-      sr = er - horizontal - sr;
+        if (horizontal != 0)
+        {
+          transX = (er - horizontal - sr) * charWidth;
+          sr = er - horizontal - sr;
+        }
+        else if (vertical != 0)
+        {
+          transY = imgHeight - ((vertical + 1) * charHeight);
+          ss = es - vertical - ss;
+        }
+      }
     }
     else
     {
@@ -1044,6 +1055,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
       else if (evt.getPropertyName().equals("endseq"))
       {
         // resize
+        fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue(),
+                true);
       }
     }
   }