1 42 43 package org.jfree.chart.annotations; 44 45 import java.awt.Graphics2D ; 46 import java.awt.Shape ; 47 import java.awt.geom.Rectangle2D ; 48 49 import org.jfree.chart.axis.ValueAxis; 50 import org.jfree.chart.entity.EntityCollection; 51 import org.jfree.chart.entity.XYAnnotationEntity; 52 import org.jfree.chart.plot.PlotRenderingInfo; 53 import org.jfree.chart.plot.XYPlot; 54 import org.jfree.util.ObjectUtilities; 55 56 60 public abstract class AbstractXYAnnotation implements XYAnnotation { 61 62 63 private String toolTipText; 64 65 66 private String url; 67 68 71 protected AbstractXYAnnotation() { 72 this.toolTipText = null; 73 this.url = null; 74 } 75 76 83 public String getToolTipText() { 84 return this.toolTipText; 85 } 86 87 92 public void setToolTipText(String text) { 93 this.toolTipText = text; 94 } 95 96 102 public String getURL() { 103 return this.url; 104 } 105 106 111 public void setURL(String url) { 112 this.url = url; 113 } 114 115 127 public abstract void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, 128 ValueAxis domainAxis, ValueAxis rangeAxis, 129 int rendererIndex, 130 PlotRenderingInfo info); 131 132 142 protected void addEntity(PlotRenderingInfo info, 143 Shape hotspot, int rendererIndex, 144 String toolTipText, String urlText) { 145 if (info == null) { 146 return; 147 } 148 EntityCollection entities = info.getOwner().getEntityCollection(); 149 if (entities == null) { 150 return; 151 } 152 XYAnnotationEntity entity = new XYAnnotationEntity( 153 hotspot, rendererIndex, toolTipText, urlText 154 ); 155 entities.add(entity); 156 } 157 158 165 public boolean equals(Object obj) { 166 if (obj == this) { 167 return true; 168 } 169 if (!(obj instanceof AbstractXYAnnotation)) { 170 return false; 171 } 172 AbstractXYAnnotation that = (AbstractXYAnnotation) obj; 173 if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { 174 return false; 175 } 176 if (!ObjectUtilities.equal(this.url, that.url)) { 177 return false; 178 } 179 return true; 180 } 181 182 } 183 | Popular Tags |