2910 * alpha channel. 2911 * 2912 * @return A {@code WritableRaster} containing the image's alpha channel. 2913 * 2914 */ 2915 public WritableRaster getAlphaRaster(WritableRaster raster) { 2916 if (hasAlpha() == false) { 2917 return null; 2918 } 2919 2920 int x = raster.getMinX(); 2921 int y = raster.getMinY(); 2922 int[] band = new int[1]; 2923 band[0] = raster.getNumBands() - 1; 2924 return raster.createWritableChild(x, y, raster.getWidth(), 2925 raster.getHeight(), x, y, 2926 band); 2927 } 2928 2929 /** 2930 * Compares this color model with another for equality. 2931 * 2932 * @param obj The object to compare with this color model. 2933 * @return {@code true} if the color model objects are equal, 2934 * {@code false} if they are not. 2935 */ 2936 public boolean equals(Object obj) { 2937 if (!super.equals(obj)) { 2938 return false; 2939 } 2940 2941 if (obj.getClass() != getClass()) { 2942 return false; 2943 } 2944 2945 return true; 2946 } 2947 2948 } | 2910 * alpha channel. 2911 * 2912 * @return A {@code WritableRaster} containing the image's alpha channel. 2913 * 2914 */ 2915 public WritableRaster getAlphaRaster(WritableRaster raster) { 2916 if (hasAlpha() == false) { 2917 return null; 2918 } 2919 2920 int x = raster.getMinX(); 2921 int y = raster.getMinY(); 2922 int[] band = new int[1]; 2923 band[0] = raster.getNumBands() - 1; 2924 return raster.createWritableChild(x, y, raster.getWidth(), 2925 raster.getHeight(), x, y, 2926 band); 2927 } 2928 2929 /** 2930 * Tests if the specified {@code Object} is an instance 2931 * of {@code ComponentColorModel} and equals this 2932 * {@code ComponentColorModel}. 2933 * @param obj the {@code Object} to test for equality 2934 * @return {@code true} if the specified {@code Object} 2935 * is an instance of {@code ComponentColorModel} and equals this 2936 * {@code ComponentColorModel}; {@code false} otherwise. 2937 */ 2938 @Override 2939 public boolean equals(Object obj) { 2940 2941 ComponentColorModel cm = (ComponentColorModel) obj; 2942 if (this == cm) { 2943 return true; 2944 } 2945 2946 if (!super.equals(obj)) { 2947 return false; 2948 } 2949 return true; 2950 } 2951 2952 /** 2953 * Returns the hash code for this ComponentColorModel. 2954 * 2955 * @return a hash code for this ComponentColorModel. 2956 */ 2957 @Override 2958 public int hashCode() { 2959 int hash = 7; 2960 hash = 79 * hash + super.hashCode(); 2961 return hash; 2962 } 2963 2964 } |