KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * ToolBarToggleButtonPainter.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 ToolBarToggleButtonPainter 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 ToolBarToggleButtonPainter to determine which region/state is being painted
21
//by that instance.
22
static final int BACKGROUND_ENABLED = 1;
23     static final int BACKGROUND_FOCUSED = 2;
24     static final int BACKGROUND_MOUSEOVER = 3;
25     static final int BACKGROUND_MOUSEOVER_FOCUSED = 4;
26     static final int BACKGROUND_PRESSED = 5;
27     static final int BACKGROUND_PRESSED_FOCUSED = 6;
28     static final int BACKGROUND_SELECTED = 7;
29     static final int BACKGROUND_SELECTED_FOCUSED = 8;
30     static final int BACKGROUND_PRESSED_SELECTED = 9;
31     static final int BACKGROUND_PRESSED_SELECTED_FOCUSED = 10;
32     static final int BACKGROUND_MOUSEOVER_SELECTED = 11;
33     static final int BACKGROUND_MOUSEOVER_SELECTED_FOCUSED = 12;
34     static final int BACKGROUND_DISABLED_SELECTED = 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 ToolBarToggleButtonPainter would be created. For the moment at least,
48
//however, all are created for each instance.
49
private Color color1 = decodeColor("nimbusFocus", 0.0f, 0.0f, 0.0f, 0);
50     private Color color2 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.06885965f, -0.36862746f, -153);
51     private Color color3 = decodeColor("nimbusBlueGrey", 0.0f, -0.020974077f, -0.21960783f, 0);
52     private Color color4 = decodeColor("nimbusBlueGrey", 0.0f, 0.11169591f, -0.53333336f, 0);
53     private Color color5 = decodeColor("nimbusBlueGrey", 0.055555582f, -0.10658931f, 0.25098038f, 0);
54     private Color color6 = decodeColor("nimbusBlueGrey", 0.0f, -0.098526314f, 0.2352941f, 0);
55     private Color color7 = decodeColor("nimbusBlueGrey", 0.0f, -0.07333623f, 0.20392156f, 0);
56     private Color color8 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, 0);
57     private Color color9 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -86);
58     private Color color10 = decodeColor("nimbusBlueGrey", -0.01111114f, -0.060526315f, -0.3529412f, 0);
59     private Color color11 = decodeColor("nimbusBlueGrey", 0.0f, -0.064372465f, -0.2352941f, 0);
60     private Color color12 = decodeColor("nimbusBlueGrey", -0.006944418f, -0.0595709f, -0.12941176f, 0);
61     private Color color13 = decodeColor("nimbusBlueGrey", 0.0f, -0.061075766f, -0.031372547f, 0);
62     private Color color14 = decodeColor("nimbusBlueGrey", 0.0f, -0.06080256f, -0.035294116f, 0);
63     private Color color15 = decodeColor("nimbusBlueGrey", 0.0f, -0.06472479f, -0.23137254f, 0);
64     private Color color16 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.06959064f, -0.0745098f, 0);
65     private Color color17 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.06401469f, -0.07058823f, 0);
66     private Color color18 = decodeColor("nimbusBlueGrey", 0.0f, -0.06530018f, 0.035294116f, 0);
67     private Color color19 = decodeColor("nimbusBlueGrey", 0.0f, -0.06507177f, 0.031372547f, 0);
68     private Color color20 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.05338346f, -0.47058824f, 0);
69     private Color color21 = decodeColor("nimbusBlueGrey", 0.0f, -0.049301825f, -0.36078432f, 0);
70     private Color color22 = decodeColor("nimbusBlueGrey", -0.018518567f, -0.03909774f, -0.2509804f, 0);
71     private Color color23 = decodeColor("nimbusBlueGrey", -0.00505054f, -0.040013492f, -0.13333333f, 0);
72     private Color color24 = decodeColor("nimbusBlueGrey", 0.01010108f, -0.039558575f, -0.1372549f, 0);
73     private Color color25 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -220);
74     private Color color26 = decodeColor("nimbusBlueGrey", 0.0f, -0.066408664f, 0.054901958f, 0);
75     private Color color27 = decodeColor("nimbusBlueGrey", 0.0f, -0.06807348f, 0.086274505f, 0);
76     private Color color28 = decodeColor("nimbusBlueGrey", 0.0f, -0.06924191f, 0.109803915f, 0);
77
78
79     //Array of current component colors, updated in each paint call
80
private Object JavaDoc[] componentColors;
81
82     public ToolBarToggleButtonPainter(PaintContext ctx, int state) {
83         super();
84         this.state = state;
85         this.ctx = ctx;
86     }
87
88     @Override JavaDoc
89     protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object JavaDoc[] extendedCacheKeys) {
90         //populate componentColors array with colors calculated in getExtendedCacheKeys call
91
componentColors = extendedCacheKeys;
92         //generate this entire method. Each state/bg/fg/border combo that has
93
//been painted gets its own KEY and paint method.
94
switch(state) {
95             case BACKGROUND_FOCUSED: paintBackgroundFocused(g); break;
96             case BACKGROUND_MOUSEOVER: paintBackgroundMouseOver(g); break;
97             case BACKGROUND_MOUSEOVER_FOCUSED: paintBackgroundMouseOverAndFocused(g); break;
98             case BACKGROUND_PRESSED: paintBackgroundPressed(g); break;
99             case BACKGROUND_PRESSED_FOCUSED: paintBackgroundPressedAndFocused(g); break;
100             case BACKGROUND_SELECTED: paintBackgroundSelected(g); break;
101             case BACKGROUND_SELECTED_FOCUSED: paintBackgroundSelectedAndFocused(g); break;
102             case BACKGROUND_PRESSED_SELECTED: paintBackgroundPressedAndSelected(g); break;
103             case BACKGROUND_PRESSED_SELECTED_FOCUSED: paintBackgroundPressedAndSelectedAndFocused(g); break;
104             case BACKGROUND_MOUSEOVER_SELECTED: paintBackgroundMouseOverAndSelected(g); break;
105             case BACKGROUND_MOUSEOVER_SELECTED_FOCUSED: paintBackgroundMouseOverAndSelectedAndFocused(g); break;
106             case BACKGROUND_DISABLED_SELECTED: paintBackgroundDisabledAndSelected(g); break;
107
108         }
109     }
110         
111
112
113     @Override JavaDoc
114     protected final PaintContext getPaintContext() {
115         return ctx;
116     }
117
118     private void paintBackgroundFocused(Graphics2D g) {
119         path = decodePath1();
120         g.setPaint(color1);
121         g.fill(path);
122
123     }
124
125     private void paintBackgroundMouseOver(Graphics2D g) {
126         roundRect = decodeRoundRect1();
127         g.setPaint(color2);
128         g.fill(roundRect);
129         roundRect = decodeRoundRect2();
130         g.setPaint(decodeGradient1(roundRect));
131         g.fill(roundRect);
132         roundRect = decodeRoundRect3();
133         g.setPaint(decodeGradient2(roundRect));
134         g.fill(roundRect);
135
136     }
137
138     private void paintBackgroundMouseOverAndFocused(Graphics2D g) {
139         roundRect = decodeRoundRect4();
140         g.setPaint(color1);
141         g.fill(roundRect);
142         roundRect = decodeRoundRect2();
143         g.setPaint(decodeGradient1(roundRect));
144         g.fill(roundRect);
145         roundRect = decodeRoundRect3();
146         g.setPaint(decodeGradient2(roundRect));
147         g.fill(roundRect);
148
149     }
150
151     private void paintBackgroundPressed(Graphics2D g) {
152         roundRect = decodeRoundRect5();
153         g.setPaint(color9);
154         g.fill(roundRect);
155         roundRect = decodeRoundRect6();
156         g.setPaint(decodeGradient3(roundRect));
157         g.fill(roundRect);
158         roundRect = decodeRoundRect7();
159         g.setPaint(decodeGradient4(roundRect));
160         g.fill(roundRect);
161
162     }
163
164     private void paintBackgroundPressedAndFocused(Graphics2D g) {
165         roundRect = decodeRoundRect8();
166         g.setPaint(color1);
167         g.fill(roundRect);
168         roundRect = decodeRoundRect6();
169         g.setPaint(decodeGradient3(roundRect));
170         g.fill(roundRect);
171         roundRect = decodeRoundRect7();
172         g.setPaint(decodeGradient4(roundRect));
173         g.fill(roundRect);
174
175     }
176
177     private void paintBackgroundSelected(Graphics2D g) {
178         roundRect = decodeRoundRect5();
179         g.setPaint(color9);
180         g.fill(roundRect);
181         roundRect = decodeRoundRect6();
182         g.setPaint(decodeGradient5(roundRect));
183         g.fill(roundRect);
184         roundRect = decodeRoundRect7();
185         g.setPaint(decodeGradient6(roundRect));
186         g.fill(roundRect);
187
188     }
189
190     private void paintBackgroundSelectedAndFocused(Graphics2D g) {
191         roundRect = decodeRoundRect8();
192         g.setPaint(color1);
193         g.fill(roundRect);
194         roundRect = decodeRoundRect6();
195         g.setPaint(decodeGradient5(roundRect));
196         g.fill(roundRect);
197         roundRect = decodeRoundRect7();
198         g.setPaint(decodeGradient6(roundRect));
199         g.fill(roundRect);
200
201     }
202
203     private void paintBackgroundPressedAndSelected(Graphics2D g) {
204         roundRect = decodeRoundRect5();
205         g.setPaint(color9);
206         g.fill(roundRect);
207         roundRect = decodeRoundRect6();
208         g.setPaint(decodeGradient7(roundRect));
209         g.fill(roundRect);
210         roundRect = decodeRoundRect7();
211         g.setPaint(decodeGradient8(roundRect));
212         g.fill(roundRect);
213
214     }
215
216     private void paintBackgroundPressedAndSelectedAndFocused(Graphics2D g) {
217         roundRect = decodeRoundRect8();
218         g.setPaint(color1);
219         g.fill(roundRect);
220         roundRect = decodeRoundRect6();
221         g.setPaint(decodeGradient7(roundRect));
222         g.fill(roundRect);
223         roundRect = decodeRoundRect7();
224         g.setPaint(decodeGradient8(roundRect));
225         g.fill(roundRect);
226
227     }
228
229     private void paintBackgroundMouseOverAndSelected(Graphics2D g) {
230         roundRect = decodeRoundRect5();
231         g.setPaint(color9);
232         g.fill(roundRect);
233         roundRect = decodeRoundRect6();
234         g.setPaint(decodeGradient3(roundRect));
235         g.fill(roundRect);
236         roundRect = decodeRoundRect7();
237         g.setPaint(decodeGradient4(roundRect));
238         g.fill(roundRect);
239
240     }
241
242     private void paintBackgroundMouseOverAndSelectedAndFocused(Graphics2D g) {
243         roundRect = decodeRoundRect8();
244         g.setPaint(color1);
245         g.fill(roundRect);
246         roundRect = decodeRoundRect6();
247         g.setPaint(decodeGradient3(roundRect));
248         g.fill(roundRect);
249         roundRect = decodeRoundRect7();
250         g.setPaint(decodeGradient4(roundRect));
251         g.fill(roundRect);
252
253     }
254
255     private void paintBackgroundDisabledAndSelected(Graphics2D g) {
256         roundRect = decodeRoundRect5();
257         g.setPaint(color25);
258         g.fill(roundRect);
259         roundRect = decodeRoundRect6();
260         g.setPaint(decodeGradient9(roundRect));
261         g.fill(roundRect);
262         roundRect = decodeRoundRect7();
263         g.setPaint(decodeGradient10(roundRect));
264         g.fill(roundRect);
265
266     }
267
268
269
270     private Path2D decodePath1() {
271         path.reset();
272         path.moveTo(decodeX(1.4133738f), decodeY(0.120000005f));
273         path.lineTo(decodeX(1.9893618f), decodeY(0.120000005f));
274         path.curveTo(decodeAnchorX(1.9893617630004883f, 3.0f), decodeAnchorY(0.12000000476837158f, 0.0f), decodeAnchorX(2.8857147693634033f, 0.0f), decodeAnchorY(1.0416666269302368f, -3.0f), decodeX(2.8857148f), decodeY(1.0416666f));
275         path.lineTo(decodeX(2.9f), decodeY(1.9166667f));
276         path.curveTo(decodeAnchorX(2.9000000953674316f, 0.0f), decodeAnchorY(1.9166667461395264f, 3.0f), decodeAnchorX(1.9893617630004883f, 3.0f), decodeAnchorY(2.671428680419922f, 0.0f), decodeX(1.9893618f), decodeY(2.6714287f));
277         path.lineTo(decodeX(1.0106384f), decodeY(2.6714287f));
278         path.curveTo(decodeAnchorX(1.0106383562088013f, -3.0f), decodeAnchorY(2.671428680419922f, 0.0f), decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(1.9166667461395264f, 3.0f), decodeX(0.120000005f), decodeY(1.9166667f));
279         path.lineTo(decodeX(0.120000005f), decodeY(1.0446429f));
280         path.curveTo(decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(1.0446429252624512f, -3.000000000000001f), decodeAnchorX(1.0106383562088013f, -3.0f), decodeAnchorY(0.12000000476837158f, 0.0f), decodeX(1.0106384f), decodeY(0.120000005f));
281         path.lineTo(decodeX(1.4148936f), decodeY(0.120000005f));
282         path.lineTo(decodeX(1.4148936f), decodeY(0.4857143f));
283         path.lineTo(decodeX(1.0106384f), decodeY(0.4857143f));
284         path.curveTo(decodeAnchorX(1.0106383562088013f, -1.928571428571427f), decodeAnchorY(0.48571428656578064f, 0.0f), decodeAnchorX(0.4714285731315613f, -0.04427948362011014f), decodeAnchorY(1.038690447807312f, -2.429218094741624f), decodeX(0.47142857f), decodeY(1.0386904f));
285         path.lineTo(decodeX(0.47142857f), decodeY(1.9166667f));
286         path.curveTo(decodeAnchorX(0.4714285731315613f, 0.0f), decodeAnchorY(1.9166667461395264f, 2.2142857142856975f), decodeAnchorX(1.0106383562088013f, -1.7857142857142847f), decodeAnchorY(2.3142857551574707f, 0.0f), decodeX(1.0106384f), decodeY(2.3142858f));
287         path.lineTo(decodeX(1.9893618f), decodeY(2.3142858f));
288         path.curveTo(decodeAnchorX(1.9893617630004883f, 2.071428571428598f), decodeAnchorY(2.3142857551574707f, 0.0f), decodeAnchorX(2.5f, 0.0f), decodeAnchorY(1.9166667461395264f, 2.2142857142857046f), decodeX(2.5f), decodeY(1.9166667f));
289         path.lineTo(decodeX(2.5142853f), decodeY(1.0416666f));
290         path.curveTo(decodeAnchorX(2.5142853260040283f, 0.0f), decodeAnchorY(1.0416666269302368f, -2.1428571428571406f), decodeAnchorX(1.990121603012085f, 2.142857142857167f), decodeAnchorY(0.4714285731315613f, 0.0f), decodeX(1.9901216f), decodeY(0.47142857f));
291         path.lineTo(decodeX(1.4148936f), decodeY(0.4857143f));
292         path.lineTo(decodeX(1.4133738f), decodeY(0.120000005f));
293         path.closePath();
294         return path;
295     }
296
297     private RoundRectangle2D decodeRoundRect1() {
298         roundRect.setRoundRect(decodeX(0.4f), //x
299
decodeY(0.6f), //y
300
decodeX(2.6f) - decodeX(0.4f), //width
301
decodeY(2.6f) - decodeY(0.6f), //height
302
12.0f, 12.0f); //rounding
303
return roundRect;
304     }
305
306     private RoundRectangle2D decodeRoundRect2() {
307         roundRect.setRoundRect(decodeX(0.4f), //x
308
decodeY(0.4f), //y
309
decodeX(2.6f) - decodeX(0.4f), //width
310
decodeY(2.4f) - decodeY(0.4f), //height
311
12.0f, 12.0f); //rounding
312
return roundRect;
313     }
314
315     private RoundRectangle2D decodeRoundRect3() {
316         roundRect.setRoundRect(decodeX(0.6f), //x
317
decodeY(0.6f), //y
318
decodeX(2.4f) - decodeX(0.6f), //width
319
decodeY(2.2f) - decodeY(0.6f), //height
320
9.0f, 9.0f); //rounding
321
return roundRect;
322     }
323
324     private RoundRectangle2D decodeRoundRect4() {
325         roundRect.setRoundRect(decodeX(0.120000005f), //x
326
decodeY(0.120000005f), //y
327
decodeX(2.8800004f) - decodeX(0.120000005f), //width
328
decodeY(2.6800003f) - decodeY(0.120000005f), //height
329
13.0f, 13.0f); //rounding
330
return roundRect;
331     }
332
333     private RoundRectangle2D decodeRoundRect5() {
334         roundRect.setRoundRect(decodeX(0.4f), //x
335
decodeY(0.6f), //y
336
decodeX(2.6f) - decodeX(0.4f), //width
337
decodeY(2.6f) - decodeY(0.6f), //height
338
10.0f, 10.0f); //rounding
339
return roundRect;
340     }
341
342     private RoundRectangle2D decodeRoundRect6() {
343         roundRect.setRoundRect(decodeX(0.4f), //x
344
decodeY(0.4f), //y
345
decodeX(2.6f) - decodeX(0.4f), //width
346
decodeY(2.4f) - decodeY(0.4f), //height
347
10.0f, 10.0f); //rounding
348
return roundRect;
349     }
350
351     private RoundRectangle2D decodeRoundRect7() {
352         roundRect.setRoundRect(decodeX(0.6f), //x
353
decodeY(0.6f), //y
354
decodeX(2.4f) - decodeX(0.6f), //width
355
decodeY(2.2f) - decodeY(0.6f), //height
356
8.0f, 8.0f); //rounding
357
return roundRect;
358     }
359
360     private RoundRectangle2D decodeRoundRect8() {
361         roundRect.setRoundRect(decodeX(0.120000005f), //x
362
decodeY(0.120000005f), //y
363
decodeX(2.8800004f) - decodeX(0.120000005f), //width
364
decodeY(2.6799998f) - decodeY(0.120000005f), //height
365
13.0f, 13.0f); //rounding
366
return roundRect;
367     }
368
369
370
371     private Paint decodeGradient1(Shape s) {
372         Rectangle2D bounds = s.getBounds2D();
373         float x = (float)bounds.getX();
374         float y = (float)bounds.getY();
375         float w = (float)bounds.getWidth();
376         float h = (float)bounds.getHeight();
377         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
378                 new float[] { 0.09f,0.52f,0.95f },
379                 new Color[] { color3,
380                             decodeColor(color3,color4,0.5f),
381                             color4});
382     }
383
384     private Paint decodeGradient2(Shape s) {
385         Rectangle2D bounds = s.getBounds2D();
386         float x = (float)bounds.getX();
387         float y = (float)bounds.getY();
388         float w = (float)bounds.getWidth();
389         float h = (float)bounds.getHeight();
390         return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y,
391                 new float[] { 0.0f,0.03f,0.06f,0.33f,0.6f,0.65f,0.7f,0.825f,0.95f,0.975f,1.0f },
392                 new Color[] { color5,
393                             decodeColor(color5,color6,0.5f),
394                             color6,
395                             decodeColor(color6,color7,0.5f),
396                             color7,
397                             decodeColor(color7,color7,0.5f),
398                             color7,
399                             decodeColor(color7,color8,0.5f),
400                             color8,
401                             decodeColor(color8,color8,0.5f),
402                             color8});
403     }
404
405     private Paint decodeGradient3(Shape s) {
406         Rectangle2D bounds = s.getBounds2D();
407         float x = (float)bounds.getX();
408         float y = (float)bounds.getY();
409         float w = (float)bounds.getWidth();
410         float h = (float)bounds.getHeight();
411         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (1.0041667f * h) + y,
412                 new float[] { 0.0f,0.5f,1.0f },
413                 new Color[] { color10,
414                             decodeColor(color10,color11,0.5f),
415                             color11});
416     }
417
418     private Paint decodeGradient4(Shape s) {
419         Rectangle2D bounds = s.getBounds2D();
420         float x = (float)bounds.getX();
421         float y = (float)bounds.getY();
422         float w = (float)bounds.getWidth();
423         float h = (float)bounds.getHeight();
424         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25126263f * w) + x, (1.0092592f * h) + y,
425                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
426                 new Color[] { color12,
427                             decodeColor(color12,color13,0.5f),
428                             color13,
429                             decodeColor(color13,color14,0.5f),
430                             color14});
431     }
432
433     private Paint decodeGradient5(Shape s) {
434         Rectangle2D bounds = s.getBounds2D();
435         float x = (float)bounds.getX();
436         float y = (float)bounds.getY();
437         float w = (float)bounds.getWidth();
438         float h = (float)bounds.getHeight();
439         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (1.0041667f * h) + y,
440                 new float[] { 0.0f,0.5f,1.0f },
441                 new Color[] { color15,
442                             decodeColor(color15,color16,0.5f),
443                             color16});
444     }
445
446     private Paint decodeGradient6(Shape s) {
447         Rectangle2D bounds = s.getBounds2D();
448         float x = (float)bounds.getX();
449         float y = (float)bounds.getY();
450         float w = (float)bounds.getWidth();
451         float h = (float)bounds.getHeight();
452         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25126263f * w) + x, (1.0092592f * h) + y,
453                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
454                 new Color[] { color17,
455                             decodeColor(color17,color18,0.5f),
456                             color18,
457                             decodeColor(color18,color19,0.5f),
458                             color19});
459     }
460
461     private Paint decodeGradient7(Shape s) {
462         Rectangle2D bounds = s.getBounds2D();
463         float x = (float)bounds.getX();
464         float y = (float)bounds.getY();
465         float w = (float)bounds.getWidth();
466         float h = (float)bounds.getHeight();
467         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (1.0041667f * h) + y,
468                 new float[] { 0.0f,0.5f,1.0f },
469                 new Color[] { color20,
470                             decodeColor(color20,color21,0.5f),
471                             color21});
472     }
473
474     private Paint decodeGradient8(Shape s) {
475         Rectangle2D bounds = s.getBounds2D();
476         float x = (float)bounds.getX();
477         float y = (float)bounds.getY();
478         float w = (float)bounds.getWidth();
479         float h = (float)bounds.getHeight();
480         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25126263f * w) + x, (1.0092592f * h) + y,
481                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
482                 new Color[] { color22,
483                             decodeColor(color22,color23,0.5f),
484                             color23,
485                             decodeColor(color23,color24,0.5f),
486                             color24});
487     }
488
489     private Paint decodeGradient9(Shape s) {
490         Rectangle2D bounds = s.getBounds2D();
491         float x = (float)bounds.getX();
492         float y = (float)bounds.getY();
493         float w = (float)bounds.getWidth();
494         float h = (float)bounds.getHeight();
495         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25f * w) + x, (1.0041667f * h) + y,
496                 new float[] { 0.0f,0.5f,1.0f },
497                 new Color[] { color26,
498                             decodeColor(color26,color27,0.5f),
499                             color27});
500     }
501
502     private Paint decodeGradient10(Shape s) {
503         Rectangle2D bounds = s.getBounds2D();
504         float x = (float)bounds.getX();
505         float y = (float)bounds.getY();
506         float w = (float)bounds.getWidth();
507         float h = (float)bounds.getHeight();
508         return decodeGradient((0.25f * w) + x, (0.0f * h) + y, (0.25126263f * w) + x, (1.0092592f * h) + y,
509                 new float[] { 0.0f,0.06684492f,0.13368984f,0.56684494f,1.0f },
510                 new Color[] { color27,
511                             decodeColor(color27,color28,0.5f),
512                             color28,
513                             decodeColor(color28,color28,0.5f),
514                             color28});
515     }
516
517
518 }
519
Popular Tags