< prev index next >

src/java.desktop/share/classes/java/awt/image/IndexColorModel.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -122,11 +122,11 @@
  * @see ColorSpace
  * @see DataBuffer
  *
  */
 public class IndexColorModel extends ColorModel {
-    private int rgb[];
+    private int[] rgb;
     private int map_size;
     private int pixel_mask;
     private int transparent_index = -1;
     private boolean allgrayopaque;
     private BigInteger validBits;

@@ -164,11 +164,11 @@
      *         than 1 or greater than 16
      * @throws IllegalArgumentException if {@code size} is less
      *         than 1
      */
     public IndexColorModel(int bits, int size,
-                           byte r[], byte g[], byte b[]) {
+                           byte[] r, byte[] g, byte[] b) {
         super(bits, opaqueBits,
               ColorSpace.getInstance(ColorSpace.CS_sRGB),
               false, false, OPAQUE,
               ColorModel.getDefaultTransferType(bits));
         if (bits < 1 || bits > 16) {

@@ -204,11 +204,11 @@
      *          1 or greater than 16
      * @throws IllegalArgumentException if {@code size} is less than
      *          1
      */
     public IndexColorModel(int bits, int size,
-                           byte r[], byte g[], byte b[], int trans) {
+                           byte[] r, byte[] g, byte[] b, int trans) {
         super(bits, opaqueBits,
               ColorSpace.getInstance(ColorSpace.CS_sRGB),
               false, false, OPAQUE,
               ColorModel.getDefaultTransferType(bits));
         if (bits < 1 || bits > 16) {

@@ -243,11 +243,11 @@
      *           than 1 or greater than 16
      * @throws IllegalArgumentException if {@code size} is less
      *           than 1
      */
     public IndexColorModel(int bits, int size,
-                           byte r[], byte g[], byte b[], byte a[]) {
+                           byte[] r, byte[] g, byte[] b, byte[] a) {
         super (bits, alphaBits,
                ColorSpace.getInstance(ColorSpace.CS_sRGB),
                true, false, TRANSLUCENT,
                ColorModel.getDefaultTransferType(bits));
         if (bits < 1 || bits > 16) {

@@ -282,11 +282,11 @@
      * @throws IllegalArgumentException if {@code bits} is less
      *           than 1 or greater than 16
      * @throws IllegalArgumentException if {@code size} is less
      *           than 1
      */
-    public IndexColorModel(int bits, int size, byte cmap[], int start,
+    public IndexColorModel(int bits, int size, byte[] cmap, int start,
                            boolean hasalpha) {
         this(bits, size, cmap, start, hasalpha, -1);
         if (bits < 1 || bits > 16) {
             throw new IllegalArgumentException("Number of bits must be between"
                                                +" 1 and 16.");

@@ -319,11 +319,11 @@
      * @throws IllegalArgumentException if {@code bits} is less than
      *               1 or greater than 16
      * @throws IllegalArgumentException if {@code size} is less than
      *               1
      */
-    public IndexColorModel(int bits, int size, byte cmap[], int start,
+    public IndexColorModel(int bits, int size, byte[] cmap, int start,
                            boolean hasalpha, int trans) {
         // REMIND: This assumes the ordering: RGB[A]
         super(bits, opaqueBits,
               ColorSpace.getInstance(ColorSpace.CS_sRGB),
               false, false, OPAQUE,

@@ -404,11 +404,11 @@
      * @throws IllegalArgumentException if {@code transferType} is not
      *           one of {@code DataBuffer.TYPE_BYTE} or
      *           {@code DataBuffer.TYPE_USHORT}
      */
     public IndexColorModel(int bits, int size,
-                           int cmap[], int start,
+                           int[] cmap, int start,
                            boolean hasalpha, int trans, int transferType) {
         // REMIND: This assumes the ordering: RGB[A]
         super(bits, opaqueBits,
               ColorSpace.getInstance(ColorSpace.CS_sRGB),
               false, false, OPAQUE,

@@ -470,11 +470,11 @@
      *           one of {@code DataBuffer.TYPE_BYTE} or
      *           {@code DataBuffer.TYPE_USHORT}
      *
      * @since 1.3
      */
-    public IndexColorModel(int bits, int size, int cmap[], int start,
+    public IndexColorModel(int bits, int size, int[] cmap, int start,
                            int transferType, BigInteger validBits) {
         super (bits, alphaBits,
                ColorSpace.getInstance(ColorSpace.CS_sRGB),
                true, false, TRANSLUCENT,
                transferType);

@@ -505,11 +505,11 @@
 
         setRGBs(size, cmap, start, true);
         calculatePixelMask();
     }
 
-    private void setRGBs(int size, byte r[], byte g[], byte b[], byte a[]) {
+    private void setRGBs(int size, byte[] r, byte[] g, byte[] b, byte[] a) {
         if (size < 1) {
             throw new IllegalArgumentException("Map size ("+size+
                                                ") must be >= 1");
         }
         map_size = size;

@@ -542,11 +542,11 @@
         }
         this.allgrayopaque = allgray;
         setTransparency(transparency);
     }
 
-    private void setRGBs(int size, int cmap[], int start, boolean hasalpha) {
+    private void setRGBs(int size, int[] cmap, int start, boolean hasalpha) {
         map_size = size;
         rgb = new int[calcRealMapSize(pixel_bits, size)];
         int j = start;
         int transparency = OPAQUE;
         boolean allgray = true;

@@ -661,11 +661,11 @@
      * Only the initial entries of the array as specified by
      * {@link #getMapSize() getMapSize} are written.
      * @param r the specified array into which the elements of the
      *      array of red color components are copied
      */
-    public final void getReds(byte r[]) {
+    public final void getReds(byte[] r) {
         for (int i = 0; i < map_size; i++) {
             r[i] = (byte) (rgb[i] >> 16);
         }
     }
 

@@ -674,11 +674,11 @@
      * Only the initial entries of the array as specified by
      * {@code getMapSize} are written.
      * @param g the specified array into which the elements of the
      *      array of green color components are copied
      */
-    public final void getGreens(byte g[]) {
+    public final void getGreens(byte[] g) {
         for (int i = 0; i < map_size; i++) {
             g[i] = (byte) (rgb[i] >> 8);
         }
     }
 

@@ -687,11 +687,11 @@
      * Only the initial entries of the array as specified by
      * {@code getMapSize} are written.
      * @param b the specified array into which the elements of the
      *      array of blue color components are copied
      */
-    public final void getBlues(byte b[]) {
+    public final void getBlues(byte[] b) {
         for (int i = 0; i < map_size; i++) {
             b[i] = (byte) rgb[i];
         }
     }
 

@@ -700,11 +700,11 @@
      * specified array.  Only the initial entries of the array as specified
      * by {@code getMapSize} are written.
      * @param a the specified array into which the elements of the
      *      array of alpha components are copied
      */
-    public final void getAlphas(byte a[]) {
+    public final void getAlphas(byte[] a) {
         for (int i = 0; i < map_size; i++) {
             a[i] = (byte) (rgb[i] >> 24);
         }
     }
 

@@ -717,11 +717,11 @@
      * written.
      * @param rgb the specified array into which the converted ARGB
      *        values from this array of color and alpha components
      *        are copied.
      */
-    public final void getRGBs(int rgb[]) {
+    public final void getRGBs(int[] rgb) {
         System.arraycopy(this.rgb, 0, rgb, 0, map_size);
     }
 
     private void setTransparentPixel(int trans) {
         if (trans >= 0 && trans < map_size) {

@@ -839,11 +839,11 @@
     public final int getRGB(int pixel) {
         return rgb[pixel & pixel_mask];
     }
 
     private static final int CACHESIZE = 40;
-    private int lookupcache[] = new int[CACHESIZE];
+    private int[] lookupcache = new int[CACHESIZE];
 
     /**
      * Returns a data element array representation of a pixel in this
      * ColorModel, given an integer pixel representation in the
      * default RGB color model.  This array can then be passed to the

@@ -943,11 +943,11 @@
             // likely to be fairly common in opaque colormaps
             // so first we will do a quick search for an
             // exact match.
 
             int smallestError = Integer.MAX_VALUE;
-            int lut[] = this.rgb;
+            int[] lut = this.rgb;
             int lutrgb;
             for (int i=0; i < map_size; i++) {
                 lutrgb = lut[i];
                 if (lutrgb == rgb && lutrgb != 0) {
                     pix = i;

@@ -990,11 +990,11 @@
             // color components in the distance calculations.
             // Look for closest match using a 4 component
             // Euclidean distance formula.
 
             int smallestError = Integer.MAX_VALUE;
-            int lut[] = this.rgb;
+            int[] lut = this.rgb;
             for (int i=0; i < map_size; i++) {
                 int lutrgb = lut[i];
                 if (lutrgb == rgb) {
                     if (validBits != null && !validBits.testBit(i)) {
                         continue;

@@ -1160,19 +1160,19 @@
      */
     public int[] getComponents(Object pixel, int[] components, int offset) {
         int intpixel;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])pixel;
+               byte[] bdata = (byte[])pixel;
                intpixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])pixel;
+               short[] sdata = (short[])pixel;
                intpixel = sdata[0] & 0xffff;
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])pixel;
+               int[] idata = (int[])pixel;
                intpixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);

@@ -1215,19 +1215,19 @@
         }
         Object inData = getDataElements(rgb, null);
         int pixel;
         switch (transferType) {
             case DataBuffer.TYPE_BYTE:
-               byte bdata[] = (byte[])inData;
+               byte[] bdata = (byte[])inData;
                pixel = bdata[0] & 0xff;
             break;
             case DataBuffer.TYPE_USHORT:
-               short sdata[] = (short[])inData;
+               short[] sdata = (short[])inData;
                pixel = sdata[0];
             break;
             case DataBuffer.TYPE_INT:
-               int idata[] = (int[])inData;
+               int[] idata = (int[])inData;
                pixel = idata[0];
             break;
             default:
                throw new UnsupportedOperationException("This method has not been "+
                    "implemented for transferType " + transferType);
< prev index next >