org.faceless.graph2
Class SplineSeries

java.lang.Object
  extended by org.faceless.graph2.Series
      extended by org.faceless.graph2.AbstractLineSeries
          extended by org.faceless.graph2.FunctionLineSeries
              extended by org.faceless.graph2.SplineSeries

public class SplineSeries
extends FunctionLineSeries

A SplineSeries is very similar to a LineSeries class, except that the line between the specified datapoints is "smoothed" by applying a Spline curve. Two splines are supplied - the CATMULLROM_SPLINE which will pass through each point, or the B_SPLINE, which does not pass through each point and so is useful for filtering out extreme values.

See Also:
LineSeries

Field Summary
static double[][] B_SPLINE
          Defines the basis matrix for a B-spline
static double[][] CATMULLROM_SPLINE
          Defines the basis matrix for a Catmull-Rom spline
 
Constructor Summary
SplineSeries(String name, double[][] matrix)
          Create a new SplineSeries
 
Method Summary
 void complete()
          Complete the function.
 double func(double x)
          Given an X value, return the equivalent Y value of this function.
 void set(double x, double y)
          Set a value on the graph.
 
Methods inherited from class org.faceless.graph2.FunctionLineSeries
createFunctionSeries, getLineSeries, setLineSeries, setSteps
 
Methods inherited from class org.faceless.graph2.AbstractLineSeries
setDepth
 
Methods inherited from class org.faceless.graph2.Series
addBox, addLine, addMarker, getName, outputToSeries, outputToSeriesFunction, setStyle, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CATMULLROM_SPLINE

public static final double[][] CATMULLROM_SPLINE
Defines the basis matrix for a Catmull-Rom spline


B_SPLINE

public static final double[][] B_SPLINE
Defines the basis matrix for a B-spline

Constructor Detail

SplineSeries

public SplineSeries(String name,
                    double[][] matrix)
Create a new SplineSeries

Parameters:
name - the name of the Series
matrix - the nx4 matrix defining the spline. Typically either CATMULLROM_SPLINE or B_SPLINE will be used, but a user-defined spline can also be passed in.
Throws:
IllegalArgumentException - if the spline matrix does not have 4 rows.
Method Detail

set

public void set(double x,
                double y)
Set a value on the graph. The x parameter specifies the horizontal position on the graph, and the y parameter specifies the vertical position. Both must be real numbers.

Parameters:
x - the X co-ordinate of the sample
y - the Y co-ordinate of the sample

complete

public void complete()
Description copied from class: FunctionLineSeries
Complete the function. This method is called after all the data points are available to the graph, and can be overridden to calculate the function based on the points in the graph. It is called automatically by the library - subclasses overriding this method must always call super.complete() first.

Overrides:
complete in class FunctionLineSeries

func

public double func(double x)
Description copied from class: FunctionLineSeries
Given an X value, return the equivalent Y value of this function. The returned value may be Double.NaN or infinite, and either of those values will result in a gap in the line.

Specified by:
func in class FunctionLineSeries
Parameters:
x - the X-value of the function - guaranteed not to be NaN or Infinite
Returns:
y the corresponding Y value


Copyright © 2001-2011 Big Faceless Organization