01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexander T. Simbirtsev
19: * @version $Revision$
20: */package javax.swing.border;
21:
22: import java.awt.Color;
23: import java.awt.Component;
24: import java.awt.Graphics;
25:
26: public class SoftBevelBorder extends BevelBorder {
27:
28: private static final int INSETS_SIZE = 3;
29:
30: public SoftBevelBorder(final int bevelType,
31: final Color highlightOuterColor,
32: final Color highlightInnerColor,
33: final Color shadowOuterColor, final Color shadowInnerColor) {
34: super (bevelType, highlightOuterColor, highlightInnerColor,
35: shadowOuterColor, shadowInnerColor);
36: }
37:
38: public SoftBevelBorder(final int bevelType, final Color highlight,
39: final Color shadow) {
40: super (bevelType, highlight, shadow);
41: }
42:
43: public SoftBevelBorder(final int bevelType) {
44: super (bevelType);
45: }
46:
47: int getInsetSize() {
48: return INSETS_SIZE;
49: }
50:
51: public void paintBorder(final Component c, final Graphics g,
52: final int x, final int y, final int width, final int height) {
53: Color oldColor = g.getColor();
54: Color color = (bevelType == BevelBorder.RAISED) ? getShadowOuterColor(c)
55: : getHighlightOuterColor(c);
56: g.setColor(color);
57: g
58: .drawLine(x + 2, y + height - 1, x + width - 1, y
59: + height - 1);
60: g.drawLine(x + width - 1, y + 2, x + width - 1, y + height - 1);
61:
62: color = (bevelType == BevelBorder.RAISED) ? getShadowInnerColor(c)
63: : getHighlightInnerColor(c);
64: g.setColor(color);
65: g.drawLine(x + width - 2, y + height - 2, x + width - 2, y
66: + height - 2);
67:
68: color = (bevelType == BevelBorder.RAISED) ? getHighlightInnerColor(c)
69: : getShadowInnerColor(c);
70: g.setColor(color);
71: g.drawLine(x + 2, y + 1, x + width - 2, y + 1);
72: g.drawLine(x + 1, y + 2, x + 1, y + height - 2);
73: g.drawLine(x, y, x + width - 1, y);
74: g.drawLine(x, y, x, y + height - 1);
75: g.drawLine(x + 2, y + 2, x + 2, y + 2);
76:
77: color = (bevelType == BevelBorder.RAISED) ? getHighlightOuterColor(c)
78: : getShadowOuterColor(c);
79: g.setColor(color);
80: g.drawLine(x, y, x + width - 2, y);
81: g.drawLine(x, y, x, y + height - 3);
82: g.drawLine(x + 1, y + 1, x + 1, y + 1);
83: g.setColor(oldColor);
84: }
85:
86: public boolean isBorderOpaque() {
87: return false;
88: }
89: }
|