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