public class XYCurve extends Object implements Result, TextWriteable
addAndSimplify(double, double)
which tries to simplify
the curve while adding points.Modifier and Type | Class and Description |
---|---|
class |
XYCurve.Itr
Iterator for the curve. 2D, does not follow Java collections style.
|
Modifier and Type | Field and Description |
---|---|
protected gnu.trove.list.array.TDoubleArrayList |
data
X and Y positions
|
protected String |
labelx
Label of X axis
|
protected String |
labely
Label of Y axis
|
protected double |
maxx
Minimum and maximum for X axis
|
protected double |
maxy
Minimum and maximum for Y axis
|
protected double |
minx
Minimum and maximum for X axis
|
protected double |
miny
Minimum and maximum for Y axis
|
protected static double |
THRESHOLD
Simplification threshold
|
Constructor and Description |
---|
XYCurve()
Constructor.
|
XYCurve(int size)
Constructor with size estimate
|
XYCurve(String labelx,
String labely)
Constructor with labels
|
XYCurve(String labelx,
String labely,
int size)
Constructor with size estimate and labels.
|
XYCurve(XYCurve curve)
Constructor, cloning an existing curve.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double x,
double y)
Add a coordinate pair, but don't simplify
|
void |
addAndSimplify(double x,
double y)
Add a coordinate pair, performing curve simplification if possible.
|
static double |
areaUnderCurve(XYCurve curve)
Compute the area under curve for a curve
monotonously increasing in X.
|
String |
getLabelx()
Get label of x axis
|
String |
getLabely()
Get label of y axis
|
String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
double |
getMaxx()
Maximum on x axis.
|
double |
getMaxy()
Maximum on y axis.
|
double |
getMinx()
Minimum on x axis.
|
double |
getMiny()
Minimum on y axis.
|
String |
getShortName()
A short name for the result, useful for file names.
|
double |
getX(int off)
Curve X value at given position
|
double |
getY(int off)
Curve Y value at given position
|
XYCurve.Itr |
iterator()
Get an iterator for the curve.
|
void |
rescale(double sx,
double sy)
Rescale the graph.
|
int |
size()
Size of curve.
|
String |
toString() |
void |
writeToText(TextWriterStream out,
String label)
Write self to the given
TextWriterStream |
protected static final double THRESHOLD
protected gnu.trove.list.array.TDoubleArrayList data
protected String labelx
protected String labely
protected double minx
protected double maxx
protected double miny
protected double maxy
public XYCurve(String labelx, String labely)
labelx
- Label for X axislabely
- Label for Y axispublic XYCurve(String labelx, String labely, int size)
labelx
- Label for X axislabely
- Label for Y axissize
- Estimated size (initial allocation size)public XYCurve()
public XYCurve(int size)
size
- Estimated size (initial allocation size)public XYCurve(XYCurve curve)
curve
- Curve to clone.public void add(double x, double y)
x
- X coordinatey
- Y coordinatepublic void addAndSimplify(double x, double y)
x
- X coordinatey
- Y coordinatepublic String getLabelx()
public String getLabely()
public double getMinx()
public double getMaxx()
public double getMiny()
public double getMaxy()
public double getX(int off)
off
- Offsetpublic double getY(int off)
off
- Offsetpublic void rescale(double sx, double sy)
sx
- Scaling factor for X axissy
- Scaling factor for Y axispublic int size()
public XYCurve.Itr iterator()
for (XYCurve.Itr it = curve.iterator(); it.valid(); it.advance()) { doSomethingWith(it.getX(), it.getY()); }
public void writeToText(TextWriterStream out, String label)
TextWriteable
TextWriterStream
writeToText
in interface TextWriteable
out
- Output writerlabel
- Labelpublic String getLongName()
Result
getLongName
in interface Result
public String getShortName()
Result
getShortName
in interface Result
public static double areaUnderCurve(XYCurve curve)
curve
- Curve