/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/basic/FantasiaPainter.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/basic/FantasiaPainter.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 4 months ago) by iliev
File size: 20672 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

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

  ViewVC Help
Powered by ViewVC