Package org.faceless.graph
Class AbstractLineGraph
- java.lang.Object
-
- org.faceless.graph.Graph
-
- org.faceless.graph.AxesGraph
-
- org.faceless.graph.AbstractLineGraph
-
public abstract class AbstractLineGraph extends AxesGraph
The abstract superclass for all graphs plotting continuous data (as opposed to bar graphs, which are for plotting discrete data). Unlike Pie Graphs and Bar Graphs, Line Graphs plot a
Curve
, which covers everything from a set of X and Y values (aDataCurve
) to complex mathematical functions.Several curves can be plotted on the same graph, for example to compare a set of readings with a theoretical curve.
-
-
Field Summary
Fields Modifier and Type Field Description protected double
maxval
The minimum and maximum X and Y values that are being plottedprotected double
maxx
The minimum and maximum X and Y values that are being plottedprotected double
minval
The minimum and maximum X and Y values that are being plottedprotected double
minx
The minimum and maximum X and Y values that are being plotted-
Fields inherited from class org.faceless.graph.AxesGraph
absolutemaxy, absoluteminy, axesmaxx, axesmaxy, axesmaxz, axesminx, axesminy, axesminz, axesstyle, boxstyle, data, xaxeslabelstyle, xaxestextstyle, xfloat, xformatter, xwallstyle, yaxeslabelstyle, yaxestextstyle, yfloat, yformatter, ywallstyle, zaxestextstyle, zfloat, zformatter, zwallstyle
-
Fields inherited from class org.faceless.graph.Graph
canvas, key, KEY_BOXED_BOTTOM, KEY_BOXED_LEFT, KEY_BOXED_RIGHT, KEY_BOXED_TOP, KEY_NONE, keyboxstyle, keypadding, keystyle, keytype, subtitle, subtitlestyle, title, titlepadding, titlestyle, xrotation, yrotation, zrotation
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLineGraph()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
optionCurveDepth(double val)
The depth "into the screen" of a curve.void
optionFunctionSmoothness(double val)
If you're plotting aFunctionCurve
, how many steps to divide the curve into.void
optionMaxDataPoints(int val)
If you're plotting aDataCurve
, the maximum number of values to plot.void
optionMaxX(double val)
The maximum value to plot on the X axis.void
optionMinX(double val)
The minimum value to plot on the X axis.protected abstract double
plotLine(int set, Curve c, double prevlastval, double prevval, double lastx, double x, double linewidth, boolean isLast, java.util.Map m)
Actually plot the line.protected void
postDrawLines()
void
setCurve(java.lang.String name, Curve curve)
Add aCurve
to the graph in the next default color.void
setCurve(java.lang.String name, Curve curve, java.awt.Color color)
Add aCurve
to the graph in the specified color.-
Methods inherited from class org.faceless.graph.AxesGraph
optionAxisStyle, optionBoxColor, optionFloorStyle, optionMaxY, optionMinY, optionXAxisAtZero, optionXAxisLabel, optionXAxisLabelStyle, optionXAxisStyle, optionXAxisTextRotation, optionXFormatter, optionXStretchToZero, optionYAxisAtZero, optionYAxisLabel, optionYAxisLabelStyle, optionYAxisStyle, optionYAxisTextRotation, optionYFormatter, optionYStretchToZero, optionYWallStyle, optionZAxisStyle, optionZFormatter, optionZWallStyle, postcomplete, postpostcomplete, prescalecomplete
-
Methods inherited from class org.faceless.graph.Graph
addElement, complete, getDefaultBorderColor, getFontScale, optionDisplayKey, optionFixedAspectRatio, optionKeyBoxStyle, optionKeyStyle, optionRemoveBackFace, optionSubTitle, optionSubTitleStyle, optionTitle, optionTitleStyle, optionXRotation, optionYRotation, optionZRotation, setDefaultBorderColor, setDefaultColors, setDefaultLineThickness, setFontScale, setLicenseKey, setLightLevel, setLightVector, setPieEdgeDegrees, toCanvas
-
-
-
-
Field Detail
-
minx
protected double minx
The minimum and maximum X and Y values that are being plotted
-
maxx
protected double maxx
The minimum and maximum X and Y values that are being plotted
-
minval
protected double minval
The minimum and maximum X and Y values that are being plotted
-
maxval
protected double maxval
The minimum and maximum X and Y values that are being plotted
-
-
Method Detail
-
setCurve
public void setCurve(java.lang.String name, Curve curve, java.awt.Color color)
Add aCurve
to the graph in the specified color. If a curve with this name already exists it will be replaced.- Parameters:
name
- the name to give this curvecurve
- the curve to addcolor
- the color to plot this curve in
-
setCurve
public void setCurve(java.lang.String name, Curve curve)
Add aCurve
to the graph in the next default color. If a curve with this name already exists it will be replaced.- Parameters:
name
- the name to give this curvecurve
- the curve to add
-
optionMinX
public void optionMinX(double val)
The minimum value to plot on the X axis. This is only a recommendation - if you're plotting one or moreDataCurve
, the actual minimum will be the lesser of this value and the lowest value in the curve. For graphs plotting only one or moreFunctionCurve
, this value is mandatory.Default: data-driven
-
optionMaxX
public void optionMaxX(double val)
The maximum value to plot on the X axis.Default: data-driven
-
optionFunctionSmoothness
public void optionFunctionSmoothness(double val)
If you're plotting aFunctionCurve
, how many steps to divide the curve into. Higher numbers give smoother curves, but slower rendering times.Default: 30
-
optionMaxDataPoints
public void optionMaxDataPoints(int val)
If you're plotting aDataCurve
, the maximum number of values to plot. If your data set has thousands of values, you may set this and drop a few to speed things up (exactly which points are dropped are undefined, but the remaning data is guaranteed to be evenly spread across the graph).Default: 100
-
optionCurveDepth
public void optionCurveDepth(double val)
The depth "into the screen" of a curve. Higher values give thicker curves.Default: 1
-
postDrawLines
protected void postDrawLines()
-
plotLine
protected abstract double plotLine(int set, Curve c, double prevlastval, double prevval, double lastx, double x, double linewidth, boolean isLast, java.util.Map m)
Actually plot the line. This method needs to be filled in by concrete subclasses of this class. This method must handleNaN
and Infinite values. All current subclasses deal with these by skipping those points and leaving a gap in the line.- Parameters:
set
- The number of the set that's being plottedc
- The curve that's being plottedprevlastval
- The value returned by the last X value from the previous set. Set toDouble.NaN
if there was no previous set, or no last X value.prevval
- The value returned by this X value from the previous set. Set toDouble.NaN
if no previous set.lastx
- The last X value passed in. Set toDouble.NaN
if no previous X value exists.x
- The current X value.linewidth
- The width (or rather depth) of the line to be plotted.isLast
- Whether this X value is the last value in the set.m
- A map which can be used by plotLine to pass data between other calls to plotLine. A common use is to set a "start" value if this is the first X value in the set.
-
-