Java Code Examples for org.jfree.data.xy.XYDataset#getSeriesCount()

The following examples show how to use org.jfree.data.xy.XYDataset#getSeriesCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolarPlot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the legend items for the plot.  Each legend item is generated by
 * the plot's m_Renderer, since the m_Renderer is responsible for the visual
 * representation of the data.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    if (this.fixedLegendItems != null) {
        return this.fixedLegendItems;
    }
    LegendItemCollection result = new LegendItemCollection();
    int count = this.datasets.size();
    for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
        XYDataset dataset = getDataset(datasetIndex);
        PolarItemRenderer renderer = getRenderer(datasetIndex);
        if (dataset != null && renderer != null) {
            int seriesCount = dataset.getSeriesCount();
            for (int i = 0; i < seriesCount; i++) {
                LegendItem item = renderer.getLegendItem(i);
                result.add(item);
            }
        }
    }
    return result;
}
 
Example 2
Source File: Cardumen_009_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the legend items for the plot.  Each legend item is generated by
 * the plot's renderer, since the renderer is responsible for the visual
 * representation of the data.
 *
 * @return The legend items.
 */
public LegendItemCollection getLegendItems() {
    if (this.fixedLegendItems != null) {
        return this.fixedLegendItems;
    }
    LegendItemCollection result = new LegendItemCollection();
    int count = this.datasets.size();
    for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
        XYDataset dataset = getDataset(datasetIndex);
        if (dataset != null) {
            XYItemRenderer renderer = getRenderer(datasetIndex);
            if (renderer == null) {
                renderer = getRenderer(0);
            }
            if (renderer != null) {
                int seriesCount = dataset.getSeriesCount();
                for (int i = 0; i < seriesCount; i++) {
                    if (renderer.isSeriesVisible(i)
                            && renderer.isSeriesVisibleInLegend(i)) {
                        LegendItem item = renderer.getLegendItem(
                                datasetIndex, i);
                        if (item != null) {
                            result.add(item);
                        }
                    }
                }
            }
        }
    }
    return result;
}
 
Example 3
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the number of series in the primary dataset for this plot.  If
 * the dataset is <code>null</code>, the method returns 0.
 *
 * @return The series count.
 */
public int getSeriesCount() {
    int result = 0;
    XYDataset dataset = getDataset();
    if (dataset != null) {
        result = dataset.getSeriesCount();
    }
    return result;
}
 
Example 4
Source File: MovingAverage.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link XYDataset} containing the moving averages of each
 * series in the <code>source</code> dataset.
 *
 * @param source  the source dataset.
 * @param suffix  the string to append to source series names to create
 *                target series names.
 * @param period  the averaging period.
 * @param skip  the length of the initial skip period.
 *
 * @return The dataset.
 */
public static XYDataset createMovingAverage(XYDataset source,
        String suffix, double period, double skip) {

    ParamChecks.nullNotPermitted(source, "source");
    XYSeriesCollection result = new XYSeriesCollection();
    for (int i = 0; i < source.getSeriesCount(); i++) {
        XYSeries s = createMovingAverage(source, i, source.getSeriesKey(i)
                + suffix, period, skip);
        result.addSeries(s);
    }
    return result;
}
 
Example 5
Source File: XYPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the legend items for the plot.  Each legend item is generated by
 * the plot's renderer, since the renderer is responsible for the visual
 * representation of the data.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    if (this.fixedLegendItems != null) {
        return this.fixedLegendItems;
    }
    LegendItemCollection result = new LegendItemCollection();
    for (XYDataset dataset : this.datasets.values()) {
        if (dataset == null) {
            continue;
        }
        int datasetIndex = indexOf(dataset);
        XYItemRenderer renderer = getRenderer(datasetIndex);
        if (renderer == null) {
            renderer = getRenderer(0);
        }
        if (renderer != null) {
            int seriesCount = dataset.getSeriesCount();
            for (int i = 0; i < seriesCount; i++) {
                if (renderer.isSeriesVisible(i)
                        && renderer.isSeriesVisibleInLegend(i)) {
                    LegendItem item = renderer.getLegendItem(
                            datasetIndex, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
    }
    return result;
}
 
Example 6
Source File: Cardumen_00194_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Iterates over the data item of the xy dataset to find
 * the range bounds.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeBounds(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData 
                    = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example 7
Source File: DatasetUtilities.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over the data item of the xy dataset to find
 * the range bounds.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeBounds(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData 
                    = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example 8
Source File: MovingAverage.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link XYDataset} containing the moving averages of each
 * series in the <code>source</code> dataset.
 *
 * @param source  the source dataset.
 * @param suffix  the string to append to source series names to create
 *                target series names.
 * @param period  the averaging period.
 * @param skip  the length of the initial skip period.
 *
 * @return The dataset.
 */
public static XYDataset createMovingAverage(XYDataset source,
        String suffix, double period, double skip) {

    ParamChecks.nullNotPermitted(source, "source");
    XYSeriesCollection result = new XYSeriesCollection();
    for (int i = 0; i < source.getSeriesCount(); i++) {
        XYSeries s = createMovingAverage(source, i, source.getSeriesKey(i)
                + suffix, period, skip);
        result.addSeries(s);
    }
    return result;
}
 
Example 9
Source File: LineChartBuilder.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    return (dataset.getSeriesCount() > 1 ? dataset.getSeriesKey(series) + " " : "")
            + DATE_FORMAT.format(new java.util.Date((long) dataset.getXValue(series, item))) + " - "
            + NUMBER_FORMAT.format(dataset.getYValue(series, item));
}
 
Example 10
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the maximum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the maximum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values are <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumRangeValue(XYDataset dataset) {

    ParamChecks.nullNotPermitted(dataset, "dataset");

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeUpperBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else  {

        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData
                            = (IntervalXYDataset) dataset;
                    value = intervalXYData.getEndYValue(series, item);
                }
                else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getHighValue(series, item);
                }
                else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            return null;
        }
        else {
            return new Double(maximum);
        }

    }

}
 
Example 11
Source File: Cardumen_0079_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Finds the minimum domain (or X) value for the specified dataset.  This 
 * is easy if the dataset implements the {@link DomainInfo} interface (a 
 * good idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.
 * <p>
 * Returns <code>null</code> if all the data values in the dataset are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainLowerBound(true));
    }
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData 
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(minimum);
        }
    }

    return result;
}
 
Example 12
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Finds the minimum domain (or X) value for the specified dataset.  This
 * is easy if the dataset implements the {@link DomainInfo} interface (a
 * good idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.
 * <p>
 * Returns <code>null</code> if all the data values in the dataset are
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumDomainValue(XYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    Number result;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainLowerBound(true));
    }
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(minimum);
        }
    }

    return result;
}
 
Example 13
Source File: TimeAndValueTooltipGenerator.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    return (dataset.getSeriesCount() > 1 ? dataset.getSeriesKey(series) + " " : "")
            + TIME_FORMAT.format(new java.util.Date((long) dataset.getXValue(series, item))) + " - "
            + NUMBER_FORMAT.format(dataset.getYValue(series, item));
}
 
Example 14
Source File: Cardumen_0079_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Finds the minimum domain (or X) value for the specified dataset.  This 
 * is easy if the dataset implements the {@link DomainInfo} interface (a 
 * good idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.
 * <p>
 * Returns <code>null</code> if all the data values in the dataset are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainLowerBound(true));
    }
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData 
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(minimum);
        }
    }

    return result;
}
 
Example 15
Source File: JGenProg2017_0047_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the maximum domain value for the specified dataset.  This is 
 * easy if the dataset implements the {@link DomainInfo} interface (a good 
 * idea if there is an efficient way to determine the maximum value).  
 * Otherwise, it involves iterating over the entire data-set.  Returns 
 * <code>null</code> if all the data values in the dataset are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainUpperBound(true));
    }

    // hasn't implemented DomainInfo, so iterate...
    else {
        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData 
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getEndXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(maximum);
        }

    }
    
    return result;
}
 
Example 16
Source File: DatasetUtilities.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the maximum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the maximum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values are <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumRangeValue(XYDataset dataset) {

    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeUpperBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else  {

        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getEndYValue(series, item);
                }
                else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getHighValue(series, item);
                }
                else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            return null;
        }
        else {
            return new Double(maximum);
        }

    }

}
 
Example 17
Source File: Chart_2_DatasetUtilities_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Finds the minimum domain (or X) value for the specified dataset.  This
 * is easy if the dataset implements the {@link DomainInfo} interface (a
 * good idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.
 * <p>
 * Returns <code>null</code> if all the data values in the dataset are
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainLowerBound(true));
    }
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(minimum);
        }
    }

    return result;
}
 
Example 18
Source File: Cardumen_00194_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum range value for the specified dataset.  This is 
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).  
 * Otherwise, it involves iterating over the entire data-set.  Returns 
 * <code>null</code> if all the data values in the dataset are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {

    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData 
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartYValue(series, item);
                }
                else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getLowValue(series, item);
                }
                else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        }
        else {
            return new Double(minimum);
        }

    }

}
 
Example 19
Source File: Cardumen_0079_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum range value for the specified dataset.  This is 
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).  
 * Otherwise, it involves iterating over the entire data-set.  Returns 
 * <code>null</code> if all the data values in the dataset are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {

    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData 
                        = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartYValue(series, item);
                }
                else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getLowValue(series, item);
                }
                else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        }
        else {
            return new Double(minimum);
        }

    }

}
 
Example 20
Source File: PolarPlot.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Returns the number of series in the dataset for this plot.  If the
 * dataset is <code>null</code>, the method returns 0.
 *
 * @return The series count.
 *
 * @deprecated Since 1.0.14, grab a reference to the dataset and check
 *     the series count directly.
 */
public int getSeriesCount() {
    int result = 0;
    XYDataset dataset = getDataset(0);
    if (dataset != null) {
        result = dataset.getSeriesCount();
    }
    return result;
}