1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
  6. *
  7. * Project Info: http://www.jfree.org/jfreechart/index.html
  8. *
  9. * This library is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  24. * in the United States and other countries.]
  25. *
  26. * ----------------------
  27. * AbstractXYDataset.java
  28. * ----------------------
  29. * (C) Copyright 2004, 2005, by Object Refinery Limited.
  30. *
  31. * Original Author: David Gilbert (for Object Refinery Limited).
  32. * Contributor(s): -;
  33. *
  34. * $Id: AbstractXYDataset.java,v 1.2 2005/01/28 14:10:03 mungady Exp $
  35. *
  36. * Changes
  37. * -------
  38. * 05-May-2004 : Version 1 (DG);
  39. * 15-Jul-2004 : Switched getX() with getXValue() and getY() with
  40. * getYValue() (DG);
  41. * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG);
  42. *
  43. */
  44. package org.jfree.data.xy;
  45. import org.jfree.data.DomainOrder;
  46. import org.jfree.data.general.AbstractSeriesDataset;
  47. /**
  48. * An base class that you can use to create new implementations of the
  49. * {@link XYDataset} interface.
  50. */
  51. public abstract class AbstractXYDataset extends AbstractSeriesDataset
  52. implements XYDataset {
  53. /**
  54. * Returns the order of the domain (X) values.
  55. *
  56. * @return The domain order.
  57. */
  58. public DomainOrder getDomainOrder() {
  59. return DomainOrder.NONE;
  60. }
  61. /**
  62. * Returns the x-value (as a double primitive) for an item within a series.
  63. *
  64. * @param series the series index (zero-based).
  65. * @param item the item index (zero-based).
  66. *
  67. * @return The value.
  68. */
  69. public double getXValue(int series, int item) {
  70. double result = Double.NaN;
  71. Number x = getX(series, item);
  72. if (x != null) {
  73. result = x.doubleValue();
  74. }
  75. return result;
  76. }
  77. /**
  78. * Returns the y-value (as a double primitive) for an item within a series.
  79. *
  80. * @param series the series index (zero-based).
  81. * @param item the item index (zero-based).
  82. *
  83. * @return The value.
  84. */
  85. public double getYValue(int series, int item) {
  86. double result = Double.NaN;
  87. Number y = getY(series, item);
  88. if (y != null) {
  89. result = y.doubleValue();
  90. }
  91. return result;
  92. }
  93. }