Example usage for org.jfree.data.time.ohlc OHLCItem getPeriod

List of usage examples for org.jfree.data.time.ohlc OHLCItem getPeriod

Introduction

In this page you can find the example usage for org.jfree.data.time.ohlc OHLCItem getPeriod.

Prototype

public RegularTimePeriod getPeriod() 

Source Link

Document

Returns the period.

Usage

From source file:org.jfree.data.time.ohlc.OHLCSeries.java

/**
 * Returns the time period for the specified item.
 *
 * @param index  the item index./*from www.  j  ava2s  . c o m*/
 *
 * @return The time period.
 */
public RegularTimePeriod getPeriod(int index) {
    OHLCItem item = (OHLCItem) getDataItem(index);
    return item.getPeriod();
}

From source file:org.jfree.data.time.ohlc.OHLCSeries.java

/**
 * Adds a data item to the series.  The values from the item passed to
 * this method will be copied into a new object.
 * //w  ww. j a  va2s.  c o m
 * @param item  the item (<code>null</code> not permitted).
 * 
 * @since 1.0.17
 */
public void add(OHLCItem item) {
    ParamChecks.nullNotPermitted(item, "item");
    add(item.getPeriod(), item.getOpenValue(), item.getHighValue(), item.getLowValue(), item.getCloseValue());
}

From source file:org.jfree.data.time.ohlc.OHLCSeries.java

/**
 * Adds a data item to the series.//from ww  w  .j a v a  2  s  .c o m
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high, double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException("Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}

From source file:org.jfree.data.time.ohlc.OHLCItemTest.java

/**
 * Some checks for the constructor./* ww  w  .  j  a v  a 2s. com*/
 */
@Test
public void testConstructor1() {
    OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0);
    assertEquals(new Year(2006), item1.getPeriod());
    assertEquals(2.0, item1.getOpenValue(), EPSILON);
    assertEquals(4.0, item1.getHighValue(), EPSILON);
    assertEquals(1.0, item1.getLowValue(), EPSILON);
    assertEquals(3.0, item1.getCloseValue(), EPSILON);
}

From source file:org.jfree.data.time.ohlc.OHLCSeriesCollection.java

/**
 * Returns the x-value for an item within a series.
 *
 * @param series  the series index.//from   w  w  w .  j  a  v  a2s. c  o m
 * @param item  the item index.
 *
 * @return The x-value.
 */
@Override
public double getXValue(int series, int item) {
    OHLCSeries s = (OHLCSeries) this.data.get(series);
    OHLCItem di = (OHLCItem) s.getDataItem(item);
    RegularTimePeriod period = di.getPeriod();
    return getX(period);
}