| 1 |
/* |
| 2 |
* @(#)RaisedBorder.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 com.jidesoft.plaf.XPUtils; |
| 9 |
|
| 10 |
import javax.swing.border.Border; |
| 11 |
import javax.swing.plaf.UIResource; |
| 12 |
import java.awt.*; |
| 13 |
|
| 14 |
public class RaisedBorder implements Border, UIResource { |
| 15 |
protected Color _highlight; |
| 16 |
protected Color _lightHighlight; |
| 17 |
protected Color _shadow; |
| 18 |
protected Color _darkShadow; |
| 19 |
protected Insets _insets; |
| 20 |
|
| 21 |
public RaisedBorder(Color highlight, Color lightHighlight, |
| 22 |
Color shadow, Color darkShadow, Insets insets) { |
| 23 |
_highlight = highlight; |
| 24 |
_lightHighlight = lightHighlight; |
| 25 |
_shadow = shadow; |
| 26 |
_darkShadow = darkShadow; |
| 27 |
_insets = insets; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Returns the insets of the border. |
| 32 |
* |
| 33 |
* @param c the component for which this border insets value applies |
| 34 |
*/ |
| 35 |
public Insets getBorderInsets(Component c) { |
| 36 |
return _insets; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Returns whether or not the border is opaque. If the border |
| 41 |
* is opaque, it is responsible for filling in it's own |
| 42 |
* background when painting. |
| 43 |
*/ |
| 44 |
public boolean isBorderOpaque() { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
public void paintBorder(Component c, Graphics g, int x, int y, |
| 49 |
int width, int height) { |
| 50 |
if (XPUtils.isXPStyleOn()) { |
| 51 |
if (_insets.top > 0) { |
| 52 |
g.setColor(_shadow); |
| 53 |
g.drawLine(x, y, x + width, y); |
| 54 |
} |
| 55 |
if (_insets.left > 0) { |
| 56 |
g.setColor(_shadow); |
| 57 |
g.drawLine(x, y, x, y + height); |
| 58 |
} |
| 59 |
if (_insets.bottom > 0) { |
| 60 |
g.setColor(_shadow); |
| 61 |
g.drawLine(x, y + height - 1, x + width, y + height - 1); |
| 62 |
} |
| 63 |
if (_insets.right > 0) { |
| 64 |
g.setColor(_shadow); |
| 65 |
g.drawLine(x + width - 1, y, x + width - 1, y + height); |
| 66 |
} |
| 67 |
} |
| 68 |
else { |
| 69 |
if (_insets.top > 0) { |
| 70 |
g.setColor(_highlight); |
| 71 |
g.drawLine(x, y, x + width, y); |
| 72 |
g.setColor(_lightHighlight); |
| 73 |
g.drawLine(x + 1, y + 1, x + width - 1, y + 1); |
| 74 |
} |
| 75 |
if (_insets.left > 0) { |
| 76 |
g.setColor(_highlight); |
| 77 |
g.drawLine(x, y, x, y + height); |
| 78 |
g.setColor(_lightHighlight); |
| 79 |
g.drawLine(x + 1, y + 1, x + 1, y + height - 1); |
| 80 |
} |
| 81 |
if (_insets.bottom > 0) { |
| 82 |
g.setColor(_shadow); |
| 83 |
g.drawLine(x + 1, y + height - 2, x + width - 1, y + height - 2); |
| 84 |
g.setColor(_darkShadow); |
| 85 |
g.drawLine(x, y + height - 1, x + width, y + height - 1); |
| 86 |
} |
| 87 |
if (_insets.right > 0) { |
| 88 |
g.setColor(_shadow); |
| 89 |
g.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2); |
| 90 |
g.setColor(_darkShadow); |
| 91 |
g.drawLine(x + width - 1, y, x + width - 1, y + height); |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
} |