1 | package genius.gui.panels;
|
---|
2 |
|
---|
3 | import javax.swing.SpinnerNumberModel;
|
---|
4 | import javax.swing.event.ChangeListener;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Just like SpinnerModel but ensures that it works with numbers of type N. This
|
---|
8 | * improves type checking. Useful when you get something out of the model....
|
---|
9 | *
|
---|
10 | * Supports only Integer because sliders support only integers.
|
---|
11 | */
|
---|
12 | public class SpinnerModel {
|
---|
13 |
|
---|
14 | private SpinnerNumberModel spinmodel;
|
---|
15 |
|
---|
16 | public SpinnerModel(Integer value, Integer minimum, Integer maximum,
|
---|
17 | Integer stepSize) {
|
---|
18 | spinmodel = new SpinnerNumberModel(value, minimum, maximum, stepSize);
|
---|
19 | }
|
---|
20 |
|
---|
21 | @SuppressWarnings("unchecked")
|
---|
22 | public Integer getMinimum() {
|
---|
23 | return (Integer) spinmodel.getMinimum();
|
---|
24 | }
|
---|
25 |
|
---|
26 | @SuppressWarnings("unchecked")
|
---|
27 | public Integer getMaximum() {
|
---|
28 | return (Integer) spinmodel.getMaximum();
|
---|
29 | }
|
---|
30 |
|
---|
31 | public javax.swing.SpinnerModel getSpinnerModel() {
|
---|
32 | return spinmodel;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @SuppressWarnings("unchecked")
|
---|
36 | public Integer getValue() {
|
---|
37 | return (Integer) spinmodel.getValue();
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void setValue(Integer value) {
|
---|
41 | spinmodel.setValue(value);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void addChangeListener(ChangeListener changeListener) {
|
---|
45 | spinmodel.addChangeListener(changeListener);
|
---|
46 | }
|
---|
47 |
|
---|
48 | public void setMinimum(Integer newMinimum) {
|
---|
49 | spinmodel.setMinimum(newMinimum);
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void setMaximum(Integer newMaximum) {
|
---|
53 | spinmodel.setMinimum(newMaximum);
|
---|
54 |
|
---|
55 | }
|
---|
56 |
|
---|
57 | }
|
---|