Example usage for org.jfree.data.xy OHLCDataset getClose

List of usage examples for org.jfree.data.xy OHLCDataset getClose

Introduction

In this page you can find the example usage for org.jfree.data.xy OHLCDataset getClose.

Prototype

public Number getClose(int series, int item);

Source Link

Document

Returns the y-value for the specified series and item.

Usage

From source file:jgnash.ui.commodity.SecurityItemLabelGenerator.java

/**
 * Generates a tooltip text item for a particular item within a series.
 *
 * @param dataset  the dataset./*from ww w  . j av  a  2  s  .  co m*/
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The tooltip text.
 */
@Override
public String generateToolTip(final XYDataset dataset, final int series, final int item) {

    String result = null;

    if (dataset instanceof OHLCDataset) {
        OHLCDataset d = (OHLCDataset) dataset;

        Number close = d.getClose(series, item);

        Number x = d.getX(series, item);

        if (x != null) {
            Date date = new Date(x.longValue());
            result = dateLabel + " " + dateFormatter.format(date);

            if (close != null) {
                result = result + " " + closeLabel + "  " + numberFormatter.format(close.doubleValue());
            }
        }
    }

    return result;
}