001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2006, 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: * OHLCItem.java
029: * -------------
030: * (C) Copyright 2006, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: OHLCItem.java,v 1.1.2.1 2006/12/04 17:08:36 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 04-Dec-2006 : Version 1 (DG);
040: *
041: */
042:
043: package org.jfree.data.time.ohlc;
044:
045: import org.jfree.data.ComparableObjectItem;
046: import org.jfree.data.time.RegularTimePeriod;
047:
048: /**
049: * An item representing data in the form (period, open, high, low, close).
050: *
051: * @since 1.0.4
052: */
053: public class OHLCItem extends ComparableObjectItem {
054:
055: /**
056: * Creates a new instance of <code>OHLCItem</code>.
057: *
058: * @param period the time period.
059: * @param open the open-value.
060: * @param high the high-value.
061: * @param low the low-value.
062: * @param close the close-value.
063: */
064: public OHLCItem(RegularTimePeriod period, double open, double high,
065: double low, double close) {
066: super (period, new OHLC(open, high, low, close));
067: }
068:
069: /**
070: * Returns the period.
071: *
072: * @return The period (never <code>null</code>).
073: */
074: public RegularTimePeriod getPeriod() {
075: return (RegularTimePeriod) getComparable();
076: }
077:
078: /**
079: * Returns the y-value.
080: *
081: * @return The y-value.
082: */
083: public double getYValue() {
084: return getCloseValue();
085: }
086:
087: /**
088: * Returns the open value.
089: *
090: * @return The open value.
091: */
092: public double getOpenValue() {
093: OHLC ohlc = (OHLC) getObject();
094: if (ohlc != null) {
095: return ohlc.getOpen();
096: } else {
097: return Double.NaN;
098: }
099: }
100:
101: /**
102: * Returns the high value.
103: *
104: * @return The high value.
105: */
106: public double getHighValue() {
107: OHLC ohlc = (OHLC) getObject();
108: if (ohlc != null) {
109: return ohlc.getHigh();
110: } else {
111: return Double.NaN;
112: }
113: }
114:
115: /**
116: * Returns the low value.
117: *
118: * @return The low value.
119: */
120: public double getLowValue() {
121: OHLC ohlc = (OHLC) getObject();
122: if (ohlc != null) {
123: return ohlc.getLow();
124: } else {
125: return Double.NaN;
126: }
127: }
128:
129: /**
130: * Returns the close value.
131: *
132: * @return The close value.
133: */
134: public double getCloseValue() {
135: OHLC ohlc = (OHLC) getObject();
136: if (ohlc != null) {
137: return ohlc.getClose();
138: } else {
139: return Double.NaN;
140: }
141: }
142:
143: }
|