Package org.faceless.graph
Class AreaGraph
- java.lang.Object
-
- org.faceless.graph.Graph
-
- org.faceless.graph.AxesGraph
-
- org.faceless.graph.AbstractLineGraph
-
- org.faceless.graph.AreaGraph
-
public class AreaGraph extends AbstractLineGraph
Plot a Line graph that has the area below the line filled in. Usually used to show individual components of a curve - for example, if you were graphing Overall Fruit Consumption over time, you could use an AreaGraph to break this down into different types of fruit. Because the area below the line is filled in, this type of graph is generally only used to show cumulative data.
Here's a contrived example, which if nothing else shows how
AreaGraph
s are used to show accumulation. The values in the curves will be totalled automatically (unless we had set the Cumulative optionimport org.faceless.graph.*; import org.faceless.graph.math.*; // Create a "curve", showing the numbers from 1 to 5 // DataCurve c = new DataCurve(); c.set(1,1); c.set(2,2); c.set(3,3); c.set(4,4); c.set(5,5); AreaGraph g = new AreaGraph(); g.addCurve("First Number", c); g.addCurve("Second Number", c); // use the same curve twice g.optionTitle("Shows the sum of two numbers"); ImageOutput out = new ImageOutput(400,400, g); out.render(g);
-
-
Field Summary
-
Fields inherited from class org.faceless.graph.AbstractLineGraph
maxval, maxx, minval, minx
-
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 Constructor Description AreaGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
complete()
Complete is the first method that's called by a Graph when it's rendered.void
optionCumulative(boolean val)
If this is set to true, the AreaGraph adds the values of the separate curves together to form a total.void
optionSegments(boolean val)
Whether to draw the Area Graph with segments, so that points defined in the data can easily be recognised.protected 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.-
Methods inherited from class org.faceless.graph.AbstractLineGraph
optionCurveDepth, optionFunctionSmoothness, optionMaxDataPoints, optionMaxX, optionMinX, postDrawLines, setCurve, setCurve
-
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, getDefaultBorderColor, getFontScale, optionDisplayKey, optionFixedAspectRatio, optionKeyBoxStyle, optionKeyStyle, optionRemoveBackFace, optionSubTitle, optionSubTitleStyle, optionTitle, optionTitleStyle, optionXRotation, optionYRotation, optionZRotation, setDefaultBorderColor, setDefaultColors, setDefaultLineThickness, setFontScale, setLicenseKey, setLightLevel, setLightVector, setPieEdgeDegrees, toCanvas
-
-
-
-
Method Detail
-
optionCumulative
public void optionCumulative(boolean val)
If this is set to true, the AreaGraph adds the values of the separate curves together to form a total. So if the first curve returned a value of 2 and the second curve returned a value of 3, the second curve would actually be plotted at 5. If your data is already accumulated, set this to false.Default: true
-
optionSegments
public void optionSegments(boolean val)
Whether to draw the Area Graph with segments, so that points defined in the data can easily be recognised.Default: true
-
complete
protected void complete()
Description copied from class:Graph
Complete is the first method that's called by a Graph when it's rendered. It should take the data from the dataset and add the various elements that it needs to the Graph. The first thing it should do, however, is callsuper.complete()
.
-
plotLine
protected double plotLine(int set, Curve c, double prevlastval, double prevval, double lastx, double x, double linewidth, boolean isLast, java.util.Map m)
Description copied from class:AbstractLineGraph
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.- Specified by:
plotLine
in classAbstractLineGraph
- 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.
-
-