View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.component;
21  
22  import java.awt.Color;
23  import java.awt.Component;
24  import java.awt.Graphics;
25  import java.awt.Insets;
26  
27  import javax.swing.border.BevelBorder;
28  
29  /***
30   * 
31   */
32  public class XNapBevelBorder extends BevelBorder
33  {
34  
35      //--- Constant(s) ---
36  
37      //--- Data field(s) ---
38  
39      //--- Constructor(s) ---
40  
41      public XNapBevelBorder(int bevelType)
42      {
43  		super(bevelType);
44      }
45  
46      //--- Method(s) ---
47  
48  	public Insets getBorderInsets(Component c)       
49  	{
50  		return new Insets(1, 1, 1, 1);
51      }
52  
53      public Insets getBorderInsets(Component c, Insets insets) 
54  	{
55          insets.left = insets.top = insets.right = insets.bottom = 1;
56          return insets;
57      }
58  
59      protected void paintLoweredBevel(Component c, Graphics g, int x, int y,
60  									 int width, int height)  
61  	{
62          Color oldColor = g.getColor();
63          int h = height;
64          int w = width;
65  
66          g.translate(x, y);
67  
68          g.setColor(getShadowOuterColor(c));
69          g.drawLine(0, 0, 0, h - 2);
70          g.drawLine(1, 0, w - 1, 0);
71  
72          g.setColor(getHighlightOuterColor(c));
73          g.drawLine(0, h - 1, w - 1, h - 1);
74          g.drawLine(w - 1, 1, w - 1, h - 2);
75  
76          g.translate(-x, -y);
77          g.setColor(oldColor);
78  
79      }
80  
81      protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
82                                      int width, int height)  
83  	{
84          Color oldColor = g.getColor();
85          int h = height;
86          int w = width;
87  
88          g.translate(x, y);
89  
90          g.setColor(getHighlightOuterColor(c));
91          g.drawLine(0, 0, 0, h - 2);
92          g.drawLine(1, 0, w - 1, 0);
93  
94          g.setColor(getShadowOuterColor(c));
95          g.drawLine(0, h - 1, w - 1, h - 1);
96          g.drawLine(w - 1, 1, w - 1, h - 2);
97  
98          g.translate(-x, -y);
99          g.setColor(oldColor);
100     }
101 
102 }