KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * CheckBoxPainter.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 CheckBoxPainter 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 CheckBoxPainter 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 CheckBoxPainter 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.06484103f, 0.027450979f, 0);
54     private Color color3 = decodeColor("nimbusBase", 0.032459438f, -0.60996324f, 0.36470586f, 0);
55     private Color color4 = decodeColor("nimbusBase", 0.02551502f, -0.5996783f, 0.3215686f, 0);
56     private Color color5 = decodeColor("nimbusBase", 0.032459438f, -0.59624064f, 0.34509802f, 0);
57     private Color color6 = decodeColor("nimbusBlueGrey", 0.0f, 0.0f, 0.0f, -89);
58     private Color color7 = decodeColor("nimbusBlueGrey", 0.0f, -0.05356429f, -0.12549019f, 0);
59     private Color color8 = decodeColor("nimbusBlueGrey", 0.0f, -0.015789472f, -0.37254903f, 0);
60     private Color color9 = decodeColor("nimbusBase", 0.08801502f, -0.63174605f, 0.43921566f, 0);
61     private Color color10 = decodeColor("nimbusBase", 0.032459438f, -0.5953556f, 0.32549018f, 0);
62     private Color color11 = decodeColor("nimbusBase", 0.032459438f, -0.59942394f, 0.4235294f, 0);
63     private Color color12 = decodeColor("nimbusFocus", 0.0f, 0.0f, 0.0f, 0);
64     private Color color13 = decodeColor("nimbusBlueGrey", 0.0f, -0.020974077f, -0.21960783f, 0);
65     private Color color14 = decodeColor("nimbusBlueGrey", 0.01010108f, 0.08947369f, -0.5294118f, 0);
66     private Color color15 = decodeColor("nimbusBase", 0.08801502f, -0.6317773f, 0.4470588f, 0);
67     private Color color16 = decodeColor("nimbusBase", 0.032459438f, -0.5985242f, 0.39999998f, 0);
68     private Color color17 = decodeColor("nimbusBase", 0.0f, -0.6357143f, 0.45098037f, 0);
69     private Color color18 = decodeColor("nimbusBlueGrey", 0.055555582f, 0.8894737f, -0.7176471f, 0);
70     private Color color19 = decodeColor("nimbusBlueGrey", 0.0f, 0.0016232133f, -0.3254902f, 0);
71     private Color color20 = decodeColor("nimbusBase", 0.027408898f, -0.5847884f, 0.2980392f, 0);
72     private Color color21 = decodeColor("nimbusBase", 0.029681683f, -0.52701867f, 0.17254901f, 0);
73     private Color color22 = decodeColor("nimbusBase", 0.029681683f, -0.5376751f, 0.25098038f, 0);
74     private Color color23 = decodeColor("nimbusBase", 5.1498413E-4f, -0.34585923f, -0.007843137f, 0);
75     private Color color24 = decodeColor("nimbusBase", 5.1498413E-4f, -0.10238093f, -0.25490198f, 0);
76     private Color color25 = decodeColor("nimbusBase", 0.004681647f, -0.6197143f, 0.43137252f, 0);
77     private Color color26 = decodeColor("nimbusBase", 5.1498413E-4f, -0.44153953f, 0.2588235f, 0);
78     private Color color27 = decodeColor("nimbusBase", 5.1498413E-4f, -0.4602757f, 0.34509802f, 0);
79     private Color color28 = decodeColor("nimbusBase", -0.57865167f, -0.6357143f, -0.54901963f, 0);
80     private Color color29 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, 0);
81     private Color color30 = decodeColor("nimbusBase", -3.528595E-5f, 0.026785731f, -0.23529413f, 0);
82     private Color color31 = decodeColor("nimbusBase", -4.2033195E-4f, -0.38050595f, 0.20392156f, 0);
83     private Color color32 = decodeColor("nimbusBase", -0.0021489263f, -0.2891234f, 0.14117646f, 0);
84     private Color color33 = decodeColor("nimbusBase", -0.006362498f, -0.016311288f, -0.02352941f, 0);
85     private Color color34 = decodeColor("nimbusBase", 0.0f, -0.17930403f, 0.21568626f, 0);
86     private Color color35 = decodeColor("nimbusBase", 0.0013483167f, -0.1769987f, -0.12156865f, 0);
87     private Color color36 = decodeColor("nimbusBase", 0.05468172f, 0.3642857f, -0.43137258f, 0);
88     private Color color37 = decodeColor("nimbusBase", 0.004681647f, -0.6198413f, 0.43921566f, 0);
89     private Color color38 = decodeColor("nimbusBase", 5.1498413E-4f, -0.4555341f, 0.3215686f, 0);
90     private Color color39 = decodeColor("nimbusBase", 5.1498413E-4f, -0.47377098f, 0.41960782f, 0);
91     private Color color40 = decodeColor("nimbusBlueGrey", -0.01111114f, -0.03771078f, 0.062745094f, 0);
92     private Color color41 = decodeColor("nimbusBlueGrey", -0.02222222f, -0.032806106f, 0.011764705f, 0);
93     private Color color42 = decodeColor("nimbusBase", 0.021348298f, -0.59223604f, 0.35294116f, 0);
94     private Color color43 = decodeColor("nimbusBase", 0.021348298f, -0.56722116f, 0.3098039f, 0);
95     private Color color44 = decodeColor("nimbusBase", 0.021348298f, -0.56875f, 0.32941175f, 0);
96     private Color color45 = decodeColor("nimbusBase", 0.027408898f, -0.5735674f, 0.14509803f, 0);
97
98
99     //Array of current component colors, updated in each paint call
100
private Object JavaDoc[] componentColors;
101
102     public CheckBoxPainter(PaintContext ctx, int state) {
103         super();
104         this.state = state;
105         this.ctx = ctx;
106     }
107
108     @Override JavaDoc
109     protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object JavaDoc[] extendedCacheKeys) {
110         //populate componentColors array with colors calculated in getExtendedCacheKeys call
111
componentColors = extendedCacheKeys;
112         //generate this entire method. Each state/bg/fg/border combo that has
113
//been painted gets its own KEY and paint method.
114
switch(state) {
115             case ICON_DISABLED: painticonDisabled(g); break;
116             case ICON_ENABLED: painticonEnabled(g); break;
117             case ICON_FOCUSED: painticonFocused(g); break;
118             case ICON_MOUSEOVER: painticonMouseOver(g); break;
119             case ICON_MOUSEOVER_FOCUSED: painticonMouseOverAndFocused(g); break;
120             case ICON_PRESSED: painticonPressed(g); break;
121             case ICON_PRESSED_FOCUSED: painticonPressedAndFocused(g); break;
122             case ICON_SELECTED: painticonSelected(g); break;
123             case ICON_SELECTED_FOCUSED: painticonSelectedAndFocused(g); break;
124             case ICON_PRESSED_SELECTED: painticonPressedAndSelected(g); break;
125             case ICON_PRESSED_SELECTED_FOCUSED: painticonPressedAndSelectedAndFocused(g); break;
126             case ICON_MOUSEOVER_SELECTED: painticonMouseOverAndSelected(g); break;
127             case ICON_MOUSEOVER_SELECTED_FOCUSED: painticonMouseOverAndSelectedAndFocused(g); break;
128             case ICON_DISABLED_SELECTED: painticonDisabledAndSelected(g); break;
129
130         }
131     }
132         
133
134
135     @Override JavaDoc
136     protected final PaintContext getPaintContext() {
137         return ctx;
138     }
139
140     private void painticonDisabled(Graphics2D g) {
141         roundRect = decodeRoundRect1();
142         g.setPaint(decodeGradient1(roundRect));
143         g.fill(roundRect);
144         roundRect = decodeRoundRect2();
145         g.setPaint(decodeGradient2(roundRect));
146         g.fill(roundRect);
147
148     }
149
150     private void painticonEnabled(Graphics2D g) {
151         roundRect = decodeRoundRect3();
152         g.setPaint(color6);
153         g.fill(roundRect);
154         roundRect = decodeRoundRect1();
155         g.setPaint(decodeGradient3(roundRect));
156         g.fill(roundRect);
157         roundRect = decodeRoundRect2();
158         g.setPaint(decodeGradient4(roundRect));
159         g.fill(roundRect);
160
161     }
162
163     private void painticonFocused(Graphics2D g) {
164         roundRect = decodeRoundRect4();
165         g.setPaint(color12);
166         g.fill(roundRect);
167         roundRect = decodeRoundRect1();
168         g.setPaint(decodeGradient3(roundRect));
169         g.fill(roundRect);
170         roundRect = decodeRoundRect2();
171         g.setPaint(decodeGradient4(roundRect));
172         g.fill(roundRect);
173
174     }
175
176     private void painticonMouseOver(Graphics2D g) {
177         roundRect = decodeRoundRect3();
178         g.setPaint(color6);
179         g.fill(roundRect);
180         roundRect = decodeRoundRect1();
181         g.setPaint(decodeGradient5(roundRect));
182         g.fill(roundRect);
183         roundRect = decodeRoundRect2();
184         g.setPaint(decodeGradient6(roundRect));
185         g.fill(roundRect);
186
187     }
188
189     private void painticonMouseOverAndFocused(Graphics2D g) {
190         roundRect = decodeRoundRect4();
191         g.setPaint(color12);
192         g.fill(roundRect);
193         roundRect = decodeRoundRect1();
194         g.setPaint(decodeGradient5(roundRect));
195         g.fill(roundRect);
196         roundRect = decodeRoundRect2();
197         g.setPaint(decodeGradient6(roundRect));
198         g.fill(roundRect);
199
200     }
201
202     private void painticonPressed(Graphics2D g) {
203         roundRect = decodeRoundRect3();
204         g.setPaint(color6);
205         g.fill(roundRect);
206         roundRect = decodeRoundRect1();
207         g.setPaint(decodeGradient7(roundRect));
208         g.fill(roundRect);
209         roundRect = decodeRoundRect2();
210         g.setPaint(decodeGradient8(roundRect));
211         g.fill(roundRect);
212
213     }
214
215     private void painticonPressedAndFocused(Graphics2D g) {
216         roundRect = decodeRoundRect4();
217         g.setPaint(color12);
218         g.fill(roundRect);
219         roundRect = decodeRoundRect1();
220         g.setPaint(decodeGradient7(roundRect));
221         g.fill(roundRect);
222         roundRect = decodeRoundRect2();
223         g.setPaint(decodeGradient8(roundRect));
224         g.fill(roundRect);
225
226     }
227
228     private void painticonSelected(Graphics2D g) {
229         roundRect = decodeRoundRect3();
230         g.setPaint(color6);
231         g.fill(roundRect);
232         roundRect = decodeRoundRect1();
233         g.setPaint(decodeGradient9(roundRect));
234         g.fill(roundRect);
235         roundRect = decodeRoundRect2();
236         g.setPaint(decodeGradient10(roundRect));
237         g.fill(roundRect);
238         path = decodePath1();
239         g.setPaint(color28);
240         g.fill(path);
241
242     }
243
244     private void painticonSelectedAndFocused(Graphics2D g) {
245         roundRect = decodeRoundRect4();
246         g.setPaint(color12);
247         g.fill(roundRect);
248         roundRect = decodeRoundRect1();
249         g.setPaint(decodeGradient9(roundRect));
250         g.fill(roundRect);
251         roundRect = decodeRoundRect2();
252         g.setPaint(decodeGradient10(roundRect));
253         g.fill(roundRect);
254         path = decodePath1();
255         g.setPaint(color28);
256         g.fill(path);
257
258     }
259
260     private void painticonPressedAndSelected(Graphics2D g) {
261         roundRect = decodeRoundRect3();
262         g.setPaint(color29);
263         g.fill(roundRect);
264         roundRect = decodeRoundRect1();
265         g.setPaint(decodeGradient11(roundRect));
266         g.fill(roundRect);
267         roundRect = decodeRoundRect2();
268         g.setPaint(decodeGradient12(roundRect));
269         g.fill(roundRect);
270         path = decodePath1();
271         g.setPaint(color28);
272         g.fill(path);
273
274     }
275
276     private void painticonPressedAndSelectedAndFocused(Graphics2D g) {
277         roundRect = decodeRoundRect4();
278         g.setPaint(color12);
279         g.fill(roundRect);
280         roundRect = decodeRoundRect1();
281         g.setPaint(decodeGradient11(roundRect));
282         g.fill(roundRect);
283         roundRect = decodeRoundRect2();
284         g.setPaint(decodeGradient12(roundRect));
285         g.fill(roundRect);
286         path = decodePath1();
287         g.setPaint(color28);
288         g.fill(path);
289
290     }
291
292     private void painticonMouseOverAndSelected(Graphics2D g) {
293         roundRect = decodeRoundRect3();
294         g.setPaint(color6);
295         g.fill(roundRect);
296         roundRect = decodeRoundRect1();
297         g.setPaint(decodeGradient13(roundRect));
298         g.fill(roundRect);
299         roundRect = decodeRoundRect2();
300         g.setPaint(decodeGradient14(roundRect));
301         g.fill(roundRect);
302         path = decodePath1();
303         g.setPaint(color28);
304         g.fill(path);
305
306     }
307
308     private void painticonMouseOverAndSelectedAndFocused(Graphics2D g) {
309         roundRect = decodeRoundRect4();
310         g.setPaint(color12);
311         g.fill(roundRect);
312         roundRect = decodeRoundRect1();
313         g.setPaint(decodeGradient13(roundRect));
314         g.fill(roundRect);
315         roundRect = decodeRoundRect2();
316         g.setPaint(decodeGradient14(roundRect));
317         g.fill(roundRect);
318         path = decodePath1();
319         g.setPaint(color28);
320         g.fill(path);
321
322     }
323
324     private void painticonDisabledAndSelected(Graphics2D g) {
325         roundRect = decodeRoundRect1();
326         g.setPaint(decodeGradient15(roundRect));
327         g.fill(roundRect);
328         roundRect = decodeRoundRect2();
329         g.setPaint(decodeGradient16(roundRect));
330         g.fill(roundRect);
331         path = decodePath1();
332         g.setPaint(color45);
333         g.fill(path);
334
335     }
336
337
338
339     private RoundRectangle2D decodeRoundRect1() {
340         roundRect.setRoundRect(decodeX(0.4f), //x
341
decodeY(0.4f), //y
342
decodeX(2.6f) - decodeX(0.4f), //width
343
decodeY(2.6f) - decodeY(0.4f), //height
344
3.7058823f, 3.7058823f); //rounding
345
return roundRect;
346     }
347
348     private RoundRectangle2D decodeRoundRect2() {
349         roundRect.setRoundRect(decodeX(0.6f), //x
350
decodeY(0.6f), //y
351
decodeX(2.4f) - decodeX(0.6f), //width
352
decodeY(2.4f) - decodeY(0.6f), //height
353
3.764706f, 3.764706f); //rounding
354
return roundRect;
355     }
356
357     private RoundRectangle2D decodeRoundRect3() {
358         roundRect.setRoundRect(decodeX(0.4f), //x
359
decodeY(1.75f), //y
360
decodeX(2.6f) - decodeX(0.4f), //width
361
decodeY(2.8f) - decodeY(1.75f), //height
362
5.1764708f, 5.1764708f); //rounding
363
return roundRect;
364     }
365
366     private RoundRectangle2D decodeRoundRect4() {
367         roundRect.setRoundRect(decodeX(0.120000005f), //x
368
decodeY(0.120000005f), //y
369
decodeX(2.8799999f) - decodeX(0.120000005f), //width
370
decodeY(2.8799999f) - decodeY(0.120000005f), //height
371
8.0f, 8.0f); //rounding
372
return roundRect;
373     }
374
375     private Path2D decodePath1() {
376         path.reset();
377         path.moveTo(decodeX(1.0036764f), decodeY(1.382353f));
378         path.lineTo(decodeX(1.2536764f), decodeY(1.382353f));
379         path.lineTo(decodeX(1.430147f), decodeY(1.757353f));
380         path.lineTo(decodeX(1.8235294f), decodeY(0.62352943f));
381         path.lineTo(decodeX(2.2f), decodeY(0.61764705f));
382         path.lineTo(decodeX(1.492647f), decodeY(2.0058823f));
383         path.lineTo(decodeX(1.382353f), decodeY(2.0058823f));
384         path.lineTo(decodeX(1.0036764f), decodeY(1.382353f));
385         path.closePath();
386         return path;
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.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * 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.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
411                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
412                 new Color[] { color3,
413                             decodeColor(color3,color4,0.5f),
414                             color4,
415                             decodeColor(color4,color5,0.5f),
416                             color5});
417     }
418
419     private Paint decodeGradient3(Shape s) {
420         Rectangle2D bounds = s.getBounds2D();
421         float x = (float)bounds.getX();
422         float y = (float)bounds.getY();
423         float w = (float)bounds.getWidth();
424         float h = (float)bounds.getHeight();
425         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
426                 new float[] { 0.0f,0.5f,1.0f },
427                 new Color[] { color7,
428                             decodeColor(color7,color8,0.5f),
429                             color8});
430     }
431
432     private Paint decodeGradient4(Shape s) {
433         Rectangle2D bounds = s.getBounds2D();
434         float x = (float)bounds.getX();
435         float y = (float)bounds.getY();
436         float w = (float)bounds.getWidth();
437         float h = (float)bounds.getHeight();
438         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
439                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
440                 new Color[] { color9,
441                             decodeColor(color9,color10,0.5f),
442                             color10,
443                             decodeColor(color10,color11,0.5f),
444                             color11});
445     }
446
447     private Paint decodeGradient5(Shape s) {
448         Rectangle2D bounds = s.getBounds2D();
449         float x = (float)bounds.getX();
450         float y = (float)bounds.getY();
451         float w = (float)bounds.getWidth();
452         float h = (float)bounds.getHeight();
453         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
454                 new float[] { 0.0f,0.5f,1.0f },
455                 new Color[] { color13,
456                             decodeColor(color13,color14,0.5f),
457                             color14});
458     }
459
460     private Paint decodeGradient6(Shape s) {
461         Rectangle2D bounds = s.getBounds2D();
462         float x = (float)bounds.getX();
463         float y = (float)bounds.getY();
464         float w = (float)bounds.getWidth();
465         float h = (float)bounds.getHeight();
466         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
467                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
468                 new Color[] { color15,
469                             decodeColor(color15,color16,0.5f),
470                             color16,
471                             decodeColor(color16,color17,0.5f),
472                             color17});
473     }
474
475     private Paint decodeGradient7(Shape s) {
476         Rectangle2D bounds = s.getBounds2D();
477         float x = (float)bounds.getX();
478         float y = (float)bounds.getY();
479         float w = (float)bounds.getWidth();
480         float h = (float)bounds.getHeight();
481         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
482                 new float[] { 0.0f,0.5f,1.0f },
483                 new Color[] { color18,
484                             decodeColor(color18,color19,0.5f),
485                             color19});
486     }
487
488     private Paint decodeGradient8(Shape s) {
489         Rectangle2D bounds = s.getBounds2D();
490         float x = (float)bounds.getX();
491         float y = (float)bounds.getY();
492         float w = (float)bounds.getWidth();
493         float h = (float)bounds.getHeight();
494         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
495                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
496                 new Color[] { color20,
497                             decodeColor(color20,color21,0.5f),
498                             color21,
499                             decodeColor(color21,color22,0.5f),
500                             color22});
501     }
502
503     private Paint decodeGradient9(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.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
510                 new float[] { 0.0f,0.5f,1.0f },
511                 new Color[] { color23,
512                             decodeColor(color23,color24,0.5f),
513                             color24});
514     }
515
516     private Paint decodeGradient10(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.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
523                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
524                 new Color[] { color25,
525                             decodeColor(color25,color26,0.5f),
526                             color26,
527                             decodeColor(color26,color27,0.5f),
528                             color27});
529     }
530
531     private Paint decodeGradient11(Shape s) {
532         Rectangle2D bounds = s.getBounds2D();
533         float x = (float)bounds.getX();
534         float y = (float)bounds.getY();
535         float w = (float)bounds.getWidth();
536         float h = (float)bounds.getHeight();
537         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
538                 new float[] { 0.0f,0.5f,1.0f },
539                 new Color[] { color28,
540                             decodeColor(color28,color30,0.5f),
541                             color30});
542     }
543
544     private Paint decodeGradient12(Shape s) {
545         Rectangle2D bounds = s.getBounds2D();
546         float x = (float)bounds.getX();
547         float y = (float)bounds.getY();
548         float w = (float)bounds.getWidth();
549         float h = (float)bounds.getHeight();
550         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
551                 new float[] { 0.0f,0.05775076f,0.11550152f,0.38003993f,0.64457834f,0.82228917f,1.0f },
552                 new Color[] { color31,
553                             decodeColor(color31,color32,0.5f),
554                             color32,
555                             decodeColor(color32,color33,0.5f),
556                             color33,
557                             decodeColor(color33,color34,0.5f),
558                             color34});
559     }
560
561     private Paint decodeGradient13(Shape s) {
562         Rectangle2D bounds = s.getBounds2D();
563         float x = (float)bounds.getX();
564         float y = (float)bounds.getY();
565         float w = (float)bounds.getWidth();
566         float h = (float)bounds.getHeight();
567         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
568                 new float[] { 0.0f,0.5f,1.0f },
569                 new Color[] { color35,
570                             decodeColor(color35,color36,0.5f),
571                             color36});
572     }
573
574     private Paint decodeGradient14(Shape s) {
575         Rectangle2D bounds = s.getBounds2D();
576         float x = (float)bounds.getX();
577         float y = (float)bounds.getY();
578         float w = (float)bounds.getWidth();
579         float h = (float)bounds.getHeight();
580         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
581                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
582                 new Color[] { color37,
583                             decodeColor(color37,color38,0.5f),
584                             color38,
585                             decodeColor(color38,color39,0.5f),
586                             color39});
587     }
588
589     private Paint decodeGradient15(Shape s) {
590         Rectangle2D bounds = s.getBounds2D();
591         float x = (float)bounds.getX();
592         float y = (float)bounds.getY();
593         float w = (float)bounds.getWidth();
594         float h = (float)bounds.getHeight();
595         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25210086f * w) + x, (0.9957983f * h) + y,
596                 new float[] { 0.0f,0.5f,1.0f },
597                 new Color[] { color40,
598                             decodeColor(color40,color41,0.5f),
599                             color41});
600     }
601
602     private Paint decodeGradient16(Shape s) {
603         Rectangle2D bounds = s.getBounds2D();
604         float x = (float)bounds.getX();
605         float y = (float)bounds.getY();
606         float w = (float)bounds.getWidth();
607         float h = (float)bounds.getHeight();
608         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (0.997549f * h) + y,
609                 new float[] { 0.0f,0.32228917f,0.64457834f,0.82228917f,1.0f },
610                 new Color[] { color42,
611                             decodeColor(color42,color43,0.5f),
612                             color43,
613                             decodeColor(color43,color44,0.5f),
614                             color44});
615     }
616
617
618 }
619
Popular Tags