Example usage for org.jfree.chart.renderer.xy XYItemRenderer findRangeBounds

List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer findRangeBounds

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYItemRenderer findRangeBounds.

Prototype

public Range findRangeBounds(XYDataset dataset);

Source Link

Document

Returns the lower and upper bounds (range) of the y-values in the specified dataset.

Usage

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Returns the range for the specified axis.
 *
 * @param axis  the axis.//from w w w  .  jav  a2  s.  c om
 *
 * @return The range.
 */
public Range getDataRange(ValueAxis axis) {

    Range result = null;
    List mappedDatasets = new ArrayList();
    boolean isDomainAxis = true;

    // is it a domain axis?
    int domainIndex = getDomainAxisIndex(axis);
    if (domainIndex >= 0) {
        isDomainAxis = true;
        mappedDatasets.addAll(getDatasetsMappedToDomainAxis(new Integer(domainIndex)));
    }

    // or is it a range axis?
    int rangeIndex = getRangeAxisIndex(axis);
    if (rangeIndex >= 0) {
        isDomainAxis = false;
        mappedDatasets.addAll(getDatasetsMappedToRangeAxis(new Integer(rangeIndex)));
    }

    // iterate through the datasets that map to the axis and get the union
    // of the ranges.
    Iterator iterator = mappedDatasets.iterator();
    while (iterator.hasNext()) {
        XYDataset d = (XYDataset) iterator.next();
        if (d != null) {
            XYItemRenderer r = getRendererForDataset(d);
            if (isDomainAxis) {
                if (r != null) {
                    result = Range.combine(result, r.findDomainBounds(d));
                } else {
                    result = Range.combine(result, DatasetUtilities.findDomainBounds(d));
                }
            } else {
                if (r != null) {
                    result = Range.combine(result, r.findRangeBounds(d));
                } else {
                    result = Range.combine(result, DatasetUtilities.findRangeBounds(d));
                }
            }
        }
    }
    return result;

}