001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-present, by David Gilbert and Contributors.
006 *
007 * Project Info:  http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it
010 * under the terms of the GNU Lesser General Public License as published by
011 * the Free Software Foundation; either version 2.1 of the License, or
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
022 * USA.
023 *
024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
025 * Other names may be trademarks of their respective owners.]
026 *
027 * ------------------------------
028 * AbstractIntervalXYDataset.java
029 * ------------------------------
030 * (C) Copyright 2004-present, by David Gilbert.
031 *
032 * Original Author:  David Gilbert.
033 * Contributor(s):   -;
034 *
035 */
036
037package org.jfree.data.xy;
038
039
040/**
041 * An base class that you can use to create new implementations of the
042 * {@link IntervalXYDataset} interface.
043 */
044public abstract class AbstractIntervalXYDataset extends AbstractXYDataset
045        implements IntervalXYDataset {
046
047    /**
048     * Returns the start x-value (as a double primitive) for an item within a
049     * series.
050     *
051     * @param series  the series index (zero-based).
052     * @param item  the item index (zero-based).
053     *
054     * @return The value.
055     */
056    @Override
057    public double getStartXValue(int series, int item) {
058        double result = Double.NaN;
059        Number x = getStartX(series, item);
060        if (x != null) {
061            result = x.doubleValue();
062        }
063        return result;
064    }
065
066    /**
067     * Returns the end x-value (as a double primitive) for an item within a
068     * series.
069     *
070     * @param series  the series index (zero-based).
071     * @param item  the item index (zero-based).
072     *
073     * @return The value.
074     */
075    @Override
076    public double getEndXValue(int series, int item) {
077        double result = Double.NaN;
078        Number x = getEndX(series, item);
079        if (x != null) {
080            result = x.doubleValue();
081        }
082        return result;
083    }
084
085    /**
086     * Returns the start y-value (as a double primitive) for an item within a
087     * series.
088     *
089     * @param series  the series index (zero-based).
090     * @param item  the item index (zero-based).
091     *
092     * @return The value.
093     */
094    @Override
095    public double getStartYValue(int series, int item) {
096        double result = Double.NaN;
097        Number y = getStartY(series, item);
098        if (y != null) {
099            result = y.doubleValue();
100        }
101        return result;
102    }
103
104    /**
105     * Returns the end y-value (as a double primitive) for an item within a
106     * series.
107     *
108     * @param series  the series (zero-based index).
109     * @param item  the item (zero-based index).
110     *
111     * @return The value.
112     */
113    @Override
114    public double getEndYValue(int series, int item) {
115        double result = Double.NaN;
116        Number y = getEndY(series, item);
117        if (y != null) {
118            result = y.doubleValue();
119        }
120        return result;
121    }
122
123}