use of org.swtchart.ISeries in project tdi-studio-se by Talend.
the class Marker method configureHovers.
/**
* Creates the hovers assuming that the time is almost the same among series
*
* @param invertedSeriesIndex The inverted series index
*/
private void configureHovers(Integer invertedSeriesIndex) {
ISeries largestSeries = getLargestSeries();
if (largestSeries == null) {
return;
}
// create hover for time
Date[] dates = largestSeries.getXDateSeries();
long time = dates[dates.length - invertedSeriesIndex].getTime();
StringBuffer buffer = new StringBuffer();
buffer.append(//$NON-NLS-1$
new SimpleDateFormat("hh:mm:ss a").format(time));
texts.put(TIME_KEY, buffer.toString());
int timeInPixel = chart.getAxisSet().getXAxes()[0].getPixelCoordinate(time);
configureHover(hovers.get(TIME_KEY), buffer.toString(), timeInPixel, chart.getPlotArea().getSize().y, true);
// create hover for values
for (ISeries series : chart.getSeriesSet().getSeries()) {
double[] ySeries = series.getYSeries();
int seriesIndex = ySeries.length - invertedSeriesIndex;
if (seriesIndex < 0) {
continue;
}
String newText = redefineHoverText(series.getId());
buffer = new StringBuffer();
buffer.append(newText).append(": ").append(getFormattedValue(ySeries[seriesIndex]));
texts.put(series.getId(), buffer.toString());
int valueInPixel = chart.getAxisSet().getYAxes()[0].getPixelCoordinate(ySeries[seriesIndex]);
configureHover(hovers.get(series.getId()), buffer.toString(), timeInPixel, valueInPixel, false);
}
}
Aggregations