1 42 43 package org.jfree.chart.labels; 44 45 import java.io.Serializable ; 46 import java.text.MessageFormat ; 47 import java.text.NumberFormat ; 48 49 import org.jfree.data.category.CategoryDataset; 50 import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; 51 import org.jfree.util.PublicCloneable; 52 53 71 public class BoxAndWhiskerToolTipGenerator 72 extends StandardCategoryToolTipGenerator 73 implements CategoryToolTipGenerator, Cloneable , PublicCloneable, 74 Serializable { 75 76 77 private static final long serialVersionUID = -6076837753823076334L; 78 79 80 public static final String DEFAULT_TOOL_TIP_FORMAT 81 = "X: {1} Mean: {2} Median: {3} Min: {4} Max: {5} Q1: {6} Q3: {7} "; 82 83 86 public BoxAndWhiskerToolTipGenerator() { 87 super(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getInstance()); 88 } 89 90 96 public BoxAndWhiskerToolTipGenerator(String format, 97 NumberFormat formatter) { 98 super(format, formatter); 99 } 100 101 111 protected Object [] createItemArray(CategoryDataset dataset, int series, 112 int item) { 113 Object [] result = new Object [8]; 114 result[0] = dataset.getRowKey(series); 115 Number y = dataset.getValue(series, item); 116 NumberFormat formatter = getNumberFormat(); 117 result[1] = formatter.format(y); 118 if (dataset instanceof BoxAndWhiskerCategoryDataset) { 119 BoxAndWhiskerCategoryDataset d 120 = (BoxAndWhiskerCategoryDataset) dataset; 121 result[2] = formatter.format(d.getMeanValue(series, item)); 122 result[3] = formatter.format(d.getMedianValue(series, item)); 123 result[4] = formatter.format(d.getMinRegularValue(series, item)); 124 result[5] = formatter.format(d.getMaxRegularValue(series, item)); 125 result[6] = formatter.format(d.getQ1Value(series, item)); 126 result[7] = formatter.format(d.getQ3Value(series, item)); 127 } 128 return result; 129 } 130 131 138 public boolean equals(Object obj) { 139 if (obj == this) { 140 return true; 141 } 142 if (obj instanceof BoxAndWhiskerToolTipGenerator) { 143 return super.equals(obj); 144 } 145 return false; 146 } 147 148 } 149 | Popular Tags |