1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.AlphaComposite; |
26 |
import java.awt.Color; |
27 |
import java.awt.Composite; |
28 |
import java.awt.GradientPaint; |
29 |
import java.awt.Graphics2D; |
30 |
import java.awt.Paint; |
31 |
|
32 |
import java.awt.geom.Area; |
33 |
import java.awt.geom.Line2D; |
34 |
import java.awt.geom.Rectangle2D; |
35 |
|
36 |
/** |
37 |
* |
38 |
* @author Grigor Iliev |
39 |
*/ |
40 |
public class FantasiaPainter { |
41 |
public static Color color1 = new Color(0x434343); |
42 |
public static Color color2 = new Color(0x535353); |
43 |
public static Color color4 = new Color(0x6e6e6e); |
44 |
public static Color color5 = new Color(0x7a7a7a); |
45 |
public static Color color6 = new Color(0x8a8a8a); |
46 |
|
47 |
public static class RoundCorners { |
48 |
public boolean topLeft, bottomLeft, bottomRight, topRight; |
49 |
|
50 |
public |
51 |
RoundCorners(boolean round) { |
52 |
this(round, round, round, round); |
53 |
} |
54 |
|
55 |
public |
56 |
RoundCorners(boolean topLeft, boolean bottomLeft, boolean bottomRight, boolean topRight) { |
57 |
this.topLeft = topLeft; |
58 |
this.topRight = topRight; |
59 |
this.bottomLeft = bottomLeft; |
60 |
this.bottomRight = bottomRight; |
61 |
} |
62 |
} |
63 |
|
64 |
public static class Border { |
65 |
public boolean paintTop, paintLeft, paintBottom, paintRight; |
66 |
|
67 |
public |
68 |
Border(boolean paintBorder) { |
69 |
this(paintBorder, paintBorder, paintBorder, paintBorder); |
70 |
} |
71 |
|
72 |
public |
73 |
Border(boolean paintTop, boolean paintLeft, boolean paintBottom, boolean paintRight) { |
74 |
this.paintTop = paintTop; |
75 |
this.paintLeft = paintLeft; |
76 |
this.paintBottom = paintBottom; |
77 |
this.paintRight = paintRight; |
78 |
} |
79 |
} |
80 |
|
81 |
private |
82 |
FantasiaPainter() { } |
83 |
|
84 |
public static void |
85 |
paintGradient(Graphics2D g2, double x1, double y1, double x2, double y2) { |
86 |
paintGradient(g2, x1, y1, x2, y2, color5, color4); |
87 |
} |
88 |
|
89 |
public static void |
90 |
paintDarkGradient(Graphics2D g2, double x1, double y1, double x2, double y2) { |
91 |
paintGradient(g2, x1, y1, x2, y2, color2, color1); |
92 |
} |
93 |
|
94 |
public static void |
95 |
paintGradient(Graphics2D g2, double x1, double y1, double x2, double y2, Color c1, Color c2) { |
96 |
Paint oldPaint = g2.getPaint(); |
97 |
|
98 |
Rectangle2D.Double rect = new Rectangle2D.Double(x1, y1, x2 - x1 + 1, y2 -y1 + 1); |
99 |
|
100 |
GradientPaint gr = new GradientPaint ( |
101 |
(float)x1, (float)y1, c1, |
102 |
(float)x1, (float)y2, c2 |
103 |
); |
104 |
|
105 |
g2.setPaint(gr); |
106 |
g2.fill(rect); |
107 |
|
108 |
g2.setPaint(oldPaint); |
109 |
} |
110 |
|
111 |
public static void |
112 |
paintOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
113 |
paintOuterBorder(g2, x1, y1, x2, y2, false); |
114 |
} |
115 |
|
116 |
public static void |
117 |
paintOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2, boolean round) { |
118 |
paintOuterBorder(g2, x1, y1, x2, y2, round, 1.0f, 1.0f); |
119 |
} |
120 |
|
121 |
public static void |
122 |
paintOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2, RoundCorners rc) { |
123 |
paintOuterBorder(g2, x1, y1, x2, y2, rc, 1.0f, 1.0f); |
124 |
} |
125 |
|
126 |
public static void |
127 |
paintOuterBorder ( |
128 |
Graphics2D g2, |
129 |
double x1, double y1, double x2, double y2, |
130 |
boolean round, float alphaWhite, float alphaBlack |
131 |
) { |
132 |
paintOuterBorder(g2, x1, y1, x2, y2, new RoundCorners(round), alphaWhite, alphaBlack); |
133 |
} |
134 |
|
135 |
public static void |
136 |
paintOuterBorder ( |
137 |
Graphics2D g2, |
138 |
double x1, double y1, double x2, double y2, |
139 |
RoundCorners rc, float alphaWhite, float alphaBlack |
140 |
) { |
141 |
|
142 |
Paint oldPaint = g2.getPaint(); |
143 |
Composite oldComposite = g2.getComposite(); |
144 |
|
145 |
AlphaComposite ac; |
146 |
ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.40f * alphaWhite); |
147 |
g2.setComposite(ac); |
148 |
|
149 |
double x1t = rc.topLeft ? x1 + 2 : x1; |
150 |
double x1b = rc.bottomLeft ? x1 + 2 : x1; |
151 |
double x2t = rc.topRight ? x2 - 2 : x2; |
152 |
double x2b = rc.bottomRight ? x2 - 2 : x2; |
153 |
double y1l = rc.topLeft ? y1 + 2 : y1; |
154 |
double y1r = rc.topRight ? y1 + 2 : y1; |
155 |
double y2l = rc.bottomLeft ? y2 - 2 : y2; |
156 |
double y2r = rc.bottomRight ? y2 - 2 : y2; |
157 |
|
158 |
g2.setPaint(Color.WHITE); |
159 |
Line2D.Double l = new Line2D.Double(x1t, y1, x2t, y1); |
160 |
g2.draw(l); |
161 |
|
162 |
if(rc.topLeft) { |
163 |
// top-left corner |
164 |
g2.setComposite(ac.derive(0.30f * alphaWhite)); |
165 |
l = new Line2D.Double(x1 + 1, y1, x1 + 1, y1); |
166 |
g2.draw(l); |
167 |
|
168 |
g2.setComposite(ac.derive(0.20f * alphaWhite)); |
169 |
l = new Line2D.Double(x1 + 1, y1 + 1, x1 + 1, y1 + 1); |
170 |
g2.draw(l); |
171 |
|
172 |
g2.setComposite(ac.derive(0.15f * alphaWhite)); |
173 |
l = new Line2D.Double(x1, y1 + 1, x1, y1 + 1); |
174 |
g2.draw(l); |
175 |
|
176 |
g2.setPaint(Color.BLACK); |
177 |
g2.setComposite(ac.derive(0.15f * alphaBlack)); |
178 |
l = new Line2D.Double(x1, y1, x1, y1); |
179 |
g2.draw(l); |
180 |
|
181 |
g2.setPaint(Color.WHITE); |
182 |
} |
183 |
|
184 |
if(rc.topRight) { |
185 |
// top-right corner |
186 |
g2.setPaint(Color.WHITE); |
187 |
g2.setComposite(ac.derive(0.20f * alphaWhite)); |
188 |
l = new Line2D.Double(x2 - 1, y1, x2 - 1, y1); |
189 |
g2.draw(l); |
190 |
|
191 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
192 |
l = new Line2D.Double(x2 - 1, y1 + 1, x2 - 1, y1 + 1); |
193 |
g2.draw(l); |
194 |
} |
195 |
|
196 |
g2.setComposite(ac.derive(0.255f * alphaWhite)); |
197 |
|
198 |
l = new Line2D.Double(x1, y1l, x1, y2l); |
199 |
g2.draw(l); |
200 |
|
201 |
g2.setComposite(ac.derive(0.40f * alphaBlack)); |
202 |
g2.setPaint(Color.BLACK); |
203 |
|
204 |
l = new Line2D.Double(x1b, y2, x2b, y2); |
205 |
g2.draw(l); |
206 |
|
207 |
if(rc.bottomLeft) { |
208 |
// bottom-left corner |
209 |
l = new Line2D.Double(x1, y2, x1, y2); |
210 |
g2.draw(l); |
211 |
|
212 |
g2.setComposite(ac.derive(0.30f * alphaBlack)); |
213 |
l = new Line2D.Double(x1 + 1, y2, x1 + 1, y2); |
214 |
g2.draw(l); |
215 |
|
216 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
217 |
l = new Line2D.Double(x1 + 1, y2 - 1, x1 + 1, y2 - 1); |
218 |
g2.draw(l); |
219 |
|
220 |
g2.setPaint(Color.WHITE); |
221 |
g2.setComposite(ac.derive(0.05f * alphaWhite)); |
222 |
l = new Line2D.Double(x1, y2 - 1, x1, y2 - 1); |
223 |
g2.draw(l); |
224 |
g2.setPaint(Color.BLACK); |
225 |
} |
226 |
|
227 |
g2.setComposite(ac.derive(0.20f * alphaBlack)); |
228 |
|
229 |
l = new Line2D.Double(x2, y1r, x2, y2r); |
230 |
g2.draw(l); |
231 |
|
232 |
if(rc.topRight) { |
233 |
//top-right corner |
234 |
g2.setComposite(ac.derive(0.15f * alphaBlack)); |
235 |
l = new Line2D.Double(x2, y1 + 1, x2, y1 + 1); |
236 |
g2.draw(l); |
237 |
|
238 |
g2.setComposite(ac.derive(0.25f * alphaBlack)); |
239 |
l = new Line2D.Double(x2, y1, x2, y1); |
240 |
g2.draw(l); |
241 |
} |
242 |
|
243 |
if(rc.bottomRight) { |
244 |
//bottom-right corner |
245 |
g2.setComposite(ac.derive(0.30f * alphaBlack)); |
246 |
l = new Line2D.Double(x2, y2 - 1, x2, y2 - 1); |
247 |
g2.draw(l); |
248 |
|
249 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
250 |
l = new Line2D.Double(x2 - 1, y2 - 1, x2 - 1, y2 - 1); |
251 |
g2.draw(l); |
252 |
|
253 |
g2.setComposite(ac.derive(0.43f * alphaBlack)); |
254 |
l = new Line2D.Double(x2, y2, x2, y2); |
255 |
g2.draw(l); |
256 |
|
257 |
g2.setComposite(ac.derive(0.38f * alphaBlack)); |
258 |
l = new Line2D.Double(x2 - 1, y2, x2 - 1, y2); |
259 |
g2.draw(l); |
260 |
} |
261 |
|
262 |
g2.setComposite(oldComposite); |
263 |
g2.setPaint(oldPaint); |
264 |
} |
265 |
|
266 |
public static void |
267 |
paintBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
268 |
paintBoldOuterBorder(g2, x1, y1, x2, y2, new Border(true)); |
269 |
} |
270 |
|
271 |
public static void |
272 |
paintBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2, Border border) { |
273 |
Paint oldPaint = g2.getPaint(); |
274 |
Composite oldComposite = g2.getComposite(); |
275 |
|
276 |
if(border.paintTop) { |
277 |
paintTopBoldOuterBorder(g2, x1 + 2, y1, x2 - 2, y1); |
278 |
paintTopBoldRoundCorners(g2, x1, y1, x2, y2); |
279 |
} |
280 |
|
281 |
if(border.paintLeft) { |
282 |
paintLeftBoldOuterBorder(g2, x1, y1, x2, y2); |
283 |
} |
284 |
|
285 |
if(border.paintBottom) { |
286 |
paintBottomBoldOuterBorder(g2, x1, y1, x2, y2); |
287 |
} |
288 |
|
289 |
paintBottomLeftBoldRoundCorner(g2, x1, y2); |
290 |
|
291 |
if(border.paintRight) { |
292 |
paintRightBoldOuterBorder(g2, x1, y1, x2, y2); |
293 |
} |
294 |
|
295 |
paintBottomRightBoldRoundCorner(g2, x2, y2); |
296 |
|
297 |
g2.setPaint(oldPaint); |
298 |
g2.setComposite(oldComposite); |
299 |
} |
300 |
|
301 |
public static void |
302 |
paintRightBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
303 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.20f); |
304 |
g2.setComposite(ac); |
305 |
|
306 |
g2.setPaint(Color.BLACK); |
307 |
Line2D.Double l = new Line2D.Double(x2, y1, x2, y2 - 3); |
308 |
g2.draw(l); |
309 |
|
310 |
g2.setComposite(ac.derive(0.10f)); |
311 |
l = new Line2D.Double(x2 - 1, y1, x2 - 1, y2 - 1); |
312 |
g2.draw(l); |
313 |
} |
314 |
|
315 |
public static void |
316 |
paintBottomBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
317 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.40f); |
318 |
g2.setComposite(ac); |
319 |
|
320 |
g2.setPaint(Color.BLACK); |
321 |
Line2D.Double l = new Line2D.Double(x1 + 3, y2, x2 - 2, y2); |
322 |
g2.draw(l); |
323 |
|
324 |
g2.setComposite(ac.derive(0.20f)); |
325 |
l = new Line2D.Double(x1 + 1, y2 - 1, x2 - 1, y2 - 1); |
326 |
g2.draw(l); |
327 |
} |
328 |
|
329 |
public static void |
330 |
paintLeftBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
331 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.255f); |
332 |
g2.setComposite(ac); |
333 |
|
334 |
g2.setPaint(Color.WHITE); |
335 |
Line2D.Double l = new Line2D.Double(x1, y1, x1, y2 - 3); |
336 |
g2.draw(l); |
337 |
|
338 |
g2.setComposite(ac.derive(0.10f)); |
339 |
l = new Line2D.Double(x1 + 1, y1, x1 + 1, y2 - 1); |
340 |
g2.draw(l); |
341 |
} |
342 |
|
343 |
public static void |
344 |
paintBottomRightBoldRoundCorner(Graphics2D g2, double x2, double y2) { |
345 |
g2.setPaint(Color.BLACK); |
346 |
// round right-down corner |
347 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.37f); |
348 |
g2.setComposite(ac); |
349 |
Line2D.Double l = new Line2D.Double(x2 - 1, y2, x2 - 1, y2); |
350 |
g2.draw(l); |
351 |
|
352 |
g2.setComposite(ac.derive(0.34f)); |
353 |
l = new Line2D.Double(x2, y2, x2, y2); |
354 |
g2.draw(l); |
355 |
/////// |
356 |
|
357 |
// round right corner |
358 |
g2.setComposite(ac.derive(0.25f)); |
359 |
l = new Line2D.Double(x2, y2 - 2, x2, y2 - 2); |
360 |
g2.draw(l); |
361 |
|
362 |
g2.setComposite(ac.derive(0.30f)); |
363 |
l = new Line2D.Double(x2, y2 - 1, x2, y2 - 1); |
364 |
g2.draw(l); |
365 |
/////// |
366 |
|
367 |
} |
368 |
|
369 |
public static void |
370 |
paintBottomLeftBoldRoundCorner(Graphics2D g2, double x1, double y2) { |
371 |
g2.setPaint(Color.WHITE); |
372 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.15f); |
373 |
g2.setComposite(ac); |
374 |
Line2D.Double l = new Line2D.Double(x1, y2 - 2, x1, y2 - 2); |
375 |
g2.draw(l); |
376 |
|
377 |
g2.setPaint(Color.BLACK); |
378 |
g2.setComposite(ac.derive(0.27f)); |
379 |
l = new Line2D.Double(x1, y2, x1, y2); |
380 |
g2.draw(l); |
381 |
|
382 |
g2.setComposite(ac.derive(0.32f)); |
383 |
l = new Line2D.Double(x1 + 1, y2, x1 + 1, y2); |
384 |
g2.draw(l); |
385 |
|
386 |
g2.setComposite(ac.derive(0.37f)); |
387 |
l = new Line2D.Double(x1 + 2, y2, x1 + 2, y2); |
388 |
g2.draw(l); |
389 |
} |
390 |
|
391 |
public static void |
392 |
paintTopBoldOuterBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
393 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.40f); |
394 |
g2.setComposite(ac); |
395 |
|
396 |
g2.setPaint(Color.WHITE); |
397 |
Line2D.Double l = new Line2D.Double(x1, y1, x2 - 1, y2); |
398 |
g2.draw(l); |
399 |
|
400 |
g2.setComposite(ac.derive(0.20f)); |
401 |
l = new Line2D.Double(x1, y1 + 1, x2, y2 + 1); |
402 |
g2.draw(l); |
403 |
} |
404 |
|
405 |
public static void |
406 |
paintTopBoldRoundCorners(Graphics2D g2, double x1, double y1, double x2, double y2) { |
407 |
paintTopLeftBoldRoundCorner(g2, x1, y1); |
408 |
paintTopRightBoldRoundCorner(g2, y1, x2); |
409 |
} |
410 |
|
411 |
public static void |
412 |
paintTopLeftBoldRoundCorner(Graphics2D g2, double x1, double y1) { |
413 |
Paint oldPaint = g2.getPaint(); |
414 |
Composite oldComposite = g2.getComposite(); |
415 |
|
416 |
g2.setPaint(Color.BLACK); |
417 |
|
418 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.20f); |
419 |
g2.setComposite(ac); |
420 |
Line2D.Double l = new Line2D.Double(x1, y1, x1, y1); |
421 |
g2.draw(l); |
422 |
|
423 |
g2.setPaint(Color.WHITE); |
424 |
g2.setComposite(ac.derive(0.20f)); |
425 |
l = new Line2D.Double(x1 + 1, y1, x1 + 1, y1); |
426 |
g2.draw(l); |
427 |
|
428 |
g2.setComposite(ac.derive(0.15f)); |
429 |
l = new Line2D.Double(x1, y1 + 1, x1, y1 + 1); |
430 |
g2.draw(l); |
431 |
|
432 |
g2.setComposite(ac.derive(0.30f)); |
433 |
l = new Line2D.Double(x1 + 1, y1 + 1, x1 + 1, y1 + 1); |
434 |
g2.draw(l); |
435 |
|
436 |
g2.setComposite(ac.derive(0.10f)); |
437 |
l = new Line2D.Double(x1, y1 + 2, x1 + 1, y1 + 2); |
438 |
g2.draw(l); |
439 |
|
440 |
g2.setPaint(oldPaint); |
441 |
g2.setComposite(oldComposite); |
442 |
} |
443 |
|
444 |
public static void |
445 |
paintTopRightBoldRoundCorner(Graphics2D g2, double y1, double x2) { |
446 |
Paint oldPaint = g2.getPaint(); |
447 |
Composite oldComposite = g2.getComposite(); |
448 |
|
449 |
g2.setPaint(Color.WHITE); |
450 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.30f); |
451 |
g2.setComposite(ac); |
452 |
Line2D.Double l = new Line2D.Double(x2 - 2, y1, x2 - 2, y1); |
453 |
g2.draw(l); |
454 |
|
455 |
g2.setComposite(ac.derive(0.20f)); |
456 |
l = new Line2D.Double(x2 - 1, y1, x2 - 1, y1); |
457 |
g2.draw(l); |
458 |
|
459 |
g2.setPaint(Color.BLACK); |
460 |
g2.setComposite(ac.derive(0.20f)); |
461 |
l = new Line2D.Double(x2, y1, x2, y1); |
462 |
g2.draw(l); |
463 |
|
464 |
g2.setPaint(Color.WHITE); |
465 |
g2.setComposite(ac.derive(0.10f)); |
466 |
l = new Line2D.Double(x2 - 1, y1 + 1, x2 - 1, y1 + 1); |
467 |
g2.draw(l); |
468 |
|
469 |
g2.setPaint(Color.BLACK); |
470 |
g2.setComposite(ac.derive(0.05f)); |
471 |
l = new Line2D.Double(x2, y1 + 1, x2, y1 + 1); |
472 |
g2.draw(l); |
473 |
|
474 |
g2.setPaint(oldPaint); |
475 |
g2.setComposite(oldComposite); |
476 |
} |
477 |
|
478 |
public static void |
479 |
paintInnerBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
480 |
paintInnerBorder(g2, x1, y1, x2, y2, false); |
481 |
} |
482 |
|
483 |
public static void |
484 |
paintInnerBorder(Graphics2D g2, double x1, double y1, double x2, double y2, boolean round) { |
485 |
paintInnerBorder(g2, x1, y1, x2, y2, round, 1.0f, 1.0f); |
486 |
} |
487 |
|
488 |
public static void |
489 |
paintInnerBorder ( |
490 |
Graphics2D g2, |
491 |
double x1, double y1, double x2, double y2, |
492 |
boolean round, float alphaWhite, float alphaBlack |
493 |
) { |
494 |
Paint oldPaint = g2.getPaint(); |
495 |
Composite oldComposite = g2.getComposite(); |
496 |
|
497 |
AlphaComposite ac; |
498 |
ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.30f * alphaWhite); |
499 |
g2.setComposite(ac); |
500 |
|
501 |
g2.setPaint(Color.WHITE); |
502 |
double x1b = round ? x1 + 3 : x1; |
503 |
double x2b = round ? x2 - 3 : x2; |
504 |
double y1b = round ? y1 + 3 : y1; |
505 |
double y2b = round ? y2 - 3 : y2; |
506 |
|
507 |
Line2D.Double l = new Line2D.Double(x1b, y2, x2b, y2); |
508 |
g2.draw(l); |
509 |
|
510 |
// bottom-left round border |
511 |
if(round) { |
512 |
g2.setComposite(ac.derive(0.20f * alphaWhite)); |
513 |
l = new Line2D.Double(x1 + 2, y2, x1 + 2, y2); |
514 |
g2.draw(l); |
515 |
|
516 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
517 |
l = new Line2D.Double(x1 + 1, y2, x1 + 1, y2); |
518 |
g2.draw(l); |
519 |
|
520 |
g2.setComposite(ac.derive(0.05f * alphaWhite)); |
521 |
l = new Line2D.Double(x1 + 1, y2 - 1, x1 + 1, y2 - 1); |
522 |
g2.draw(l); |
523 |
} |
524 |
/////// |
525 |
|
526 |
g2.setComposite(ac.derive(0.20f * alphaWhite)); |
527 |
l = new Line2D.Double(x2, y1b, x2, y2b); |
528 |
g2.draw(l); |
529 |
|
530 |
// bottom-right round border |
531 |
if(round) { |
532 |
g2.setComposite(ac.derive(0.15f * alphaWhite)); |
533 |
l = new Line2D.Double(x2, y2 - 2, x2, y2 - 2); |
534 |
g2.draw(l); |
535 |
|
536 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
537 |
l = new Line2D.Double(x2, y2 - 1, x2, y2 - 1); |
538 |
g2.draw(l); |
539 |
|
540 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
541 |
l = new Line2D.Double(x2 - 1, y2 - 1, x2 - 1, y2 - 1); |
542 |
g2.draw(l); |
543 |
|
544 |
/***/ |
545 |
|
546 |
g2.setComposite(ac.derive(0.15f * alphaWhite)); |
547 |
l = new Line2D.Double(x2 - 2, y2, x2 - 2, y2); |
548 |
g2.draw(l); |
549 |
|
550 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
551 |
l = new Line2D.Double(x2 - 1, y2, x2 - 1, y2); |
552 |
g2.draw(l); |
553 |
} |
554 |
/////// |
555 |
|
556 |
g2.setComposite(ac.derive(0.20f * alphaBlack)); |
557 |
g2.setPaint(Color.BLACK); |
558 |
|
559 |
l = new Line2D.Double(x1b, y1, x2b, y1); |
560 |
g2.draw(l); |
561 |
|
562 |
if(round) { |
563 |
// top-left round border |
564 |
g2.setComposite(ac.derive(0.05f * alphaBlack)); |
565 |
l = new Line2D.Double(x1, y1, x1, y1); |
566 |
g2.draw(l); |
567 |
|
568 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
569 |
l = new Line2D.Double(x1 + 1, y1, x1 + 1, y1); |
570 |
g2.draw(l); |
571 |
|
572 |
g2.setComposite(ac.derive(0.15f * alphaBlack)); |
573 |
l = new Line2D.Double(x1 + 2, y1, x1 + 2, y1); |
574 |
g2.draw(l); |
575 |
|
576 |
g2.setPaint(Color.WHITE); |
577 |
g2.setComposite(ac.derive(0.15f * alphaWhite)); |
578 |
l = new Line2D.Double(x1 + 1, y1 + 1, x1 + 1, y1 + 1); |
579 |
g2.draw(l); |
580 |
|
581 |
// top-right round border |
582 |
g2.setComposite(ac.derive(0.05f * alphaWhite)); |
583 |
l = new Line2D.Double(x2, y1 + 1, x2, y1 + 1); |
584 |
g2.draw(l); |
585 |
|
586 |
g2.setComposite(ac.derive(0.10f * alphaWhite)); |
587 |
l = new Line2D.Double(x2, y1 + 2, x2, y1 + 2); |
588 |
g2.draw(l); |
589 |
|
590 |
g2.setComposite(ac.derive(0.15f * alphaWhite)); |
591 |
l = new Line2D.Double(x2 - 1, y1 + 1, x2 - 1, y1 + 1); |
592 |
g2.draw(l); |
593 |
|
594 |
g2.setPaint(Color.BLACK); |
595 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
596 |
l = new Line2D.Double(x2 - 2, y1, x2 - 2, y1); |
597 |
g2.draw(l); |
598 |
|
599 |
g2.setComposite(ac.derive(0.05f * alphaBlack)); |
600 |
l = new Line2D.Double(x2 - 1, y1, x2 - 1, y1); |
601 |
g2.draw(l); |
602 |
} |
603 |
|
604 |
g2.setComposite(ac.derive(0.20f * alphaBlack)); |
605 |
l = new Line2D.Double(x1, y1b, x1, y2b); |
606 |
g2.draw(l); |
607 |
|
608 |
if(round) { |
609 |
// top-left round border |
610 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
611 |
l = new Line2D.Double(x1, y1 + 1, x1, y1 + 1); |
612 |
g2.draw(l); |
613 |
|
614 |
g2.setComposite(ac.derive(0.15f * alphaBlack)); |
615 |
l = new Line2D.Double(x1, y1 + 2, x1, y1 + 2); |
616 |
g2.draw(l); |
617 |
|
618 |
// bottom-left round border |
619 |
g2.setComposite(ac.derive(0.10f * alphaBlack)); |
620 |
l = new Line2D.Double(x1, y2 - 2, x1, y2 - 2); |
621 |
g2.draw(l); |
622 |
|
623 |
g2.setComposite(ac.derive(0.05f * alphaBlack)); |
624 |
l = new Line2D.Double(x1, y2 - 1, x1, y2 - 1); |
625 |
g2.draw(l); |
626 |
} |
627 |
/////// |
628 |
|
629 |
g2.setComposite(oldComposite); |
630 |
g2.setPaint(oldPaint); |
631 |
} |
632 |
|
633 |
public static void |
634 |
paintBoldInnerBorder(Graphics2D g2, double x1, double y1, double x2, double y2) { |
635 |
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.40f); |
636 |
g2.setComposite(ac); |
637 |
|
638 |
g2.setPaint(Color.WHITE); |
639 |
Line2D.Double l = new Line2D.Double(x1, y2, x2, y2); |
640 |
g2.draw(l); |
641 |
|
642 |
g2.setComposite(ac.derive(0.15f)); |
643 |
l = new Line2D.Double(x1 - 1, y2 + 1, x2 + 1, y2 + 1); |
644 |
g2.draw(l); |
645 |
|
646 |
g2.setComposite(ac.derive(0.255f)); |
647 |
l = new Line2D.Double(x2, y1, x2, y2); |
648 |
g2.draw(l); |
649 |
|
650 |
g2.setComposite(ac.derive(0.13f)); |
651 |
l = new Line2D.Double(x2 + 1, y1 - 1, x2 + 1, y2 + 1); |
652 |
g2.draw(l); |
653 |
|
654 |
g2.setComposite(ac.derive(0.20f)); |
655 |
g2.setPaint(Color.BLACK); |
656 |
|
657 |
l = new Line2D.Double(x1 - 1, y1 - 1, x2 + 1, y1 - 1); |
658 |
g2.draw(l); |
659 |
|
660 |
g2.setComposite(ac.derive(0.40f)); |
661 |
g2.setPaint(Color.BLACK); |
662 |
|
663 |
l = new Line2D.Double(x1, y1, x2, y1); |
664 |
g2.draw(l); |
665 |
|
666 |
g2.setComposite(ac.derive(0.20f)); |
667 |
|
668 |
l = new Line2D.Double(x1 - 1, y1 - 1, x1 - 1, y2 + 1); |
669 |
g2.draw(l); |
670 |
|
671 |
g2.setComposite(ac.derive(0.40f)); |
672 |
|
673 |
l = new Line2D.Double(x1, y1, x1, y2); |
674 |
g2.draw(l); |
675 |
} |
676 |
|
677 |
public static void |
678 |
paintBorder(Graphics2D g2, double x1, double y1, double x2, double y2, double size) { |
679 |
paintBorder(g2, x1, y1, x2, y2, size, true); |
680 |
} |
681 |
|
682 |
public static void |
683 |
paintBorder ( |
684 |
Graphics2D g2, |
685 |
double x1, double y1, double x2, double y2, |
686 |
double size, |
687 |
boolean paintInnerBorder |
688 |
) { |
689 |
Paint oldPaint = g2.getPaint(); |
690 |
Composite oldComposite = g2.getComposite(); |
691 |
|
692 |
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, x2 - x1 + 1, y2 - y1 + 1); |
693 |
Area area = new Area(rect); |
694 |
|
695 |
rect = new Rectangle2D.Double ( |
696 |
x1 + size, y1 + size, x2 - x1 + 1 - (2 * size), y2 - y1 + 1 - (2 * size) |
697 |
); |
698 |
area.subtract(new Area(rect)); |
699 |
|
700 |
GradientPaint gr = new GradientPaint ( |
701 |
0.0f, (float)y1, FantasiaPainter.color5, |
702 |
0.0f, (float)y2, FantasiaPainter.color4 |
703 |
); |
704 |
|
705 |
g2.setPaint(gr); |
706 |
g2.fill(area); |
707 |
|
708 |
if(paintInnerBorder) { |
709 |
paintInnerBorder ( |
710 |
g2, x1 + size - 1, y1 + size - 1, x2 - size + 1, y2 - size + 1, true |
711 |
); |
712 |
} |
713 |
|
714 |
paintBoldOuterBorder(g2, x1, y1, x2, y2); |
715 |
|
716 |
g2.setPaint(oldPaint); |
717 |
g2.setComposite(oldComposite); |
718 |
} |
719 |
} |