JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / BasicStroke.js
1 Clazz.declarePackage ("java.awt");\r
2 Clazz.load (["java.awt.Stroke"], "java.awt.BasicStroke", ["java.lang.Float", "$.IllegalArgumentException", "java.util.Arrays"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.width = 0;\r
5 this.join = 0;\r
6 this.cap = 0;\r
7 this.miterlimit = 0;\r
8 this.dash = null;\r
9 this.dash_phase = 0;\r
10 Clazz.instantialize (this, arguments);\r
11 }, java.awt, "BasicStroke", null, java.awt.Stroke);\r
12 Clazz.makeConstructor (c$, \r
13 function (width, cap, join, miterlimit, dash, dash_phase) {\r
14 if (width < 0.0) {\r
15 throw  new IllegalArgumentException ("negative width");\r
16 }if (cap != 0 && cap != 1 && cap != 2) {\r
17 throw  new IllegalArgumentException ("illegal end cap value");\r
18 }if (join == 0) {\r
19 if (miterlimit < 1.0) {\r
20 throw  new IllegalArgumentException ("miter limit < 1");\r
21 }} else if (join != 1 && join != 2) {\r
22 throw  new IllegalArgumentException ("illegal line join value");\r
23 }if (dash != null) {\r
24 if (dash_phase < 0.0) {\r
25 throw  new IllegalArgumentException ("negative dash phase");\r
26 }var allzero = true;\r
27 for (var i = 0; i < dash.length; i++) {\r
28 var d = dash[i];\r
29 if (d > 0.0) {\r
30 allzero = false;\r
31 } else if (d < 0.0) {\r
32 throw  new IllegalArgumentException ("negative dash length");\r
33 }}\r
34 if (allzero) {\r
35 throw  new IllegalArgumentException ("dash lengths all zero");\r
36 }}this.width = width;\r
37 this.cap = cap;\r
38 this.join = join;\r
39 this.miterlimit = miterlimit;\r
40 if (dash != null) {\r
41 this.dash = dash.clone ();\r
42 }this.dash_phase = dash_phase;\r
43 }, "~N,~N,~N,~N,~A,~N");\r
44 Clazz.makeConstructor (c$, \r
45 function (width, cap, join, miterlimit) {\r
46 this.construct (width, cap, join, miterlimit, null, 0.0);\r
47 }, "~N,~N,~N,~N");\r
48 Clazz.makeConstructor (c$, \r
49 function (width, cap, join) {\r
50 this.construct (width, cap, join, 10.0, null, 0.0);\r
51 }, "~N,~N,~N");\r
52 Clazz.makeConstructor (c$, \r
53 function (width) {\r
54 this.construct (width, 2, 0, 10.0, null, 0.0);\r
55 }, "~N");\r
56 Clazz.makeConstructor (c$, \r
57 function () {\r
58 this.construct (1.0, 2, 0, 10.0, null, 0.0);\r
59 });\r
60 Clazz.overrideMethod (c$, "createStrokedShape", \r
61 function (s) {\r
62 return s;\r
63 }, "java.awt.Shape");\r
64 Clazz.defineMethod (c$, "getLineWidth", \r
65 function () {\r
66 return this.width;\r
67 });\r
68 Clazz.defineMethod (c$, "getEndCap", \r
69 function () {\r
70 return this.cap;\r
71 });\r
72 Clazz.defineMethod (c$, "getLineJoin", \r
73 function () {\r
74 return this.join;\r
75 });\r
76 Clazz.defineMethod (c$, "getMiterLimit", \r
77 function () {\r
78 return this.miterlimit;\r
79 });\r
80 Clazz.defineMethod (c$, "getDashArray", \r
81 function () {\r
82 if (this.dash == null) {\r
83 return null;\r
84 }return this.dash.clone ();\r
85 });\r
86 Clazz.defineMethod (c$, "getDashPhase", \r
87 function () {\r
88 return this.dash_phase;\r
89 });\r
90 Clazz.overrideMethod (c$, "hashCode", \r
91 function () {\r
92 var hash = Float.floatToIntBits (this.width);\r
93 hash = hash * 31 + this.join;\r
94 hash = hash * 31 + this.cap;\r
95 hash = hash * 31 + Float.floatToIntBits (this.miterlimit);\r
96 if (this.dash != null) {\r
97 hash = hash * 31 + Float.floatToIntBits (this.dash_phase);\r
98 for (var i = 0; i < this.dash.length; i++) {\r
99 hash = hash * 31 + Float.floatToIntBits (this.dash[i]);\r
100 }\r
101 }return hash;\r
102 });\r
103 Clazz.overrideMethod (c$, "equals", \r
104 function (obj) {\r
105 if (!(Clazz.instanceOf (obj, java.awt.BasicStroke))) {\r
106 return false;\r
107 }var bs = obj;\r
108 if (this.width != bs.width) {\r
109 return false;\r
110 }if (this.join != bs.join) {\r
111 return false;\r
112 }if (this.cap != bs.cap) {\r
113 return false;\r
114 }if (this.miterlimit != bs.miterlimit) {\r
115 return false;\r
116 }if (this.dash != null) {\r
117 if (this.dash_phase != bs.dash_phase) {\r
118 return false;\r
119 }if (!java.util.Arrays.equals (this.dash, bs.dash)) {\r
120 return false;\r
121 }} else if (bs.dash != null) {\r
122 return false;\r
123 }return true;\r
124 }, "~O");\r
125 Clazz.defineStatics (c$,\r
126 "JOIN_MITER", 0,\r
127 "JOIN_ROUND", 1,\r
128 "JOIN_BEVEL", 2,\r
129 "CAP_BUTT", 0,\r
130 "CAP_ROUND", 1,\r
131 "CAP_SQUARE", 2);\r
132 });\r