*/
return;
}
+
try
{
if (dragMode == DragMode.Resize)
}
private volatile boolean imageFresh = false;
-
private Rectangle visibleRect = new Rectangle(),
clipBounds = new Rectangle();
@Override
public void paintComponent(Graphics g)
{
-
// BH: note that this method is generally recommended to
// call super.paintComponent(g). Otherwise, the children of this
// component will not be rendered. That is not needed here
// just a JPanel contained in a JViewPort.
computeVisibleRect(visibleRect);
-
g.setColor(Color.white);
g.fillRect(0, 0, visibleRect.width, visibleRect.height);
.getClipBounds(clipBounds)).width)
|| (visibleRect.height != clipBounds.height))
{
- g.drawImage(image, 0, 0, this);
+
+
+ g.drawImage(image, 0, 0, this);
fastPaint = false;
return;
}
}
-
imgWidth = (ranges.getEndRes() - ranges.getStartRes() + 1)
* av.getCharWidth();
-
if (imgWidth < 1)
{
fastPaint = false;
gg = (Graphics2D) image.getGraphics();
}
-
- drawComponent(gg, ranges.getStartRes(), av.getRanges().getEndRes() + 1);
+
+ drawComponent(gg, av.getRanges().getStartRes(),
+ av.getRanges().getEndRes() + 1);
gg.dispose();
imageFresh = false;
g.drawImage(image, 0, 0, this);
fastPaint = false;
return;
}
-
Graphics2D gg = (Graphics2D) image.getGraphics();
- gg.copyArea(0, 0, imgWidth, getHeight(),
- -horizontal * av.getCharWidth(), 0);
-
- if (horizontal > 0) // scrollbar pulled right, image to the left
- {
- transX = (er - sr - horizontal) * av.getCharWidth();
- sr = er - horizontal;
- }
- else if (horizontal < 0)
- {
- er = sr - horizontal;
+ if (imgWidth>Math.abs(horizontal*av.getCharWidth())) {
+ //scroll is less than imgWidth away so can re-use buffered graphics
+ gg.copyArea(0, 0, imgWidth, getHeight(),
+ -horizontal * av.getCharWidth(), 0);
+
+ if (horizontal > 0) // scrollbar pulled right, image to the left
+ {
+ transX = (er - sr - horizontal) * av.getCharWidth();
+ sr = er - horizontal;
+ }
+ else if (horizontal < 0)
+ {
+ er = sr - horizontal;
+ }
}
gg.translate(transX, 0);
gg.translate(-transX, 0);
gg.dispose();
-
fastPaint = true;
// Call repaint on alignment panel so that repaints from other alignment
private int[] bounds = new int[2];
private boolean allowFastPaint;
-
@Override
public int[] getVisibleVRange()
{
{
allowFastPaint = false;
}
-
}