e00f5dce366ea46a71c1d7f59180d082779bceaf
[jalviewjs.git] / site / swingjs / j2s / javax / swing / SpinnerNumberModel.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.AbstractSpinnerModel"], "javax.swing.SpinnerNumberModel", ["java.lang.Byte", "$.Double", "$.Float", "$.IllegalArgumentException", "$.Long", "$.Number", "$.Short"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.stepSize = null;
5 this.value = null;
6 this.minimum = null;
7 this.maximum = null;
8 Clazz.instantialize (this, arguments);
9 }, javax.swing, "SpinnerNumberModel", javax.swing.AbstractSpinnerModel);
10 Clazz.makeConstructor (c$, 
11 function (value, minimum, maximum, stepSize) {
12 Clazz.superConstructor (this, javax.swing.SpinnerNumberModel, []);
13 if ((value == null) || (stepSize == null)) {
14 throw  new IllegalArgumentException ("value and stepSize must be non-null");
15 }if (!(((minimum == null) || (minimum.compareTo (value) <= 0)) && ((maximum == null) || (maximum.compareTo (value) >= 0)))) {
16 throw  new IllegalArgumentException ("(minimum <= value <= maximum) is false");
17 }this.value = value;
18 this.minimum = minimum;
19 this.maximum = maximum;
20 this.stepSize = stepSize;
21 }, "Number,Comparable,Comparable,Number");
22 Clazz.makeConstructor (c$, 
23 function (value, minimum, maximum, stepSize) {
24 this.construct ( new Integer (value),  new Integer (minimum),  new Integer (maximum),  new Integer (stepSize));
25 }, "~N,~N,~N,~N");
26 Clazz.makeConstructor (c$, 
27 function (value, minimum, maximum, stepSize) {
28 this.construct ( new Double (value),  new Double (minimum),  new Double (maximum),  new Double (stepSize));
29 }, "~N,~N,~N,~N");
30 Clazz.makeConstructor (c$, 
31 function () {
32 this.construct ( new Integer (0), null, null,  new Integer (1));
33 });
34 Clazz.defineMethod (c$, "setMinimum", 
35 function (minimum) {
36 if ((minimum == null) ? (this.minimum != null) : !minimum.equals (this.minimum)) {
37 this.minimum = minimum;
38 this.fireStateChanged ();
39 }}, "Comparable");
40 Clazz.defineMethod (c$, "getMinimum", 
41 function () {
42 return this.minimum;
43 });
44 Clazz.defineMethod (c$, "setMaximum", 
45 function (maximum) {
46 if ((maximum == null) ? (this.maximum != null) : !maximum.equals (this.maximum)) {
47 this.maximum = maximum;
48 this.fireStateChanged ();
49 }}, "Comparable");
50 Clazz.defineMethod (c$, "getMaximum", 
51 function () {
52 return this.maximum;
53 });
54 Clazz.defineMethod (c$, "setStepSize", 
55 function (stepSize) {
56 if (stepSize == null) {
57 throw  new IllegalArgumentException ("null stepSize");
58 }if (!stepSize.equals (this.stepSize)) {
59 this.stepSize = stepSize;
60 this.fireStateChanged ();
61 }}, "Number");
62 Clazz.defineMethod (c$, "getStepSize", 
63 function () {
64 return this.stepSize;
65 });
66 Clazz.defineMethod (c$, "incrValue", 
67  function (dir) {
68 var newValue;
69 if ((Clazz.instanceOf (this.value, Float)) || (Clazz.instanceOf (this.value, Double))) {
70 var v = this.value.doubleValue () + (this.stepSize.doubleValue () * dir);
71 if (Clazz.instanceOf (this.value, Double)) {
72 newValue =  new Double (v);
73 } else {
74 newValue =  new Float (v);
75 }} else {
76 var v = this.value.longValue () + (this.stepSize.longValue () * dir);
77 if (Clazz.instanceOf (this.value, Long)) {
78 newValue =  new Long (v);
79 } else if (Clazz.instanceOf (this.value, Integer)) {
80 newValue =  new Integer (v);
81 } else if (Clazz.instanceOf (this.value, Short)) {
82 newValue =  new Short (v);
83 } else {
84 newValue =  new Byte (v);
85 }}if ((this.maximum != null) && (this.maximum.compareTo (newValue) < 0)) {
86 return null;
87 }if ((this.minimum != null) && (this.minimum.compareTo (newValue) > 0)) {
88 return null;
89 } else {
90 return newValue;
91 }}, "~N");
92 Clazz.overrideMethod (c$, "getNextValue", 
93 function () {
94 return this.incrValue (1);
95 });
96 Clazz.overrideMethod (c$, "getPreviousValue", 
97 function () {
98 return this.incrValue (-1);
99 });
100 Clazz.defineMethod (c$, "getNumber", 
101 function () {
102 return this.value;
103 });
104 Clazz.overrideMethod (c$, "getValue", 
105 function () {
106 return this.value;
107 });
108 Clazz.overrideMethod (c$, "setValue", 
109 function (value) {
110 if ((value == null) || !(Clazz.instanceOf (value, Number))) {
111 throw  new IllegalArgumentException ("illegal value");
112 }if (!value.equals (this.value)) {
113 this.value = value;
114 this.fireStateChanged ();
115 }}, "~O");
116 });