/** * Returns a string representing this instance, primarily for debugging * use. * * @return A string. */ @Override public String toString() { return "[" + getXValue() + ", " + getYValue() + "]"; }
/** * Returns a string representing this instance, primarily for debugging * use. * * @return A string. */ public String toString() { return "[" + getXValue() + ", " + getYValue() + "]"; }
continue; if (leftPeakPoint.getYValue() < point.getYValue()) { leftPeakPoint = point; leftPeakPointIndex = index; rightPeakPoint = point; } else if (leftPeakPoint.getYValue() == point.getYValue()) { rightPeakPoint = point; } else { if (prev.getYValue() <= leftPeakPoint.getYValue()) { double peakx = rightPeakPoint.getXValue() - ((rightPeakPoint.getXValue() - leftPeakPoint.getXValue()) / 2D); maxPoints.add(new XYDataItem(peakx, leftPeakPoint.getYValue()));
/** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value ({@code null} permitted). * * @since 1.0.1 */ public void updateByIndex(int index, Number y) { XYDataItem item = getRawDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); }
/** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value (<code>null</code> permitted). * * @deprecated Renamed {@link #updateByIndex(int, Number)} to avoid * confusion with the {@link #update(Number, Number)} method. */ public void update(int index, Number y) { XYDataItem item = getRawDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); }
double y = item.getYValue(); if (!Double.isNaN(y)) { if (y <= this.minY || y >= this.maxY) {
double y = item.getYValue(); if (!Double.isNaN(y)) { if (y <= this.minY || y >= this.maxY) {
/** * Updates the cached values for the minimum and maximum data values. * * @param item the item added (<code>null</code> not permitted). * * @since 1.0.13 */ private void updateBoundsForAddedItem(XYDataItem item) { double x = item.getXValue(); this.minX = minIgnoreNaN(this.minX, x); this.maxX = maxIgnoreNaN(this.maxX, x); if (item.getY() != null) { double y = item.getYValue(); this.minY = minIgnoreNaN(this.minY, y); this.maxY = maxIgnoreNaN(this.maxY, y); } }
/** * Updates the cached values for the minimum and maximum data values. * * @param item the item added ({@code null} not permitted). * * @since 1.0.13 */ private void updateBoundsForAddedItem(XYDataItem item) { double x = item.getXValue(); this.minX = minIgnoreNaN(this.minX, x); this.maxX = maxIgnoreNaN(this.maxX, x); if (item.getY() != null) { double y = item.getYValue(); this.minY = minIgnoreNaN(this.minY, y); this.maxY = maxIgnoreNaN(this.maxY, y); } }
private XYIntervalSeries computeRegressionData(double xStart, double xEnd) { if (scatterpointsDataset.getItemCount(0) > 1) { final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0); final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]); final XYSeries regressionData = DatasetUtilities.sampleFunction2DToSeries( curve, xStart, xEnd, 100, "regression line"); final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey()); final List<XYDataItem> regressionDataItems = regressionData.getItems(); for (XYDataItem item : regressionDataItems) { final double x = item.getXValue(); final double y = item.getYValue(); xyIntervalRegression.add(x, x, x, y, y, y); } return xyIntervalRegression; } else { JOptionPane.showMessageDialog(this, "Unable to compute regression line.\n" + "At least 2 values are needed to compute regression coefficients."); return null; } }
double oldY = existing.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY;
double oldY = existing.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY;
private XYIntervalSeries computeAcceptableDeviationData(double lowerBound, double upperBound) { final XYSeries identity = DatasetUtilities.sampleFunction2DToSeries(x -> x, lowerBound, upperBound, 100, "1:1 line"); final XYIntervalSeries xyIntervalSeries = new XYIntervalSeries(identity.getKey()); for (int i = 0; i < identity.getItemCount(); i++) { XYDataItem item = identity.getDataItem(i); final double x = item.getXValue(); final double y = item.getYValue(); if (scatterPlotModel.showAcceptableDeviation) { final double acceptableDeviation = scatterPlotModel.acceptableDeviationInterval; final double xOff = acceptableDeviation * x / 100; final double yOff = acceptableDeviation * y / 100; xyIntervalSeries.add(x, x - xOff, x + xOff, y, y - yOff, y + yOff); } else { xyIntervalSeries.add(x, x, x, y, y, y); } } return xyIntervalSeries; }
private XYIntervalSeries computeAcceptableDeviationData(double lowerBound, double upperBound) { final Function2D identityFunction = new Function2D() { @Override public double getValue(double x) { return x; } }; final XYSeries identity = DatasetUtilities.sampleFunction2DToSeries(identityFunction, lowerBound, upperBound, 100, "1:1 line"); final XYIntervalSeries xyIntervalSeries = new XYIntervalSeries(identity.getKey()); final List<XYDataItem> items = identity.getItems(); for (XYDataItem item : items) { final double x = item.getXValue(); final double y = item.getYValue(); if (scatterPlotModel.showAcceptableDeviation) { final double acceptableDeviation = scatterPlotModel.acceptableDeviationInterval; final double xOff = acceptableDeviation * x / 100; final double yOff = acceptableDeviation * y / 100; xyIntervalSeries.add(x, x - xOff, x + xOff, y, y - yOff, y + yOff); } else { xyIntervalSeries.add(x, x, x, y, y, y); } } return xyIntervalSeries; }
private XYIntervalSeries computeRegressionData(double xStart, double xEnd) { if (scatterpointsDataset.getItemCount(0) > 1) { final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0); final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]); final XYSeries regressionData = DatasetUtilities.sampleFunction2DToSeries(curve, xStart, xEnd, 100, "regression line"); final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey()); for (int i = 0; i < regressionData.getItemCount(); i++) { XYDataItem item = regressionData.getDataItem(i); final double x = item.getXValue(); final double y = item.getYValue(); xyIntervalRegression.add(x, x, x, y, y, y); } return xyIntervalRegression; } else { Dialogs.showInformation("Unable to compute regression line.\n" + "At least 2 values are needed to compute regression coefficients."); return null; } }