本文整理汇总了Java中org.jfree.data.function.LineFunction2D类的典型用法代码示例。如果您正苦于以下问题:Java LineFunction2D类的具体用法?Java LineFunction2D怎么用?Java LineFunction2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineFunction2D类属于org.jfree.data.function包,在下文中一共展示了LineFunction2D类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawRegression
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/** Handles drawing of the regression line */
private void drawRegression(XYDataset scatterPlotData, XYPlot xyplot) {
// compute regression function
double regressionParams[] = Regression.getOLSRegression(
scatterPlotData, 0);
Function2D regression = new LineFunction2D(regressionParams[0],
regressionParams[1]);
// sample function values
double lowerBound = xyplot.getDomainAxis().getLowerBound();
double upperBound = xyplot.getDomainAxis().getUpperBound();
XYDataset regressionDataset = DatasetUtilities.sampleFunction2D(
regression, lowerBound, upperBound,
REGRESSION_LINE_SAMPLE_COUNT, "Fitted Regression Line");
xyplot.setDataset(1, regressionDataset);
// render regression line into plot
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,
false);
xyplot.setRenderer(1, renderer);
renderer.setSeriesPaint(0, REGRESSION_LINE_COLOR);
}
示例2: computeRegressionData
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
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;
}
}
示例3: plotRel2dChartData
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
protected boolean plotRel2dChartData(String xAxisName, ArrayList<Double> xarr, String yAxisName, ArrayList<Double> yarr) {
clear2dChartData();
if (setXYSeries(runData, xarr, yarr)) {
double[] ols = Regression.getOLSRegression(chartPanel.getChart().getXYPlot().getDataset(1), 0);
Function2D curve = new LineFunction2D(ols[0], ols[1]);
trendData.clear();
trendData.add(runData.getMinX(), curve.getValue(runData.getMinX()));
trendData.add(runData.getMaxX(), curve.getValue(runData.getMaxX()));
double paddingX = runData.getMaxX() * 0.05;
double paddingY = runData.getMaxY() * 0.05;
XYPlot plot = chartPanel.getChart().getXYPlot();
plot.getDomainAxis(0).setRange(runData.getMinX() - paddingX, runData.getMaxX() + paddingX);
plot.getRangeAxis(0).setRange(runData.getMinY() - paddingY, runData.getMaxY() + paddingY);
plot.getDomainAxis(0).setLabel(xAxisName);
plot.getRangeAxis(0).setLabel(yAxisName);
plot.getRenderer(0).setSeriesVisible(0, true);
return true;
}
return false;
}
示例4: testSampleFunction2D
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/**
* 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);
}
示例5: testSampleFunction2D
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/**
* Some checks for the sampleFunction2D() method.
*/
@Test
public void testSampleFunction2D() {
Function2D f = new LineFunction2D(0, 1);
XYDataset dataset = DatasetUtils.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);
}
示例6: testSampleFunction2D
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/**
* 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);
}
示例7: plotTrimRpmData
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
private boolean plotTrimRpmData() {
if (setXYSeries(runData, rpmArray, trimArray)) {
double[] ols = Regression.getOLSRegression(mafChartPanel.getChartPanel().getChart().getXYPlot().getDataset(1), 0);
Function2D curve = new LineFunction2D(ols[0], ols[1]);
currMafData.clear();
currMafData.add(runData.getMinX(), curve.getValue(runData.getMinX()));
currMafData.add(runData.getMaxX(), curve.getValue(runData.getMaxX()));
return true;
}
return false;
}
示例8: testConstructor
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/**
* 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);
}
示例9: testHashCode
import org.jfree.data.function.LineFunction2D; //导入依赖的package包/类
/**
* 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());
}