Example usage for org.jfree.data.time Day compareTo

List of usage examples for org.jfree.data.time Day compareTo

Introduction

In this page you can find the example usage for org.jfree.data.time Day compareTo.

Prototype

@Override
public int compareTo(Object o1) 

Source Link

Document

Returns an integer indicating the order of this Day object relative to the specified object: negative == before, zero == same, positive == after.

Usage

From source file:org.yccheok.jstock.gui.charting.ChartLayerUI.java

private int getDataIndex(TimeSeries timeSeries, Day targetDay) {
    int low = 0;/*from www.j ava  2  s  . c o m*/
    int high = timeSeries.getItemCount() - 1;

    while (low <= high) {
        int mid = (low + high) >>> 1;

        final TimeSeriesDataItem timeSeriesDataItem = timeSeries.getDataItem(mid);
        final Day searchDay = (Day) timeSeriesDataItem.getPeriod();
        final long cmp = searchDay.compareTo(targetDay);

        if (cmp < 0) {
            low = mid + 1;
        } else if (cmp > 0) {
            high = mid - 1;
        } else {
            return mid;
        }
    }
    return -1;
}