/Users/lyon/j4p/src/bookExamples/ch19Events/observables/ObservablePoint3d.java

1    package bookExamples.ch19Events.observables; 
2     
3    import java.util.Observable; 
4     
5    public class ObservablePoint3d extends Observable { 
6        private double d1 = 0; 
7        private double d2 = 0; 
8        private double d3 = 0; 
9     
10       public void setD1(double _d) { 
11           if (d1 != _d) { 
12               d1 = _d; 
13               setChanged(); 
14               super.notifyObservers(this); 
15           } 
16       } 
17    
18       public void setD2(double _d) { 
19           if (d2 != _d) { 
20               d2 = _d; 
21               setChanged(); 
22               super.notifyObservers(this); 
23           } 
24       } 
25    
26       public void setD3(double _d) { 
27           if (d3 != _d) { 
28               d3 = _d; 
29               setChanged(); 
30               super.notifyObservers(this); 
31           } 
32       } 
33    
34       public double getD1() { 
35           return d1; 
36       } 
37    
38       public double getD2() { 
39           return d2; 
40       } 
41    
42       public double getD3() { 
43           return d3; 
44       } 
45    
46       public String toString() { 
47           return "d1,d2,d3=" + d1 + "," + d2 + "," + d3; 
48       } 
49   } 
50