Example usage for org.jfree.data.function PowerFunction2D PowerFunction2D

List of usage examples for org.jfree.data.function PowerFunction2D PowerFunction2D

Introduction

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

Prototype

public PowerFunction2D(double a, double b) 

Source Link

Document

Creates a new power function.

Usage

From source file:org.jfree.data.function.PowerFunction2DTest.java

/**
 * Some tests for the constructor./* w w  w .j  a  v a2 s . c om*/
 */
@Test
public void testConstructor() {
    PowerFunction2D f = new PowerFunction2D(1.0, 2.0);
    assertEquals(1.0, f.getA(), EPSILON);
    assertEquals(2.0, f.getB(), EPSILON);
}

From source file:org.jfree.data.function.PowerFunction2DTest.java

/**
 * For datasets, the equals() method just checks keys and values.
 *///  www . j  a v a2s.c om
@Test
public void testEquals() {
    PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0);
    PowerFunction2D f2 = new PowerFunction2D(1.0, 2.0);
    assertTrue(f1.equals(f2));
    f1 = new PowerFunction2D(2.0, 3.0);
    assertFalse(f1.equals(f2));
    f2 = new PowerFunction2D(2.0, 3.0);
    assertTrue(f1.equals(f2));
}

From source file:org.jfree.data.function.PowerFunction2DTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   ww  w  .  j  ava2 s. c o m
@Test
public void testSerialization() {
    PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0);
    PowerFunction2D f2 = (PowerFunction2D) TestUtilities.serialised(f1);
    assertEquals(f1, f2);
}

From source file:org.jfree.data.function.PowerFunction2DTest.java

/**
 * Objects that are equal should have the same hash code otherwise FindBugs
 * will tell on us...//from www. j a  v  a  2s  . co  m
 */
@Test
public void testHashCode() {
    PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0);
    PowerFunction2D f2 = new PowerFunction2D(1.0, 2.0);
    assertEquals(f1.hashCode(), f2.hashCode());
}

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

private XYSeries createCurveSeries(UICurve curve, XYDataset data, int index) {
    if (data.getItemCount(index) < 2) {
        throw new IllegalArgumentException("Not enough data");
    }//from  w ww .j  av a  2s  .  c om

    Key key = new Key(index, curve.getLegend());

    if (curve instanceof UIAverageLine) {
        double period = ((UIAverageLine) curve).getPeriod();
        double skip = ((UIAverageLine) curve).getSkip();
        if (data instanceof TimeSeriesCollection) {
            TimeSeries ts = ((TimeSeriesCollection) data).getSeries(index);
            return MovingAverage.createMovingAverage(ts, key, (int) period, (int) skip);
        } else {
            return MovingAverage.createMovingAverage(data, index, key, period, skip);
        }
    } else if (curve instanceof UIRegressionLine) {
        RegressionType type = ((UIRegressionLine) curve).getType();
        int samples = ((UIRegressionLine) curve).getSamples();
        if (type == null || type == RegressionType.Linear) {
            double[] p = Regression.getOLSRegression(data, index);
            Function2D f = new LineFunction2D(p[0], p[1]);
            return createFunctionSeries(data, index, key, f, samples);
        } else if (type == RegressionType.Power) {
            double[] p = Regression.getPowerRegression(data, index);
            Function2D f = new PowerFunction2D(p[0], p[1]);
            return createFunctionSeries(data, index, key, f, samples);
        } else {
            throw new IllegalArgumentException(type.toString());
        }
    } else if (curve instanceof UISpline) {
        SplineType type = ((UISpline) curve).getType();
        int samples = ((UISpline) curve).getSamples();
        int degree = ((UISpline) curve).getDegree();
        if (type == null || type == SplineType.BSpline) {
            return BSpline.createBSpline(data, index, key, samples, degree);
        } else if (type == SplineType.CubicSpline) {
            return CubicSpline.createCubicSpline(data, index, key, samples);
        }
    }

    return null;
}