001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2022, 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-2022, 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<S extends Comparable<S>> 045 extends AbstractXYDataset<S> 046 implements IntervalXYDataset<S> { 047 048 /** 049 * Returns the start x-value (as a double primitive) for an item within a 050 * series. 051 * 052 * @param series the series index (zero-based). 053 * @param item the item index (zero-based). 054 * 055 * @return The value. 056 */ 057 @Override 058 public double getStartXValue(int series, int item) { 059 double result = Double.NaN; 060 Number x = getStartX(series, item); 061 if (x != null) { 062 result = x.doubleValue(); 063 } 064 return result; 065 } 066 067 /** 068 * Returns the end x-value (as a double primitive) for an item within a 069 * series. 070 * 071 * @param series the series index (zero-based). 072 * @param item the item index (zero-based). 073 * 074 * @return The value. 075 */ 076 @Override 077 public double getEndXValue(int series, int item) { 078 double result = Double.NaN; 079 Number x = getEndX(series, item); 080 if (x != null) { 081 result = x.doubleValue(); 082 } 083 return result; 084 } 085 086 /** 087 * Returns the start y-value (as a double primitive) for an item within a 088 * series. 089 * 090 * @param series the series index (zero-based). 091 * @param item the item index (zero-based). 092 * 093 * @return The value. 094 */ 095 @Override 096 public double getStartYValue(int series, int item) { 097 double result = Double.NaN; 098 Number y = getStartY(series, item); 099 if (y != null) { 100 result = y.doubleValue(); 101 } 102 return result; 103 } 104 105 /** 106 * Returns the end y-value (as a double primitive) for an item within a 107 * series. 108 * 109 * @param series the series (zero-based index). 110 * @param item the item (zero-based index). 111 * 112 * @return The value. 113 */ 114 @Override 115 public double getEndYValue(int series, int item) { 116 double result = Double.NaN; 117 Number y = getEndY(series, item); 118 if (y != null) { 119 result = y.doubleValue(); 120 } 121 return result; 122 } 123 124}