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