001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2007, by Object Refinery Limited 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: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * -------------------
028: * VectorDataItem.java
029: * -------------------
030: * (C) Copyright 2007, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: VectorDataItem.java,v 1.1.2.1 2007/05/25 14:44:38 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 30-Jan-2007 : Version 1 (DG);
040: * 24-May-2007 : Added getVector(), renamed getDeltaX() --> getVectorX(),
041: * and likewise for getDeltaY() (DG);
042: * 25-May-2007 : Moved from experimental to the main source tree (DG);
043: *
044: */
045:
046: package org.jfree.data.xy;
047:
048: import org.jfree.data.ComparableObjectItem;
049:
050: /**
051: * A data item representing data in the form (x, y, deltaX, deltaY), intended
052: * for use by the {@link VectorSeries} class.
053: *
054: * @since 1.0.6
055: */
056: public class VectorDataItem extends ComparableObjectItem {
057:
058: /**
059: * Creates a new instance of <code>YIntervalItem</code>.
060: *
061: * @param x the x-value.
062: * @param y the y-value.
063: * @param deltaX the vector x.
064: * @param deltaY the vector y.
065: */
066: public VectorDataItem(double x, double y, double deltaX,
067: double deltaY) {
068: super (new XYCoordinate(x, y), new Vector(deltaX, deltaY));
069: }
070:
071: /**
072: * Returns the x-value.
073: *
074: * @return The x-value (never <code>null</code>).
075: */
076: public double getXValue() {
077: XYCoordinate xy = (XYCoordinate) getComparable();
078: return xy.getX();
079: }
080:
081: /**
082: * Returns the y-value.
083: *
084: * @return The y-value.
085: */
086: public double getYValue() {
087: XYCoordinate xy = (XYCoordinate) getComparable();
088: return xy.getY();
089: }
090:
091: /**
092: * Returns the vector.
093: *
094: * @return The vector (possibly <code>null</code>).
095: */
096: public Vector getVector() {
097: return (Vector) getObject();
098: }
099:
100: /**
101: * Returns the x-component for the vector.
102: *
103: * @return The x-component.
104: */
105: public double getVectorX() {
106: Vector vi = (Vector) getObject();
107: if (vi != null) {
108: return vi.getX();
109: } else {
110: return Double.NaN;
111: }
112: }
113:
114: /**
115: * Returns the y-component for the vector.
116: *
117: * @return The y-component.
118: */
119: public double getVectorY() {
120: Vector vi = (Vector) getObject();
121: if (vi != null) {
122: return vi.getY();
123: } else {
124: return Double.NaN;
125: }
126: }
127:
128: }
|