summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/NumberAttribute.java
blob: 51e30a9ca1e31637f0903e2534c9e139004a51a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import java.io.DataInputStream;
/*     */ import java.io.DataOutputStream;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class NumberAttribute
/*     */   extends Attribute
/*     */ {
/*     */   public NumberAttribute(int attrID)
/*     */   {
/*  23 */     super(attrID);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  31 */   float value = 0.0F;
/*     */   
/*     */ 
/*     */ 
/*     */   public NumberAttribute() {}
/*     */   
/*     */ 
/*     */   public void set(float x)
/*     */   {
/*  40 */     this.value = x;
/*     */     
/*  42 */     noteChange();
/*     */   }
/*     */   
/*     */   public float get()
/*     */   {
/*  47 */     return this.value;
/*     */   }
/*     */   
/*     */   public void generateNetData(DataOutputStream s)
/*     */     throws IOException
/*     */   {
/*  53 */     s.writeFloat(this.value);
/*     */   }
/*     */   
/*     */   public void setFromNetData(DataInputStream ds, int len) throws IOException
/*     */   {
/*  58 */     this.value = ds.readFloat();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/*  68 */     Object ret = null;
/*  69 */     switch (index - offset) {
/*     */     case 0: 
/*  71 */       if (mode == 0) {
/*  72 */         ret = FloatPropertyEditor.make(
/*  73 */           new Property(this, index, "value"));
/*  74 */       } else if (mode == 1) {
/*  75 */         ret = new Float(get());
/*  76 */       } else if (mode == 2)
/*  77 */         set(((Float)value).floatValue());
/*  78 */       break;
/*     */     default: 
/*  80 */       ret = super.properties(index, offset + 1, mode, value);
/*     */     }
/*  82 */     return ret;
/*     */   }
/*     */   
/*     */ 
/*  86 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/*  90 */     s.saveVersion(0, classCookie);
/*  91 */     super.saveState(s);
/*     */     
/*  93 */     s.saveFloat(this.value);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/*  98 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 0: 
/* 100 */       super.restoreState(r);
/* 101 */       this.value = r.restoreFloat();
/* 102 */       break;
/*     */     default: 
/* 104 */       throw new TooNewException();
/*     */     }
/*     */     
/* 107 */     set(this.value);
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/* 112 */     return super.toString() + "[" + get() + "]";
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\NumberAttribute.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */