1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ihm;
import java.text.DateFormat;
import java.text.NumberFormat;
import org.jfree.chart.labels.AbstractXYItemLabelGenerator;
import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.data.xy.XYDataset;
import org.jfree.util.PublicCloneable;
/**
*
* @author sabine
*/
public class MyXYToolTipGenerator extends AbstractXYItemLabelGenerator
implements XYToolTipGenerator, Cloneable, PublicCloneable {
/** For serialization. */
private static final long serialVersionUID = -3564164459039540785L;
/** The default tooltip format. */
static final String gen = "{0}";
static final String date = "{1}";
static final String activite = "{2}";
static final String Newligne = System.getProperty("line.separator");
static final String resultat = gen + Newligne + date + Newligne + activite;
public static final String DEFAULT_TOOL_TIP_FORMAT = resultat;
/**
* Returns a tool tip generator that formats the x-values as dates and the
* y-values as numbers.
*
* @return A tool tip generator (never <code>null</code>).
*/
public static MyXYToolTipGenerator getTimeSeriesInstance() {
return new MyXYToolTipGenerator(DEFAULT_TOOL_TIP_FORMAT,
DateFormat.getInstance(), NumberFormat.getInstance());
}
/**
* Creates a tool tip generator using default number formatters.
*/
public MyXYToolTipGenerator() {
this(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getNumberInstance(),
NumberFormat.getNumberInstance());
}
/**
* Creates a tool tip generator using the specified number formatters.
*
* @param formatString the item label format string (<code>null</code> not
* permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
*/
public MyXYToolTipGenerator(String formatString,
NumberFormat xFormat, NumberFormat yFormat) {
super(formatString, xFormat, yFormat);
}
/**
* Creates a tool tip generator using the specified number formatters.
*
* @param formatString the label format string (<code>null</code> not
* permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
*/
public MyXYToolTipGenerator(String formatString, DateFormat xFormat,
NumberFormat yFormat) {
super(formatString, xFormat, yFormat);
}
/**
* Creates a tool tip generator using the specified formatters (a
* number formatter for the x-values and a date formatter for the
* y-values).
*
* @param formatString the item label format string (<code>null</code>
* not permitted).
* @param xFormat the format object for the x values (<code>null</code>
* permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
*
* @since 1.0.4
*/
public MyXYToolTipGenerator(String formatString,
NumberFormat xFormat, DateFormat yFormat) {
super(formatString, xFormat, yFormat);
}
/**
* Creates a tool tip generator using the specified date formatters.
*
* @param formatString the label format string (<code>null</code> not
* permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
*/
public MyXYToolTipGenerator(String formatString,
DateFormat xFormat, DateFormat yFormat) {
super(formatString, xFormat, yFormat);
}
/**
* Generates the tool tip text for an item in a dataset.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param series the series index (zero-based).
* @param item the item index (zero-based).
*
* @return The tooltip text (possibly <code>null</code>).
*/
public String generateToolTip(XYDataset dataset, int series, int item) {
return generateLabelString(dataset, series, item);
}
/**
* Tests this object for equality with an arbitrary object.
*
* @param obj the other object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof MyXYToolTipGenerator)) {
return false;
}
return super.equals(obj);
}
/**
* Returns an independent copy of the generator.
*
* @return A clone.
*
* @throws CloneNotSupportedException if cloning is not supported.
*/
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
} |
Partager