01: package gnu.kawa.models;
02:
03: import java.awt.*;
04: import java.awt.geom.*;
05:
06: public class WithPaint implements Paintable {
07: Paintable paintable;
08: Paint paint;
09:
10: public WithPaint(Paintable paintable, Paint paint) {
11: this .paintable = paintable;
12: this .paint = paint;
13: }
14:
15: public void paint(Graphics2D graphics) {
16: Paint saved = graphics.getPaint();
17: try {
18: graphics.setPaint(paint);
19: paintable.paint(graphics);
20: } finally {
21: graphics.setPaint(saved);
22: }
23: }
24:
25: public Rectangle2D getBounds2D() {
26: return paintable.getBounds2D();
27: }
28:
29: public Paintable transform(AffineTransform tr) {
30: return new WithPaint(paintable.transform(tr), paint);
31: }
32: }
|