JAL-2600 Add in IdCanvas and checks for 0 size images
[jalview.git] / src / jalview / gui / SeqCanvas.java
index fdad32b..f1b473c 100755 (executable)
@@ -303,23 +303,26 @@ 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;
 
-      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;
+        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