JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / AlphaComposite.js
1 Clazz.declarePackage ("java.awt");\r
2 Clazz.load (["java.awt.Composite"], "java.awt.AlphaComposite", ["java.lang.Float", "$.IllegalArgumentException", "jssun.java2d.SunCompositeContext"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.extraAlpha = 0;\r
5 this.rule = 0;\r
6 Clazz.instantialize (this, arguments);\r
7 }, java.awt, "AlphaComposite", null, java.awt.Composite);\r
8 Clazz.makeConstructor (c$, \r
9  function (rule) {\r
10 this.construct (rule, 1.0);\r
11 }, "~N");\r
12 Clazz.makeConstructor (c$, \r
13  function (rule, alpha) {\r
14 if (alpha < 0.0 || alpha > 1.0) {\r
15 throw  new IllegalArgumentException ("alpha value out of range");\r
16 }if (rule < 1 || rule > 12) {\r
17 throw  new IllegalArgumentException ("unknown composite rule");\r
18 }this.rule = rule;\r
19 this.extraAlpha = alpha;\r
20 }, "~N,~N");\r
21 c$.getInstance = Clazz.defineMethod (c$, "getInstance", \r
22 function (rule) {\r
23 switch (rule) {\r
24 case 1:\r
25 return java.awt.AlphaComposite.Clear;\r
26 case 2:\r
27 return java.awt.AlphaComposite.Src;\r
28 case 9:\r
29 return java.awt.AlphaComposite.Dst;\r
30 case 3:\r
31 return java.awt.AlphaComposite.SrcOver;\r
32 case 4:\r
33 return java.awt.AlphaComposite.DstOver;\r
34 case 5:\r
35 return java.awt.AlphaComposite.SrcIn;\r
36 case 6:\r
37 return java.awt.AlphaComposite.DstIn;\r
38 case 7:\r
39 return java.awt.AlphaComposite.SrcOut;\r
40 case 8:\r
41 return java.awt.AlphaComposite.DstOut;\r
42 case 10:\r
43 return java.awt.AlphaComposite.SrcAtop;\r
44 case 11:\r
45 return java.awt.AlphaComposite.DstAtop;\r
46 case 12:\r
47 return java.awt.AlphaComposite.Xor;\r
48 default:\r
49 throw  new IllegalArgumentException ("unknown composite rule");\r
50 }\r
51 }, "~N");\r
52 c$.getInstance = Clazz.defineMethod (c$, "getInstance", \r
53 function (rule, alpha) {\r
54 if (alpha == 1.0) {\r
55 return java.awt.AlphaComposite.getInstance (rule);\r
56 }return  new java.awt.AlphaComposite (rule, alpha);\r
57 }, "~N,~N");\r
58 Clazz.overrideMethod (c$, "createContext", \r
59 function (srcColorModel, dstColorModel, hints) {\r
60 return  new jssun.java2d.SunCompositeContext (this, srcColorModel, dstColorModel);\r
61 }, "java.awt.image.ColorModel,java.awt.image.ColorModel,java.awt.RenderingHints");\r
62 Clazz.defineMethod (c$, "getAlpha", \r
63 function () {\r
64 return this.extraAlpha;\r
65 });\r
66 Clazz.defineMethod (c$, "getRule", \r
67 function () {\r
68 return this.rule;\r
69 });\r
70 Clazz.defineMethod (c$, "derive", \r
71 function (rule) {\r
72 return (this.rule == rule) ? this : java.awt.AlphaComposite.getInstance (rule, this.extraAlpha);\r
73 }, "~N");\r
74 Clazz.defineMethod (c$, "derive", \r
75 function (alpha) {\r
76 return (this.extraAlpha == alpha) ? this : java.awt.AlphaComposite.getInstance (this.rule, alpha);\r
77 }, "~N");\r
78 Clazz.overrideMethod (c$, "hashCode", \r
79 function () {\r
80 return (Float.floatToIntBits (this.extraAlpha) * 31 + this.rule);\r
81 });\r
82 Clazz.overrideMethod (c$, "equals", \r
83 function (obj) {\r
84 if (!(Clazz.instanceOf (obj, java.awt.AlphaComposite))) {\r
85 return false;\r
86 }var ac = obj;\r
87 if (this.rule != ac.rule) {\r
88 return false;\r
89 }if (this.extraAlpha != ac.extraAlpha) {\r
90 return false;\r
91 }return true;\r
92 }, "~O");\r
93 Clazz.defineStatics (c$,\r
94 "CLEAR", 1,\r
95 "SRC", 2,\r
96 "DST", 9,\r
97 "SRC_OVER", 3,\r
98 "DST_OVER", 4,\r
99 "SRC_IN", 5,\r
100 "DST_IN", 6,\r
101 "SRC_OUT", 7,\r
102 "DST_OUT", 8,\r
103 "SRC_ATOP", 10,\r
104 "DST_ATOP", 11,\r
105 "XOR", 12);\r
106 c$.Clear = c$.prototype.Clear =  new java.awt.AlphaComposite (1);\r
107 c$.Src = c$.prototype.Src =  new java.awt.AlphaComposite (2);\r
108 c$.Dst = c$.prototype.Dst =  new java.awt.AlphaComposite (9);\r
109 c$.SrcOver = c$.prototype.SrcOver =  new java.awt.AlphaComposite (3);\r
110 c$.DstOver = c$.prototype.DstOver =  new java.awt.AlphaComposite (4);\r
111 c$.SrcIn = c$.prototype.SrcIn =  new java.awt.AlphaComposite (5);\r
112 c$.DstIn = c$.prototype.DstIn =  new java.awt.AlphaComposite (6);\r
113 c$.SrcOut = c$.prototype.SrcOut =  new java.awt.AlphaComposite (7);\r
114 c$.DstOut = c$.prototype.DstOut =  new java.awt.AlphaComposite (8);\r
115 c$.SrcAtop = c$.prototype.SrcAtop =  new java.awt.AlphaComposite (10);\r
116 c$.DstAtop = c$.prototype.DstAtop =  new java.awt.AlphaComposite (11);\r
117 c$.Xor = c$.prototype.Xor =  new java.awt.AlphaComposite (12);\r
118 Clazz.defineStatics (c$,\r
119 "MIN_RULE", 1,\r
120 "MAX_RULE", 12);\r
121 });\r