Example usage for org.jfree.data.xy XYSeriesCollection getDomainBounds

List of usage examples for org.jfree.data.xy XYSeriesCollection getDomainBounds

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection getDomainBounds.

Prototype

@Override
public Range getDomainBounds(boolean includeInterval) 

Source Link

Document

Returns the range of the values in this dataset's domain.

Usage

From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java

/**
 * Some checks for the getDomainBounds() method.
 */// w  w  w .  j a  v  a  2  s  .c  o m
public void testGetDomainBounds() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    Range r = dataset.getDomainBounds(false);
    assertNull(r);
    r = dataset.getDomainBounds(true);
    assertNull(r);

    XYSeries series = new XYSeries("S1");
    dataset.addSeries(series);
    r = dataset.getDomainBounds(false);
    assertNull(r);
    r = dataset.getDomainBounds(true);
    assertNull(r);

    series.add(1.0, 1.1);
    r = dataset.getDomainBounds(false);
    assertEquals(new Range(1.0, 1.0), r);
    r = dataset.getDomainBounds(true);
    assertEquals(new Range(0.5, 1.5), r);

    series.add(-1.0, -1.1);
    r = dataset.getDomainBounds(false);
    assertEquals(new Range(-1.0, 1.0), r);
    r = dataset.getDomainBounds(true);
    assertEquals(new Range(-1.5, 1.5), r);
}

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

/**
 * Some checks for the getDomainBounds() method.
 *//*w  w  w  . jav a2s  .  c  om*/
@Test
public void testGetDomainBounds() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    Range r = dataset.getDomainBounds(false);
    assertNull(r);
    r = dataset.getDomainBounds(true);
    assertNull(r);

    XYSeries series = new XYSeries("S1");
    dataset.addSeries(series);
    r = dataset.getDomainBounds(false);
    assertNull(r);
    r = dataset.getDomainBounds(true);
    assertNull(r);

    series.add(1.0, 1.1);
    r = dataset.getDomainBounds(false);
    assertEquals(new Range(1.0, 1.0), r);
    r = dataset.getDomainBounds(true);
    assertEquals(new Range(0.5, 1.5), r);

    series.add(-1.0, -1.1);
    r = dataset.getDomainBounds(false);
    assertEquals(new Range(-1.0, 1.0), r);
    r = dataset.getDomainBounds(true);
    assertEquals(new Range(-1.5, 1.5), r);
}

From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java

private Range getDomainRange(final XYSeriesCollection seriesCol) {
    if (this.boundingBox == null)
        return seriesCol.getDomainBounds(true);
    else//from w  w w  .j  a  v  a2  s.  c  o m
        return new Range(boundingBox.minX, boundingBox.maxX);
}

From source file:info.financialecology.finance.utilities.datastruct.VersatileChart.java

public JFreeChart drawTimeSeries(ArrayList<VersatileTimeSeries> atsArray) {
    JFreeChart chart;//from  www.j a v  a 2s. c  o  m
    ArrayList<String> visibleKeys = new ArrayList<String>();

    if (params.ticks) {
        XYSeriesCollection dataSet = new XYSeriesCollection();

        for (VersatileTimeSeries ats : atsArray) {
            XYSeries xySeries = new XYSeries(ats.getKey());
            dataSet.addSeries(xySeries);

            for (int i = 0; i < ats.getItemCount(); i++)
                xySeries.add(i, ats.getValue(i));
        }

        chart = ChartFactory.createXYLineChart(params.title, params.xLabel, params.yLabel, dataSet,
                PlotOrientation.VERTICAL, params.legend, params.toolTips, false);

        if (params.autoRange) {
            Range currentRange = dataSet.getRangeBounds(true);
            Range newRange = new Range((1 - params.autoRangePadding) * currentRange.getLowerBound(),
                    (1 + params.autoRangePadding) * currentRange.getUpperBound());
            chart.getXYPlot().getRangeAxis().setRange(newRange);
        }
    } else {
        TimeSeriesCollection dataSet = new TimeSeriesCollection();

        for (VersatileTimeSeries ats : atsArray) {
            dataSet.addSeries(ats);
            visibleKeys.add((String) ats.getKey());
        }

        chart = ChartFactory.createTimeSeriesChart(params.title, params.xLabel, params.yLabel, dataSet,
                params.legend, params.toolTips, false);

        if (params.autoRange) {
            Range currentRange = dataSet.getRangeBounds(visibleKeys, dataSet.getDomainBounds(true), true);
            Range newRange = new Range((1 - params.autoRangePadding) * currentRange.getLowerBound(),
                    (1 + params.autoRangePadding) * currentRange.getUpperBound());
            chart.getXYPlot().getRangeAxis().setRange(newRange);
        }
    }

    return chart;
}

From source file:info.financialecology.finance.utilities.datastruct.VersatileChart.java

public JFreeChart drawTimeSeriesCollections(ArrayList<VersatileTimeSeriesCollection> atscArray) {
    JFreeChart chart;// w w  w  . j a  va  2 s.c  o m
    ArrayList<String> visibleKeys = new ArrayList<String>();

    if (params.ticks) {
        XYSeriesCollection dataSet = new XYSeriesCollection();

        for (VersatileTimeSeriesCollection atsc : atscArray) {
            List<VersatileTimeSeries> atsList = atsc.getSeries();

            for (VersatileTimeSeries ats : atsList) {
                XYSeries xySeries = new XYSeries(ats.getKey());
                dataSet.addSeries(xySeries);

                for (int i = 0; i < ats.getItemCount(); i++)
                    xySeries.add(i, ats.getValue(i));
            }
        }

        chart = ChartFactory.createXYLineChart(params.title, params.xLabel, params.yLabel, dataSet,
                PlotOrientation.VERTICAL, params.legend, params.toolTips, false);

        if (params.autoRange) {
            Range currentRange = dataSet.getRangeBounds(true);
            Range newRange = new Range((1 - params.autoRangePadding) * currentRange.getLowerBound(),
                    (1 + params.autoRangePadding) * currentRange.getUpperBound());
            chart.getXYPlot().getRangeAxis().setRange(newRange);
        }
    } else {
        TimeSeriesCollection dataSet = new TimeSeriesCollection();

        for (VersatileTimeSeriesCollection atsc : atscArray) {
            List<VersatileTimeSeries> atsList = atsc.getSeries();

            for (VersatileTimeSeries ats : atsList) {
                dataSet.addSeries(ats);
                visibleKeys.add((String) ats.getKey());
            }
        }

        chart = ChartFactory.createTimeSeriesChart(params.title, params.xLabel, params.yLabel, dataSet,
                params.legend, params.toolTips, false);

        if (params.autoRange) {
            Range currentRange = dataSet.getRangeBounds(visibleKeys, dataSet.getDomainBounds(true), true);
            Range newRange = new Range((1 - params.autoRangePadding) * currentRange.getLowerBound(),
                    (1 + params.autoRangePadding) * currentRange.getUpperBound());
            chart.getXYPlot().getRangeAxis().setRange(newRange);
        }
    }

    return chart;
}