1 18 package org.apache.batik.ext.awt.image; 19 20 import java.io.Serializable ; 21 22 28 public final class ARGBChannel implements Serializable { 29 33 public static final int CHANNEL_A = 3; 34 public static final int CHANNEL_R = 2; 35 public static final int CHANNEL_G = 1; 36 public static final int CHANNEL_B = 0; 37 38 42 public static final String RED = "Red"; 43 public static final String GREEN = "Green"; 44 public static final String BLUE = "Blue"; 45 public static final String ALPHA = "Alpha"; 46 47 50 public static final ARGBChannel R 51 = new ARGBChannel(CHANNEL_R, RED); 52 public static final ARGBChannel G 53 = new ARGBChannel(CHANNEL_G, GREEN); 54 public static final ARGBChannel B 55 = new ARGBChannel(CHANNEL_B, BLUE); 56 public static final ARGBChannel A 57 = new ARGBChannel(CHANNEL_A, ALPHA); 58 59 62 private static final 63 ARGBChannel[] enumValues = {R, G, B, A}; 64 65 private String desc; 66 private int val; 67 68 73 private ARGBChannel(int val, String desc){ 74 this.desc = desc; 75 this.val = val; 76 } 77 78 81 public String toString(){ 82 return desc; 83 } 84 85 89 public int toInt(){ 90 return val; 91 } 92 93 94 99 public Object readResolve() { 100 switch(val){ 101 case CHANNEL_R: 102 return R; 103 case CHANNEL_G: 104 return G; 105 case CHANNEL_B: 106 return B; 107 case CHANNEL_A: 108 return A; 109 default: 110 throw new Error ("Unknown ARGBChannel value"); 111 } 112 } 113 } 114 | Popular Tags |