01: /*
02: * TitlePanel.java
03: *
04: * Created on 20 March 2007, 16:18
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package com.xoetrope.tools;
11:
12: import java.awt.AlphaComposite;
13: import java.awt.Color;
14: import java.awt.Composite;
15: import java.awt.Graphics;
16: import java.awt.Graphics2D;
17: import java.awt.RenderingHints;
18: import java.awt.geom.Arc2D;
19: import net.xoetrope.swing.XPanel;
20: import org.jdesktop.swingx.painter.Painter;
21:
22: /**
23: *
24: * @author kingsley.elmes
25: */
26: public class TitlePanel extends XPanel {
27: private Painter painter;
28:
29: /** Creates a new instance of TitlePanel */
30: public TitlePanel() {
31: }
32:
33: public void paintComponent(Graphics g) {
34: int width = getSize().width;
35: int height = getSize().height;
36: Color bkColor = getBackground();
37: if (usesLaf)
38: bkColor = bkColor.brighter();
39: else
40: bkColor = bkColor.darker();
41:
42: if (isOpaque() || translucent) {
43: if (usesLaf)
44: super .paintComponent(g);
45: else if (painter != null)
46: painter.paint((Graphics2D) g, this , width, height);
47: else {
48: g.setColor(getBackground());
49:
50: Graphics2D g2d = (Graphics2D) g;
51: g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
52: RenderingHints.VALUE_ANTIALIAS_ON);
53:
54: g2d.fillRect(0, 28, width, (height - 56));
55: g2d.fillRect(7, (height - 28), (width - 14), height);
56: g2d.fillRect(0, (height - 28), 7, 21);
57: g2d.fillRect((width - 7), (height - 28), 7, 21);
58:
59: Arc2D.Double leftArc = new Arc2D.Double(0,
60: (height - 14), 14, 14, 180, 90, Arc2D.PIE);
61: g2d.fill(leftArc);
62:
63: Arc2D.Double rightArc = new Arc2D.Double((width - 14),
64: (height - 14), 14, 14, 270, 90, Arc2D.PIE);
65: g2d.fill(rightArc);
66:
67: g2d.setColor(Color.gray);
68: Composite composite = g2d.getComposite();
69: Composite fade = AlphaComposite.getInstance(
70: AlphaComposite.SRC_OVER, 0.8F);
71: g2d.setComposite(fade);
72:
73: g2d.fillRect(7, 0, (width - 14), 28);
74: g2d.fillRect(0, 7, 7, 21);
75: g2d.fillRect((width - 7), 7, 7, 21);
76:
77: Arc2D.Double leftTitleArc = new Arc2D.Double(0, 0, 14,
78: 14, 90, 90, Arc2D.PIE);
79: g2d.fill(leftTitleArc);
80:
81: Arc2D.Double rightTitleArc = new Arc2D.Double(
82: (width - 14), 0, 14, 14, 0, 90, Arc2D.PIE);
83: g2d.fill(rightTitleArc);
84:
85: fade = AlphaComposite.getInstance(
86: AlphaComposite.SRC_OVER, 1.0F);
87: g2d.setComposite(fade);
88: }
89: }
90: }
91: }
|