Debian Codegraph @

src/com/jidesoft/plaf/vsnet/ResizeFrameBorder.java

raw
1 /*
2 * @(#)FrameBorder.java
3 *
4 * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
5 */
6 package com.jidesoft.plaf.vsnet;
7
8 import javax.swing.border.Border;
9 import javax.swing.plaf.UIResource;
10 import java.awt.*;
11
12 /**
13 * This class is an implementation of the DockableFrame border.
14 */
15 public class ResizeFrameBorder 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 ResizeFrameBorder(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 g.setColor(_highlight);
53 g.drawLine(x, y, x + width, y);
54
55 g.setColor(_lightHighlight);
56 g.drawLine(x + 1, y + 1, x + width - 2, y + 1);
57 if (_insets.left == 0) {
58 g.drawLine(x, y + 1, x + 1, y + 1);
59 }
60 if (_insets.right == 0) {
61 g.drawLine(x + width - 2, y + 1, x + width - 1, y + 1);
62 }
63
64 g.setColor(_highlight);
65 g.drawLine(x + 2, y + 2, x + width - 4, y + 2);
66 g.drawLine(x + 2, y + 3, x + width - 4, y + 3);
67
68 if (_insets.left == 0) {
69 g.drawLine(x, y + 2, x + 2, y + 2);
70 g.drawLine(x, y + 3, x + 2, y + 3);
71 }
72 if (_insets.right == 0) {
73 g.drawLine(x + width - 4, y + 2, x + width - 1, y + 2);
74 g.drawLine(x + width - 4, y + 3, x + width - 1, y + 3);
75 }
76 }
77
78 if (_insets.left > 0) {
79 g.setColor(_highlight);
80 g.drawLine(x, y, x, y + height);
81
82 g.setColor(_lightHighlight);
83 g.drawLine(x + 1, y + 1, x + 1, y + height - 2);
84
85 if (_insets.top == 0) {
86 g.drawLine(x + 1, y, x + 1, y + 1);
87 }
88 if (_insets.bottom == 0) {
89 g.drawLine(x + 1, y + height - 2, x + 1, y + height - 1);
90 }
91
92 g.setColor(_highlight);
93 g.drawLine(x + 2, y + 2, x + 2, y + height - 4);
94 g.drawLine(x + 3, y + 2, x + 3, y + height - 4);
95 if (_insets.top == 0) {
96 g.drawLine(x + 2, y, x + 2, y + 2);
97 g.drawLine(x + 3, y, x + 3, y + 2);
98 }
99 if (_insets.bottom == 0) {
100 g.drawLine(x + 2, y + height - 4, x + 2, y + height - 1);
101 g.drawLine(x + 3, y + height - 4, x + 3, y + height - 1);
102 }
103 }
104
105 if (_insets.bottom > 0) {
106 g.setColor(_darkShadow);
107 g.drawLine(x, y + height - 1, x + width, y + height - 1);
108
109 g.setColor(_shadow);
110 g.drawLine(x + 1, y + height - 2, x + width - 2, y + height - 2);
111 if (_insets.left == 0) {
112 g.drawLine(x, y + height - 2, x + 1, y + height - 2);
113 }
114 if (_insets.right == 0) {
115 g.drawLine(x + width - 2, y + height - 2, x + width - 1, y + height - 2);
116 }
117
118 g.setColor(_highlight);
119 g.drawLine(x + 2, y + height - 3, x + width - 4, y + height - 3);
120 g.drawLine(x + 2, y + height - 4, x + width - 4, y + height - 4);
121 if (_insets.left == 0) {
122 g.drawLine(x, y + height - 3, x + 2, y + height - 3);
123 g.drawLine(x, y + height - 4, x + 2, y + height - 4);
124 }
125 if (_insets.right == 0) {
126 g.drawLine(x + width - 4, y + height - 3, x + width - 1, y + height - 3);
127 g.drawLine(x + width - 4, y + height - 4, x + width - 1, y + height - 4);
128 }
129 }
130
131 if (_insets.right > 0) {
132 g.setColor(_darkShadow);
133 g.drawLine(x + width - 1, y, x + width - 1, y + height);
134
135 g.setColor(_shadow);
136 g.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2);
137 if (_insets.top == 0) {
138 g.drawLine(x + width - 2, y, x + width - 2, y + 1);
139 }
140 if (_insets.bottom == 0) {
141 g.drawLine(x + width - 2, y + height - 2, x + width - 2, y + height - 1);
142 }
143
144 g.setColor(_highlight);
145 g.drawLine(x + width - 3, y + 2, x + width - 3, y + height - 4);
146 g.drawLine(x + width - 4, y + 2, x + width - 4, y + height - 4);
147 if (_insets.top == 0) {
148 g.drawLine(x + width - 3, y, x + width - 3, y + 2);
149 g.drawLine(x + width - 4, y, x + width - 4, y + 2);
150 }
151 if (_insets.bottom == 0) {
152 g.drawLine(x + width - 3, y + height - 4, x + width - 3, y + height - 1);
153 g.drawLine(x + width - 4, y + height - 4, x + width - 4, y + height - 1);
154 }
155 }
156 }
157 }