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