Example usage for org.jfree.data.function Function2D getValue

List of usage examples for org.jfree.data.function Function2D getValue

Introduction

In this page you can find the example usage for org.jfree.data.function Function2D getValue.

Prototype

public double getValue(double x);

Source Link

Document

Returns the value of the function ('y') for a given input ('x').

Usage

From source file:com.vgi.mafscaling.ClosedLoop.java

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();//from  w w w  .  ja  v  a 2  s. co m
        currMafData.add(runData.getMinX(), curve.getValue(runData.getMinX()));
        currMafData.add(runData.getMaxX(), curve.getValue(runData.getMaxX()));
        return true;
    }
    return false;
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

private XYSeries createFunctionSeries(XYDataset data, int index, Key key, Function2D f, int samples) {
    XYSeries series = new XYSeries(key);
    double start = data.getXValue(index, 0);
    double end = data.getXValue(index, data.getItemCount(index) - 1);
    double step = (end - start) / samples;
    for (int i = 0; i < samples; i++) {
        double x = start + (step * i);
        series.add(x, f.getValue(x));
    }//from  ww w . java2s. co  m
    return series;
}

From source file:org.jfree.data.general.DatasetUtils.java

/**
 * Creates an {@link XYSeries} by sampling the specified function over a
 * fixed range.//  ww  w .  j a v  a  2s .  c  o m
 *
 * @param f  the function ({@code null} not permitted).
 * @param start  the start value for the range.
 * @param end  the end value for the range.
 * @param samples  the number of sample points (must be &gt; 1).
 * @param seriesKey  the key to give the resulting series
 *                   ({@code null} not permitted).
 *
 * @return A series.
 *
 * @since 1.0.13
 */
public static XYSeries sampleFunction2DToSeries(Function2D f, double start, double end, int samples,
        Comparable seriesKey) {

    Args.nullNotPermitted(f, "f");
    Args.nullNotPermitted(seriesKey, "seriesKey");
    if (start >= end) {
        throw new IllegalArgumentException("Requires 'start' < 'end'.");
    }
    if (samples < 2) {
        throw new IllegalArgumentException("Requires 'samples' > 1");
    }

    XYSeries series = new XYSeries(seriesKey);
    double step = (end - start) / (samples - 1);
    for (int i = 0; i < samples; i++) {
        double x = start + (step * i);
        series.add(x, f.getValue(x));
    }
    return series;
}

From source file:org.jfree.data.general.DatasetUtilities.java

/**
 * Creates an {@link XYSeries} by sampling the specified function over a
 * fixed range./* w w w .  j  ava  2 s .c  o  m*/
 *
 * @param f  the function (<code>null</code> not permitted).
 * @param start  the start value for the range.
 * @param end  the end value for the range.
 * @param samples  the number of sample points (must be &gt; 1).
 * @param seriesKey  the key to give the resulting series
 *                   (<code>null</code> not permitted).
 *
 * @return A series.
 *
 * @since 1.0.13
 */
public static XYSeries sampleFunction2DToSeries(Function2D f, double start, double end, int samples,
        Comparable seriesKey) {

    ParamChecks.nullNotPermitted(f, "f");
    ParamChecks.nullNotPermitted(seriesKey, "seriesKey");
    if (start >= end) {
        throw new IllegalArgumentException("Requires 'start' < 'end'.");
    }
    if (samples < 2) {
        throw new IllegalArgumentException("Requires 'samples' > 1");
    }

    XYSeries series = new XYSeries(seriesKey);
    double step = (end - start) / (samples - 1);
    for (int i = 0; i < samples; i++) {
        double x = start + (step * i);
        series.add(x, f.getValue(x));
    }
    return series;
}