_origin = origin;
// redraw offscreen if needed
if (_offscreen == null) { // full redraw
_offscreen = new Image(getDisplay(), size.x, size.y);
GC gc = new GC(_offscreen);
RenderingContext c = newRenderingContext(gc);
c.getOutputDevice().setClip(new java.awt.Rectangle(0, 0, size.x, size.y));
doRender(c);
gc.dispose();
} else if (_specialRedraw instanceof RedrawTarget) { // targetted
Rectangle target = ((RedrawTarget) _specialRedraw)._target;
GC gc = new GC(_offscreen);
RenderingContext c = newRenderingContext(gc);
c.getOutputDevice().setClip(convertRectangle(target));
doRender(c);
gc.dispose();
} else if (_specialRedraw instanceof RedrawNewOrigin) { // scroll
Point previousOrigin = ((RedrawNewOrigin) _specialRedraw)._previousOrigin;
Image img = new Image(getDisplay(), size.x, size.y);
GC gc = new GC(img);
gc.drawImage(_offscreen, previousOrigin.x - _origin.x, previousOrigin.y
- _origin.y);
Area a = new Area();
if (_origin.x < previousOrigin.x) {
int width = Math.min(size.x, previousOrigin.x - _origin.x);
a.add(new Area(new java.awt.Rectangle(0, 0, width, size.y)));
} else if (_origin.x > previousOrigin.x) {
int width = Math.min(size.x, _origin.x - previousOrigin.x);
a.add(new Area(new java.awt.Rectangle(size.x - width, 0, width, size.y)));
}
if (_origin.y < previousOrigin.y) {
int height = Math.min(size.y, previousOrigin.y - _origin.y);
a.add(new Area(new java.awt.Rectangle(0, 0, size.x, height)));
} else if (_origin.y > previousOrigin.y) {
int height = Math.min(size.y, _origin.y - previousOrigin.y);
a.add(new Area(new java.awt.Rectangle(0, size.y - height, size.x, height)));
}
RenderingContext c = newRenderingContext(gc);
c.getOutputDevice().setClip(a);
doRender(c);
gc.dispose();
_offscreen.dispose();
_offscreen = img;
} else if (_specialRedraw instanceof RedrawNewSize) { // adjust
// size
Point previousSize = ((RedrawNewSize) _specialRedraw)._previousSize;
Image img = new Image(getDisplay(), size.x, size.y);
GC gc = new GC(img);
gc.drawImage(_offscreen, 0, 0);
if (size.x > previousSize.x || size.y > previousSize.y) {
Area a = new Area();
if (size.x > previousSize.x) {
a.add(new Area(new java.awt.Rectangle(previousSize.x, 0, size.x
- previousSize.x, size.y)));
}
if (size.y > previousSize.y) {
a.add(new Area(new java.awt.Rectangle(0, previousSize.y, size.x, size.y
- previousSize.y)));
}
RenderingContext c = newRenderingContext(gc);
c.getOutputDevice().setClip(a);
doRender(c);
gc.setClipping((Rectangle) null);
}
gc.dispose();
_offscreen.dispose();