01: /*
02: * @(#)SunkenBorder.java 2/12/2005
03: *
04: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.plaf.eclipse;
07:
08: import javax.swing.border.Border;
09: import javax.swing.plaf.UIResource;
10: import java.awt.*;
11:
12: public class SunkenBorder implements Border, UIResource {
13: protected Color _highlight;
14: protected Color _lightHighlight;
15: protected Color _shadow;
16: protected Color _darkShadow;
17: protected Insets _insets;
18:
19: public SunkenBorder(Color highlight, Color lightHighlight,
20: Color shadow, Color darkShadow, Insets insets) {
21: _highlight = highlight;
22: _lightHighlight = lightHighlight;
23: _shadow = shadow;
24: _darkShadow = darkShadow;
25: _insets = insets;
26: }
27:
28: /**
29: * Returns the insets of the border.
30: *
31: * @param c the component for which this border insets value applies
32: */
33: public Insets getBorderInsets(Component c) {
34: return _insets;
35: }
36:
37: /**
38: * Returns whether or not the border is opaque. If the border
39: * is opaque, it is responsible for filling in it's own
40: * background when painting.
41: */
42: public boolean isBorderOpaque() {
43: return true;
44: }
45:
46: public void paintBorder(Component c, Graphics g, int x, int y,
47: int width, int height) {
48: if (_insets.top > 0) {
49: g.setColor(_shadow);
50: g.drawLine(x, y, x + width, y);
51: }
52: if (_insets.left > 0) {
53: g.setColor(_shadow);
54: g.drawLine(x, y, x, y + height);
55: }
56: if (_insets.bottom > 0) {
57: g.setColor(_lightHighlight);
58: g.drawLine(x, y + height - 1, x + width, y + height - 1);
59: }
60: if (_insets.right > 0) {
61: g.setColor(_lightHighlight);
62: g.drawLine(x + width - 1, y, x + width - 1, y + height);
63: }
64: }
65: }
|