Search in sources :

Example 66 with ISeries

use of org.swtchart.ISeries in project jbosstools-server by jbosstools.

the class TimelineChart method deleteMonitoredSeries.

/**
 * Delete series if not monitored any longer.
 */
private void deleteMonitoredSeries() {
    ISeriesSet seriesSet = getSeriesSet();
    List<IMonitoredMXBeanAttribute> attributes = attributeGroup.getAttributes();
    for (ISeries series : seriesSet.getSeries()) {
        String seriesId = series.getId();
        boolean found = false;
        for (IMonitoredMXBeanAttribute attribute : attributes) {
            if (series.getId().equals(getSeriesId(attribute))) {
                found = true;
            }
        }
        if (!found) {
            seriesSet.deleteSeries(seriesId);
        }
    }
}
Also used : ISeriesSet(org.swtchart.ISeriesSet) IMonitoredMXBeanAttribute(org.jboss.tools.jmx.jvmmonitor.core.mbean.IMonitoredMXBeanAttribute) ISeries(org.swtchart.ISeries)

Example 67 with ISeries

use of org.swtchart.ISeries in project jbosstools-server by jbosstools.

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(Messages.timeLabel).append(' ').append(// $NON-NLS-1$
    new SimpleDateFormat("HH:mm:ss").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;
        }
        buffer = new StringBuffer();
        // $NON-NLS-1$
        buffer.append(series.getId()).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)

Example 68 with ISeries

use of org.swtchart.ISeries in project jbosstools-server by jbosstools.

the class Marker method getInvertedSeriesIndex.

/**
 * Gets the inverted series index that is the nearest to mouse position.
 *
 * @param desiredX
 *            The desired x pixel coordinate
 * @return The inverted series index, or <tt>null</tt> if not found
 */
private Integer getInvertedSeriesIndex(int desiredX) {
    long desiredTime = (long) chart.getAxisSet().getAxes()[0].getDataCoordinate(desiredX);
    // find largest size of series
    ISeries largestSeries = getLargestSeries();
    if (largestSeries == null) {
        return null;
    }
    // find the time series index
    Date[] dates = largestSeries.getXDateSeries();
    for (int i = 0; i < dates.length; i++) {
        if (dates[i].getTime() < desiredTime && i != dates.length - 1) {
            continue;
        }
        int nearestIndex;
        if (i > 0 && dates[i].getTime() - desiredTime > desiredTime - dates[i - 1].getTime()) {
            nearestIndex = i - 1;
        } else {
            nearestIndex = i;
        }
        return dates.length - nearestIndex;
    }
    return null;
}
Also used : ISeries(org.swtchart.ISeries) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point)

Aggregations

ISeries (org.swtchart.ISeries)68 Point (org.eclipse.swt.graphics.Point)27 IAxis (org.swtchart.IAxis)17 Date (java.util.Date)15 ArrayList (java.util.ArrayList)11 Range (org.swtchart.Range)10 LocalDate (java.time.LocalDate)7 HashMap (java.util.HashMap)5 GC (org.eclipse.swt.graphics.GC)5 IBarSeries (org.swtchart.IBarSeries)5 ILineSeries (org.swtchart.ILineSeries)5 DecimalFormat (java.text.DecimalFormat)4 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 DataPoint (org.netxms.ui.eclipse.charts.api.DataPoint)4 Series (org.swtchart.internal.series.Series)4 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)3 Interval (name.abuchen.portfolio.util.Interval)3 Pair (name.abuchen.portfolio.util.Pair)3 Color (org.eclipse.swt.graphics.Color)3