f9a8b0d91bdf08b1c8abf063f496d93877994a9a
[jalviewjs.git] / site / j2s / jssun / awt / geom / ChainEnd.js
1 Clazz.declarePackage ("jssun.awt.geom");
2 Clazz.load (null, "jssun.awt.geom.ChainEnd", ["java.lang.InternalError"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.head = null;
5 this.tail = null;
6 this.partner = null;
7 this.etag = 0;
8 Clazz.instantialize (this, arguments);
9 }, jssun.awt.geom, "ChainEnd");
10 Clazz.makeConstructor (c$, 
11 function (first, partner) {
12 this.head = first;
13 this.tail = first;
14 this.partner = partner;
15 this.etag = first.getEdgeTag ();
16 }, "jssun.awt.geom.CurveLink,jssun.awt.geom.ChainEnd");
17 Clazz.defineMethod (c$, "getChain", 
18 function () {
19 return this.head;
20 });
21 Clazz.defineMethod (c$, "setOtherEnd", 
22 function (partner) {
23 this.partner = partner;
24 }, "jssun.awt.geom.ChainEnd");
25 Clazz.defineMethod (c$, "getPartner", 
26 function () {
27 return this.partner;
28 });
29 Clazz.defineMethod (c$, "linkTo", 
30 function (that) {
31 if (this.etag == 0 || that.etag == 0) {
32 throw  new InternalError ("ChainEnd linked more than once!");
33 }if (this.etag == that.etag) {
34 throw  new InternalError ("Linking chains of the same type!");
35 }var enter;
36 var exit;
37 if (this.etag == 1) {
38 enter = this;
39 exit = that;
40 } else {
41 enter = that;
42 exit = this;
43 }this.etag = 0;
44 that.etag = 0;
45 enter.tail.setNext (exit.head);
46 enter.tail = exit.tail;
47 if (this.partner === that) {
48 return enter.head;
49 }var otherenter = exit.partner;
50 var otherexit = enter.partner;
51 otherenter.partner = otherexit;
52 otherexit.partner = otherenter;
53 if (enter.head.getYTop () < otherenter.head.getYTop ()) {
54 enter.tail.setNext (otherenter.head);
55 otherenter.head = enter.head;
56 } else {
57 otherexit.tail.setNext (enter.head);
58 otherexit.tail = enter.tail;
59 }return null;
60 }, "jssun.awt.geom.ChainEnd");
61 Clazz.defineMethod (c$, "addLink", 
62 function (newlink) {
63 if (this.etag == 1) {
64 this.tail.setNext (newlink);
65 this.tail = newlink;
66 } else {
67 newlink.setNext (this.head);
68 this.head = newlink;
69 }}, "jssun.awt.geom.CurveLink");
70 Clazz.defineMethod (c$, "getX", 
71 function () {
72 if (this.etag == 1) {
73 return this.tail.getXBot ();
74 } else {
75 return this.head.getXBot ();
76 }});
77 });