org.jfree.data.function.LineFunction2D Java Examples
The following examples show how to use
org.jfree.data.function.LineFunction2D.
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: ScatterPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
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; } }
Example #2
Source File: DatasetUtilitiesTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ @Test public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #3
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ @Test public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #4
Source File: DatasetUtilitiesTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ @Test public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #5
Source File: DatasetUtilitiesTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ @Test public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #6
Source File: DatasetUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #7
Source File: DatasetUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Some checks for the sampleFunction2D() method. */ @Test public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); }
Example #8
Source File: LineFunction2DTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Some tests for the constructor. */ public void testConstructor() { LineFunction2D f = new LineFunction2D(1.0, 2.0); assertEquals(1.0, f.getIntercept(), EPSILON); assertEquals(2.0, f.getSlope(), EPSILON); }
Example #9
Source File: LineFunction2DTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Objects that are equal should have the same hash code otherwise FindBugs * will tell on us... */ public void testHashCode() { LineFunction2D f1 = new LineFunction2D(1.0, 2.0); LineFunction2D f2 = new LineFunction2D(1.0, 2.0); assertEquals(f1.hashCode(), f2.hashCode()); }