KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * RadioButtonPainter.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 RadioButtonPainter 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 RadioButtonPainter 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 ICON_DISABLED = 3;
25     static final int ICON_ENABLED = 4;
26     static final int ICON_FOCUSED = 5;
27     static final int ICON_MOUSEOVER = 6;
28     static final int ICON_MOUSEOVER_FOCUSED = 7;
29     static final int ICON_PRESSED = 8;
30     static final int ICON_PRESSED_FOCUSED = 9;
31     static final int ICON_SELECTED = 10;
32     static final int ICON_SELECTED_FOCUSED = 11;
33     static final int ICON_PRESSED_SELECTED = 12;
34     static final int ICON_PRESSED_SELECTED_FOCUSED = 13;
35     static final int ICON_MOUSEOVER_SELECTED = 14;
36     static final int ICON_MOUSEOVER_SELECTED_FOCUSED = 15;
37     static final int ICON_DISABLED_SELECTED = 16;
38
39
40     private int state; //refers to one of the static final ints above
41
private PaintContext ctx;
42
43     //the following 4 variables are reused during the painting code of the layers
44
private Path2D path = new Path2D.Float();
45     private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0);
46     private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0);
47     private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0);
48
49     //All Colors used for painting are stored here. Ideally, only those colors being used
50
//by a particular instance of RadioButtonPainter would be created. For the moment at least,
51
//however, all are created for each instance.
52
private Color color1 = decodeColor("nimbusBlueGrey", 0.0f, -0.06766917f, 0.07843137f, 0);
53     private Color color2 = decodeColor("nimbusBlueGrey", 0.0f, -0.06413457f, 0.015686274f, 0);
54     private Color color3 = decodeColor("nimbusBlueGrey", 0.0f, -0.08466425f, 0.16470587f, 0);
55     private Color color4 = decodeColor("nimbusBlueGrey", 0.0f, -0.07016757f, 0.12941176f, 0);
56     private Color color5 = decodeColor("nimbusBlueGrey", 0.0f, -0.070703305f, 0.14117646f, 0);
57     private Color color6 = decodeColor("nimbusBlueGrey", 0.0f, -0.07052632f, 0.1372549f, 0);
58     private Color color7 = decodeColor("nimbusBlueGrey", 0.0f, 0.0f, 0.0f, -112);
59     private Color color8 = decodeColor("nimbusBlueGrey", 0.0f, -0.053201474f, -0.12941176f, 0);
60     private Color color9 = decodeColor("nimbusBlueGrey", 0.0f, 0.006356798f, -0.44313726f, 0);
61     private Color color10 = decodeColor("nimbusBlueGrey", 0.055555582f, -0.10654225f, 0.23921567f, 0);
62     private Color color11 = decodeColor("nimbusBlueGrey", 0.0f, -0.07206477f, 0.17254901f, 0);
63     private Color color12 = decodeColor("nimbusFocus", 0.0f, 0.0f, 0.0f, 0);
64     private Color color13 = decodeColor("nimbusBlueGrey", -0.00505054f, -0.027819552f, -0.2235294f, 0);
65     private Color color14 = decodeColor("nimbusBlueGrey", 0.0f, 0.24241486f, -0.6117647f, 0);
66     private Color color15 = decodeColor("nimbusBlueGrey", -0.111111104f, -0.10655806f, 0.24313724f, 0);
67     private Color color16 = decodeColor("nimbusBlueGrey", 0.0f, -0.07333623f, 0.20392156f, 0);
68     private Color color17 = decodeColor("nimbusBlueGrey", 0.08585858f, -0.067389056f, 0.25490195f, 0);
69     private Color color18 = decodeColor("nimbusBlueGrey", -0.111111104f, -0.10628903f, 0.18039215f, 0);
70     private Color color19 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, 0);
71     private Color color20 = decodeColor("nimbusBlueGrey", 0.055555582f, 0.23947367f, -0.6666667f, 0);
72     private Color color21 = decodeColor("nimbusBlueGrey", -0.0777778f, -0.06815343f, -0.28235295f, 0);
73     private Color color22 = decodeColor("nimbusBlueGrey", 0.0f, -0.06866585f, 0.09803921f, 0);
74     private Color color23 = decodeColor("nimbusBlueGrey", -0.0027777553f, -0.0018306673f, -0.02352941f, 0);
75     private Color color24 = decodeColor("nimbusBlueGrey", 0.002924025f, -0.02047892f, 0.082352936f, 0);
76     private Color color25 = decodeColor("nimbusBase", 2.9569864E-4f, -0.36035198f, -0.007843137f, 0);
77     private Color color26 = decodeColor("nimbusBase", 2.9569864E-4f, 0.019458115f, -0.32156867f, 0);
78     private Color color27 = decodeColor("nimbusBase", 0.004681647f, -0.6195853f, 0.4235294f, 0);
79     private Color color28 = decodeColor("nimbusBase", 0.004681647f, -0.56704473f, 0.36470586f, 0);
80     private Color color29 = decodeColor("nimbusBase", 5.1498413E-4f, -0.43866998f, 0.24705881f, 0);
81     private Color color30 = decodeColor("nimbusBase", 5.1498413E-4f, -0.44879842f, 0.29019606f, 0);
82     private Color color31 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.07243107f, -0.33333334f, 0);
83     private Color color32 = decodeColor("nimbusBlueGrey", -0.6111111f, -0.110526316f, -0.74509805f, 0);
84     private Color color33 = decodeColor("nimbusBlueGrey", -0.027777791f, 0.07129187f, -0.6156863f, 0);
85     private Color color34 = decodeColor("nimbusBase", -0.57865167f, -0.6357143f, -0.49803925f, 0);
86     private Color color35 = decodeColor("nimbusBase", 0.0030477047f, -0.1257143f, -0.15686277f, 0);
87     private Color color36 = decodeColor("nimbusBase", -0.0017285943f, -0.4367347f, 0.21960783f, 0);
88     private Color color37 = decodeColor("nimbusBase", -0.0010654926f, -0.31349206f, 0.15686274f, 0);
89     private Color color38 = decodeColor("nimbusBase", 0.0f, 0.0f, 0.0f, 0);
90     private Color color39 = decodeColor("nimbusBase", 8.05676E-4f, -0.12380952f, 0.109803915f, 0);
91     private Color color40 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.080223285f, -0.4862745f, 0);
92     private Color color41 = decodeColor("nimbusBase", -6.374717E-4f, -0.20452163f, -0.12156865f, 0);
93     private Color color42 = decodeColor("nimbusBase", -0.57865167f, -0.6357143f, -0.5058824f, 0);
94     private Color color43 = decodeColor("nimbusBase", -0.011985004f, -0.6157143f, 0.43137252f, 0);
95     private Color color44 = decodeColor("nimbusBase", 0.004681647f, -0.56932425f, 0.3960784f, 0);
96     private Color color45 = decodeColor("nimbusBase", 5.1498413E-4f, -0.4555341f, 0.3215686f, 0);
97     private Color color46 = decodeColor("nimbusBase", 5.1498413E-4f, -0.46550155f, 0.372549f, 0);
98     private Color color47 = decodeColor("nimbusBase", 0.0024294257f, -0.47271872f, 0.34117645f, 0);
99     private Color color48 = decodeColor("nimbusBase", 0.010237217f, -0.56289876f, 0.2588235f, 0);
100     private Color color49 = decodeColor("nimbusBase", 0.016586483f, -0.5620301f, 0.19607842f, 0);
101     private Color color50 = decodeColor("nimbusBase", 0.027408898f, -0.5878882f, 0.35294116f, 0);
102     private Color color51 = decodeColor("nimbusBase", 0.021348298f, -0.56722116f, 0.3098039f, 0);
103     private Color color52 = decodeColor("nimbusBase", 0.021348298f, -0.567841f, 0.31764704f, 0);
104     private Color color53 = decodeColor("nimbusBlueGrey", -0.01111114f, -0.058170296f, 0.0039215684f, 0);
105     private Color color54 = decodeColor("nimbusBlueGrey", -0.013888836f, -0.04195489f, -0.058823526f, 0);
106     private Color color55 = decodeColor("nimbusBlueGrey", 0.009259284f, -0.0147816315f, -0.007843137f, 0);
107
108
109     //Array of current component colors, updated in each paint call
110
private Object JavaDoc[] componentColors;
111
112     public RadioButtonPainter(PaintContext ctx, int state) {
113         super();
114         this.state = state;
115         this.ctx = ctx;
116     }
117
118     @Override JavaDoc
119     protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object JavaDoc[] extendedCacheKeys) {
120         //populate componentColors array with colors calculated in getExtendedCacheKeys call
121
componentColors = extendedCacheKeys;
122         //generate this entire method. Each state/bg/fg/border combo that has
123
//been painted gets its own KEY and paint method.
124
switch(state) {
125             case ICON_DISABLED: painticonDisabled(g); break;
126             case ICON_ENABLED: painticonEnabled(g); break;
127             case ICON_FOCUSED: painticonFocused(g); break;
128             case ICON_MOUSEOVER: painticonMouseOver(g); break;
129             case ICON_MOUSEOVER_FOCUSED: painticonMouseOverAndFocused(g); break;
130             case ICON_PRESSED: painticonPressed(g); break;
131             case ICON_PRESSED_FOCUSED: painticonPressedAndFocused(g); break;
132             case ICON_SELECTED: painticonSelected(g); break;
133             case ICON_SELECTED_FOCUSED: painticonSelectedAndFocused(g); break;
134             case ICON_PRESSED_SELECTED: painticonPressedAndSelected(g); break;
135             case ICON_PRESSED_SELECTED_FOCUSED: painticonPressedAndSelectedAndFocused(g); break;
136             case ICON_MOUSEOVER_SELECTED: painticonMouseOverAndSelected(g); break;
137             case ICON_MOUSEOVER_SELECTED_FOCUSED: painticonMouseOverAndSelectedAndFocused(g); break;
138             case ICON_DISABLED_SELECTED: painticonDisabledAndSelected(g); break;
139
140         }
141     }
142         
143
144
145     @Override JavaDoc
146     protected final PaintContext getPaintContext() {
147         return ctx;
148     }
149
150     private void painticonDisabled(Graphics2D g) {
151         ellipse = decodeEllipse1();
152         g.setPaint(decodeGradient1(ellipse));
153         g.fill(ellipse);
154         ellipse = decodeEllipse2();
155         g.setPaint(decodeGradient2(ellipse));
156         g.fill(ellipse);
157
158     }
159
160     private void painticonEnabled(Graphics2D g) {
161         ellipse = decodeEllipse3();
162         g.setPaint(color7);
163         g.fill(ellipse);
164         ellipse = decodeEllipse1();
165         g.setPaint(decodeGradient3(ellipse));
166         g.fill(ellipse);
167         ellipse = decodeEllipse2();
168         g.setPaint(decodeGradient4(ellipse));
169         g.fill(ellipse);
170
171     }
172
173     private void painticonFocused(Graphics2D g) {
174         ellipse = decodeEllipse4();
175         g.setPaint(color12);
176         g.fill(ellipse);
177         ellipse = decodeEllipse1();
178         g.setPaint(decodeGradient3(ellipse));
179         g.fill(ellipse);
180         ellipse = decodeEllipse2();
181         g.setPaint(decodeGradient4(ellipse));
182         g.fill(ellipse);
183
184     }
185
186     private void painticonMouseOver(Graphics2D g) {
187         ellipse = decodeEllipse3();
188         g.setPaint(color7);
189         g.fill(ellipse);
190         ellipse = decodeEllipse1();
191         g.setPaint(decodeGradient5(ellipse));
192         g.fill(ellipse);
193         ellipse = decodeEllipse2();
194         g.setPaint(decodeGradient6(ellipse));
195         g.fill(ellipse);
196
197     }
198
199     private void painticonMouseOverAndFocused(Graphics2D g) {
200         ellipse = decodeEllipse4();
201         g.setPaint(color12);
202         g.fill(ellipse);
203         ellipse = decodeEllipse1();
204         g.setPaint(decodeGradient5(ellipse));
205         g.fill(ellipse);
206         ellipse = decodeEllipse2();
207         g.setPaint(decodeGradient6(ellipse));
208         g.fill(ellipse);
209
210     }
211
212     private void painticonPressed(Graphics2D g) {
213         ellipse = decodeEllipse3();
214         g.setPaint(color19);
215         g.fill(ellipse);
216         ellipse = decodeEllipse1();
217         g.setPaint(decodeGradient7(ellipse));
218         g.fill(ellipse);
219         ellipse = decodeEllipse2();
220         g.setPaint(decodeGradient8(ellipse));
221         g.fill(ellipse);
222
223     }
224
225     private void painticonPressedAndFocused(Graphics2D g) {
226         ellipse = decodeEllipse4();
227         g.setPaint(color12);
228         g.fill(ellipse);
229         ellipse = decodeEllipse1();
230         g.setPaint(decodeGradient7(ellipse));
231         g.fill(ellipse);
232         ellipse = decodeEllipse2();
233         g.setPaint(decodeGradient8(ellipse));
234         g.fill(ellipse);
235
236     }
237
238     private void painticonSelected(Graphics2D g) {
239         ellipse = decodeEllipse3();
240         g.setPaint(color7);
241         g.fill(ellipse);
242         ellipse = decodeEllipse1();
243         g.setPaint(decodeGradient9(ellipse));
244         g.fill(ellipse);
245         ellipse = decodeEllipse2();
246         g.setPaint(decodeGradient10(ellipse));
247         g.fill(ellipse);
248         ellipse = decodeEllipse5();
249         g.setPaint(decodeGradient11(ellipse));
250         g.fill(ellipse);
251
252     }
253
254     private void painticonSelectedAndFocused(Graphics2D g) {
255         ellipse = decodeEllipse4();
256         g.setPaint(color12);
257         g.fill(ellipse);
258         ellipse = decodeEllipse1();
259         g.setPaint(decodeGradient9(ellipse));
260         g.fill(ellipse);
261         ellipse = decodeEllipse2();
262         g.setPaint(decodeGradient10(ellipse));
263         g.fill(ellipse);
264         ellipse = decodeEllipse5();
265         g.setPaint(decodeGradient11(ellipse));
266         g.fill(ellipse);
267
268     }
269
270     private void painticonPressedAndSelected(Graphics2D g) {
271         ellipse = decodeEllipse3();
272         g.setPaint(color19);
273         g.fill(ellipse);
274         ellipse = decodeEllipse1();
275         g.setPaint(decodeGradient12(ellipse));
276         g.fill(ellipse);
277         ellipse = decodeEllipse2();
278         g.setPaint(decodeGradient13(ellipse));
279         g.fill(ellipse);
280         ellipse = decodeEllipse5();
281         g.setPaint(decodeGradient14(ellipse));
282         g.fill(ellipse);
283
284     }
285
286     private void painticonPressedAndSelectedAndFocused(Graphics2D g) {
287         ellipse = decodeEllipse4();
288         g.setPaint(color12);
289         g.fill(ellipse);
290         ellipse = decodeEllipse1();
291         g.setPaint(decodeGradient12(ellipse));
292         g.fill(ellipse);
293         ellipse = decodeEllipse2();
294         g.setPaint(decodeGradient13(ellipse));
295         g.fill(ellipse);
296         ellipse = decodeEllipse5();
297         g.setPaint(decodeGradient14(ellipse));
298         g.fill(ellipse);
299
300     }
301
302     private void painticonMouseOverAndSelected(Graphics2D g) {
303         ellipse = decodeEllipse3();
304         g.setPaint(color7);
305         g.fill(ellipse);
306         ellipse = decodeEllipse1();
307         g.setPaint(decodeGradient15(ellipse));
308         g.fill(ellipse);
309         ellipse = decodeEllipse2();
310         g.setPaint(decodeGradient16(ellipse));
311         g.fill(ellipse);
312         ellipse = decodeEllipse5();
313         g.setPaint(decodeGradient11(ellipse));
314         g.fill(ellipse);
315
316     }
317
318     private void painticonMouseOverAndSelectedAndFocused(Graphics2D g) {
319         ellipse = decodeEllipse4();
320         g.setPaint(color12);
321         g.fill(ellipse);
322         ellipse = decodeEllipse1();
323         g.setPaint(decodeGradient15(ellipse));
324         g.fill(ellipse);
325         ellipse = decodeEllipse2();
326         g.setPaint(decodeGradient16(ellipse));
327         g.fill(ellipse);
328         ellipse = decodeEllipse5();
329         g.setPaint(decodeGradient11(ellipse));
330         g.fill(ellipse);
331
332     }
333
334     private void painticonDisabledAndSelected(Graphics2D g) {
335         ellipse = decodeEllipse1();
336         g.setPaint(decodeGradient17(ellipse));
337         g.fill(ellipse);
338         ellipse = decodeEllipse2();
339         g.setPaint(decodeGradient18(ellipse));
340         g.fill(ellipse);
341         ellipse = decodeEllipse5();
342         g.setPaint(decodeGradient19(ellipse));
343         g.fill(ellipse);
344
345     }
346
347
348
349     private Ellipse2D decodeEllipse1() {
350         ellipse.setFrame(decodeX(0.4f), //x
351
decodeY(0.4f), //y
352
decodeX(2.6f) - decodeX(0.4f), //width
353
decodeY(2.6f) - decodeY(0.4f)); //height
354
return ellipse;
355     }
356
357     private Ellipse2D decodeEllipse2() {
358         ellipse.setFrame(decodeX(0.6f), //x
359
decodeY(0.6f), //y
360
decodeX(2.4f) - decodeX(0.6f), //width
361
decodeY(2.4f) - decodeY(0.6f)); //height
362
return ellipse;
363     }
364
365     private Ellipse2D decodeEllipse3() {
366         ellipse.setFrame(decodeX(0.4f), //x
367
decodeY(0.6f), //y
368
decodeX(2.6f) - decodeX(0.4f), //width
369
decodeY(2.8f) - decodeY(0.6f)); //height
370
return ellipse;
371     }
372
373     private Ellipse2D decodeEllipse4() {
374         ellipse.setFrame(decodeX(0.120000005f), //x
375
decodeY(0.120000005f), //y
376
decodeX(2.8799999f) - decodeX(0.120000005f), //width
377
decodeY(2.8799999f) - decodeY(0.120000005f)); //height
378
return ellipse;
379     }
380
381     private Ellipse2D decodeEllipse5() {
382         ellipse.setFrame(decodeX(1.125f), //x
383
decodeY(1.125f), //y
384
decodeX(1.875f) - decodeX(1.125f), //width
385
decodeY(1.875f) - decodeY(1.125f)); //height
386
return ellipse;
387     }
388
389
390
391     private Paint decodeGradient1(Shape s) {
392         Rectangle2D bounds = s.getBounds2D();
393         float x = (float)bounds.getX();
394         float y = (float)bounds.getY();
395         float w = (float)bounds.getWidth();
396         float h = (float)bounds.getHeight();
397         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
398                 new float[] { 0.0f,0.5f,1.0f },
399                 new Color[] { color1,
400                             decodeColor(color1,color2,0.5f),
401                             color2});
402     }
403
404     private Paint decodeGradient2(Shape s) {
405         Rectangle2D bounds = s.getBounds2D();
406         float x = (float)bounds.getX();
407         float y = (float)bounds.getY();
408         float w = (float)bounds.getWidth();
409         float h = (float)bounds.getHeight();
410         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
411                 new float[] { 0.06344411f,0.21601209f,0.36858007f,0.54833835f,0.72809666f,0.77492446f,0.82175225f,0.91087615f,1.0f },
412                 new Color[] { color3,
413                             decodeColor(color3,color4,0.5f),
414                             color4,
415                             decodeColor(color4,color4,0.5f),
416                             color4,
417                             decodeColor(color4,color5,0.5f),
418                             color5,
419                             decodeColor(color5,color6,0.5f),
420                             color6});
421     }
422
423     private Paint decodeGradient3(Shape s) {
424         Rectangle2D bounds = s.getBounds2D();
425         float x = (float)bounds.getX();
426         float y = (float)bounds.getY();
427         float w = (float)bounds.getWidth();
428         float h = (float)bounds.getHeight();
429         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
430                 new float[] { 0.0f,0.5f,1.0f },
431                 new Color[] { color8,
432                             decodeColor(color8,color9,0.5f),
433                             color9});
434     }
435
436     private Paint decodeGradient4(Shape s) {
437         Rectangle2D bounds = s.getBounds2D();
438         float x = (float)bounds.getX();
439         float y = (float)bounds.getY();
440         float w = (float)bounds.getWidth();
441         float h = (float)bounds.getHeight();
442         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
443                 new float[] { 0.06344411f,0.25009555f,0.43674698f,0.48042166f,0.52409637f,0.70481926f,0.88554215f },
444                 new Color[] { color10,
445                             decodeColor(color10,color4,0.5f),
446                             color4,
447                             decodeColor(color4,color4,0.5f),
448                             color4,
449                             decodeColor(color4,color11,0.5f),
450                             color11});
451     }
452
453     private Paint decodeGradient5(Shape s) {
454         Rectangle2D bounds = s.getBounds2D();
455         float x = (float)bounds.getX();
456         float y = (float)bounds.getY();
457         float w = (float)bounds.getWidth();
458         float h = (float)bounds.getHeight();
459         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
460                 new float[] { 0.0f,0.5f,1.0f },
461                 new Color[] { color13,
462                             decodeColor(color13,color14,0.5f),
463                             color14});
464     }
465
466     private Paint decodeGradient6(Shape s) {
467         Rectangle2D bounds = s.getBounds2D();
468         float x = (float)bounds.getX();
469         float y = (float)bounds.getY();
470         float w = (float)bounds.getWidth();
471         float h = (float)bounds.getHeight();
472         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
473                 new float[] { 0.06344411f,0.21601209f,0.36858007f,0.54833835f,0.72809666f,0.77492446f,0.82175225f,0.91087615f,1.0f },
474                 new Color[] { color15,
475                             decodeColor(color15,color16,0.5f),
476                             color16,
477                             decodeColor(color16,color16,0.5f),
478                             color16,
479                             decodeColor(color16,color17,0.5f),
480                             color17,
481                             decodeColor(color17,color18,0.5f),
482                             color18});
483     }
484
485     private Paint decodeGradient7(Shape s) {
486         Rectangle2D bounds = s.getBounds2D();
487         float x = (float)bounds.getX();
488         float y = (float)bounds.getY();
489         float w = (float)bounds.getWidth();
490         float h = (float)bounds.getHeight();
491         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
492                 new float[] { 0.0f,0.5f,1.0f },
493                 new Color[] { color20,
494                             decodeColor(color20,color21,0.5f),
495                             color21});
496     }
497
498     private Paint decodeGradient8(Shape s) {
499         Rectangle2D bounds = s.getBounds2D();
500         float x = (float)bounds.getX();
501         float y = (float)bounds.getY();
502         float w = (float)bounds.getWidth();
503         float h = (float)bounds.getHeight();
504         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
505                 new float[] { 0.06344411f,0.20792687f,0.35240963f,0.45030123f,0.5481928f,0.748494f,0.9487952f },
506                 new Color[] { color22,
507                             decodeColor(color22,color23,0.5f),
508                             color23,
509                             decodeColor(color23,color23,0.5f),
510                             color23,
511                             decodeColor(color23,color24,0.5f),
512                             color24});
513     }
514
515     private Paint decodeGradient9(Shape s) {
516         Rectangle2D bounds = s.getBounds2D();
517         float x = (float)bounds.getX();
518         float y = (float)bounds.getY();
519         float w = (float)bounds.getWidth();
520         float h = (float)bounds.getHeight();
521         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
522                 new float[] { 0.0f,0.5f,1.0f },
523                 new Color[] { color25,
524                             decodeColor(color25,color26,0.5f),
525                             color26});
526     }
527
528     private Paint decodeGradient10(Shape s) {
529         Rectangle2D bounds = s.getBounds2D();
530         float x = (float)bounds.getX();
531         float y = (float)bounds.getY();
532         float w = (float)bounds.getWidth();
533         float h = (float)bounds.getHeight();
534         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
535                 new float[] { 0.0813253f,0.100903615f,0.12048193f,0.28915662f,0.45783132f,0.6159638f,0.77409637f,0.82981926f,0.88554215f },
536                 new Color[] { color27,
537                             decodeColor(color27,color28,0.5f),
538                             color28,
539                             decodeColor(color28,color29,0.5f),
540                             color29,
541                             decodeColor(color29,color29,0.5f),
542                             color29,
543                             decodeColor(color29,color30,0.5f),
544                             color30});
545     }
546
547     private Paint decodeGradient11(Shape s) {
548         Rectangle2D bounds = s.getBounds2D();
549         float x = (float)bounds.getX();
550         float y = (float)bounds.getY();
551         float w = (float)bounds.getWidth();
552         float h = (float)bounds.getHeight();
553         return decodeGradient((0.50490195f * w) + x, (0.0f * h) + y, (0.49509802f * w) + x, (1.0f * h) + y,
554                 new float[] { 0.0f,0.23192771f,0.46385542f,0.73192775f,1.0f },
555                 new Color[] { color31,
556                             decodeColor(color31,color32,0.5f),
557                             color32,
558                             decodeColor(color32,color33,0.5f),
559                             color33});
560     }
561
562     private Paint decodeGradient12(Shape s) {
563         Rectangle2D bounds = s.getBounds2D();
564         float x = (float)bounds.getX();
565         float y = (float)bounds.getY();
566         float w = (float)bounds.getWidth();
567         float h = (float)bounds.getHeight();
568         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
569                 new float[] { 0.0f,0.5f,1.0f },
570                 new Color[] { color34,
571                             decodeColor(color34,color26,0.5f),
572                             color26});
573     }
574
575     private Paint decodeGradient13(Shape s) {
576         Rectangle2D bounds = s.getBounds2D();
577         float x = (float)bounds.getX();
578         float y = (float)bounds.getY();
579         float w = (float)bounds.getWidth();
580         float h = (float)bounds.getHeight();
581         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
582                 new float[] { 0.039156627f,0.07831325f,0.11746988f,0.2876506f,0.45783132f,0.56174695f,0.66566265f,0.7756024f,0.88554215f },
583                 new Color[] { color36,
584                             decodeColor(color36,color37,0.5f),
585                             color37,
586                             decodeColor(color37,color38,0.5f),
587                             color38,
588                             decodeColor(color38,color38,0.5f),
589                             color38,
590                             decodeColor(color38,color39,0.5f),
591                             color39});
592     }
593
594     private Paint decodeGradient14(Shape s) {
595         Rectangle2D bounds = s.getBounds2D();
596         float x = (float)bounds.getX();
597         float y = (float)bounds.getY();
598         float w = (float)bounds.getWidth();
599         float h = (float)bounds.getHeight();
600         return decodeGradient((0.50490195f * w) + x, (0.0f * h) + y, (0.49509802f * w) + x, (1.0f * h) + y,
601                 new float[] { 0.0f,0.23192771f,0.46385542f,0.73192775f,1.0f },
602                 new Color[] { color40,
603                             decodeColor(color40,color32,0.5f),
604                             color32,
605                             decodeColor(color32,color33,0.5f),
606                             color33});
607     }
608
609     private Paint decodeGradient15(Shape s) {
610         Rectangle2D bounds = s.getBounds2D();
611         float x = (float)bounds.getX();
612         float y = (float)bounds.getY();
613         float w = (float)bounds.getWidth();
614         float h = (float)bounds.getHeight();
615         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
616                 new float[] { 0.0f,0.5f,1.0f },
617                 new Color[] { color41,
618                             decodeColor(color41,color42,0.5f),
619                             color42});
620     }
621
622     private Paint decodeGradient16(Shape s) {
623         Rectangle2D bounds = s.getBounds2D();
624         float x = (float)bounds.getX();
625         float y = (float)bounds.getY();
626         float w = (float)bounds.getWidth();
627         float h = (float)bounds.getHeight();
628         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
629                 new float[] { 0.0813253f,0.100903615f,0.12048193f,0.20180723f,0.28313252f,0.49246985f,0.7018072f,0.7560241f,0.810241f,0.84789157f,0.88554215f },
630                 new Color[] { color43,
631                             decodeColor(color43,color44,0.5f),
632                             color44,
633                             decodeColor(color44,color45,0.5f),
634                             color45,
635                             decodeColor(color45,color45,0.5f),
636                             color45,
637                             decodeColor(color45,color46,0.5f),
638                             color46,
639                             decodeColor(color46,color47,0.5f),
640                             color47});
641     }
642
643     private Paint decodeGradient17(Shape s) {
644         Rectangle2D bounds = s.getBounds2D();
645         float x = (float)bounds.getX();
646         float y = (float)bounds.getY();
647         float w = (float)bounds.getWidth();
648         float h = (float)bounds.getHeight();
649         return decodeGradient((0.49789914f * w) + x, (-0.004201681f * h) + y, (0.5f * w) + x, (0.9978992f * h) + y,
650                 new float[] { 0.0f,0.5f,1.0f },
651                 new Color[] { color48,
652                             decodeColor(color48,color49,0.5f),
653                             color49});
654     }
655
656     private Paint decodeGradient18(Shape s) {
657         Rectangle2D bounds = s.getBounds2D();
658         float x = (float)bounds.getX();
659         float y = (float)bounds.getY();
660         float w = (float)bounds.getWidth();
661         float h = (float)bounds.getHeight();
662         return decodeGradient((0.49754903f * w) + x, (0.004901961f * h) + y, (0.50735295f * w) + x, (1.0f * h) + y,
663                 new float[] { 0.0813253f,0.2695783f,0.45783132f,0.67168677f,0.88554215f },
664                 new Color[] { color50,
665                             decodeColor(color50,color51,0.5f),
666                             color51,
667                             decodeColor(color51,color52,0.5f),
668                             color52});
669     }
670
671     private Paint decodeGradient19(Shape s) {
672         Rectangle2D bounds = s.getBounds2D();
673         float x = (float)bounds.getX();
674         float y = (float)bounds.getY();
675         float w = (float)bounds.getWidth();
676         float h = (float)bounds.getHeight();
677         return decodeGradient((0.50490195f * w) + x, (0.0f * h) + y, (0.49509802f * w) + x, (1.0f * h) + y,
678                 new float[] { 0.0f,0.23192771f,0.46385542f,0.73192775f,1.0f },
679                 new Color[] { color53,
680                             decodeColor(color53,color54,0.5f),
681                             color54,
682                             decodeColor(color54,color55,0.5f),
683                             color55});
684     }
685
686
687 }
688
Popular Tags