int transX = 0;
int transY = 0;
- gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth,
- imgHeight, -horizontal * charWidth, -vertical * charHeight);
+ gg.copyArea(horizontal * charWidth, vertical * charHeight,
+ img.getWidth(), img.getHeight(), -horizontal * charWidth,
+ -vertical * charHeight);
if (horizontal > 0) // scrollbar pulled right, image to the left
{
}
else
{
- transY = imgHeight - ((vertical + 1) * charHeight);
+ transY = img.getHeight() - ((vertical + 1) * charHeight);
}
}
else if (vertical < 0)
// selectImage will hold any selection we have
// lcimg is a local *copy* of img which we'll draw selectImage on top of
- if (img == null)
- {
- setupImage();
- }
- if (img == null)
- {
- return;
- }
-
BufferedImage selectImage = drawSelectionGroup();
if (fastPaint || (getVisibleRect().width != g.getClipBounds().width)
fastPaint = false;
return;
}
+
+ int width = getWidth();
+ int height = getHeight();
+
+ width -= (width % charWidth);
+ height -= (height % charHeight);
+
+ if ((width < 1) || (height < 1))
+ {
+ return;
+ }
+
+ if (img == null || width != img.getWidth() || height != img.getHeight())
+ {
+ img = setupImage();
+ gg = (Graphics2D) img.getGraphics();
+ gg.setFont(av.getFont());
+ }
+ if (img == null)
+ {
+ return;
+ }
+
if (av.antiAlias)
{
}
gg.setColor(Color.white);
- gg.fillRect(0, 0, imgWidth, imgHeight);
+ gg.fillRect(0, 0, img.getWidth(), img.getHeight());
ViewportRanges ranges = av.getRanges();
if (av.getWrapAlignment())
repaint();
}
- private void setupImage()
+ /*private void setupImage()
{
// this draws the whole of the alignment
imgWidth = getWidth();
imgHeight = getHeight();
-
+
imgWidth -= (imgWidth % charWidth);
imgHeight -= (imgHeight % charHeight);
-
+
if ((imgWidth < 1) || (imgHeight < 1))
{
return;
}
-
-
+
try
{
img = new BufferedImage(imgWidth, imgHeight,
System.gc();
System.err.println("SeqCanvas OutOfMemory Redraw Error.\n" + er);
new OOMWarning("Creating alignment image for display", er);
-
+
return;
}
+
+ }*/
- }
-
- private BufferedImage setupSelectionImage()
+ private BufferedImage setupImage()
{
BufferedImage lcimg = null;
private BufferedImage drawSelectionGroup()
{
// get a new image of the correct size
- BufferedImage selectionImage = setupSelectionImage();
+ BufferedImage selectionImage = setupImage();
if (selectionImage == null)
{