private int wrappedVisibleWidths; // number of wrapped widths displayed
- private Graphics2D gg;
+ // Don't do this! Graphics handles are supposed to be transient
+ //private Graphics2D gg;
/**
* Creates a new SeqCanvas object.
for (ScaleMark mark : marks)
{
int mpos = mark.column; // (i - startx - 1)
+// System.out.println("n " + mpos + " " + ypos);
if (mpos < 0)
{
continue;
int yPos = ypos + charHeight;
int startX = startx;
int endX = endx;
+
+ //System.out.println("v " + startx + " " + endx + " " + ypos);
+
if (av.hasHiddenColumns())
{
// fillRect origin is top left of rectangle
g.fillRect(0, y - charHeight, left ? labelWidthWest : labelWidthEast,
charHeight + 1);
-
+
if (value != -1)
{
/*
int xOffset = labelSpace - labelLength;
g.setColor(Color.black);
g.drawString(valueAsString, xOffset, y);
+
+ //System.out.println("v " + valueAsString + " " + xOffset + " " + y);
+
}
}
}
*/
public void fastPaint(int horizontal, int vertical)
{
- if (fastpainting || gg == null || img == null)
+ if (fastpainting || img == null)
{
return;
}
int transX = 0;
int transY = 0;
+ Graphics gg = img.getGraphics();
gg.copyArea(horizontal * charWidth, vertical * charHeight,
img.getWidth(), img.getHeight(), -horizontal * charWidth,
-vertical * charHeight);
gg.translate(transX, transY);
drawPanel(gg, startRes, endRes, startSeq, endSeq, 0);
gg.translate(-transX, -transY);
-
+ gg.dispose();
+
// Call repaint on alignment panel so that repaints from other alignment
// panel components can be aggregated. Otherwise performance of the
// overview window and others may be adversely affected.
@Override
public void paintComponent(Graphics g)
{
- super.paintComponent(g);
-
+ super.paintComponent(g);
+
int charHeight = av.getCharHeight();
int charWidth = av.getCharWidth();
-
+
ViewportRanges ranges = av.getRanges();
-
+
int width = getWidth();
int height = getHeight();
-
+
width -= (width % charWidth);
height -= (height % charHeight);
-
+
// selectImage is the selection group outline image
- BufferedImage selectImage = drawSelectionGroup(
- ranges.getStartRes(), ranges.getEndRes(),
- ranges.getStartSeq(), ranges.getEndSeq());
-
+ BufferedImage selectImage = drawSelectionGroup(ranges.getStartRes(),
+ ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq());
+
if ((img != null) && (fastPaint
|| (getVisibleRect().width != g.getClipBounds().width)
|| (getVisibleRect().height != g.getClipBounds().height)))
{
return;
}
- gg = (Graphics2D) img.getGraphics();
- gg.setFont(av.getFont());
}
-
+
+
+ Graphics2D gg = (Graphics2D) img.getGraphics();
+ gg.setFont(av.getFont());
+
if (av.antiAlias)
{
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
-
+
gg.setColor(Color.white);
gg.fillRect(0, 0, img.getWidth(), img.getHeight());
-
+
if (av.getWrapAlignment())
{
drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes());
drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(),
ranges.getStartSeq(), ranges.getEndSeq(), 0);
}
-
+
+
+ gg.dispose();
+
// lcimg is a local *copy* of img which we'll draw selectImage on top of
BufferedImage lcimg = buildLocalImage(selectImage);
g.drawImage(lcimg, 0, 0, this);
if (av.getScaleRightWrapped())
{
int x = labelWidthWest + viewportWidth * charWidth;
+
+ //System.out.println("shifting " + x);
g.translate(x, 0);
drawVerticalScale(g, startCol, endColumn, ypos, false);
g.translate(-x, 0);
*/
protected boolean drawMappedPositions(SearchResultsI results)
{
- if ((results == null) || (gg == null)) // JAL-2784 check gg is not null
+ if ((results == null) || (img == null)) // JAL-2784 check gg is not null
{
return false;
}
}
int transX = (firstCol - ranges.getStartRes()) * av.getCharWidth();
int transY = (firstSeq - ranges.getStartSeq()) * av.getCharHeight();
+ Graphics gg = img.getGraphics();
gg.translate(transX, transY);
drawPanel(gg, firstCol, lastCol, firstSeq, lastSeq, 0);
gg.translate(-transX, -transY);
+ gg.dispose();
}
return matchFound;
return;
}
- if (fastpainting || gg == null)
+ if (fastpainting || img == null)
{
return;
}
try
{
+
+ Graphics gg = img.getGraphics();
+
calculateWrappedGeometry(getWidth(), getHeight());
/*
*/
drawWrappedDecorators(gg, ranges.getStartRes());
+ gg.dispose();
+
repaint();
} finally
{
return;
}
+ Graphics gg = img.getGraphics();
+
ViewportRanges ranges = av.getRanges();
int viewportWidth = ranges.getViewportWidth();
int charWidth = av.getCharWidth();
/*
* white fill first to erase annotations
*/
+
+
gg.translate(xOffset, 0);
gg.setColor(Color.white);
gg.fillRect(labelWidthWest, ypos,
gg.translate(-xOffset, 0);
drawWrappedWidth(gg, ypos, startRes, endRes, canvasHeight);
+
}
/*
gg.setColor(Color.white);
gg.fillRect(0, canvasHeight - heightBelow, getWidth(), heightBelow);
}
- }
+ gg.dispose();
+ }
/**
* Shifts the visible alignment by the specified number of columns - left if
{
return;
}
+
+ Graphics gg = img.getGraphics();
+
int charWidth = av.getCharWidth();
int canvasHeight = getHeight();
* charWidth, heightToCopy, widthToCopy,
-wrappedRepeatHeightPx);
}
-
y += wrappedRepeatHeightPx;
xpos += viewportWidth;
}
}
+ gg.dispose();
}
*/
protected boolean drawMappedPositionsWrapped(SearchResultsI results)
{
- if ((results == null) || (gg == null)) // JAL-2784 check gg is not null
+ if ((results == null) || (img == null)) // JAL-2784 check gg is not null
{
return false;
}
int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1);
+
+ Graphics gg = img.getGraphics();
+
for (int seqNo = ranges.getStartSeq(); seqNo <= ranges
.getEndSeq(); seqNo++)
{
}
}
+ gg.dispose();
+
return matchFound;
}