1 45 46 package org.jfree.chart.plot; 47 48 import java.awt.BasicStroke ; 49 import java.awt.Color ; 50 import java.awt.Paint ; 51 import java.awt.Stroke ; 52 import java.io.Serializable ; 53 54 import org.jfree.chart.event.MarkerChangeEvent; 55 import org.jfree.ui.LengthAdjustmentType; 56 57 65 public class CategoryMarker extends Marker implements Cloneable , Serializable { 66 67 68 private Comparable key; 69 70 73 private boolean drawAsLine = false; 74 75 80 public CategoryMarker(Comparable key) { 81 this(key, Color.gray, new BasicStroke (1.0f)); 82 } 83 84 91 public CategoryMarker(Comparable key, Paint paint, Stroke stroke) { 92 this(key, paint, stroke, paint, stroke, 1.0f); 93 } 94 95 105 public CategoryMarker(Comparable key, Paint paint, Stroke stroke, 106 Paint outlinePaint, Stroke outlineStroke, 107 float alpha) { 108 super(paint, stroke, outlinePaint, outlineStroke, alpha); 109 this.key = key; 110 setLabelOffsetType(LengthAdjustmentType.EXPAND); 111 } 112 113 118 public Comparable getKey() { 119 return this.key; 120 } 121 122 130 public void setKey(Comparable key) { 131 if (key == null) { 132 throw new IllegalArgumentException ("Null 'key' argument."); 133 } 134 this.key = key; 135 notifyListeners(new MarkerChangeEvent(this)); 136 } 137 138 144 public boolean getDrawAsLine() { 145 return this.drawAsLine; 146 } 147 148 155 public void setDrawAsLine(boolean drawAsLine) { 156 this.drawAsLine = drawAsLine; 157 notifyListeners(new MarkerChangeEvent(this)); 158 } 159 160 167 public boolean equals(Object obj) { 168 if (obj == null) { 169 return false; 170 } 171 if (!(obj instanceof CategoryMarker)) { 172 return false; 173 } 174 if (!super.equals(obj)) { 175 return false; 176 } 177 CategoryMarker that = (CategoryMarker) obj; 178 if (!this.key.equals(that.key)) { 179 return false; 180 } 181 if (this.drawAsLine != that.drawAsLine) { 182 return false; 183 } 184 return true; 185 } 186 187 } 188 | Popular Tags |