1 package org.wcb.gui.component;
2
3 import javax.swing.Icon;
4 import java.awt.Color;
5 import java.awt.Graphics;
6 import java.awt.Component;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 public class TriangleSquareCornerWindowIcon implements Icon {
35
36
37 private static final Color THREE_D_EFFECT_COLOR = new Color(255, 255, 255);
38 private static final Color SQUARE_COLOR_LEFT = new Color(184, 180, 163);
39 private static final Color SQUARE_COLOR_TOP_RIGHT = new Color(184, 180, 161);
40 private static final Color SQUARE_COLOR_BOTTOM_RIGHT = new Color(184, 181, 161);
41
42
43 private static final int WIDTH = 12;
44 private static final int HEIGHT = 12;
45
46
47
48
49
50 public int getIconHeight() {
51 return WIDTH;
52 }
53
54
55
56
57
58 public int getIconWidth() {
59 return HEIGHT;
60 }
61
62
63
64
65
66
67
68
69 public void paintIcon(Component c, Graphics g, int x, int y) {
70
71
72 int firstRow = 0;
73 int firstColumn = 0;
74 int rowDiff = 4;
75 int columnDiff = 4;
76
77 int secondRow = firstRow + rowDiff;
78 int secondColumn = firstColumn + columnDiff;
79 int thirdRow = secondRow + rowDiff;
80 int thirdColumn = secondColumn + columnDiff;
81
82
83
84 draw3dSquare(g, firstColumn + 1, thirdRow + 1);
85
86 draw3dSquare(g, secondColumn + 1, secondRow + 1);
87 draw3dSquare(g, secondColumn + 1, thirdRow + 1);
88
89 draw3dSquare(g, thirdColumn + 1, firstRow + 1);
90 draw3dSquare(g, thirdColumn + 1, secondRow + 1);
91 draw3dSquare(g, thirdColumn + 1, thirdRow + 1);
92
93
94 drawSquare(g, firstColumn, thirdRow);
95
96 drawSquare(g, secondColumn, secondRow);
97 drawSquare(g, secondColumn, thirdRow);
98
99 drawSquare(g, thirdColumn, firstRow);
100 drawSquare(g, thirdColumn, secondRow);
101 drawSquare(g, thirdColumn, thirdRow);
102
103 }
104
105
106
107
108
109
110
111 private void draw3dSquare(Graphics g, int x, int y) {
112 Color oldColor = g.getColor();
113 g.setColor(THREE_D_EFFECT_COLOR);
114 g.fillRect(x, y, 2, 2);
115 g.setColor(oldColor);
116 }
117
118
119
120
121
122
123
124 private void drawSquare(Graphics g, int x, int y) {
125 Color oldColor = g.getColor();
126 g.setColor(SQUARE_COLOR_LEFT);
127 g.drawLine(x, y, x, y + 1);
128 g.setColor(SQUARE_COLOR_TOP_RIGHT);
129 g.drawLine(x + 1, y, x + 1, y);
130 g.setColor(SQUARE_COLOR_BOTTOM_RIGHT);
131 g.drawLine(x + 1, y + 1, x + 1, y + 1);
132 g.setColor(oldColor);
133 }
134
135 }