1 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 17 public final class ProgressBarPainter extends AbstractRegionPainter { 18 static final int BACKGROUND_ENABLED = 1; 23 static final int BACKGROUND_DISABLED = 2; 24 static final int FOREGROUND_ENABLED = 3; 25 static final int FOREGROUND_ENABLED_FINISHED = 4; 26 static final int FOREGROUND_ENABLED_INDETERMINATE = 5; 27 static final int FOREGROUND_DISABLED = 6; 28 static final int FOREGROUND_DISABLED_FINISHED = 7; 29 static final int FOREGROUND_DISABLED_INDETERMINATE = 8; 30 31 32 private int state; private PaintContext ctx; 34 35 private Path2D path = new Path2D.Float(); 37 private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0); 38 private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0); 39 private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0); 40 41 private Color color1 = decodeColor("nimbusBlueGrey", 0.0f, -0.04845735f, -0.17647058f, 0); 45 private Color color2 = decodeColor("nimbusBlueGrey", 0.0f, -0.061345987f, -0.027450979f, 0); 46 private Color color3 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, 0); 47 private Color color4 = decodeColor("nimbusBlueGrey", 0.0f, -0.097921275f, 0.18823528f, 0); 48 private Color color5 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.0925083f, 0.12549019f, 0); 49 private Color color6 = decodeColor("nimbusBlueGrey", 0.0f, -0.08222443f, 0.086274505f, 0); 50 private Color color7 = decodeColor("nimbusBlueGrey", 0.0f, -0.08477524f, 0.16862744f, 0); 51 private Color color8 = decodeColor("nimbusBlueGrey", 0.0f, -0.086996906f, 0.25490195f, 0); 52 private Color color9 = decodeColor("nimbusBlueGrey", 0.0f, -0.061613273f, -0.02352941f, 0); 53 private Color color10 = decodeColor("nimbusBlueGrey", -0.01111114f, -0.061265234f, 0.05098039f, 0); 54 private Color color11 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.09378991f, 0.19215685f, 0); 55 private Color color12 = decodeColor("nimbusBlueGrey", 0.0f, -0.08455229f, 0.1607843f, 0); 56 private Color color13 = decodeColor("nimbusBlueGrey", -0.027777791f, -0.08362049f, 0.12941176f, 0); 57 private Color color14 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.07826825f, 0.10588235f, 0); 58 private Color color15 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.07982456f, 0.1490196f, 0); 59 private Color color16 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.08099045f, 0.18431371f, 0); 60 private Color color17 = decodeColor("nimbusOrange", 0.0f, 0.0f, 0.0f, -156); 61 private Color color18 = decodeColor("nimbusOrange", -0.015796512f, 0.02094239f, -0.15294117f, 0); 62 private Color color19 = decodeColor("nimbusOrange", -0.004321605f, 0.02094239f, -0.0745098f, 0); 63 private Color color20 = decodeColor("nimbusOrange", -0.008021399f, 0.02094239f, -0.10196078f, 0); 64 private Color color21 = decodeColor("nimbusOrange", -0.011706904f, -0.1790576f, -0.02352941f, 0); 65 private Color color22 = decodeColor("nimbusOrange", -0.048691254f, 0.02094239f, -0.3019608f, 0); 66 private Color color23 = decodeColor("nimbusOrange", 0.003940329f, -0.7375322f, 0.17647058f, 0); 67 private Color color24 = decodeColor("nimbusOrange", 0.005506739f, -0.46764207f, 0.109803915f, 0); 68 private Color color25 = decodeColor("nimbusOrange", 0.0042127445f, -0.18595415f, 0.04705882f, 0); 69 private Color color26 = decodeColor("nimbusOrange", 0.0047626942f, 0.02094239f, 0.0039215684f, 0); 70 private Color color27 = decodeColor("nimbusOrange", 0.0047626942f, -0.15147138f, 0.1607843f, 0); 71 private Color color28 = decodeColor("nimbusOrange", 0.010665476f, -0.27317524f, 0.25098038f, 0); 72 private Color color29 = decodeColor("nimbusBlueGrey", -0.54444444f, -0.08748484f, 0.10588235f, 0); 73 private Color color30 = decodeColor("nimbusOrange", 0.0047626942f, -0.21715283f, 0.23921567f, 0); 74 private Color color31 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -173); 75 private Color color32 = decodeColor("nimbusBlueGrey", 0.0f, -0.110526316f, 0.25490195f, -170); 76 private Color color33 = decodeColor("nimbusOrange", 0.024554357f, -0.8873145f, 0.10588235f, -156); 77 private Color color34 = decodeColor("nimbusOrange", -0.023593787f, -0.7963165f, 0.02352941f, 0); 78 private Color color35 = decodeColor("nimbusOrange", -0.010608241f, -0.7760873f, 0.043137252f, 0); 79 private Color color36 = decodeColor("nimbusOrange", -0.015402906f, -0.7840576f, 0.035294116f, 0); 80 private Color color37 = decodeColor("nimbusOrange", -0.017112307f, -0.8091547f, 0.058823526f, 0); 81 private Color color38 = decodeColor("nimbusOrange", -0.07044564f, -0.844649f, -0.019607842f, 0); 82 private Color color39 = decodeColor("nimbusOrange", -0.009704903f, -0.9381485f, 0.11372548f, 0); 83 private Color color40 = decodeColor("nimbusOrange", -4.4563413E-4f, -0.86742973f, 0.09411764f, 0); 84 private Color color41 = decodeColor("nimbusOrange", -4.4563413E-4f, -0.79896283f, 0.07843137f, 0); 85 private Color color42 = decodeColor("nimbusOrange", 0.0013274103f, -0.7530961f, 0.06666666f, 0); 86 private Color color43 = decodeColor("nimbusOrange", 0.0013274103f, -0.7644457f, 0.109803915f, 0); 87 private Color color44 = decodeColor("nimbusOrange", 0.009244293f, -0.78794646f, 0.13333333f, 0); 88 private Color color45 = decodeColor("nimbusBlueGrey", -0.015872955f, -0.0803539f, 0.16470587f, 0); 89 private Color color46 = decodeColor("nimbusBlueGrey", 0.007936537f, -0.07968931f, 0.14509803f, 0); 90 private Color color47 = decodeColor("nimbusBlueGrey", 0.02222228f, -0.08779904f, 0.11764705f, 0); 91 private Color color48 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.075128086f, 0.14117646f, 0); 92 private Color color49 = decodeColor("nimbusBlueGrey", 0.0138888955f, -0.07604356f, 0.16470587f, 0); 93 private Color color50 = decodeColor("nimbusOrange", 0.0014062226f, -0.77816474f, 0.12941176f, 0); 94 95 96 private Object [] componentColors; 98 99 public ProgressBarPainter(PaintContext ctx, int state) { 100 super(); 101 this.state = state; 102 this.ctx = ctx; 103 } 104 105 @Override 106 protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object [] extendedCacheKeys) { 107 componentColors = extendedCacheKeys; 109 switch(state) { 112 case BACKGROUND_ENABLED: paintBackgroundEnabled(g); break; 113 case BACKGROUND_DISABLED: paintBackgroundDisabled(g); break; 114 case FOREGROUND_ENABLED: paintForegroundEnabled(g); break; 115 case FOREGROUND_ENABLED_FINISHED: paintForegroundEnabledAndFinished(g); break; 116 case FOREGROUND_ENABLED_INDETERMINATE: paintForegroundEnabledAndIndeterminate(g); break; 117 case FOREGROUND_DISABLED: paintForegroundDisabled(g); break; 118 case FOREGROUND_DISABLED_FINISHED: paintForegroundDisabledAndFinished(g); break; 119 case FOREGROUND_DISABLED_INDETERMINATE: paintForegroundDisabledAndIndeterminate(g); break; 120 121 } 122 } 123 124 125 126 @Override 127 protected final PaintContext getPaintContext() { 128 return ctx; 129 } 130 131 private void paintBackgroundEnabled(Graphics2D g) { 132 rect = decodeRect1(); 133 g.setPaint(decodeGradient1(rect)); 134 g.fill(rect); 135 rect = decodeRect2(); 136 g.setPaint(decodeGradient2(rect)); 137 g.fill(rect); 138 139 } 140 141 private void paintBackgroundDisabled(Graphics2D g) { 142 rect = decodeRect1(); 143 g.setPaint(decodeGradient3(rect)); 144 g.fill(rect); 145 rect = decodeRect2(); 146 g.setPaint(decodeGradient4(rect)); 147 g.fill(rect); 148 149 } 150 151 private void paintForegroundEnabled(Graphics2D g) { 152 path = decodePath1(); 153 g.setPaint(color17); 154 g.fill(path); 155 rect = decodeRect3(); 156 g.setPaint(decodeGradient5(rect)); 157 g.fill(rect); 158 rect = decodeRect4(); 159 g.setPaint(decodeGradient6(rect)); 160 g.fill(rect); 161 162 } 163 164 private void paintForegroundEnabledAndFinished(Graphics2D g) { 165 path = decodePath2(); 166 g.setPaint(color17); 167 g.fill(path); 168 rect = decodeRect1(); 169 g.setPaint(decodeGradient5(rect)); 170 g.fill(rect); 171 rect = decodeRect2(); 172 g.setPaint(decodeGradient6(rect)); 173 g.fill(rect); 174 175 } 176 177 private void paintForegroundEnabledAndIndeterminate(Graphics2D g) { 178 rect = decodeRect5(); 179 g.setPaint(decodeGradient7(rect)); 180 g.fill(rect); 181 path = decodePath3(); 182 g.setPaint(decodeGradient8(path)); 183 g.fill(path); 184 rect = decodeRect6(); 185 g.setPaint(color31); 186 g.fill(rect); 187 rect = decodeRect7(); 188 g.setPaint(color32); 189 g.fill(rect); 190 191 } 192 193 private void paintForegroundDisabled(Graphics2D g) { 194 path = decodePath1(); 195 g.setPaint(color17); 196 g.fill(path); 197 rect = decodeRect3(); 198 g.setPaint(decodeGradient5(rect)); 199 g.fill(rect); 200 rect = decodeRect4(); 201 g.setPaint(decodeGradient6(rect)); 202 g.fill(rect); 203 204 } 205 206 private void paintForegroundDisabledAndFinished(Graphics2D g) { 207 path = decodePath4(); 208 g.setPaint(color33); 209 g.fill(path); 210 rect = decodeRect1(); 211 g.setPaint(decodeGradient9(rect)); 212 g.fill(rect); 213 rect = decodeRect2(); 214 g.setPaint(decodeGradient10(rect)); 215 g.fill(rect); 216 217 } 218 219 private void paintForegroundDisabledAndIndeterminate(Graphics2D g) { 220 rect = decodeRect5(); 221 g.setPaint(decodeGradient11(rect)); 222 g.fill(rect); 223 path = decodePath5(); 224 g.setPaint(decodeGradient12(path)); 225 g.fill(path); 226 227 } 228 229 230 231 private Rectangle2D decodeRect1() { 232 rect.setRect(decodeX(0.4f), decodeY(0.4f), decodeX(2.6f) - decodeX(0.4f), decodeY(2.6f) - decodeY(0.4f)); return rect; 237 } 238 239 private Rectangle2D decodeRect2() { 240 rect.setRect(decodeX(0.6f), decodeY(0.6f), decodeX(2.4f) - decodeX(0.6f), decodeY(2.4f) - decodeY(0.6f)); return rect; 245 } 246 247 private Path2D decodePath1() { 248 path.reset(); 249 path.moveTo(decodeX(0.6f), decodeY(0.12666667f)); 250 path.curveTo(decodeAnchorX(0.6000000238418579f, -2.0f), decodeAnchorY(0.12666666507720947f, 0.0f), decodeAnchorX(0.12666666507720947f, 0.0f), decodeAnchorY(0.6000000238418579f, -2.0f), decodeX(0.12666667f), decodeY(0.6f)); 251 path.curveTo(decodeAnchorX(0.12666666507720947f, 0.0f), decodeAnchorY(0.6000000238418579f, 2.0f), decodeAnchorX(0.12666666507720947f, 0.0f), decodeAnchorY(2.4000000953674316f, -2.0f), decodeX(0.12666667f), decodeY(2.4f)); 252 path.curveTo(decodeAnchorX(0.12666666507720947f, 0.0f), decodeAnchorY(2.4000000953674316f, 2.0f), decodeAnchorX(0.6000000238418579f, -2.0f), decodeAnchorY(2.8933334350585938f, 0.0f), decodeX(0.6f), decodeY(2.8933334f)); 253 path.curveTo(decodeAnchorX(0.6000000238418579f, 2.0f), decodeAnchorY(2.8933334350585938f, 0.0f), decodeAnchorX(3.0f, 0.0f), decodeAnchorY(2.8933334350585938f, 0.0f), decodeX(3.0f), decodeY(2.8933334f)); 254 path.lineTo(decodeX(3.0f), decodeY(2.6f)); 255 path.lineTo(decodeX(0.4f), decodeY(2.6f)); 256 path.lineTo(decodeX(0.4f), decodeY(0.4f)); 257 path.lineTo(decodeX(3.0f), decodeY(0.4f)); 258 path.lineTo(decodeX(3.0f), decodeY(0.120000005f)); 259 path.curveTo(decodeAnchorX(3.0f, 0.0f), decodeAnchorY(0.12000000476837158f, 0.0f), decodeAnchorX(0.6000000238418579f, 2.0f), decodeAnchorY(0.12666666507720947f, 0.0f), decodeX(0.6f), decodeY(0.12666667f)); 260 path.closePath(); 261 return path; 262 } 263 264 private Rectangle2D decodeRect3() { 265 rect.setRect(decodeX(0.4f), decodeY(0.4f), decodeX(3.0f) - decodeX(0.4f), decodeY(2.6f) - decodeY(0.4f)); return rect; 270 } 271 272 private Rectangle2D decodeRect4() { 273 rect.setRect(decodeX(0.6f), decodeY(0.6f), decodeX(2.8f) - decodeX(0.6f), decodeY(2.4f) - decodeY(0.6f)); return rect; 278 } 279 280 private Path2D decodePath2() { 281 path.reset(); 282 path.moveTo(decodeX(0.5466667f), decodeY(0.12666667f)); 283 path.curveTo(decodeAnchorX(0.54666668176651f, -2.000000000000001f), decodeAnchorY(0.12666666507720947f, 0.0f), decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(0.6066666841506958f, -1.9999999999999998f), decodeX(0.120000005f), decodeY(0.6066667f)); 284 path.lineTo(decodeX(0.120000005f), decodeY(2.4266667f)); 285 path.curveTo(decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(2.426666736602783f, 2.0f), decodeAnchorX(0.5800000429153442f, -2.0f), decodeAnchorY(2.879999876022339f, 0.0f), decodeX(0.58000004f), decodeY(2.8799999f)); 286 path.lineTo(decodeX(2.4f), decodeY(2.8733335f)); 287 path.curveTo(decodeAnchorX(2.4000000953674316f, 1.9709292441265305f), decodeAnchorY(2.87333345413208f, 0.019857039365145823f), decodeAnchorX(2.866666793823242f, -0.03333333333333499f), decodeAnchorY(2.433333158493042f, 1.9333333333333869f), decodeX(2.8666668f), decodeY(2.4333332f)); 288 path.lineTo(decodeX(2.8733335f), decodeY(1.9407407f)); 289 path.lineTo(decodeX(2.8666668f), decodeY(1.1814815f)); 290 path.lineTo(decodeX(2.8666668f), decodeY(0.6066667f)); 291 path.curveTo(decodeAnchorX(2.866666793823242f, 0.0042173304174148996f), decodeAnchorY(0.6066666841506958f, -1.9503377583381705f), decodeAnchorX(2.4599997997283936f, 1.9659460194139413f), decodeAnchorY(0.13333334028720856f, 0.017122267221350018f), decodeX(2.4599998f), decodeY(0.13333334f)); 292 path.lineTo(decodeX(0.5466667f), decodeY(0.12666667f)); 293 path.closePath(); 294 return path; 295 } 296 297 private Rectangle2D decodeRect5() { 298 rect.setRect(decodeX(0.0f), decodeY(0.0f), decodeX(3.0f) - decodeX(0.0f), decodeY(3.0f) - decodeY(0.0f)); return rect; 303 } 304 305 private Path2D decodePath3() { 306 path.reset(); 307 path.moveTo(decodeX(0.0f), decodeY(1.3333334f)); 308 path.curveTo(decodeAnchorX(0.0f, 2.678571428571433f), decodeAnchorY(1.3333333730697632f, 8.881784197001252E-16f), decodeAnchorX(1.3678570985794067f, -6.214285714285715f), decodeAnchorY(0.20714285969734192f, -0.03571428571428292f), decodeX(1.3678571f), decodeY(0.20714286f)); 309 path.lineTo(decodeX(1.5642858f), decodeY(0.20714286f)); 310 path.curveTo(decodeAnchorX(1.5642857551574707f, 8.329670329670357f), decodeAnchorY(0.20714285969734192f, 0.002747252747249629f), decodeAnchorX(2.5999999046325684f, -5.2857142857142705f), decodeAnchorY(1.3333333730697632f, 0.03571428571428559f), decodeX(2.6f), decodeY(1.3333334f)); 311 path.lineTo(decodeX(3.0f), decodeY(1.3333334f)); 312 path.lineTo(decodeX(3.0f), decodeY(1.6666667f)); 313 path.lineTo(decodeX(2.6f), decodeY(1.6666667f)); 314 path.curveTo(decodeAnchorX(2.5999999046325684f, -5.321428571428569f), decodeAnchorY(1.6666667461395264f, 0.0357142857142847f), decodeAnchorX(1.5642857551574707f, 8.983516483516496f), decodeAnchorY(2.799999952316284f, 0.03846153846153122f), decodeX(1.5642858f), decodeY(2.8f)); 315 path.lineTo(decodeX(1.3892857f), decodeY(2.8f)); 316 path.curveTo(decodeAnchorX(1.389285683631897f, -6.714285714285704f), decodeAnchorY(2.799999952316284f, 0.0f), decodeAnchorX(0.0f, 2.6071428571428568f), decodeAnchorY(1.6666667461395264f, 0.03571428571428559f), decodeX(0.0f), decodeY(1.6666667f)); 317 path.lineTo(decodeX(0.0f), decodeY(1.3333334f)); 318 path.closePath(); 319 return path; 320 } 321 322 private Rectangle2D decodeRect6() { 323 rect.setRect(decodeX(1.25f), decodeY(0.0f), decodeX(1.3f) - decodeX(1.25f), decodeY(3.0f) - decodeY(0.0f)); return rect; 328 } 329 330 private Rectangle2D decodeRect7() { 331 rect.setRect(decodeX(1.75f), decodeY(0.0f), decodeX(1.8f) - decodeX(1.75f), decodeY(3.0f) - decodeY(0.0f)); return rect; 336 } 337 338 private Path2D decodePath4() { 339 path.reset(); 340 path.moveTo(decodeX(0.59333336f), decodeY(0.120000005f)); 341 path.curveTo(decodeAnchorX(0.59333336353302f, -1.9999999999999993f), decodeAnchorY(0.12000000476837158f, 0.0f), decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(0.59333336353302f, -2.000000000000001f), decodeX(0.120000005f), decodeY(0.59333336f)); 342 path.curveTo(decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(0.59333336353302f, 1.9999999999999991f), decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(2.3933331966400146f, -2.0000000000000053f), decodeX(0.120000005f), decodeY(2.3933332f)); 343 path.curveTo(decodeAnchorX(0.12000000476837158f, 0.0f), decodeAnchorY(2.3933331966400146f, 2.000000000000007f), decodeAnchorX(0.59333336353302f, -1.9999999999999993f), decodeAnchorY(2.8866665363311768f, 0.0f), decodeX(0.59333336f), decodeY(2.8866665f)); 344 path.curveTo(decodeAnchorX(0.59333336353302f, 2.000000000000003f), decodeAnchorY(2.8866665363311768f, 0.0f), decodeAnchorX(2.700000047683716f, 0.0f), decodeAnchorY(2.879999876022339f, 0.0f), decodeX(2.7f), decodeY(2.8799999f)); 345 path.lineTo(decodeX(2.8466668f), decodeY(2.6933334f)); 346 path.lineTo(decodeX(2.8533332f), decodeY(1.6148149f)); 347 path.lineTo(decodeX(2.86f), decodeY(1.4074074f)); 348 path.lineTo(decodeX(2.86f), decodeY(0.37333333f)); 349 path.lineTo(decodeX(2.7599998f), decodeY(0.13333334f)); 350 path.curveTo(decodeAnchorX(2.7599997520446777f, 0.0f), decodeAnchorY(0.13333334028720856f, 0.0f), decodeAnchorX(0.59333336353302f, 2.000000000000003f), decodeAnchorY(0.12000000476837158f, 0.0f), decodeX(0.59333336f), decodeY(0.120000005f)); 351 path.closePath(); 352 return path; 353 } 354 355 private Path2D decodePath5() { 356 path.reset(); 357 path.moveTo(decodeX(0.0f), decodeY(1.3333334f)); 358 path.curveTo(decodeAnchorX(0.0f, 2.678571428571433f), decodeAnchorY(1.3333333730697632f, 8.881784197001252E-16f), decodeAnchorX(1.3678570985794067f, -6.357142857142872f), decodeAnchorY(0.20714285969734192f, -0.03571428571428337f), decodeX(1.3678571f), decodeY(0.20714286f)); 359 path.lineTo(decodeX(1.5642858f), decodeY(0.20714286f)); 360 path.curveTo(decodeAnchorX(1.5642857551574707f, 3.9999999999999964f), decodeAnchorY(0.20714285969734192f, 0.0f), decodeAnchorX(2.5999999046325684f, -5.2857142857142705f), decodeAnchorY(1.3333333730697632f, 0.03571428571428559f), decodeX(2.6f), decodeY(1.3333334f)); 361 path.lineTo(decodeX(3.0f), decodeY(1.3333334f)); 362 path.lineTo(decodeX(3.0f), decodeY(1.6666667f)); 363 path.lineTo(decodeX(2.6f), decodeY(1.6666667f)); 364 path.curveTo(decodeAnchorX(2.5999999046325684f, -5.321428571428569f), decodeAnchorY(1.6666667461395264f, 0.0357142857142847f), decodeAnchorX(1.5642857551574707f, 3.999999999999986f), decodeAnchorY(2.799999952316284f, 0.0f), decodeX(1.5642858f), decodeY(2.8f)); 365 path.lineTo(decodeX(1.3892857f), decodeY(2.8f)); 366 path.curveTo(decodeAnchorX(1.389285683631897f, -6.571428571428584f), decodeAnchorY(2.799999952316284f, -0.035714285714286476f), decodeAnchorX(0.0f, 2.6071428571428568f), decodeAnchorY(1.6666667461395264f, 0.03571428571428559f), decodeX(0.0f), decodeY(1.6666667f)); 367 path.lineTo(decodeX(0.0f), decodeY(1.3333334f)); 368 path.closePath(); 369 return path; 370 } 371 372 373 374 private Paint decodeGradient1(Shape s) { 375 Rectangle2D bounds = s.getBounds2D(); 376 float x = (float)bounds.getX(); 377 float y = (float)bounds.getY(); 378 float w = (float)bounds.getWidth(); 379 float h = (float)bounds.getHeight(); 380 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 381 new float[] { 0.0f,0.5f,1.0f }, 382 new Color[] { color1, 383 decodeColor(color1,color2,0.5f), 384 color2}); 385 } 386 387 private Paint decodeGradient2(Shape s) { 388 Rectangle2D bounds = s.getBounds2D(); 389 float x = (float)bounds.getX(); 390 float y = (float)bounds.getY(); 391 float w = (float)bounds.getWidth(); 392 float h = (float)bounds.getHeight(); 393 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 394 new float[] { 0.038709678f,0.05967742f,0.08064516f,0.23709677f,0.3935484f,0.41612905f,0.43870968f,0.67419356f,0.90967745f,0.91451615f,0.91935486f }, 395 new Color[] { color3, 396 decodeColor(color3,color4,0.5f), 397 color4, 398 decodeColor(color4,color5,0.5f), 399 color5, 400 decodeColor(color5,color6,0.5f), 401 color6, 402 decodeColor(color6,color7,0.5f), 403 color7, 404 decodeColor(color7,color8,0.5f), 405 color8}); 406 } 407 408 private Paint decodeGradient3(Shape s) { 409 Rectangle2D bounds = s.getBounds2D(); 410 float x = (float)bounds.getX(); 411 float y = (float)bounds.getY(); 412 float w = (float)bounds.getWidth(); 413 float h = (float)bounds.getHeight(); 414 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 415 new float[] { 0.05483871f,0.5032258f,0.9516129f }, 416 new Color[] { color9, 417 decodeColor(color9,color10,0.5f), 418 color10}); 419 } 420 421 private Paint decodeGradient4(Shape s) { 422 Rectangle2D bounds = s.getBounds2D(); 423 float x = (float)bounds.getX(); 424 float y = (float)bounds.getY(); 425 float w = (float)bounds.getWidth(); 426 float h = (float)bounds.getHeight(); 427 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 428 new float[] { 0.038709678f,0.05967742f,0.08064516f,0.23709677f,0.3935484f,0.41612905f,0.43870968f,0.67419356f,0.90967745f,0.91612905f,0.92258066f }, 429 new Color[] { color11, 430 decodeColor(color11,color12,0.5f), 431 color12, 432 decodeColor(color12,color13,0.5f), 433 color13, 434 decodeColor(color13,color14,0.5f), 435 color14, 436 decodeColor(color14,color15,0.5f), 437 color15, 438 decodeColor(color15,color16,0.5f), 439 color16}); 440 } 441 442 private Paint decodeGradient5(Shape s) { 443 Rectangle2D bounds = s.getBounds2D(); 444 float x = (float)bounds.getX(); 445 float y = (float)bounds.getY(); 446 float w = (float)bounds.getWidth(); 447 float h = (float)bounds.getHeight(); 448 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 449 new float[] { 0.038709678f,0.05483871f,0.07096774f,0.28064516f,0.4903226f,0.6967742f,0.9032258f,0.9241935f,0.9451613f }, 450 new Color[] { color18, 451 decodeColor(color18,color19,0.5f), 452 color19, 453 decodeColor(color19,color20,0.5f), 454 color20, 455 decodeColor(color20,color21,0.5f), 456 color21, 457 decodeColor(color21,color22,0.5f), 458 color22}); 459 } 460 461 private Paint decodeGradient6(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.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 468 new float[] { 0.038709678f,0.061290324f,0.08387097f,0.27258065f,0.46129033f,0.4903226f,0.5193548f,0.71774197f,0.91612905f,0.92419356f,0.93225807f }, 469 new Color[] { color23, 470 decodeColor(color23,color24,0.5f), 471 color24, 472 decodeColor(color24,color25,0.5f), 473 color25, 474 decodeColor(color25,color26,0.5f), 475 color26, 476 decodeColor(color26,color27,0.5f), 477 color27, 478 decodeColor(color27,color28,0.5f), 479 color28}); 480 } 481 482 private Paint decodeGradient7(Shape s) { 483 Rectangle2D bounds = s.getBounds2D(); 484 float x = (float)bounds.getX(); 485 float y = (float)bounds.getY(); 486 float w = (float)bounds.getWidth(); 487 float h = (float)bounds.getHeight(); 488 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 489 new float[] { 0.051612902f,0.06612903f,0.08064516f,0.2935484f,0.5064516f,0.6903226f,0.87419355f,0.88870966f,0.9032258f }, 490 new Color[] { color3, 491 decodeColor(color3,color4,0.5f), 492 color4, 493 decodeColor(color4,color29,0.5f), 494 color29, 495 decodeColor(color29,color7,0.5f), 496 color7, 497 decodeColor(color7,color8,0.5f), 498 color8}); 499 } 500 501 private Paint decodeGradient8(Shape s) { 502 Rectangle2D bounds = s.getBounds2D(); 503 float x = (float)bounds.getX(); 504 float y = (float)bounds.getY(); 505 float w = (float)bounds.getWidth(); 506 float h = (float)bounds.getHeight(); 507 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 508 new float[] { 0.0f,0.20645161f,0.41290322f,0.44193548f,0.47096774f,0.7354839f,1.0f }, 509 new Color[] { color24, 510 decodeColor(color24,color25,0.5f), 511 color25, 512 decodeColor(color25,color26,0.5f), 513 color26, 514 decodeColor(color26,color30,0.5f), 515 color30}); 516 } 517 518 private Paint decodeGradient9(Shape s) { 519 Rectangle2D bounds = s.getBounds2D(); 520 float x = (float)bounds.getX(); 521 float y = (float)bounds.getY(); 522 float w = (float)bounds.getWidth(); 523 float h = (float)bounds.getHeight(); 524 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 525 new float[] { 0.038709678f,0.05483871f,0.07096774f,0.28064516f,0.4903226f,0.6967742f,0.9032258f,0.9241935f,0.9451613f }, 526 new Color[] { color34, 527 decodeColor(color34,color35,0.5f), 528 color35, 529 decodeColor(color35,color36,0.5f), 530 color36, 531 decodeColor(color36,color37,0.5f), 532 color37, 533 decodeColor(color37,color38,0.5f), 534 color38}); 535 } 536 537 private Paint decodeGradient10(Shape s) { 538 Rectangle2D bounds = s.getBounds2D(); 539 float x = (float)bounds.getX(); 540 float y = (float)bounds.getY(); 541 float w = (float)bounds.getWidth(); 542 float h = (float)bounds.getHeight(); 543 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 544 new float[] { 0.038709678f,0.061290324f,0.08387097f,0.27258065f,0.46129033f,0.4903226f,0.5193548f,0.71774197f,0.91612905f,0.92419356f,0.93225807f }, 545 new Color[] { color39, 546 decodeColor(color39,color40,0.5f), 547 color40, 548 decodeColor(color40,color41,0.5f), 549 color41, 550 decodeColor(color41,color42,0.5f), 551 color42, 552 decodeColor(color42,color43,0.5f), 553 color43, 554 decodeColor(color43,color44,0.5f), 555 color44}); 556 } 557 558 private Paint decodeGradient11(Shape s) { 559 Rectangle2D bounds = s.getBounds2D(); 560 float x = (float)bounds.getX(); 561 float y = (float)bounds.getY(); 562 float w = (float)bounds.getWidth(); 563 float h = (float)bounds.getHeight(); 564 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 565 new float[] { 0.051612902f,0.06612903f,0.08064516f,0.2935484f,0.5064516f,0.6903226f,0.87419355f,0.88870966f,0.9032258f }, 566 new Color[] { color45, 567 decodeColor(color45,color46,0.5f), 568 color46, 569 decodeColor(color46,color47,0.5f), 570 color47, 571 decodeColor(color47,color48,0.5f), 572 color48, 573 decodeColor(color48,color49,0.5f), 574 color49}); 575 } 576 577 private Paint decodeGradient12(Shape s) { 578 Rectangle2D bounds = s.getBounds2D(); 579 float x = (float)bounds.getX(); 580 float y = (float)bounds.getY(); 581 float w = (float)bounds.getWidth(); 582 float h = (float)bounds.getHeight(); 583 return decodeGradient((0.5f * w) + x, (0.0f * h) + y, (0.5f * w) + x, (1.0f * h) + y, 584 new float[] { 0.0f,0.20645161f,0.41290322f,0.44193548f,0.47096774f,0.7354839f,1.0f }, 585 new Color[] { color40, 586 decodeColor(color40,color41,0.5f), 587 color41, 588 decodeColor(color41,color42,0.5f), 589 color42, 590 decodeColor(color42,color50,0.5f), 591 color50}); 592 } 593 594 595 } 596 | Popular Tags |