001: /*
002: * @(#)FrameBorder.java
003: *
004: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
005: */
006: package com.jidesoft.plaf.vsnet;
007:
008: import javax.swing.border.Border;
009: import javax.swing.plaf.UIResource;
010: import java.awt.*;
011:
012: /**
013: * This class is an implementation of the DockableFrame border.
014: */
015: public class ResizeFrameBorder implements Border, UIResource {
016: protected Color _highlight;
017: protected Color _lightHighlight;
018: protected Color _shadow;
019: protected Color _darkShadow;
020: protected Insets _insets;
021:
022: public ResizeFrameBorder(Color highlight, Color lightHighlight,
023: Color shadow, Color darkShadow, Insets insets) {
024: _highlight = highlight;
025: _lightHighlight = lightHighlight;
026: _shadow = shadow;
027: _darkShadow = darkShadow;
028: _insets = insets;
029: }
030:
031: /**
032: * Returns the insets of the border.
033: *
034: * @param c the component for which this border insets value applies
035: */
036: public Insets getBorderInsets(Component c) {
037: return _insets;
038: }
039:
040: /**
041: * Returns whether or not the border is opaque. If the border
042: * is opaque, it is responsible for filling in it's own
043: * background when painting.
044: */
045: public boolean isBorderOpaque() {
046: return true;
047: }
048:
049: public void paintBorder(Component c, Graphics g, int x, int y,
050: int width, int height) {
051: if (_insets.top > 0) {
052: g.setColor(_highlight);
053: g.drawLine(x, y, x + width, y);
054:
055: g.setColor(_lightHighlight);
056: g.drawLine(x + 1, y + 1, x + width - 2, y + 1);
057: if (_insets.left == 0) {
058: g.drawLine(x, y + 1, x + 1, y + 1);
059: }
060: if (_insets.right == 0) {
061: g.drawLine(x + width - 2, y + 1, x + width - 1, y + 1);
062: }
063:
064: g.setColor(_highlight);
065: g.drawLine(x + 2, y + 2, x + width - 4, y + 2);
066: g.drawLine(x + 2, y + 3, x + width - 4, y + 3);
067:
068: if (_insets.left == 0) {
069: g.drawLine(x, y + 2, x + 2, y + 2);
070: g.drawLine(x, y + 3, x + 2, y + 3);
071: }
072: if (_insets.right == 0) {
073: g.drawLine(x + width - 4, y + 2, x + width - 1, y + 2);
074: g.drawLine(x + width - 4, y + 3, x + width - 1, y + 3);
075: }
076: }
077:
078: if (_insets.left > 0) {
079: g.setColor(_highlight);
080: g.drawLine(x, y, x, y + height);
081:
082: g.setColor(_lightHighlight);
083: g.drawLine(x + 1, y + 1, x + 1, y + height - 2);
084:
085: if (_insets.top == 0) {
086: g.drawLine(x + 1, y, x + 1, y + 1);
087: }
088: if (_insets.bottom == 0) {
089: g
090: .drawLine(x + 1, y + height - 2, x + 1, y
091: + height - 1);
092: }
093:
094: g.setColor(_highlight);
095: g.drawLine(x + 2, y + 2, x + 2, y + height - 4);
096: g.drawLine(x + 3, y + 2, x + 3, y + height - 4);
097: if (_insets.top == 0) {
098: g.drawLine(x + 2, y, x + 2, y + 2);
099: g.drawLine(x + 3, y, x + 3, y + 2);
100: }
101: if (_insets.bottom == 0) {
102: g
103: .drawLine(x + 2, y + height - 4, x + 2, y
104: + height - 1);
105: g
106: .drawLine(x + 3, y + height - 4, x + 3, y
107: + height - 1);
108: }
109: }
110:
111: if (_insets.bottom > 0) {
112: g.setColor(_darkShadow);
113: g.drawLine(x, y + height - 1, x + width, y + height - 1);
114:
115: g.setColor(_shadow);
116: g.drawLine(x + 1, y + height - 2, x + width - 2, y + height
117: - 2);
118: if (_insets.left == 0) {
119: g.drawLine(x, y + height - 2, x + 1, y + height - 2);
120: }
121: if (_insets.right == 0) {
122: g.drawLine(x + width - 2, y + height - 2,
123: x + width - 1, y + height - 2);
124: }
125:
126: g.setColor(_highlight);
127: g.drawLine(x + 2, y + height - 3, x + width - 4, y + height
128: - 3);
129: g.drawLine(x + 2, y + height - 4, x + width - 4, y + height
130: - 4);
131: if (_insets.left == 0) {
132: g.drawLine(x, y + height - 3, x + 2, y + height - 3);
133: g.drawLine(x, y + height - 4, x + 2, y + height - 4);
134: }
135: if (_insets.right == 0) {
136: g.drawLine(x + width - 4, y + height - 3,
137: x + width - 1, y + height - 3);
138: g.drawLine(x + width - 4, y + height - 4,
139: x + width - 1, y + height - 4);
140: }
141: }
142:
143: if (_insets.right > 0) {
144: g.setColor(_darkShadow);
145: g.drawLine(x + width - 1, y, x + width - 1, y + height);
146:
147: g.setColor(_shadow);
148: g.drawLine(x + width - 2, y + 1, x + width - 2, y + height
149: - 2);
150: if (_insets.top == 0) {
151: g.drawLine(x + width - 2, y, x + width - 2, y + 1);
152: }
153: if (_insets.bottom == 0) {
154: g.drawLine(x + width - 2, y + height - 2,
155: x + width - 2, y + height - 1);
156: }
157:
158: g.setColor(_highlight);
159: g.drawLine(x + width - 3, y + 2, x + width - 3, y + height
160: - 4);
161: g.drawLine(x + width - 4, y + 2, x + width - 4, y + height
162: - 4);
163: if (_insets.top == 0) {
164: g.drawLine(x + width - 3, y, x + width - 3, y + 2);
165: g.drawLine(x + width - 4, y, x + width - 4, y + 2);
166: }
167: if (_insets.bottom == 0) {
168: g.drawLine(x + width - 3, y + height - 4,
169: x + width - 3, y + height - 1);
170: g.drawLine(x + width - 4, y + height - 4,
171: x + width - 4, y + height - 1);
172: }
173: }
174: }
175: }
|