Search in sources :

Example 6 with ISeries

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);
    }
}
Also used : ISeries(org.swtchart.ISeries) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point)

Aggregations

ISeries (org.swtchart.ISeries)6 Date (java.util.Date)4 Point (org.eclipse.swt.graphics.Point)3 Shell (org.eclipse.swt.widgets.Shell)2 IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)2 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseTrackAdapter (org.eclipse.swt.events.MouseTrackAdapter)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1 Region (org.eclipse.swt.graphics.Region)1 ISeriesSet (org.swtchart.ISeriesSet)1 Range (org.swtchart.Range)1 AxisUnit (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)1