1 package org.catacomb.interlish.content;
2
3
4 public class DoubleValue extends PrimitiveValue {
5
6
7 private double dble;
8
9 private DoubleValue peer;
10
11
12 public DoubleValue() {
13 super();
14 dble = 0.0;
15 }
16
17
18
19 public DoubleValue(double d) {
20 super();
21 dble = d;
22 }
23
24 public String toString() {
25 return String.format("%.3g", new Double(dble));
26 }
27
28
29 public void setPeer(DoubleValue dv) {
30 peer = dv;
31 peer.reportableSetDouble(dble, this);
32 }
33
34
35 public void releasePeer() {
36 peer = null;
37 }
38
39
40 public void silentSetDouble(double d) {
41 dble = d;
42 logChange();
43 if (peer != null) {
44 peer.silentSetDouble(d);
45 }
46 }
47
48 public double getDouble() {
49 double ret = 0.;
50 if (peer != null) {
51 ret = peer.getDouble();
52 dble = ret;
53 } else {
54 ret = dble;
55 }
56 return ret;
57 }
58
59
60 public void setValue(double d) {
61 reportableSetDouble(d, null);
62 }
63
64 public void reportableSetDouble(double d, Object src) {
65 silentSetDouble(d);
66 reportValueChange(src);
67 if (peer != null) {
68 peer.reportableSetDouble(d, src);
69 }
70 }
71
72
73
74 public void copyFrom(DoubleValue src) {
75 silentSetDouble(src.getDouble());
76 }
77
78
79
80
81
82 }