01: package org.zilonis.tool.ext.aerith.ui;
02:
03: /*
04: * AerithPanelPainter.java
05: *
06: * Created on March 31, 2006, 2:26 PM
07: *
08: * To change this template, choose Tools | Template Manager
09: * and open the template in the editor.
10: */
11:
12: import java.awt.AlphaComposite;
13: import java.awt.Color;
14: import java.awt.Composite;
15: import java.awt.Graphics2D;
16: import java.awt.Rectangle;
17: import java.awt.RenderingHints;
18: import java.awt.geom.Area;
19: import java.awt.geom.Ellipse2D;
20: import java.awt.geom.RoundRectangle2D;
21: import javax.swing.JComponent;
22:
23: import org.jdesktop.swingx.painter.AbstractPainter;
24:
25: /**
26: * Simple CompositePainter that gives the look we want
27: *
28: * @author rbair
29: */
30: public class AerithPanelPainter extends AbstractPainter {
31: /** Creates a new instance of AerithPanelPainter */
32: public AerithPanelPainter() {
33: super ();
34: setUseCache(false);
35: setAntialiasing(RenderingHints.VALUE_ANTIALIAS_ON);
36: }
37:
38: @Override
39: public void paintBackground(Graphics2D g2, JComponent c) {
40: float alpha = 0.8f;
41: Composite composite = g2.getComposite();
42: if (composite instanceof AlphaComposite) {
43: alpha *= ((AlphaComposite) composite).getAlpha();
44: }
45:
46: g2.setComposite(AlphaComposite.getInstance(
47: AlphaComposite.SRC_OVER, alpha));
48: g2.setColor(new Color(0.0f, 0.0f, 0.0f));
49: RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, c
50: .getWidth() - 1, c.getHeight() - 1, 24, 24);
51: g2.fill(rect);
52:
53: Ellipse2D ellipse = new Ellipse2D.Double(-c.getWidth(), c
54: .getHeight() / 3.0, c.getWidth() * 3.0,
55: c.getHeight() * 2.0);
56:
57: Area area = new Area(new Rectangle(0, 0, c.getWidth(), c
58: .getHeight()));
59: area.subtract(new Area(ellipse));
60: area.intersect(new Area(rect));
61:
62: alpha = .1f;
63: if (composite instanceof AlphaComposite) {
64: alpha *= ((AlphaComposite) composite).getAlpha();
65: }
66: g2.setComposite(AlphaComposite.getInstance(
67: AlphaComposite.SRC_OVER, alpha));
68: g2.setColor(new Color(1.0f, 1.0f, 1.0f));
69: g2.fill(area);
70: g2.setComposite(composite);
71: }
72: }
|