JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / color / ColorSpace.js
1 Clazz.declarePackage ("java.awt.color");\r
2 Clazz.load (null, "java.awt.color.ColorSpace", ["java.lang.IllegalArgumentException"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.type = 0;\r
5 this.numComponents = 0;\r
6 this.compName = null;\r
7 Clazz.instantialize (this, arguments);\r
8 }, java.awt.color, "ColorSpace");\r
9 Clazz.makeConstructor (c$, \r
10 function (type, numcomponents) {\r
11 this.type = type;\r
12 this.numComponents = numcomponents;\r
13 }, "~N,~N");\r
14 c$.getInstance = Clazz.defineMethod (c$, "getInstance", \r
15 function (colorspace) {\r
16 var theColorSpace;\r
17 switch (colorspace) {\r
18 default:\r
19 case 1000:\r
20 if (java.awt.color.ColorSpace.sRGBspace == null) {\r
21 java.awt.color.ColorSpace.sRGBspace =  new java.awt.color.ColorSpace (5, 3);\r
22 }theColorSpace = java.awt.color.ColorSpace.sRGBspace;\r
23 break;\r
24 }\r
25 return theColorSpace;\r
26 }, "~N");\r
27 Clazz.defineMethod (c$, "isCS_sRGB", \r
28 function () {\r
29 return (this === java.awt.color.ColorSpace.sRGBspace);\r
30 });\r
31 Clazz.defineMethod (c$, "toRGB", \r
32 function (colorvalue) {\r
33 return colorvalue;\r
34 }, "~A");\r
35 Clazz.defineMethod (c$, "fromRGB", \r
36 function (rgbvalue) {\r
37 return rgbvalue;\r
38 }, "~A");\r
39 Clazz.defineMethod (c$, "getType", \r
40 function () {\r
41 return this.type;\r
42 });\r
43 Clazz.defineMethod (c$, "getNumComponents", \r
44 function () {\r
45 return this.numComponents;\r
46 });\r
47 Clazz.defineMethod (c$, "getName", \r
48 function (idx) {\r
49 if ((idx < 0) || (idx > this.numComponents - 1)) {\r
50 throw  new IllegalArgumentException ("Component index out of range: " + idx);\r
51 }if (this.compName == null) {\r
52 switch (this.type) {\r
53 case 0:\r
54 this.compName =  Clazz.newArray (-1, ["X", "Y", "Z"]);\r
55 break;\r
56 case 1:\r
57 this.compName =  Clazz.newArray (-1, ["L", "a", "b"]);\r
58 break;\r
59 case 2:\r
60 this.compName =  Clazz.newArray (-1, ["L", "u", "v"]);\r
61 break;\r
62 case 3:\r
63 this.compName =  Clazz.newArray (-1, ["Y", "Cb", "Cr"]);\r
64 break;\r
65 case 4:\r
66 this.compName =  Clazz.newArray (-1, ["Y", "x", "y"]);\r
67 break;\r
68 case 5:\r
69 this.compName =  Clazz.newArray (-1, ["Red", "Green", "Blue"]);\r
70 break;\r
71 case 6:\r
72 this.compName =  Clazz.newArray (-1, ["Gray"]);\r
73 break;\r
74 case 7:\r
75 this.compName =  Clazz.newArray (-1, ["Hue", "Saturation", "Value"]);\r
76 break;\r
77 case 8:\r
78 this.compName =  Clazz.newArray (-1, ["Hue", "Lightness", "Saturation"]);\r
79 break;\r
80 case 9:\r
81 this.compName =  Clazz.newArray (-1, ["Cyan", "Magenta", "Yellow", "Black"]);\r
82 break;\r
83 case 11:\r
84 this.compName =  Clazz.newArray (-1, ["Cyan", "Magenta", "Yellow"]);\r
85 break;\r
86 default:\r
87 var tmp =  new Array (this.numComponents);\r
88 for (var i = 0; i < tmp.length; i++) {\r
89 tmp[i] = "Unnamed color component(" + i + ")";\r
90 }\r
91 this.compName = tmp;\r
92 }\r
93 }return this.compName[idx];\r
94 }, "~N");\r
95 Clazz.defineMethod (c$, "getMinValue", \r
96 function (component) {\r
97 if ((component < 0) || (component > this.numComponents - 1)) {\r
98 throw  new IllegalArgumentException ("Component index out of range: " + component);\r
99 }return 0.0;\r
100 }, "~N");\r
101 Clazz.defineMethod (c$, "getMaxValue", \r
102 function (component) {\r
103 if ((component < 0) || (component > this.numComponents - 1)) {\r
104 throw  new IllegalArgumentException ("Component index out of range: " + component);\r
105 }return 1.0;\r
106 }, "~N");\r
107 Clazz.defineStatics (c$,\r
108 "sRGBspace", null,\r
109 "TYPE_XYZ", 0,\r
110 "TYPE_Lab", 1,\r
111 "TYPE_Luv", 2,\r
112 "TYPE_YCbCr", 3,\r
113 "TYPE_Yxy", 4,\r
114 "TYPE_RGB", 5,\r
115 "TYPE_GRAY", 6,\r
116 "TYPE_HSV", 7,\r
117 "TYPE_HLS", 8,\r
118 "TYPE_CMYK", 9,\r
119 "TYPE_CMY", 11,\r
120 "TYPE_2CLR", 12,\r
121 "TYPE_3CLR", 13,\r
122 "TYPE_4CLR", 14,\r
123 "TYPE_5CLR", 15,\r
124 "TYPE_6CLR", 16,\r
125 "TYPE_7CLR", 17,\r
126 "TYPE_8CLR", 18,\r
127 "TYPE_9CLR", 19,\r
128 "TYPE_ACLR", 20,\r
129 "TYPE_BCLR", 21,\r
130 "TYPE_CCLR", 22,\r
131 "TYPE_DCLR", 23,\r
132 "TYPE_ECLR", 24,\r
133 "TYPE_FCLR", 25,\r
134 "CS_sRGB", 1000,\r
135 "CS_LINEAR_RGB", 1004,\r
136 "CS_CIEXYZ", 1001,\r
137 "CS_PYCC", 1002,\r
138 "CS_GRAY", 1003);\r
139 });\r