1 44 45 package org.jfree.chart; 46 47 import java.awt.Color ; 48 import java.awt.Font ; 49 import java.awt.Paint ; 50 import java.awt.Stroke ; 51 import java.io.IOException ; 52 import java.io.ObjectInputStream ; 53 import java.io.ObjectOutputStream ; 54 import java.io.Serializable ; 55 56 import org.jfree.io.SerialUtilities; 57 import org.jfree.util.ObjectUtils; 58 59 68 public class Marker implements Serializable , Cloneable { 69 70 71 private double value; 72 73 74 private transient Paint outlinePaint; 75 76 77 private transient Stroke outlineStroke; 78 79 80 private transient Paint paint; 81 82 83 private float alpha; 84 85 86 private String label = null; 87 88 89 private Font labelFont; 90 91 92 private transient Paint labelPaint; 93 94 95 private MarkerLabelPosition labelPosition = MarkerLabelPosition.TOP_LEFT; 96 97 102 public Marker(double value) { 103 this(value, Color.gray, new java.awt.BasicStroke (0.5f), Color.gray, 0.80f); 104 } 105 106 112 public Marker(double value, Paint outlinePaint) { 113 this(value, outlinePaint, new java.awt.BasicStroke (0.5f), Color.red, 0.80f); 114 } 115 116 125 public Marker(double value, Paint outlinePaint, Stroke outlineStroke, 126 Paint paint, float alpha) { 127 128 if (outlinePaint == null) { 130 throw new IllegalArgumentException ("Marker(...) : null outlinePaint not permitted."); 131 } 132 if (outlineStroke == null) { 133 throw new IllegalArgumentException ("Marker(...) : null outlineStroke not permitted."); 134 } 135 if (paint == null) { 136 throw new IllegalArgumentException ("Marker(...) : null paint not permitted."); 137 } 138 139 this.value = value; 140 this.outlinePaint = outlinePaint; 141 this.outlineStroke = outlineStroke; 142 this.paint = paint; 143 this.alpha = alpha; 144 145 this.labelFont = new Font ("SansSerif", Font.PLAIN, 9); 146 this.labelPaint = Color.black; 147 148 } 149 150 155 public double getValue() { 156 return this.value; 157 } 158 159 164 public Paint getOutlinePaint() { 165 return this.outlinePaint; 166 } 167 168 173 public Stroke getOutlineStroke() { 174 return this.outlineStroke; 175 } 176 177 182 public Paint getPaint() { 183 return this.paint; 184 } 185 186 191 public float getAlpha() { 192 return this.alpha; 193 } 194 195 200 public String getLabel() { 201 return this.label; 202 } 203 204 209 public void setLabel(String label) { 210 this.label = label; 211 } 212 213 218 public Font getLabelFont() { 219 return this.labelFont; 220 } 221 222 227 public void setLabelFont(Font font) { 228 if (paint == null) { 229 throw new IllegalArgumentException ("Marker.setLabelFont(...): null not permitted."); 230 } 231 this.labelFont = font; 232 } 233 234 239 public Paint getLabelPaint() { 240 return this.labelPaint; 241 } 242 243 248 public void setLabelPaint(Paint paint) { 249 if (paint == null) { 250 throw new IllegalArgumentException ("Marker.setLabelPaint(...): null not permitted."); 251 } 252 this.labelPaint = paint; 253 } 254 255 260 public MarkerLabelPosition getLabelPosition() { 261 return this.labelPosition; 262 } 263 264 269 public void setLabelPosition(MarkerLabelPosition position) { 270 this.labelPosition = position; 271 } 272 273 280 public boolean equals(Object object) { 281 282 if (object == null) { 283 return false; 284 } 285 286 if (object == this) { 287 return true; 288 } 289 290 if (object instanceof Marker) { 291 Marker marker = (Marker) object; 292 boolean b0 = (this.value == marker.value); 293 boolean b1 = ObjectUtils.equal(this.outlinePaint, marker.outlinePaint); 294 boolean b2 = ObjectUtils.equal(this.outlineStroke, marker.outlineStroke); 295 boolean b3 = ObjectUtils.equal(this.paint, marker.paint); 296 boolean b4 = (this.alpha == marker.alpha); 297 boolean b5 = ObjectUtils.equal(this.label, marker.label); 298 boolean b6 = ObjectUtils.equal(this.labelFont, marker.labelFont); 299 boolean b7 = ObjectUtils.equal(this.labelPaint, marker.labelPaint); 300 boolean b8 = (this.labelPosition == marker.labelPosition); 301 302 return b0 && b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8; 303 } 304 305 return false; 306 307 } 308 309 316 private void writeObject(ObjectOutputStream stream) throws IOException { 317 318 stream.defaultWriteObject(); 319 SerialUtilities.writePaint(this.outlinePaint, stream); 320 SerialUtilities.writeStroke(this.outlineStroke, stream); 321 SerialUtilities.writePaint(this.paint, stream); 322 323 } 324 325 333 private void readObject(ObjectInputStream stream) throws IOException , ClassNotFoundException { 334 335 stream.defaultReadObject(); 336 this.outlinePaint = SerialUtilities.readPaint(stream); 337 this.outlineStroke = SerialUtilities.readStroke(stream); 338 this.paint = SerialUtilities.readPaint(stream); 339 340 } 341 342 } 343 | Popular Tags |