Example usage for org.jfree.data.xy XYSeries getAutoSort

List of usage examples for org.jfree.data.xy XYSeries getAutoSort

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeries getAutoSort.

Prototype

public boolean getAutoSort() 

Source Link

Document

Returns the flag that controls whether the items in the series are automatically sorted.

Usage

From source file:edu.ucsf.valelab.saim.plot.PlotUtils.java

public static XYSeries normalize(XYSeries input) {
    double max = input.getMaxY();
    // double min = input.getMinY();
    XYSeries output = new XYSeries(input.getKey(), input.getAutoSort(), input.getAllowDuplicateXValues());
    for (int i = 0; i < input.getItemCount(); i++) {
        output.add(input.getX(i), (input.getY(i).doubleValue()) / (max));
    }/*from   w  w w  . java2 s  . co m*/
    return output;
}

From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java

public static Pair<String, XYSeriesCollection> adjustTime(XYSeriesCollection chartsCollection,
        Collection<IntervalMarker> markers) {
    int maxTime = 0;
    for (int i = 0; i < chartsCollection.getSeriesCount(); i++) {
        XYSeries series = chartsCollection.getSeries(i);
        for (int j = 0; j < series.getItemCount(); j++) {
            int x = series.getX(j).intValue();
            if (x > maxTime) {
                maxTime = x;//from w  w w . j av a2 s . co  m
            }
        }
    }

    String type = "ms";
    int div = 1;

    if (maxTime > 10 * 60 * 1000) {
        div = 60 * 1000;
        type = "min";
    }

    if (maxTime > 30 * 1000) {
        div = 1000;
        type = "sec";
    }

    XYSeriesCollection result = new XYSeriesCollection();

    for (int i = 0; i < chartsCollection.getSeriesCount(); i++) {

        XYSeries old = chartsCollection.getSeries(i);
        XYSeries series = new XYSeries(old.getKey(), old.getAutoSort(), old.getAllowDuplicateXValues());
        for (int j = 0; j < old.getItemCount(); j++) {
            Number x = old.getX(j).doubleValue() / div;
            Number y = old.getY(j);
            series.add(x, y);
        }

        result.addSeries(series);
    }

    if (markers != null) {
        for (IntervalMarker marker : markers) {
            marker.setStartValue(marker.getStartValue() / div);
            marker.setEndValue(marker.getEndValue() / div);
        }
    }

    return Pair.of(type, result);
}

From source file:org.jfree.data.xy.XYSeriesCollection.java

/**
 * Returns the order of the domain (X) values, if this is known.
 *
 * @return The domain order.//from  w w w  . ja v a 2  s . com
 */
@Override
public DomainOrder getDomainOrder() {
    int seriesCount = getSeriesCount();
    for (int i = 0; i < seriesCount; i++) {
        XYSeries s = getSeries(i);
        if (!s.getAutoSort()) {
            return DomainOrder.NONE; // we can't be sure of the order
        }
    }
    return DomainOrder.ASCENDING;
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java

/***********************************************************************************************
 * Dump the (partial) contents of each Series in an XYdatset.
 *
 * @param dump//from w ww.  j  av  a 2  s  .  co m
 * @param calendar
 * @param dataset
 * @param dumprowcount
 * @param title
 */

public static void dumpXYDataset(final boolean dump, final Calendar calendar, final XYDataset dataset,
        final int dumprowcount, final String title) {
    final String SOURCE = "ChartHelper.dumpXYDataset() ";

    if (dump) {
        LOGGER.log(title);

        if ((dataset != null) && (dataset instanceof XYSeriesCollection)) {
            final XYSeriesCollection seriesCollection;

            seriesCollection = (XYSeriesCollection) dataset;

            LOGGER.log("XYSeriesCollection");
            LOGGER.log("    [series.count=" + seriesCollection.getSeriesCount() + "]");
            LOGGER.log("    [domain.lowerbound.interval.true="
                    + (long) seriesCollection.getDomainLowerBound(true) + "]");
            LOGGER.log("    [domain.lowerbound.interval.false="
                    + (long) seriesCollection.getDomainLowerBound(false) + "]");
            LOGGER.log("    [domain.upperbound.interval.true="
                    + (long) seriesCollection.getDomainUpperBound(true) + "]");
            LOGGER.log("    [domain.upperbound.interval.false="
                    + (long) seriesCollection.getDomainUpperBound(false) + "]");
            LOGGER.log("    [domain.order=" + seriesCollection.getDomainOrder() + "]");

            for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) {
                final XYSeries xySeries;

                LOGGER.log("");
                LOGGER.log("    [xyseries.index=" + intSeriesIndex + "]");

                xySeries = seriesCollection.getSeries(intSeriesIndex);
                LOGGER.log("    [xyseries.itemcount=" + xySeries.getItemCount() + "]");
                LOGGER.log("    [xyseries.key=" + xySeries.getKey() + "]");
                LOGGER.log("    [xyseries.xmin=" + xySeries.getMinX() + "]");
                LOGGER.log("    [xyseries.xmax=" + xySeries.getMaxX() + "]");
                LOGGER.log("    [xyseries.ymin=" + xySeries.getMinY() + "]");
                LOGGER.log("    [xyseries.ymax=" + xySeries.getMaxY() + "]");
                LOGGER.log("    [xyseries.description=" + xySeries.getDescription() + "]");
                LOGGER.log("    [xyseries.autosort=" + xySeries.getAutoSort() + "]");
                LOGGER.log("    [xyseries.allowduplicatex=" + xySeries.getAllowDuplicateXValues() + "]");

                // Dump the first chunk
                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        xySeries.getItemCount())); intItemIndex++) {
                    final XYDataItem item;

                    item = xySeries.getDataItem(intItemIndex);

                    LOGGER.log("        [item.index=" + intItemIndex + "] [item.x=" + item.getXValue()
                            + "] [item.y=" + item.getYValue() + "]");
                }

                LOGGER.log("    ...");

                // Dump the last chunk
                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        xySeries.getItemCount())); intItemIndex++) {
                    final XYDataItem item;
                    final int intIndex;

                    intIndex = Math.max(0, xySeries.getItemCount() - dumprowcount) + intItemIndex;
                    item = xySeries.getDataItem(intIndex);

                    LOGGER.log("        [item.index=" + intIndex + "] [item.x=" + item.getXValue()
                            + "] [item.y=" + item.getYValue() + "]");
                }
            }
        } else if ((dataset != null) && (dataset instanceof TimeSeriesCollection)) {
            final TimeSeriesCollection seriesCollection;

            seriesCollection = (TimeSeriesCollection) dataset;

            LOGGER.log("TimeSeriesCollection");
            LOGGER.log("    [series.count=" + seriesCollection.getSeriesCount() + "]");
            LOGGER.log("    [domain.lowerbound.interval.true="
                    + (long) seriesCollection.getDomainLowerBound(true) + "]");
            LOGGER.log("    [domain.lowerbound.interval.false="
                    + (long) seriesCollection.getDomainLowerBound(false) + "]");
            LOGGER.log("    [domain.upperbound.interval.true="
                    + (long) seriesCollection.getDomainUpperBound(true) + "]");
            LOGGER.log("    [domain.upperbound.interval.false="
                    + (long) seriesCollection.getDomainUpperBound(false) + "]");
            LOGGER.log("    [domain.order=" + seriesCollection.getDomainOrder() + "]");

            for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) {
                final TimeSeries timeSeries;

                LOGGER.log("");
                LOGGER.log("    [timeseries.index=" + intSeriesIndex + "]");

                timeSeries = seriesCollection.getSeries(intSeriesIndex);
                LOGGER.log("    [timeseries.itemcount=" + timeSeries.getItemCount() + "]");
                LOGGER.log("    [timeseries.key=" + timeSeries.getKey() + "]");
                LOGGER.log("    [timeseries.ymin=" + timeSeries.getMinY() + "]");
                LOGGER.log("    [timeseries.ymax=" + timeSeries.getMaxY() + "]");
                LOGGER.log("    [timeseries.domain=" + timeSeries.getDomainDescription() + "]");
                LOGGER.log("    [timeseries.range=" + timeSeries.getRangeDescription() + "]");
                LOGGER.log(
                        "    [timeseries.timeperiodclass=" + timeSeries.getTimePeriodClass().getName() + "]");

                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        timeSeries.getItemCount())); intItemIndex++) {
                    final TimeSeriesDataItem item;

                    item = timeSeries.getDataItem(intItemIndex);

                    LOGGER.log("        [item.index=" + intItemIndex + "] [item.period.serialindex="
                            + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis="
                            + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value="
                            + item.getValue() + "]");
                }

                LOGGER.log("    ...");

                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        timeSeries.getItemCount())); intItemIndex++) {
                    final TimeSeriesDataItem item;
                    final int intIndex;

                    intIndex = Math.max(0, timeSeries.getItemCount() - dumprowcount) + intItemIndex;
                    item = timeSeries.getDataItem(intIndex);

                    LOGGER.log("        [item.index=" + intIndex + "] [item.period.serialindex="
                            + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis="
                            + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value="
                            + item.getValue() + "]");
                }
            }
        } else {
            LOGGER.error(SOURCE + "Unsupported XYDataset type");
        }
    }
}