KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > nimbus > ToggleButtonPainter


1 /*
2  * ToggleButtonPainter.java %E%
3  *
4  * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.java.swing.plaf.nimbus;
8
9 import java.awt.*;
10 import java.awt.geom.*;
11 import java.awt.image.*;
12 import javax.swing.*;
13 import com.sun.java.swing.Painter;
14
15 /**
16  */

17 public final class ToggleButtonPainter extends AbstractRegionPainter {
18     //package private integers representing the available states that
19
//this painter will paint. These are used when creating a new instance
20
//of ToggleButtonPainter to determine which region/state is being painted
21
//by that instance.
22
static final int BACKGROUND_DISABLED = 1;
23     static final int BACKGROUND_ENABLED = 2;
24     static final int BACKGROUND_FOCUSED = 3;
25     static final int BACKGROUND_MOUSEOVER = 4;
26     static final int BACKGROUND_MOUSEOVER_FOCUSED = 5;
27     static final int BACKGROUND_PRESSED = 6;
28     static final int BACKGROUND_PRESSED_FOCUSED = 7;
29     static final int BACKGROUND_SELECTED = 8;
30     static final int BACKGROUND_SELECTED_FOCUSED = 9;
31     static final int BACKGROUND_PRESSED_SELECTED = 10;
32     static final int BACKGROUND_PRESSED_SELECTED_FOCUSED = 11;
33     static final int BACKGROUND_MOUSEOVER_SELECTED = 12;
34     static final int BACKGROUND_MOUSEOVER_SELECTED_FOCUSED = 13;
35     static final int BACKGROUND_DISABLED_SELECTED = 14;
36
37
38     private int state; //refers to one of the static final ints above
39
private PaintContext ctx;
40
41     //the following 4 variables are reused during the painting code of the layers
42
private Path2D path = new Path2D.Float();
43     private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0);
44     private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0);
45     private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0);
46
47     //All Colors used for painting are stored here. Ideally, only those colors being used
48
//by a particular instance of ToggleButtonPainter would be created. For the moment at least,
49
//however, all are created for each instance.
50
private Color color1 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.06885965f, -0.36862746f, -232);
51     private Color color2 = decodeColor("nimbusBlueGrey", 0.0f, -0.06766917f, 0.07843137f, 0);
52     private Color color3 = decodeColor("nimbusBlueGrey", 0.0f, -0.06484103f, 0.027450979f, 0);
53     private Color color4 = decodeColor("nimbusBlueGrey", 0.0f, -0.08477524f, 0.16862744f, 0);
54     private Color color5 = decodeColor("nimbusBlueGrey", -0.015872955f, -0.080091536f, 0.15686274f, 0);
55     private Color color6 = decodeColor("nimbusBlueGrey", 0.0f, -0.07016757f, 0.12941176f, 0);
56     private Color color7 = decodeColor("nimbusBlueGrey", 0.0f, -0.07052632f, 0.1372549f, 0);
57     private Color color8 = decodeColor("nimbusBlueGrey", 0.0f, -0.070878744f, 0.14509803f, 0);
58     private Color color9 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.06885965f, -0.36862746f, -190);
59     private Color color10 = decodeColor("nimbusBlueGrey", -0.055555522f, -0.05356429f, -0.12549019f, 0);
60     private Color color11 = decodeColor("nimbusBlueGrey", 0.0f, -0.0147816315f, -0.3764706f, 0);
61     private Color color12 = decodeColor("nimbusBlueGrey", 0.055555582f, -0.10655806f, 0.24313724f, 0);
62     private Color color13 = decodeColor("nimbusBlueGrey", 0.0f, -0.09823123f, 0.2117647f, 0);
63     private Color color14 = decodeColor("nimbusBlueGrey", 0.0f, -0.0749532f, 0.24705881f, 0);
64     private Color color15 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, 0);
65     private Color color16 = decodeColor("nimbusFocus", 0.0f, 0.0f, 0.0f, 0);
66     private Color color17 = decodeColor("nimbusBlueGrey", 0.0f, -0.020974077f, -0.21960783f, 0);
67     private Color color18 = decodeColor("nimbusBlueGrey", 0.0f, 0.11169591f, -0.53333336f, 0);
68     private Color color19 = decodeColor("nimbusBlueGrey", 0.055555582f, -0.10658931f, 0.25098038f, 0);
69     private Color color20 = decodeColor("nimbusBlueGrey", 0.0f, -0.098526314f, 0.2352941f, 0);
70     private Color color21 = decodeColor("nimbusBlueGrey", 0.0f, -0.07333623f, 0.20392156f, 0);
71     private Color color22 = new Color(245, 250, 255, 160);
72     private Color color23 = decodeColor("nimbusBlueGrey", 0.055555582f, 0.8894737f, -0.7176471f, 0);
73     private Color color24 = decodeColor("nimbusBlueGrey", 0.0f, 5.847961E-4f, -0.32156864f, 0);
74     private Color color25 = decodeColor("nimbusBlueGrey", -0.00505054f, -0.05960039f, 0.10196078f, 0);
75     private Color color26 = decodeColor("nimbusBlueGrey", -0.008547008f, -0.04772438f, 0.06666666f, 0);
76     private Color color27 = decodeColor("nimbusBlueGrey", -0.0027777553f, -0.0018306673f, -0.02352941f, 0);
77     private Color color28 = decodeColor("nimbusBlueGrey", -0.0027777553f, -0.0212406f, 0.13333333f, 0);
78     private Color color29 = decodeColor("nimbusBlueGrey", 0.0055555105f, -0.030845039f, 0.23921567f, 0);
79     private Color color30 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -86);
80     private Color color31 = decodeColor("nimbusBlueGrey", 0.0f, -0.06472479f, -0.23137254f, 0);
81     private Color color32 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.06959064f, -0.0745098f, 0);
82     private Color color33 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.06401469f, -0.07058823f, 0);
83     private Color color34 = decodeColor("nimbusBlueGrey", 0.0f, -0.06530018f, 0.035294116f, 0);
84     private Color color35 = decodeColor("nimbusBlueGrey", 0.0f, -0.06507177f, 0.031372547f, 0);
85     private Color color36 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.05338346f, -0.47058824f, 0);
86     private Color color37 = decodeColor("nimbusBlueGrey", 0.0f, -0.049301825f, -0.36078432f, 0);
87     private Color color38 = decodeColor("nimbusBlueGrey", -0.018518567f, -0.03909774f, -0.2509804f, 0);
88     private Color color39 = decodeColor("nimbusBlueGrey", -0.00505054f, -0.040013492f, -0.13333333f, 0);
89     private Color color40 = decodeColor("nimbusBlueGrey", 0.01010108f, -0.039558575f, -0.1372549f, 0);
90     private Color color41 = decodeColor("nimbusBlueGrey", -0.01111114f, -0.060526315f, -0.3529412f, 0);
91     private Color color42 = decodeColor("nimbusBlueGrey", 0.0f, -0.064372465f, -0.2352941f, 0);
92     private Color color43 = decodeColor("nimbusBlueGrey", -0.006944418f, -0.0595709f, -0.12941176f, 0);
93     private Color color44 = decodeColor("nimbusBlueGrey", 0.0f, -0.061075766f, -0.031372547f, 0);
94     private Color color45 = decodeColor("nimbusBlueGrey", 0.0f, -0.06080256f, -0.035294116f, 0);
95     private Color color46 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -220);
96     private Color color47 = decodeColor("nimbusBlueGrey", 0.0f, -0.066408664f, 0.054901958f, 0);
97     private Color color48 = decodeColor("nimbusBlueGrey", 0.0f, -0.06807348f, 0.086274505f, 0);
98     private Color color49 = decodeColor("nimbusBlueGrey", 0.0f, -0.06924191f, 0.109803915f, 0);
99
100
101     //Array of current component colors, updated in each paint call
102
private Object JavaDoc[] componentColors;
103
104     public ToggleButtonPainter(PaintContext ctx, int state) {
105         super();
106         this.state = state;
107         this.ctx = ctx;
108     }
109
110     @Override JavaDoc
111     protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object JavaDoc[] extendedCacheKeys) {
112         //populate componentColors array with colors calculated in getExtendedCacheKeys call
113
componentColors = extendedCacheKeys;
114         //generate this entire method. Each state/bg/fg/border combo that has
115
//been painted gets its own KEY and paint method.
116
switch(state) {
117             case BACKGROUND_DISABLED: paintBackgroundDisabled(g); break;
118             case BACKGROUND_ENABLED: paintBackgroundEnabled(g); break;
119             case BACKGROUND_FOCUSED: paintBackgroundFocused(g); break;
120             case BACKGROUND_MOUSEOVER: paintBackgroundMouseOver(g); break;
121             case BACKGROUND_MOUSEOVER_FOCUSED: paintBackgroundMouseOverAndFocused(g); break;
122             case BACKGROUND_PRESSED: paintBackgroundPressed(g); break;
123             case BACKGROUND_PRESSED_FOCUSED: paintBackgroundPressedAndFocused(g); break;
124             case BACKGROUND_SELECTED: paintBackgroundSelected(g); break;
125             case BACKGROUND_SELECTED_FOCUSED: paintBackgroundSelectedAndFocused(g); break;
126             case BACKGROUND_PRESSED_SELECTED: paintBackgroundPressedAndSelected(g); break;
127             case BACKGROUND_PRESSED_SELECTED_FOCUSED: paintBackgroundPressedAndSelectedAndFocused(g); break;
128             case BACKGROUND_MOUSEOVER_SELECTED: paintBackgroundMouseOverAndSelected(g); break;
129             case BACKGROUND_MOUSEOVER_SELECTED_FOCUSED: paintBackgroundMouseOverAndSelectedAndFocused(g); break;
130             case BACKGROUND_DISABLED_SELECTED: paintBackgroundDisabledAndSelected(g); break;
131
132         }
133     }
134         
135     protected Object JavaDoc[] getExtendedCacheKeys(JComponent c) {
136         Object JavaDoc[] extendedCacheKeys = null;
137         switch(state) {
138             case BACKGROUND_ENABLED:
139                 extendedCacheKeys = new Object JavaDoc[] {
140                      getComponentColor(c, "background", color12, -0.10655806f, 0.24313724f, 0),
141                      getComponentColor(c, "background", color13, -0.09823123f, 0.2117647f, 0),
142                      getComponentColor(c, "background", color6, -0.07016757f, 0.12941176f, 0),
143                      getComponentColor(c, "background", color14, -0.0749532f, 0.24705881f, 0),
144                      getComponentColor(c, "background", color15, -0.110526316f, 0.25490195f, 0)};
145                 break;
146             case BACKGROUND_FOCUSED:
147                 extendedCacheKeys = new Object JavaDoc[] {
148                      getComponentColor(c, "background", color12, -0.10655806f, 0.24313724f, 0),
149                      getComponentColor(c, "background", color13, -0.09823123f, 0.2117647f, 0),
150                      getComponentColor(c, "background", color6, -0.07016757f, 0.12941176f, 0),
151                      getComponentColor(c, "background", color14, -0.0749532f, 0.24705881f, 0),
152                      getComponentColor(c, "background", color15, -0.110526316f, 0.25490195f, 0)};
153                 break;
154             case BACKGROUND_MOUSEOVER:
155                 extendedCacheKeys = new Object JavaDoc[] {
156                      getComponentColor(c, "background", color19, -0.10658931f, 0.25098038f, 0),
157                      getComponentColor(c, "background", color20, -0.098526314f, 0.2352941f, 0),
158                      getComponentColor(c, "background", color21, -0.07333623f, 0.20392156f, 0),
159                      getComponentColor(c, "background", color15, -0.110526316f, 0.25490195f, 0)};
160                 break;
161             case BACKGROUND_MOUSEOVER_FOCUSED:
162                 extendedCacheKeys = new Object JavaDoc[] {
163                      getComponentColor(c, "background", color19, -0.10658931f, 0.25098038f, 0),
164                      getComponentColor(c, "background", color20, -0.098526314f, 0.2352941f, 0),
165                      getComponentColor(c, "background", color21, -0.07333623f, 0.20392156f, 0),
166                      getComponentColor(c, "background", color15, -0.110526316f, 0.25490195f, 0)};
167                 break;
168             case BACKGROUND_PRESSED:
169                 extendedCacheKeys = new Object JavaDoc[] {
170                      getComponentColor(c, "background", color25, -0.05960039f, 0.10196078f, 0),
171                      getComponentColor(c, "background", color26, -0.04772438f, 0.06666666f, 0),
172                      getComponentColor(c, "background", color27, -0.0018306673f, -0.02352941f, 0),
173                      getComponentColor(c, "background", color28, -0.0212406f, 0.13333333f, 0),
174                      getComponentColor(c, "background", color29, -0.030845039f, 0.23921567f, 0)};
175                 break;
176             case BACKGROUND_PRESSED_FOCUSED:
177                 extendedCacheKeys = new Object JavaDoc[] {
178                      getComponentColor(c, "background", color25, -0.05960039f, 0.10196078f, 0),
179                      getComponentColor(c, "background", color26, -0.04772438f, 0.06666666f, 0),
180                      getComponentColor(c, "background", color27, -0.0018306673f, -0.02352941f, 0),
181                      getComponentColor(c, "background", color28, -0.0212406f, 0.13333333f, 0),
182                      getComponentColor(c, "background", color29, -0.030845039f, 0.23921567f, 0)};
183                 break;
184             case BACKGROUND_SELECTED:
185                 extendedCacheKeys = new Object JavaDoc[] {
186                      getComponentColor(c, "background", color33, -0.06401469f, -0.07058823f, 0),
187                      getComponentColor(c, "background", color34, -0.06530018f, 0.035294116f, 0),
188                      getComponentColor(c, "background", color35, -0.06507177f, 0.031372547f, 0)};
189                 break;
190             case BACKGROUND_SELECTED_FOCUSED:
191                 extendedCacheKeys = new Object JavaDoc[] {
192                      getComponentColor(c, "background", color33, -0.06401469f, -0.07058823f, 0),
193                      getComponentColor(c, "background", color34, -0.06530018f, 0.035294116f, 0),
194                      getComponentColor(c, "background", color35, -0.06507177f, 0.031372547f, 0)};
195                 break;
196             case BACKGROUND_PRESSED_SELECTED:
197                 extendedCacheKeys = new Object JavaDoc[] {
198                      getComponentColor(c, "background", color38, -0.03909774f, -0.2509804f, 0),
199                      getComponentColor(c, "background", color39, -0.040013492f, -0.13333333f, 0),
200                      getComponentColor(c, "background", color40, -0.039558575f, -0.1372549f, 0)};
201                 break;
202             case BACKGROUND_PRESSED_SELECTED_FOCUSED:
203                 extendedCacheKeys = new Object JavaDoc[] {
204                      getComponentColor(c, "background", color38, -0.03909774f, -0.2509804f, 0),
205                      getComponentColor(c, "background", color39, -0.040013492f, -0.13333333f, 0),
206                      getComponentColor(c, "background", color40, -0.039558575f, -0.1372549f, 0)};
207                 break;
208             case BACKGROUND_MOUSEOVER_SELECTED:
209                 extendedCacheKeys = new Object JavaDoc[] {
210                      getComponentColor(c, "background", color43, -0.0595709f, -0.12941176f, 0),
211                      getComponentColor(c, "background", color44, -0.061075766f, -0.031372547f, 0),
212                      getComponentColor(c, "background", color45, -0.06080256f, -0.035294116f, 0)};
213                 break;
214             case BACKGROUND_MOUSEOVER_SELECTED_FOCUSED:
215                 extendedCacheKeys = new Object JavaDoc[] {
216                      getComponentColor(c, "background", color43, -0.0595709f, -0.12941176f, 0),
217                      getComponentColor(c, "background", color44, -0.061075766f, -0.031372547f, 0),
218                      getComponentColor(c, "background", color45, -0.06080256f, -0.035294116f, 0)};
219                 break;
220         }
221         return extendedCacheKeys;
222     }
223
224     @Override JavaDoc
225     protected final PaintContext getPaintContext() {
226         return ctx;
227     }
228
229     private void paintBackgroundDisabled(Graphics2D g) {
230         roundRect = decodeRoundRect1();
231         g.setPaint(color1);
232         g.fill(roundRect);
233         roundRect = decodeRoundRect2();
234         g.setPaint(decodeGradient1(roundRect));
235         g.fill(roundRect);
236         roundRect = decodeRoundRect3();
237         g.setPaint(decodeGradient2(roundRect));
238         g.fill(roundRect);
239
240     }
241
242     private void paintBackgroundEnabled(Graphics2D g) {
243         roundRect = decodeRoundRect1();
244         g.setPaint(color9);
245         g.fill(roundRect);
246         roundRect = decodeRoundRect2();
247         g.setPaint(decodeGradient3(roundRect));
248         g.fill(roundRect);
249         roundRect = decodeRoundRect3();
250         g.setPaint(decodeGradient4(roundRect));
251         g.fill(roundRect);
252
253     }
254
255     private void paintBackgroundFocused(Graphics2D g) {
256         roundRect = decodeRoundRect4();
257         g.setPaint(color16);
258         g.fill(roundRect);
259         roundRect = decodeRoundRect2();
260         g.setPaint(decodeGradient3(roundRect));
261         g.fill(roundRect);
262         roundRect = decodeRoundRect3();
263         g.setPaint(decodeGradient5(roundRect));
264         g.fill(roundRect);
265
266     }
267
268     private void paintBackgroundMouseOver(Graphics2D g) {
269         roundRect = decodeRoundRect1();
270         g.setPaint(color9);
271         g.fill(roundRect);
272         roundRect = decodeRoundRect2();
273         g.setPaint(decodeGradient6(roundRect));
274         g.fill(roundRect);
275         roundRect = decodeRoundRect3();
276         g.setPaint(decodeGradient7(roundRect));
277         g.fill(roundRect);
278
279     }
280
281     private void paintBackgroundMouseOverAndFocused(Graphics2D g) {
282         roundRect = decodeRoundRect4();
283         g.setPaint(color16);
284         g.fill(roundRect);
285         roundRect = decodeRoundRect2();
286         g.setPaint(decodeGradient6(roundRect));
287         g.fill(roundRect);
288         roundRect = decodeRoundRect3();
289         g.setPaint(decodeGradient7(roundRect));
290         g.fill(roundRect);
291
292     }
293
294     private void paintBackgroundPressed(Graphics2D g) {
295         roundRect = decodeRoundRect1();
296         g.setPaint(color22);
297         g.fill(roundRect);
298         roundRect = decodeRoundRect2();
299         g.setPaint(decodeGradient8(roundRect));
300         g.fill(roundRect);
301         roundRect = decodeRoundRect3();
302         g.setPaint(decodeGradient4(roundRect));
303         g.fill(roundRect);
304
305     }
306
307     private void paintBackgroundPressedAndFocused(Graphics2D g) {
308         roundRect = decodeRoundRect4();
309         g.setPaint(color16);
310         g.fill(roundRect);
311         roundRect = decodeRoundRect2();
312         g.setPaint(decodeGradient8(roundRect));
313         g.fill(roundRect);
314         roundRect = decodeRoundRect3();
315         g.setPaint(decodeGradient4(roundRect));
316         g.fill(roundRect);
317
318     }
319
320     private void paintBackgroundSelected(Graphics2D g) {
321         roundRect = decodeRoundRect5();
322         g.setPaint(color30);
323         g.fill(roundRect);
324         roundRect = decodeRoundRect2();
325         g.setPaint(decodeGradient9(roundRect));
326         g.fill(roundRect);
327         roundRect = decodeRoundRect3();
328         g.setPaint(decodeGradient10(roundRect));
329         g.fill(roundRect);
330
331     }
332
333     private void paintBackgroundSelectedAndFocused(Graphics2D g) {
334         roundRect = decodeRoundRect6();
335         g.setPaint(color16);
336         g.fill(roundRect);
337         roundRect = decodeRoundRect2();
338         g.setPaint(decodeGradient9(roundRect));
339         g.fill(roundRect);
340         roundRect = decodeRoundRect3();
341         g.setPaint(decodeGradient10(roundRect));
342         g.fill(roundRect);
343
344     }
345
346     private void paintBackgroundPressedAndSelected(Graphics2D g) {
347         roundRect = decodeRoundRect5();
348         g.setPaint(color30);
349         g.fill(roundRect);
350         roundRect = decodeRoundRect2();
351         g.setPaint(decodeGradient11(roundRect));
352         g.fill(roundRect);
353         roundRect = decodeRoundRect3();
354         g.setPaint(decodeGradient10(roundRect));
355         g.fill(roundRect);
356
357     }
358
359     private void paintBackgroundPressedAndSelectedAndFocused(Graphics2D g) {
360         roundRect = decodeRoundRect6();
361         g.setPaint(color16);
362         g.fill(roundRect);
363         roundRect = decodeRoundRect2();
364         g.setPaint(decodeGradient11(roundRect));
365         g.fill(roundRect);
366         roundRect = decodeRoundRect3();
367         g.setPaint(decodeGradient10(roundRect));
368         g.fill(roundRect);
369
370     }
371
372     private void paintBackgroundMouseOverAndSelected(Graphics2D g) {
373         roundRect = decodeRoundRect5();
374         g.setPaint(color30);
375         g.fill(roundRect);
376         roundRect = decodeRoundRect2();
377         g.setPaint(decodeGradient12(roundRect));
378         g.fill(roundRect);
379         roundRect = decodeRoundRect3();
380         g.setPaint(decodeGradient10(roundRect));
381         g.fill(roundRect);
382
383     }
384
385     private void paintBackgroundMouseOverAndSelectedAndFocused(Graphics2D g) {
386         roundRect = decodeRoundRect6();
387         g.setPaint(color16);
388         g.fill(roundRect);
389         roundRect = decodeRoundRect2();
390         g.setPaint(decodeGradient12(roundRect));
391         g.fill(roundRect);
392         roundRect = decodeRoundRect3();
393         g.setPaint(decodeGradient10(roundRect));
394         g.fill(roundRect);
395
396     }
397
398     private void paintBackgroundDisabledAndSelected(Graphics2D g) {
399         roundRect = decodeRoundRect5();
400         g.setPaint(color46);
401         g.fill(roundRect);
402         roundRect = decodeRoundRect2();
403         g.setPaint(decodeGradient13(roundRect));
404         g.fill(roundRect);
405         roundRect = decodeRoundRect3();
406         g.setPaint(decodeGradient14(roundRect));
407         g.fill(roundRect);
408
409     }
410
411
412
413     private RoundRectangle2D decodeRoundRect1() {
414         roundRect.setRoundRect(decodeX(0.2857143f), //x
415
decodeY(0.42857143f), //y
416
decodeX(2.7142859f) - decodeX(0.2857143f), //width
417
decodeY(2.857143f) - decodeY(0.42857143f), //height
418
12.0f, 12.0f); //rounding
419
return roundRect;
420     }
421
422     private RoundRectangle2D decodeRoundRect2() {
423         roundRect.setRoundRect(decodeX(0.2857143f), //x
424
decodeY(0.2857143f), //y
425
decodeX(2.7142859f) - decodeX(0.2857143f), //width
426
decodeY(2.7142859f) - decodeY(0.2857143f), //height
427
9.0f, 9.0f); //rounding
428
return roundRect;
429     }
430
431     private RoundRectangle2D decodeRoundRect3() {
432         roundRect.setRoundRect(decodeX(0.42857143f), //x
433
decodeY(0.42857143f), //y
434
decodeX(2.5714285f) - decodeX(0.42857143f), //width
435
decodeY(2.5714285f) - decodeY(0.42857143f), //height
436
7.0f, 7.0f); //rounding
437
return roundRect;
438     }
439
440     private RoundRectangle2D decodeRoundRect4() {
441         roundRect.setRoundRect(decodeX(0.08571429f), //x
442
decodeY(0.08571429f), //y
443
decodeX(2.914286f) - decodeX(0.08571429f), //width
444
decodeY(2.914286f) - decodeY(0.08571429f), //height
445
11.0f, 11.0f); //rounding
446
return roundRect;
447     }
448
449     private RoundRectangle2D decodeRoundRect5() {
450         roundRect.setRoundRect(decodeX(0.2857143f), //x
451
decodeY(0.42857143f), //y
452
decodeX(2.7142859f) - decodeX(0.2857143f), //width
453
decodeY(2.857143f) - decodeY(0.42857143f), //height
454
9.0f, 9.0f); //rounding
455
return roundRect;
456     }
457
458     private RoundRectangle2D decodeRoundRect6() {
459         roundRect.setRoundRect(decodeX(0.08571429f), //x
460
decodeY(0.08571429f), //y
461
decodeX(2.914286f) - decodeX(0.08571429f), //width
462
decodeY(2.9142857f) - decodeY(0.08571429f), //height
463
11.0f, 11.0f); //rounding
464
return roundRect;
465     }
466
467
468
469     private Paint decodeGradient1(Shape s) {
470         Rectangle2D bounds = s.getBounds2D();
471         float x = (float)bounds.getX();
472         float y = (float)bounds.getY();
473         float w = (float)bounds.getWidth();
474         float h = (float)bounds.getHeight();
475         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
476                 new float[] { 0.09f,0.52f,0.95f },
477                 new Color[] { color2,
478                             decodeColor(color2,color3,0.5f),
479                             color3});
480     }
481
482     private Paint decodeGradient2(Shape s) {
483         Rectangle2D bounds = s.getBounds2D();
484         float x = (float)bounds.getX();
485         float y = (float)bounds.getY();
486         float w = (float)bounds.getWidth();
487         float h = (float)bounds.getHeight();
488         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
489                 new float[] { 0.0f,0.03f,0.06f,0.33f,0.6f,0.65f,0.7f,0.825f,0.95f,0.975f,1.0f },
490                 new Color[] { color4,
491                             decodeColor(color4,color5,0.5f),
492                             color5,
493                             decodeColor(color5,color6,0.5f),
494                             color6,
495                             decodeColor(color6,color6,0.5f),
496                             color6,
497                             decodeColor(color6,color7,0.5f),
498                             color7,
499                             decodeColor(color7,color8,0.5f),
500                             color8});
501     }
502
503     private Paint decodeGradient3(Shape s) {
504         Rectangle2D bounds = s.getBounds2D();
505         float x = (float)bounds.getX();
506         float y = (float)bounds.getY();
507         float w = (float)bounds.getWidth();
508         float h = (float)bounds.getHeight();
509         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
510                 new float[] { 0.09f,0.52f,0.95f },
511                 new Color[] { color10,
512                             decodeColor(color10,color11,0.5f),
513                             color11});
514     }
515
516     private Paint decodeGradient4(Shape s) {
517         Rectangle2D bounds = s.getBounds2D();
518         float x = (float)bounds.getX();
519         float y = (float)bounds.getY();
520         float w = (float)bounds.getWidth();
521         float h = (float)bounds.getHeight();
522         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
523                 new float[] { 0.0f,0.024f,0.06f,0.276f,0.6f,0.65f,0.7f,0.856f,0.96f,0.98399997f,1.0f },
524                 new Color[] { (Color)componentColors[0],
525                             decodeColor((Color)componentColors[0],(Color)componentColors[1],0.5f),
526                             (Color)componentColors[1],
527                             decodeColor((Color)componentColors[1],(Color)componentColors[2],0.5f),
528                             (Color)componentColors[2],
529                             decodeColor((Color)componentColors[2],(Color)componentColors[2],0.5f),
530                             (Color)componentColors[2],
531                             decodeColor((Color)componentColors[2],(Color)componentColors[3],0.5f),
532                             (Color)componentColors[3],
533                             decodeColor((Color)componentColors[3],(Color)componentColors[4],0.5f),
534                             (Color)componentColors[4]});
535     }
536
537     private Paint decodeGradient5(Shape s) {
538         Rectangle2D bounds = s.getBounds2D();
539         float x = (float)bounds.getX();
540         float y = (float)bounds.getY();
541         float w = (float)bounds.getWidth();
542         float h = (float)bounds.getHeight();
543         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
544                 new float[] { 0.0f,0.03f,0.06f,0.33f,0.6f,0.65f,0.7f,0.825f,0.95f,0.975f,1.0f },
545                 new Color[] { (Color)componentColors[0],
546                             decodeColor((Color)componentColors[0],(Color)componentColors[1],0.5f),
547                             (Color)componentColors[1],
548                             decodeColor((Color)componentColors[1],(Color)componentColors[2],0.5f),
549                             (Color)componentColors[2],
550                             decodeColor((Color)componentColors[2],(Color)componentColors[2],0.5f),
551                             (Color)componentColors[2],
552                             decodeColor((Color)componentColors[2],(Color)componentColors[3],0.5f),
553                             (Color)componentColors[3],
554                             decodeColor((Color)componentColors[3],(Color)componentColors[4],0.5f),
555                             (Color)componentColors[4]});
556     }
557
558     private Paint decodeGradient6(Shape s) {
559         Rectangle2D bounds = s.getBounds2D();
560         float x = (float)bounds.getX();
561         float y = (float)bounds.getY();
562         float w = (float)bounds.getWidth();
563         float h = (float)bounds.getHeight();
564         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
565                 new float[] { 0.09f,0.52f,0.95f },
566                 new Color[] { color17,
567                             decodeColor(color17,color18,0.5f),
568                             color18});
569     }
570
571     private Paint decodeGradient7(Shape s) {
572         Rectangle2D bounds = s.getBounds2D();
573         float x = (float)bounds.getX();
574         float y = (float)bounds.getY();
575         float w = (float)bounds.getWidth();
576         float h = (float)bounds.getHeight();
577         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
578                 new float[] { 0.0f,0.024f,0.06f,0.276f,0.6f,0.65f,0.7f,0.856f,0.96f,0.98f,1.0f },
579                 new Color[] { (Color)componentColors[0],
580                             decodeColor((Color)componentColors[0],(Color)componentColors[1],0.5f),
581                             (Color)componentColors[1],
582                             decodeColor((Color)componentColors[1],(Color)componentColors[2],0.5f),
583                             (Color)componentColors[2],
584                             decodeColor((Color)componentColors[2],(Color)componentColors[2],0.5f),
585                             (Color)componentColors[2],
586                             decodeColor((Color)componentColors[2],(Color)componentColors[3],0.5f),
587                             (Color)componentColors[3],
588                             decodeColor((Color)componentColors[3],(Color)componentColors[3],0.5f),
589                             (Color)componentColors[3]});
590     }
591
592     private Paint decodeGradient8(Shape s) {
593         Rectangle2D bounds = s.getBounds2D();
594         float x = (float)bounds.getX();
595         float y = (float)bounds.getY();
596         float w = (float)bounds.getWidth();
597         float h = (float)bounds.getHeight();
598         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
599                 new float[] { 0.05f,0.5f,0.95f },
600                 new Color[] { color23,
601                             decodeColor(color23,color24,0.5f),
602                             color24});
603     }
604
605     private Paint decodeGradient9(Shape s) {
606         Rectangle2D bounds = s.getBounds2D();
607         float x = (float)bounds.getX();
608         float y = (float)bounds.getY();
609         float w = (float)bounds.getWidth();
610         float h = (float)bounds.getHeight();
611         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
612                 new float[] { 0.0f,0.5f,1.0f },
613                 new Color[] { color31,
614                             decodeColor(color31,color32,0.5f),
615                             color32});
616     }
617
618     private Paint decodeGradient10(Shape s) {
619         Rectangle2D bounds = s.getBounds2D();
620         float x = (float)bounds.getX();
621         float y = (float)bounds.getY();
622         float w = (float)bounds.getWidth();
623         float h = (float)bounds.getHeight();
624         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
625                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
626                 new Color[] { (Color)componentColors[0],
627                             decodeColor((Color)componentColors[0],(Color)componentColors[1],0.5f),
628                             (Color)componentColors[1],
629                             decodeColor((Color)componentColors[1],(Color)componentColors[2],0.5f),
630                             (Color)componentColors[2]});
631     }
632
633     private Paint decodeGradient11(Shape s) {
634         Rectangle2D bounds = s.getBounds2D();
635         float x = (float)bounds.getX();
636         float y = (float)bounds.getY();
637         float w = (float)bounds.getWidth();
638         float h = (float)bounds.getHeight();
639         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
640                 new float[] { 0.0f,0.5f,1.0f },
641                 new Color[] { color36,
642                             decodeColor(color36,color37,0.5f),
643                             color37});
644     }
645
646     private Paint decodeGradient12(Shape s) {
647         Rectangle2D bounds = s.getBounds2D();
648         float x = (float)bounds.getX();
649         float y = (float)bounds.getY();
650         float w = (float)bounds.getWidth();
651         float h = (float)bounds.getHeight();
652         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
653                 new float[] { 0.0f,0.5f,1.0f },
654                 new Color[] { color41,
655                             decodeColor(color41,color42,0.5f),
656                             color42});
657     }
658
659     private Paint decodeGradient13(Shape s) {
660         Rectangle2D bounds = s.getBounds2D();
661         float x = (float)bounds.getX();
662         float y = (float)bounds.getY();
663         float w = (float)bounds.getWidth();
664         float h = (float)bounds.getHeight();
665         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
666                 new float[] { 0.0f,0.5f,1.0f },
667                 new Color[] { color47,
668                             decodeColor(color47,color48,0.5f),
669                             color48});
670     }
671
672     private Paint decodeGradient14(Shape s) {
673         Rectangle2D bounds = s.getBounds2D();
674         float x = (float)bounds.getX();
675         float y = (float)bounds.getY();
676         float w = (float)bounds.getWidth();
677         float h = (float)bounds.getHeight();
678         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
679                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
680                 new Color[] { color48,
681                             decodeColor(color48,color49,0.5f),
682                             color49,
683                             decodeColor(color49,color49,0.5f),
684                             color49});
685     }
686
687
688 }
689
Popular Tags