Example usage for org.jfree.data.time.ohlc OHLCSeriesCollection getYValue

List of usage examples for org.jfree.data.time.ohlc OHLCSeriesCollection getYValue

Introduction

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

Prototype

@Override
public double getYValue(int series, int item) 

Source Link

Document

Returns the y-value (as a double primitive) for an item within a series.

Usage

From source file:com.ceabie.CandlestickToolTipGenerator.java

@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    if (dataset instanceof OHLCSeriesCollection) {
        OHLCSeriesCollection d = (OHLCSeriesCollection) dataset;

        double x = dataset.getXValue(series, item);
        DateFormat xDateFormat = getXDateFormat();
        if (xDateFormat != null) {
            return MessageFormat.format(DEFAULT_TOOL_TIP_FORMAT, xDateFormat.format(new Date((long) x)),
                    d.getOpenValue(series, item), d.getCloseValue(series, item), d.getHighValue(series, item),
                    d.getLowValue(series, item));
        }/*from w w  w  .  j a  v a  2s  .  co  m*/
    } else if (dataset instanceof TimeSeriesCollection) {
        TimeSeriesCollection d = (TimeSeriesCollection) dataset;
        double x = dataset.getXValue(series, item);
        DateFormat xDateFormat = getXDateFormat();
        if (xDateFormat != null) {
            return MessageFormat.format(DEFAULT_SINGLE_TOOL_TIP_FORMAT, xDateFormat.format(new Date((long) x)),
                    d.getYValue(series, item));
        }
    }

    return generateLabelString(dataset, series, item);
}