< prev index next >

src/demo/share/jfc/J2Ddemo/java2d/demos/Mix/Balls.java

Print this page

        

@@ -1,8 +1,8 @@
 /*
  *
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *

@@ -63,15 +63,15 @@
  * Animated color bouncing balls with custom controls.
  */
 @SuppressWarnings("serial")
 public class Balls extends AnimatingControlsSurface {
 
-    private static Color colors[] = { RED, ORANGE, YELLOW, GREEN.darker(), BLUE,
+    private static Color[] colors = { RED, ORANGE, YELLOW, GREEN.darker(), BLUE,
         new Color(75, 00, 82), new Color(238, 130, 238) };
     private long now, deltaT, lasttime;
     private boolean active;
-    protected Ball balls[] = new Ball[colors.length];
+    protected Ball[] balls = new Ball[colors.length];
     protected boolean clearToggle;
     protected JComboBox combo;
 
     public Balls() {
         setBackground(WHITE);

@@ -127,11 +127,11 @@
             g2.drawImage(b.imgs[b.index], (int) b.x, (int) b.y, this);
         }
         lasttime = now;
     }
 
-    public static void main(String argv[]) {
+    public static void main(String[] argv) {
         createDemoFrame(new Balls());
     }
 
 
     protected static final class Ball {

@@ -139,11 +139,11 @@
         public static final int nImgs = 5;
         public int bsize;
         public float x, y;
         public float Vx = 0.1f;
         public float Vy = 0.05f;
-        public BufferedImage imgs[];
+        public BufferedImage[] imgs;
         // Pick a random starting image index, but not the last: we're going UP
         // and that would throw us off the end.
         public int index = (int) (random() * (nImgs - 1));
         private static final float inelasticity = .96f;
         private static final float Ax = 0.0f;

@@ -180,15 +180,15 @@
             }
 
             imgs = new BufferedImage[nImgs];
 
             int bg = 255;
-            byte red[] = new byte[256];
+            byte[] red = new byte[256];
             red[0] = (byte) bg;
-            byte green[] = new byte[256];
+            byte[] green = new byte[256];
             green[0] = (byte) bg;
-            byte blue[] = new byte[256];
+            byte[] blue = new byte[256];
             blue[0] = (byte) bg;
 
             for (int r = 0; r < imgs.length; r++) {
                 float b = 0.5f + ((r + 1f) / imgs.length / 2f);
                 for (int i = maxr; i >= 1; --i) {

@@ -200,11 +200,11 @@
                             (byte) blend(blend(color.getBlue(), 255, d), bg, b);
                 }
                 IndexColorModel icm = new IndexColorModel(8, maxr + 1,
                         red, green, blue, 0);
                 DataBufferByte dbb = new DataBufferByte(data, data.length);
-                int bandOffsets[] = { 0 };
+                int[] bandOffsets = { 0 };
                 WritableRaster wr = Raster.createInterleavedRaster(dbb,
                         R * 2, R * 2, R * 2, 1, bandOffsets, null);
                 imgs[r] = new BufferedImage(icm, wr, icm.isAlphaPremultiplied(),
                         null);
             }
< prev index next >