1 | package genius.gui.panels;
|
---|
2 |
|
---|
3 | import javax.swing.BoundedRangeModel;
|
---|
4 | import javax.swing.event.ChangeListener;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Adapts {@link IntegerModel} to {@link BoundedRangeModel} so that we can use
|
---|
8 | * it for sliders.
|
---|
9 | */
|
---|
10 | public class IntegerToBoundeRangeAdapter implements BoundedRangeModel {
|
---|
11 |
|
---|
12 | private IntegerModel model;
|
---|
13 | private boolean valueIsAdjusting = false;
|
---|
14 |
|
---|
15 | public IntegerToBoundeRangeAdapter(IntegerModel model) {
|
---|
16 | this.model = model;
|
---|
17 | }
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public int getMinimum() {
|
---|
21 | return model.getMinimum();
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public void setMinimum(int newMinimum) {
|
---|
26 | // HACK. Does this work?? Problems down the line?
|
---|
27 | model.setMinimum(newMinimum);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public int getMaximum() {
|
---|
32 | return model.getMaximum();
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public void setMaximum(int newMaximum) {
|
---|
37 | model.setMaximum(newMaximum);
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public int getValue() {
|
---|
43 | return model.getValue();
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public void setValue(int newValue) {
|
---|
48 | model.setValue(newValue);
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public void setValueIsAdjusting(boolean b) {
|
---|
53 | valueIsAdjusting = b;
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Override
|
---|
57 | public boolean getValueIsAdjusting() {
|
---|
58 | return valueIsAdjusting;
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Override
|
---|
62 | public int getExtent() {
|
---|
63 | return 0;
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public void setExtent(int newExtent) {
|
---|
68 | // not supported
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public void setRangeProperties(int value, int extent, int min, int max,
|
---|
73 | boolean adjusting) {
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public void addChangeListener(ChangeListener x) {
|
---|
78 | model.getSpinnerModel().addChangeListener(x);
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Override
|
---|
82 | public void removeChangeListener(ChangeListener x) {
|
---|
83 | model.getSpinnerModel().addChangeListener(x);
|
---|
84 | }
|
---|
85 |
|
---|
86 | }
|
---|