KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > aqua > AquaRoundedLowerBorder


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * AquaRoundedLowerBorder.java
21  *
22  * Created on March 14, 2004, 7:50 PM
23  */

24
25 package org.netbeans.swing.plaf.aqua;
26
27 import org.netbeans.swing.plaf.util.UIUtils;
28
29 import javax.swing.*;
30 import javax.swing.border.Border JavaDoc;
31 import java.awt.*;
32 import java.awt.geom.Area JavaDoc;
33 import java.awt.geom.GeneralPath JavaDoc;
34
35 /** Border for editor and view tab controls with rounded corners. Cooperates
36  * with DropShadowBorder for floating panels.
37  *
38  * @author Tim Boudreau
39  */

40 public class AquaRoundedLowerBorder implements Border JavaDoc {
41     static int ARCSIZE = AquaEditorTabControlBorder.ARCSIZE;
42     
43     /** Creates a new instance of AquaRoundedLowerBorder */
44     public AquaRoundedLowerBorder() {
45     }
46
47     public Insets getBorderInsets(Component component) {
48         return isFloating(component) ? new Insets (0,0,0,0) : new Insets (0,2,3,2);
49     }
50
51     public boolean isBorderOpaque() {
52         return true;
53     }
54     
55     private boolean isFloating (Component c) {
56         boolean result = c.getParent() != null;
57         if (result) {
58             result = c.getParent().getParent() != null;
59         }
60         if (result) {
61             result = c.getParent().getParent() instanceof JLayeredPane;
62         }
63         return result;
64     }
65
66     public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
67         if (isFloating(c)) {
68             return;
69         }
70         UIUtils.configureRenderingHints(g);
71         int halfArc = ARCSIZE/2;
72         
73         Color col = UIUtils.getMiddle(UIManager.getColor("controlShadow"),
74             UIManager.getColor("control"));
75
76         g.setColor(col);
77         g.drawLine(x, y, x, y+h-halfArc);
78         g.drawLine(x+w-1, y, x+w-1, y+h-halfArc);
79
80         g.drawArc (x, y+h-(ARCSIZE+1), ARCSIZE, ARCSIZE, 180, 90);
81         g.drawArc (x+w-(ARCSIZE+1), y+h-(ARCSIZE+1), ARCSIZE, ARCSIZE, 270, 90);
82
83         g.drawLine (x+(ARCSIZE/2)-3, y+h-1, x+w-(ARCSIZE/2), y+h-1);
84         
85     }
86 }
87
Popular Tags