Line | |
---|
1 | package genius.gui.panels;
|
---|
2 |
|
---|
3 | import genius.core.listener.DefaultListenable;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Model behind a double value (from a text field). Listeners receive the new string value as object.
|
---|
7 | *
|
---|
8 | */
|
---|
9 | public class DoubleModel extends DefaultListenable<Double> implements Lockable
|
---|
10 | {
|
---|
11 | private Double value;
|
---|
12 | private boolean isLocked = false;
|
---|
13 |
|
---|
14 | public DoubleModel(Double initial) {
|
---|
15 | this.value = initial;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public void setText(Double newvalue)
|
---|
19 | {
|
---|
20 | if (!value.equals(newvalue)) {
|
---|
21 | value = newvalue;
|
---|
22 | notifyChange(value);
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public Double getValue()
|
---|
27 | {
|
---|
28 | return value;
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void setLock(boolean isLock)
|
---|
33 | {
|
---|
34 | this.isLocked = isLock;
|
---|
35 | notifyChange(value);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public boolean isLocked() {
|
---|
40 | return isLocked;
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.