View Javadoc

1   package org.telscenter.pas.ui.border;
2   
3   import java.awt.Color;
4   import java.awt.Component;
5   import java.awt.Graphics;
6   import java.awt.Insets;
7   
8   import javax.swing.border.BevelBorder;
9   
10  public class InvertedBevelBorder extends BevelBorder {
11  
12  	
13  	private Color leftColor;
14  	private Color rightColor;
15  	
16  	public InvertedBevelBorder(int bevelType,Color leftColor, Color rightColor) {
17  		super(bevelType);
18  		setLeftColor(leftColor);
19  		setRightColor(rightColor);
20  	}
21  	
22  	public InvertedBevelBorder(int bevelType) {
23  		super(bevelType);
24  		// TODO Auto-generated constructor stub
25  	}
26  
27  	public InvertedBevelBorder(int bevelType, Color highlightOuterColor,
28  			Color highlightInnerColor, Color shadowOuterColor,
29  			Color shadowInnerColor) {
30  		super(bevelType, highlightOuterColor, highlightInnerColor,
31  				shadowOuterColor, shadowInnerColor);
32  		// TODO Auto-generated constructor stub
33  	}
34  	
35  	protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
36  		
37  		 Color oldColor = g.getColor();
38  	        int h = height;
39  	        int w = width;
40  
41  	        g.translate(x, y);
42  
43  	        //out hightlight
44  	         
45  	        g.setColor(getLeftColor());
46  	        g.drawLine(0, 0, 0, h-2);
47  	        
48  	        g.setColor(getRightColor());
49  	        g.drawLine(1, 0, w-2, 0); //read
50  
51  	        g.setColor(getLeftColor());
52  	        g.drawLine(0, h-1, w-1, h-1);
53  	        g.setColor(getRightColor());
54  	        g.drawLine(w-1, 0, w-1, h-2);
55  
56  	        g.translate(-x, -y);
57  	        g.setColor(oldColor);
58  	}
59  
60      public Insets getBorderInsets(Component c)       {
61      		return getBorderInsets(c, new Insets(3,4,3,4));
62      }
63      
64      /*** 
65       * Reinitialize the insets parameter with this Border's current Insets. 
66       * @param c the component for which this border insets value applies
67       * @param insets the object to be reinitialized
68       */
69      public Insets getBorderInsets(Component c, Insets insets) {
70      		insets.left = insets.right = 4;
71      		insets.top = insets.bottom = 3;
72          return insets;
73      }
74      
75  	public Color getLeftColor() {
76  		return leftColor;
77  	}
78  
79  	public void setLeftColor(Color leftColor) {
80  		this.leftColor = leftColor;
81  	}
82  
83  	public Color getRightColor() {
84  		return rightColor;
85  	}
86  
87  	public void setRightColor(Color rightColor) {
88  		this.rightColor = rightColor;
89  	}
90  
91  
92  }