Package org.faceless.graph2
Class SplineSeries
- java.lang.Object
-
- org.faceless.graph2.Series
-
- org.faceless.graph2.AbstractLineSeries
-
- org.faceless.graph2.FunctionLineSeries
-
- org.faceless.graph2.SplineSeries
-
public class SplineSeries extends FunctionLineSeries
ASplineSeriesis very similar to aLineSeriesclass, except that the line between the specified datapoints is "smoothed" by applying a Spline curve. Two splines are supplied - theCATMULLROM_SPLINEwhich will pass through each point, or theB_SPLINE, which does not pass through each point and so is useful for filtering out extreme values.- See Also:
LineSeries
-
-
Field Summary
Fields Modifier and Type Field Description static double[][]B_SPLINEDefines the basis matrix for a B-splinestatic double[][]CATMULLROM_SPLINEDefines the basis matrix for a Catmull-Rom spline
-
Constructor Summary
Constructors Constructor Description SplineSeries(String name, double[][] matrix)Create a new SplineSeries
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Complete the function.doublefunc(double x)Given an X value, return the equivalent Y value of this function.voidset(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
-
-
-
-
Constructor Detail
-
SplineSeries
public SplineSeries(String name, double[][] matrix)
Create a new SplineSeries- Parameters:
name- the name of the Seriesmatrix- the nx4 matrix defining the spline. Typically eitherCATMULLROM_SPLINEorB_SPLINEwill 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. Thexparameter specifies the horizontal position on the graph, and theyparameter specifies the vertical position. Both must be real numbers.- Parameters:
x- the X co-ordinate of the sampley- the Y co-ordinate of the sample
-
complete
public void complete()
Description copied from class:FunctionLineSeriesComplete 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 callsuper.complete()first.- Overrides:
completein classFunctionLineSeries
-
func
public double func(double x)
Description copied from class:FunctionLineSeriesGiven an X value, return the equivalent Y value of this function. The returned value may beDouble.NaNor infinite, and either of those values will result in a gap in the line.- Specified by:
funcin classFunctionLineSeries- Parameters:
x- the X-value of the function - guaranteed not to be NaN or Infinite- Returns:
- y the corresponding Y value
-
-