1 46 47 package org.jfree.chart.labels; 48 49 import java.io.Serializable ; 50 import java.util.List ; 51 52 import org.jfree.data.xy.XYDataset; 53 import org.jfree.util.PublicCloneable; 54 55 61 public class CustomXYToolTipGenerator implements XYToolTipGenerator, 62 Cloneable , 63 PublicCloneable, 64 Serializable { 65 66 67 private static final long serialVersionUID = 8636030004670141362L; 68 69 70 private List toolTipSeries = new java.util.ArrayList (); 71 72 75 public CustomXYToolTipGenerator() { 76 super(); 77 } 78 79 84 public int getListCount() { 85 return this.toolTipSeries.size(); 86 } 87 88 95 public int getToolTipCount(int list) { 96 97 int result = 0; 98 List tooltips = (List ) this.toolTipSeries.get(list); 99 if (tooltips != null) { 100 result = tooltips.size(); 101 } 102 return result; 103 } 104 105 113 public String getToolTipText(int series, int item) { 114 115 String result = null; 116 117 if (series < getListCount()) { 118 List tooltips = (List ) this.toolTipSeries.get(series); 119 if (tooltips != null) { 120 if (item < tooltips.size()) { 121 result = (String ) tooltips.get(item); 122 } 123 } 124 } 125 126 return result; 127 } 128 129 134 public void addToolTipSeries(List toolTips) { 135 this.toolTipSeries.add(toolTips); 136 } 137 138 147 public String generateToolTip(XYDataset data, int series, int item) { 148 149 return getToolTipText(series, item); 150 151 } 152 153 160 public Object clone() throws CloneNotSupportedException { 161 162 CustomXYToolTipGenerator clone 163 = (CustomXYToolTipGenerator) super.clone(); 164 if (this.toolTipSeries != null) { 165 clone.toolTipSeries = new java.util.ArrayList (this.toolTipSeries); 166 } 167 return clone; 168 169 } 170 177 public boolean equals(Object obj) { 178 179 if (obj == this) { 180 return true; 181 } 182 183 if (obj instanceof CustomXYToolTipGenerator) { 184 CustomXYToolTipGenerator generator = (CustomXYToolTipGenerator) obj; 185 boolean result = true; 186 for (int series = 0; series < getListCount(); series++) { 187 for (int item = 0; item < getToolTipCount(series); item++) { 188 String t1 = getToolTipText(series, item); 189 String t2 = generator.getToolTipText(series, item); 190 if (t1 != null) { 191 result = result && t1.equals(t2); 192 } 193 else { 194 result = result && (t2 == null); 195 } 196 } 197 } 198 return result; 199 } 200 201 return false; 202 203 } 204 205 } 206 | Popular Tags |