net.maizegenetics.analysis.chart.XYAndLineToolTipGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tassel Show documentation
Show all versions of tassel Show documentation
TASSEL is a software package to evaluate traits associations, evolutionary patterns, and linkage
disequilibrium.
The newest version!
/*
* XYAndLineToolTipGenerator
*/
package net.maizegenetics.analysis.chart;
import java.text.DecimalFormat;
import java.util.Map;
import org.jfree.chart.labels.AbstractXYItemLabelGenerator;
import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.data.xy.XYDataset;
/**
*
* @author yz79
*/
public class XYAndLineToolTipGenerator extends AbstractXYItemLabelGenerator implements XYToolTipGenerator {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
TableReportQQDataset myDataset = (TableReportQQDataset) dataset;
int[] positions = myDataset.getPositions();
String[] markers = myDataset.getMarkers();
Map myTable = myDataset.getLookupTable();
int index = (Integer) myTable.get(myDataset.getYValue(series, item));
DecimalFormat df = new DecimalFormat("#0.000");
StringBuilder sb = new StringBuilder("SNP ID: ");
sb.append(markers[index]);
sb.append(", -Log10(P-Value): ");
sb.append(df.format(myDataset.getYValue(series, item)));
sb.append(", Expected: ");
sb.append(df.format(myDataset.getXValue(series, item)));
sb.append(", Position: ");
sb.append(positions[index]);
return sb.toString();
}
}