KickJava   Java API By Example, From Geeks To Geeks.

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


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