Package org.faceless.graph
Class FloatingBarGraph
- java.lang.Object
-
- org.faceless.graph.Graph
-
- org.faceless.graph.AxesGraph
-
- org.faceless.graph.AbstractBarGraph
-
- org.faceless.graph.FloatingBarGraph
-
public class FloatingBarGraph extends AbstractBarGraph
A type of Bar graph where the bars float above the axis. It's used to show a range of values, with the average, median or some other value in the middle. The graph only extends along the X axis (i.e. it has no depth).
There are two datasets defined, called
MIN
andMAX
(for the bottom and top parts of the bar). You can change the colors of these sets withsetColor("MIN", color)
Here's an example showing a simple
FloatingBarGraph
.import org.faceless.graph.output.ImageOutput; import java.awt.Color; // Create a new Floating Bar Graph and // set the color of the bars. // FloatingBarGraph g = new FloatingBarGraph(); g.optionTitle("My First Floating Bar Graph"); g.setColor("MIN", Color.yellow); g.setColor("MAX", Color.green); // Add some bars to the graph. The averages // in this example aren't very useful... // g.set("Cabbages", 10, (10+18)/2, 18); g.set("Cauliflower", 12, (12+19)/2, 19); g.set("Courgettes", 11, (11+15)/2, 15); // Render to an image that's 400x400 // ImageOutput out = new ImageOutput(400,400); out.render(g);
-
-
Field Summary
-
Fields inherited from class org.faceless.graph.AbstractBarGraph
bardepth, barwidth, displayvalue, DISPLAYVALUE_INSIDETOP, DISPLAYVALUE_MIDDLE, DISPLAYVALUE_NONE, DISPLAYVALUE_TOP, maxv, maxx, maxz, minv, minx, minz, roundbars, xkey, ykey, zkey
-
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 FloatingBarGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
plotBar(int ix, int iy, int iz, double maxval)
Needs to be completed by concrete subclasses of this class.void
set(java.lang.String xset, double min, double center, double max)
Add a bar with the specified bottom, middle and top values.void
setColor(java.lang.String name, java.awt.Paint color)
Set the color of a dataset.-
Methods inherited from class org.faceless.graph.AbstractBarGraph
complete, getBoxElement, optionBarDepth, optionBarWidth, optionDisplayValue, optionRoundBars, optionXStretchToZero, optionYStretchToZero, plotBarValue, postcomplete, prescalecomplete
-
Methods inherited from class org.faceless.graph.AxesGraph
optionAxisStyle, optionBoxColor, optionFloorStyle, optionMaxY, optionMinY, optionXAxisAtZero, optionXAxisLabel, optionXAxisLabelStyle, optionXAxisStyle, optionXAxisTextRotation, optionXFormatter, optionYAxisAtZero, optionYAxisLabel, optionYAxisLabelStyle, optionYAxisStyle, optionYAxisTextRotation, optionYFormatter, optionYWallStyle, optionZAxisStyle, optionZFormatter, optionZWallStyle, postpostcomplete
-
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
-
set
public void set(java.lang.String xset, double min, double center, double max)
Add a bar with the specified bottom, middle and top values.- Parameters:
xset
- The data set on the X axis. If it doesn't exist, it's created.min
- The Y axis value for the bottom of the barcenter
- The value at which to end the bottom half and start the top half of the barmax
- The Y axis value for the top of the bar- Throws:
java.lang.IllegalArgumentException
- If paramaters min, max or center are infite.
-
setColor
public void setColor(java.lang.String name, java.awt.Paint color)
Set the color of a dataset. The set must be either MIN or MAX, otherwise anIllegalArgumentException
is thrown.- Parameters:
name
- the name of the dataset, either MIN or MAXcolor
- the color to set this dataset to.
-
plotBar
protected void plotBar(int ix, int iy, int iz, double maxval)
Description copied from class:AbstractBarGraph
Needs to be completed by concrete subclasses of this class.- Specified by:
plotBar
in classAbstractBarGraph
- Parameters:
ix
- The X position of this valueiy
- The Y position of this valueiz
- The Z position of this valuemaxval
- The value to plot.
-
-