3afc2d7b63792d96d9a29b70f07efe3ea219b033
[jalviewjs.git] / site / j2s / javax / swing / text / TabSet.js
1 Clazz.declarePackage ("javax.swing.text");
2 Clazz.load (null, "javax.swing.text.TabSet", ["java.lang.IllegalArgumentException", "$.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.tabs = null;
5 this.$hashCode = 2147483647;
6 Clazz.instantialize (this, arguments);
7 }, javax.swing.text, "TabSet");
8 Clazz.makeConstructor (c$, 
9 function (tabs) {
10 if (tabs != null) {
11 var tabCount = tabs.length;
12 this.tabs =  new Array (tabCount);
13 System.arraycopy (tabs, 0, this.tabs, 0, tabCount);
14 } else this.tabs = null;
15 }, "~A");
16 Clazz.defineMethod (c$, "getTabCount", 
17 function () {
18 return (this.tabs == null) ? 0 : this.tabs.length;
19 });
20 Clazz.defineMethod (c$, "getTab", 
21 function (index) {
22 var numTabs = this.getTabCount ();
23 if (index < 0 || index >= numTabs) throw  new IllegalArgumentException (index + " is outside the range of tabs");
24 return this.tabs[index];
25 }, "~N");
26 Clazz.defineMethod (c$, "getTabAfter", 
27 function (location) {
28 var index = this.getTabIndexAfter (location);
29 return (index == -1) ? null : this.tabs[index];
30 }, "~N");
31 Clazz.defineMethod (c$, "getTabIndex", 
32 function (tab) {
33 for (var counter = this.getTabCount () - 1; counter >= 0; counter--) if (this.getTab (counter) === tab) return counter;
34
35 return -1;
36 }, "javax.swing.text.TabStop");
37 Clazz.defineMethod (c$, "getTabIndexAfter", 
38 function (location) {
39 var current;
40 var min;
41 var max;
42 min = 0;
43 max = this.getTabCount ();
44 while (min != max) {
45 current = Clazz.doubleToInt ((max - min) / 2) + min;
46 if (location > this.tabs[current].getPosition ()) {
47 if (min == current) min = max;
48  else min = current;
49 } else {
50 if (current == 0 || location > this.tabs[current - 1].getPosition ()) return current;
51 max = current;
52 }}
53 return -1;
54 }, "~N");
55 Clazz.overrideMethod (c$, "equals", 
56 function (o) {
57 if (o === this) {
58 return true;
59 }if (Clazz.instanceOf (o, javax.swing.text.TabSet)) {
60 var ts = o;
61 var count = this.getTabCount ();
62 if (ts.getTabCount () != count) {
63 return false;
64 }for (var i = 0; i < count; i++) {
65 var ts1 = this.getTab (i);
66 var ts2 = ts.getTab (i);
67 if ((ts1 == null && ts2 != null) || (ts1 != null && !this.getTab (i).equals (ts.getTab (i)))) {
68 return false;
69 }}
70 return true;
71 }return false;
72 }, "~O");
73 Clazz.overrideMethod (c$, "hashCode", 
74 function () {
75 if (this.$hashCode == 2147483647) {
76 this.$hashCode = 0;
77 var len = this.getTabCount ();
78 for (var i = 0; i < len; i++) {
79 var ts = this.getTab (i);
80 this.$hashCode ^= ts != null ? this.getTab (i).hashCode () : 0;
81 }
82 if (this.$hashCode == 2147483647) {
83 this.$hashCode -= 1;
84 }}return this.$hashCode;
85 });
86 Clazz.overrideMethod (c$, "toString", 
87 function () {
88 var tabCount = this.getTabCount ();
89 var buffer =  new StringBuffer ("[ ");
90 for (var counter = 0; counter < tabCount; counter++) {
91 if (counter > 0) buffer.append (" - ");
92 buffer.append (this.getTab (counter).toString ());
93 }
94 buffer.append (" ]");
95 return buffer.toString ();
96 });
97 });