Java Code Examples for org.jfree.data.general.DatasetUtilities#findDomainBounds()

The following examples show how to use org.jfree.data.general.DatasetUtilities#findDomainBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param includeInterval  include the interval (if any) for the dataset?
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @since 1.0.13
 */
protected Range findDomainBounds(XYDataset dataset,
        boolean includeInterval) {
    if (dataset == null) {
        return null;
    }
    if (getDataBoundsIncludesVisibleSeriesOnly()) {
        List visibleSeriesKeys = new ArrayList();
        int seriesCount = dataset.getSeriesCount();
        for (int s = 0; s < seriesCount; s++) {
            if (isSeriesVisible(s)) {
                visibleSeriesKeys.add(dataset.getSeriesKey(s));
            }
        }
        return DatasetUtilities.findDomainBounds(dataset,
                visibleSeriesKeys, includeInterval);
    }
    return DatasetUtilities.findDomainBounds(dataset, includeInterval);
}
 
Example 2
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This test checks that NaN values are ignored.
 */
public void testFindDomainBounds_NaN() {
    DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset();
    double[] x1 = new double[] {1.0, 2.0, Double.NaN};
    double[] x1Start = new double[] {0.9, 1.9, Double.NaN};
    double[] x1End = new double[] {1.1, 2.1, Double.NaN};
    double[] y1 = new double[] {4.0, 5.0, 6.0};
    double[] y1Start = new double[] {1.09, 2.09, 3.09};
    double[] y1End = new double[] {1.11, 2.11, 3.11};
    double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start,
            y1End};
    dataset.addSeries("S1", data1);
    Range r = DatasetUtilities.findDomainBounds(dataset);
    assertEquals(0.9, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findDomainBounds(dataset, false);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example 3
Source File: AbstractXYItemRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param includeInterval  include the interval (if any) for the dataset?
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @since 1.0.13
 */
protected Range findDomainBounds(XYDataset dataset,
        boolean includeInterval) {
    if (dataset == null) {
        return null;
    }
    if (getDataBoundsIncludesVisibleSeriesOnly()) {
        List visibleSeriesKeys = new ArrayList();
        int seriesCount = dataset.getSeriesCount();
        for (int s = 0; s < seriesCount; s++) {
            if (isSeriesVisible(s)) {
                visibleSeriesKeys.add(dataset.getSeriesKey(s));
            }
        }
        return DatasetUtilities.findDomainBounds(dataset,
                visibleSeriesKeys, includeInterval);
    }
    return DatasetUtilities.findDomainBounds(dataset, includeInterval);
}
 
Example 4
Source File: ContourPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the range for an axis.
 *
 * @param axis  the axis.
 *
 * @return The range for an axis.
 */
@Override
public Range getDataRange(ValueAxis axis) {

    if (this.dataset == null) {
        return null;
    }

    Range result = null;

    if (axis == getDomainAxis()) {
        result = DatasetUtilities.findDomainBounds(this.dataset);
    }
    else if (axis == getRangeAxis()) {
        result = DatasetUtilities.findRangeBounds(this.dataset);
    }
    return result;
}
 
Example 5
Source File: ContourPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the range for an axis.
 *
 * @param axis  the axis.
 *
 * @return The range for an axis.
 */
@Override
public Range getDataRange(ValueAxis axis) {

    if (this.dataset == null) {
        return null;
    }

    Range result = null;

    if (axis == getDomainAxis()) {
        result = DatasetUtilities.findDomainBounds(this.dataset);
    }
    else if (axis == getRangeAxis()) {
        result = DatasetUtilities.findRangeBounds(this.dataset);
    }
    return result;
}
 
Example 6
Source File: XYBlockRenderer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        Range r = DatasetUtilities.findDomainBounds(dataset, false);
        if (r == null) {
            return null;
        }
        else {
            return new Range(r.getLowerBound() + this.xOffset,
                    r.getUpperBound() + this.blockWidth + this.xOffset);
        }
    }
    else {
        return null;
    }
}
 
Example 7
Source File: AbstractXYItemRenderer.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param includeInterval  include the interval (if any) for the dataset?
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @since 1.0.13
 */
protected Range findDomainBounds(XYDataset dataset,
        boolean includeInterval) {
    if (dataset == null) {
        return null;
    }
    if (getDataBoundsIncludesVisibleSeriesOnly()) {
        List visibleSeriesKeys = new ArrayList();
        int seriesCount = dataset.getSeriesCount();
        for (int s = 0; s < seriesCount; s++) {
            if (isSeriesVisible(s)) {
                visibleSeriesKeys.add(dataset.getSeriesKey(s));
            }
        }
        return DatasetUtilities.findDomainBounds(dataset,
                visibleSeriesKeys, includeInterval);
    }
    return DatasetUtilities.findDomainBounds(dataset, includeInterval);
}
 
Example 8
Source File: TimeSeriesCollectionTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * This method provides a check for the bounds calculated using the
 * {@link DatasetUtilities#findDomainBounds(org.jfree.data.xy.XYDataset,
 * java.util.List, boolean)} method.
 */
@Test
public void testFindDomainBounds() {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    List visibleSeriesKeys = new java.util.ArrayList();
    Range r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys,
            true);
    assertNull(r);

    TimeSeries s1 = new TimeSeries("S1");
    dataset.addSeries(s1);
    visibleSeriesKeys.add("S1");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertNull(r);

    // store the current time zone
    TimeZone saved = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));

    s1.add(new Year(2008), 8.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    TimeSeries s2 = new TimeSeries("S2");
    dataset.addSeries(s2);
    s2.add(new Year(2009), 9.0);
    s2.add(new Year(2010), 10.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    visibleSeriesKeys.add("S2");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1293836399999.0, r.getUpperBound(), EPSILON);

    // restore the default time zone
    TimeZone.setDefault(saved);
}
 
Example 9
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the findDomainBounds() method.
 */
public void testFindDomainBounds() {
    XYDataset dataset = createXYDataset1();
    Range r = DatasetUtilities.findDomainBounds(dataset);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(3.0, r.getUpperBound(), EPSILON);
}
 
Example 10
Source File: XYShapeRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2;
    return new Range(r.getLowerBound() + offset,
                     r.getUpperBound() + offset);
}
 
Example 11
Source File: XYBlockRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    return new Range(r.getLowerBound() + this.xOffset,
                     r.getUpperBound() + this.blockWidth + this.xOffset);
}
 
Example 12
Source File: XYShapeRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2;
    return new Range(r.getLowerBound() + offset,
                     r.getUpperBound() + offset);
}
 
Example 13
Source File: XYBlockRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    return new Range(r.getLowerBound() + this.xOffset,
                     r.getUpperBound() + this.blockWidth + this.xOffset);
}
 
Example 14
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the findDomainBounds() method.
 */
public void testFindDomainBounds() {
    XYDataset dataset = createXYDataset1();
    Range r = DatasetUtilities.findDomainBounds(dataset);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(3.0, r.getUpperBound(), EPSILON);
}
 
Example 15
Source File: XYBlockRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    return new Range(r.getLowerBound() + this.xOffset,
                     r.getUpperBound() + this.blockWidth + this.xOffset);
}
 
Example 16
Source File: XYShapeRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    Range r = DatasetUtilities.findDomainBounds(dataset, false);
    if (r == null) {
        return null;
    }
    double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2;
    return new Range(r.getLowerBound() + offset,
                     r.getUpperBound() + offset);
}
 
Example 17
Source File: XYErrorRenderer.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the range required by this renderer to display all the domain
 * values in the specified dataset.
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range, or <code>null</code> if the dataset is 
 *     <code>null</code>.
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findDomainBounds(dataset, true);
    }
    else {
        return null;
    }
}
 
Example 18
Source File: XYBarRenderer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the 
 * specified dataset.  Since this renderer uses the x-interval in the 
 * dataset, this is taken into account for the range.
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is 
 *         <code>null</code> or empty).
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findDomainBounds(dataset, true);
    }
    else {
        return null;
    }
}
 
Example 19
Source File: XYBarRenderer.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the 
 * specified dataset.  Since this renderer uses the x-interval in the 
 * dataset, this is taken into account for the range.
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is 
 *         <code>null</code> or empty).
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findDomainBounds(dataset, true);
    }
    else {
        return null;
    }
}
 
Example 20
Source File: XYErrorRenderer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the range required by this renderer to display all the domain
 * values in the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range, or <code>null</code> if the dataset is
 *     <code>null</code>.
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findDomainBounds(dataset, true);
    }
    else {
        return null;
    }
}