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