< prev index next >

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

Print this page

        

*** 25,34 **** --- 25,35 ---- package java.awt.image; import java.awt.Transparency; import java.awt.color.ColorSpace; + import java.util.Arrays; /** * The {@code PackedColorModel} class is an abstract * {@link ColorModel} class that works with pixel values which represent * color and alpha information as separate samples and which pack all
*** 391,419 **** * @param obj the {@code Object} to test for equality * @return {@code true} if the specified {@code Object} * is an instance of {@code PackedColorModel} and equals this * {@code PackedColorModel}; {@code false} otherwise. */ public boolean equals(Object obj) { if (!(obj instanceof PackedColorModel)) { return false; } if (!super.equals(obj)) { return false; } - PackedColorModel cm = (PackedColorModel) obj; int numC = cm.getNumComponents(); for(int i=0; i < numC; i++) { if (maskArray[i] != cm.getMask(i)) { return false; } } return true; } private static final int[] createBitsArray(int[]colorMaskArray, int alphaMask) { int numColors = colorMaskArray.length; int numAlpha = (alphaMask == 0 ? 0 : 1); int[] arr = new int[numColors+numAlpha]; --- 392,439 ---- * @param obj the {@code Object} to test for equality * @return {@code true} if the specified {@code Object} * is an instance of {@code PackedColorModel} and equals this * {@code PackedColorModel}; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { + if (!(obj instanceof PackedColorModel)) { return false; } + PackedColorModel cm = (PackedColorModel) obj; + if (this == cm) { + return true; + } + if (!super.equals(obj)) { return false; } int numC = cm.getNumComponents(); for(int i=0; i < numC; i++) { if (maskArray[i] != cm.getMask(i)) { return false; } } return true; } + /** + * Returns the hash code for this PackedColorModel. + * + * @return a hash code for this PackedColorModel. + */ + @Override + public int hashCode() { + int hash = 3; + hash = 89 * hash + super.hashCode(); + hash = 89 * hash + Arrays.hashCode(this.maskArray); + return hash; + } + private static final int[] createBitsArray(int[]colorMaskArray, int alphaMask) { int numColors = colorMaskArray.length; int numAlpha = (alphaMask == 0 ? 0 : 1); int[] arr = new int[numColors+numAlpha];
< prev index next >