A {@link Painter} implementation composed of an array of Painter
s.CompoundPainter
provides a means for combining several individual Painter
s, or groups of them, into one logical unit. Each of the Painter
s are executed in order. BufferedImageOp filter effects can be applied to them together as a whole. The entire set of painting operations may be cached together.
For example, if I want to create a CompoundPainter that started with a blue background, had pinstripes on it running at a 45 degree angle, and those pinstripes appeared to "fade in" from left to right, I would write the following:
Color blue = new Color(0x417DDD); Color translucent = new Color(blue.getRed(), blue.getGreen(), blue.getBlue(), 0); panel.setBackground(blue); panel.setForeground(Color.LIGHT_GRAY); GradientPaint blueToTranslucent = new GradientPaint( new Point2D.Double(.4, 0), blue, new Point2D.Double(1, 0), translucent); MattePainter veil = new MattePainter(blueToTranslucent); veil.setPaintStretched(true); Painter pinstripes = new PinstripePainter(45); Painter backgroundPainter = new RectanglePainter(this.getBackground(), null); Painter p = new CompoundPainter(backgroundPainter, pinstripes, veil); panel.setBackgroundPainter(p);
@author rbair
|
|
|
|