1 43 44 package org.jfree.chart.plot; 45 46 import java.awt.BasicStroke ; 47 import java.awt.Color ; 48 import java.awt.Paint ; 49 import java.awt.Stroke ; 50 import java.io.IOException ; 51 import java.io.ObjectInputStream ; 52 import java.io.ObjectOutputStream ; 53 import java.io.Serializable ; 54 55 import org.jfree.data.Range; 56 import org.jfree.io.SerialUtilities; 57 import org.jfree.util.ObjectUtilities; 58 import org.jfree.util.PaintUtilities; 59 60 64 public class MeterInterval implements Serializable { 65 66 67 private static final long serialVersionUID = 1530982090622488257L; 68 69 70 private String label; 71 72 73 private Range range; 74 75 76 private transient Paint outlinePaint; 77 78 79 private transient Stroke outlineStroke; 80 81 82 private transient Paint backgroundPaint; 83 84 90 public MeterInterval(String label, Range range) { 91 this(label, range, Color.yellow, new BasicStroke (2.0f), null); 92 } 93 94 104 public MeterInterval(String label, Range range, Paint outlinePaint, 105 Stroke outlineStroke, Paint backgroundPaint) { 106 if (label == null) { 107 throw new IllegalArgumentException ("Null 'label' argument."); 108 } 109 if (range == null) { 110 throw new IllegalArgumentException ("Null 'range' argument."); 111 } 112 this.label = label; 113 this.range = range; 114 this.outlinePaint = outlinePaint; 115 this.outlineStroke = outlineStroke; 116 this.backgroundPaint = backgroundPaint; 117 } 118 119 124 public String getLabel() { 125 return this.label; 126 } 127 128 133 public Range getRange() { 134 return this.range; 135 } 136 137 143 public Paint getBackgroundPaint() { 144 return this.backgroundPaint; 145 } 146 147 152 public Paint getOutlinePaint() { 153 return this.outlinePaint; 154 } 155 156 161 public Stroke getOutlineStroke() { 162 return this.outlineStroke; 163 } 164 165 172 public boolean equals(Object obj) { 173 if (obj == this) { 174 return true; 175 } 176 if (!(obj instanceof MeterInterval)) { 177 return false; 178 } 179 MeterInterval that = (MeterInterval) obj; 180 if (!this.label.equals(that.label)) { 181 return false; 182 } 183 if (!this.range.equals(that.range)) { 184 return false; 185 } 186 if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { 187 return false; 188 } 189 if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { 190 return false; 191 } 192 if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { 193 return false; 194 } 195 return true; 196 } 197 198 205 private void writeObject(ObjectOutputStream stream) throws IOException { 206 stream.defaultWriteObject(); 207 SerialUtilities.writePaint(this.outlinePaint, stream); 208 SerialUtilities.writeStroke(this.outlineStroke, stream); 209 SerialUtilities.writePaint(this.backgroundPaint, stream); 210 } 211 212 220 private void readObject(ObjectInputStream stream) 221 throws IOException , ClassNotFoundException { 222 stream.defaultReadObject(); 223 this.outlinePaint = SerialUtilities.readPaint(stream); 224 this.outlineStroke = SerialUtilities.readStroke(stream); 225 this.backgroundPaint = SerialUtilities.readPaint(stream); 226 } 227 228 } 229 | Popular Tags |