Java Code Examples for org.jfree.data.xy.XYDataset#getItemCount()
The following examples show how to use
org.jfree.data.xy.XYDataset#getItemCount() .
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: JGenProg2017_0047_s.java From coming with MIT License | 6 votes |
/** * Returns <code>true</code> if the dataset is empty (or <code>null</code>), * and <code>false</code> otherwise. * * @param dataset the dataset (<code>null</code> permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(XYDataset dataset) { boolean result = true; if (dataset != null) { for (int s = 0; s < dataset.getSeriesCount(); s++) { if (dataset.getItemCount(s) > 0) { result = false; continue; } } } return result; }
Example 2
Source File: Cardumen_0079_s.java From coming with MIT License | 6 votes |
/** * Returns <code>true</code> if the dataset is empty (or <code>null</code>), * and <code>false</code> otherwise. * * @param dataset the dataset (<code>null</code> permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(XYDataset dataset) { boolean result = true; if (dataset != null) { for (int s = 0; s < dataset.getSeriesCount(); s++) { if (dataset.getItemCount(s) > 0) { result = false; continue; } } } return result; }
Example 3
Source File: Cardumen_009_s.java From coming with MIT License | 5 votes |
/** * Selects the data items within the specified region. * * @param region the region (in Java2D coordinates). * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // cycle through the datasets and change the selection state for the // items that fall within the specified region int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { XYDataset dataset = (XYDataset) this.datasets.get(d); if (dataset == null) { continue; } XYDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } GeneralPath path = convertToDataSpace(region, dataArea, dataset); // now we have to iterate over all the dataset values and // convert each point to Java2D space and then check if it should // be selected. int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { double x = dataset.getXValue(s, i); double y = dataset.getYValue(s, i); if (path.contains(x, y)) { state.setSelected(s, i, true); // FIXME: we should fire just one dataset change event // for the whole selection } } } } }
Example 4
Source File: DatasetUtilities.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: XYItemLabelGenerator.java From openbd-core with GNU General Public License v3.0 | 5 votes |
private static double calculateYTotal(XYDataset dataset, int series) { double total = 0; int numItems = dataset.getItemCount(series); for ( int i = 0; i < numItems; i++ ) total += dataset.getYValue(series,i); return total; }
Example 6
Source File: Regression.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to * the data using a power regression equation. The result is returned as * an array, where double[0] --> a, and double[1] --> b. * * @param data the data. * @param series the series to fit the regression line against. * * @return The parameters. */ public static double[] getPowerRegression(XYDataset data, int series) { int n = data.getItemCount(series); if (n < 2) { throw new IllegalArgumentException("Not enough data."); } double sumX = 0; double sumY = 0; double sumXX = 0; double sumXY = 0; for (int i = 0; i < n; i++) { double x = Math.log(data.getXValue(series, i)); double y = Math.log(data.getYValue(series, i)); sumX += x; sumY += y; double xx = x * x; sumXX += xx; double xy = x * y; sumXY += xy; } double sxx = sumXX - (sumX * sumX) / n; double sxy = sumXY - (sumX * sumY) / n; double xbar = sumX / n; double ybar = sumY / n; double[] result = new double[2]; result[1] = sxy / sxx; result[0] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar); return result; }
Example 7
Source File: MovingAverage.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a new {@link XYSeries} containing the moving averages of one * series in the <code>source</code> dataset. * * @param source the source dataset. * @param series the series index (zero based). * @param name the name for the new series. * @param period the averaging period. * @param skip the length of the initial skip period. * * @return The dataset. */ public static XYSeries createMovingAverage(XYDataset source, int series, String name, double period, double skip) { if (source == null) { throw new IllegalArgumentException("Null source (XYDataset)."); } if (period < Double.MIN_VALUE) { throw new IllegalArgumentException("period must be positive."); } if (skip < 0.0) { throw new IllegalArgumentException("skip must be >= 0.0."); } XYSeries result = new XYSeries(name); if (source.getItemCount(series) > 0) { // if the initial averaging period is to be excluded, then // calculate the lowest x-value to have an average calculated... double first = source.getXValue(series, 0) + skip; for (int i = source.getItemCount(series) - 1; i >= 0; i--) { // get the current data item... double x = source.getXValue(series, i); if (x >= first) { // work out the average for the earlier values... int n = 0; double sum = 0.0; double limit = x - period; int offset = 0; boolean finished = false; while (!finished) { if ((i - offset) >= 0) { double xx = source.getXValue(series, i - offset); Number yy = source.getY(series, i - offset); if (xx > limit) { if (yy != null) { sum = sum + yy.doubleValue(); n = n + 1; } } else { finished = true; } } else { finished = true; } offset = offset + 1; } if (n > 0) { result.add(x, sum / n); } else { result.add(x, null); } } } } return result; }
Example 8
Source File: Cardumen_0079_t.java From coming with MIT License | 4 votes |
/** * 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 9
Source File: DatasetUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * 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 10
Source File: DatasetUtilities.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * 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 11
Source File: DatasetUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * 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 12
Source File: SpectraDatabaseSearchLabelGenerator.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
@Override public String generateLabel(XYDataset dataset, int series, int item) { // X and Y values of current data point double originalX = dataset.getX(series, item).doubleValue(); double originalY = dataset.getY(series, item).doubleValue(); // Calculate data size of 1 screen pixel double xLength = plot.getXYPlot().getDomainAxis().getRange().getLength(); double pixelX = xLength / plot.getWidth(); // Size of data set int itemCount = dataset.getItemCount(series); // Search for data points higher than this one in the interval // from limitLeft to limitRight double limitLeft = originalX - ((POINTS_RESERVE_X / 2) * pixelX); double limitRight = originalX + ((POINTS_RESERVE_X / 2) * pixelX); // Iterate data points to the left and right for (int i = 1; (item - i > 0) || (item + i < itemCount); i++) { // If we get out of the limit we can stop searching if ((item - i > 0) && (dataset.getXValue(series, item - i) < limitLeft) && ((item + i >= itemCount) || (dataset.getXValue(series, item + i) > limitRight))) break; if ((item + i < itemCount) && (dataset.getXValue(series, item + i) > limitRight) && ((item - i <= 0) || (dataset.getXValue(series, item - i) < limitLeft))) break; // If we find higher data point, bail out if ((item - i > 0) && (originalY <= dataset.getYValue(series, item - i))) return null; if ((item + i < itemCount) && (originalY <= dataset.getYValue(series, item + i))) return null; } // Create label String label = null; if (dataset.getSeriesKey(1).equals("Detected compounds")) { if (item < annotations.length) label = annotations[item]; } return label; }
Example 13
Source File: DPPResultsLabelGenerator.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
/** * @see org.jfree.chart.labels.XYItemLabelGenerator#generateLabel(org.jfree.data.xy.XYDataset, * int, int) */ public String generateLabel(XYDataset dataset, int series, int item) { // X and Y values of current data point double originalX = dataset.getX(series, item).doubleValue(); double originalY = dataset.getY(series, item).doubleValue(); // Calculate data size of 1 screen pixel double xLength = (double) plot.getXYPlot().getDomainAxis().getRange().getLength(); double pixelX = xLength / plot.getWidth(); // Size of data set int itemCount = dataset.getItemCount(series); // Search for data points higher than this one in the interval // from limitLeft to limitRight double limitLeft = originalX - ((POINTS_RESERVE_X / 2) * pixelX); double limitRight = originalX + ((POINTS_RESERVE_X / 2) * pixelX); // Iterate data points to the left and right for (int i = 1; (item - i > 0) || (item + i < itemCount); i++) { // If we get out of the limit we can stop searching if ((item - i > 0) && (dataset.getXValue(series, item - i) < limitLeft) && ((item + i >= itemCount) || (dataset.getXValue(series, item + i) > limitRight))) break; if ((item + i < itemCount) && (dataset.getXValue(series, item + i) > limitRight) && ((item - i <= 0) || (dataset.getXValue(series, item - i) < limitLeft))) break; // If we find higher data point, bail out if ((item - i > 0) && (originalY <= dataset.getYValue(series, item - i))) return null; if ((item + i < itemCount) && (originalY <= dataset.getYValue(series, item + i))) return null; } // Create label String label = null; if (dataset instanceof ScanDataSet) { label = ((ScanDataSet) dataset).getAnnotation(item); } else if (dataset instanceof DPPResultsDataSet) { DataPoint[] dps = ((DPPResultsDataSet) dataset).getDataPoints(); if (dps[item] instanceof ProcessedDataPoint) { ProcessedDataPoint p = (ProcessedDataPoint) dps[item]; label = createLabel(p); } } if (label == null || label.equals("")) { double mzValue = dataset.getXValue(series, item); label = mzFormat.format(mzValue); } return label; }
Example 14
Source File: Chart_2_DatasetUtilities_t.java From coming with MIT License | 4 votes |
/** * 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: Cardumen_00194_s.java From coming with MIT License | 4 votes |
/** * 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 16
Source File: DatasetUtilities.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * 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) { 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.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 17
Source File: DatasetUtilities.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * 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 18
Source File: Cardumen_0079_s.java From coming with MIT License | 4 votes |
/** * 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: DatasetUtilities.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * 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 20
Source File: DatasetUtilities.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * 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; }