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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1785 - (hide annotations) (download)
Tue Oct 7 00:07:14 2008 UTC (15 years, 6 months ago) by iliev
File size: 19977 byte(s)
* Fantasia: Implemented multiple channels panels
* Fantasia: Refactoring - all basic UI components moved to
  org.jsampler.view.fantasia.basic package

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

  ViewVC Help
Powered by ViewVC