org.faceless.graph2
Class AxesGraph

java.lang.Object
  extended by org.faceless.graph2.Graph
      extended by org.faceless.graph2.AxesGraph

public class AxesGraph
extends Graph

The AxesGraph class represents any type of graph that's plotted against an axis - bar graphs, line graphs and so on.

An AxesGraph is made up of several components.

For example, to plot a very simple BarGraph you could do the following:

  AxesGraph graph = new AxesGraph();
  BarSeries series = new BarSeries("Fruit");
  series.set("Apples", 20);
  series.set("Oranges", 30);
  series.set("Bananas", 15);
  graph.addSeries(series);
 

See Also:
BarSeries, LineSeries, NumericAxis, Graph

Field Summary
static int BOTTOMLEFT
          Constant used by the addSeries method to plot the series against the bottom and left axes.
static int BOTTOMRIGHT
          Constant used by the addSeries method to plot the series against the bottom and right axes.
static int TOPLEFT
          Constant used by the addSeries method to plot the series against the top and left axes.
static int TOPRIGHT
          Constant used by the addSeries method to plot the series against the top and right axes.
 
Fields inherited from class org.faceless.graph2.Graph
VERSION
 
Constructor Summary
AxesGraph()
          Create a new AxesGraph
 
Method Summary
 void addSeries(Series series)
          Add a series to this Graph, plotted against the bottom and left axes.
 void addSeries(Series series, int pos)
          Add a series to this Graph, plotted against the specified axes.
 Axis getAxis(int pos)
           Get the axis that's currently in the specified position on the graph.
 Series getSeries(String name)
          Return the series with the specified name from this AxesGraph, or null if no such series has been added yet
 void setAxis(int pos, Axis axis)
          Set the specified axis.
 void setBackWallPaint(Paint paint)
          Set the paint to use on the back wall.
 void setBackWallPaint(Paint[] paints, Color stripe, int axis, int alt, double[] dash)
           Set the paint to use on the back wall to a series of stripes.
 void setHorizontalScale(double b1, double t1, double b2, double t2)
          Change the scaling ratio for the horizontal axes.
 void setVerticalScale(double l1, double r1, double l2, double r2)
          Change the scaling ratio for the vertical axes.
 
Methods inherited from class org.faceless.graph2.Graph
addKey, addKey, addText, draw, interrupt, isInterrupted, setAutoColors, setColorOrdering, setDefaultColors, setFixedAspectRatio, setFixedSize, setLicenseKey, setLightLevel, setLightVector, setMetaData, setXRotation, setYRotation, setZRotation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOTTOMLEFT

public static final int BOTTOMLEFT
Constant used by the addSeries method to plot the series against the bottom and left axes.

See Also:
Constant Field Values

BOTTOMRIGHT

public static final int BOTTOMRIGHT
Constant used by the addSeries method to plot the series against the bottom and right axes.

See Also:
Constant Field Values

TOPLEFT

public static final int TOPLEFT
Constant used by the addSeries method to plot the series against the top and left axes.

See Also:
Constant Field Values

TOPRIGHT

public static final int TOPRIGHT
Constant used by the addSeries method to plot the series against the top and right axes.

See Also:
Constant Field Values
Constructor Detail

AxesGraph

public AxesGraph()
Create a new AxesGraph

Method Detail

addSeries

public void addSeries(Series series)
Add a series to this Graph, plotted against the bottom and left axes.

Parameters:
series - the Series to add to the graph
Throws:
IllegalArgumentException - if the series has already been added

addSeries

public void addSeries(Series series,
                      int pos)
Add a series to this Graph, plotted against the specified axes.

Parameters:
series - the Series to add to the graph
pos - the axes to plot the series against. One of BOTTOMLEFT, BOTTOMRIGHT, TOPLEFT or TOPRIGHT.
Throws:
IllegalArgumentException - if the series has already been added

getSeries

public Series getSeries(String name)
Return the series with the specified name from this AxesGraph, or null if no such series has been added yet

Parameters:
name - the name of the series to return
Returns:
the specified Series, or null if it doesn't exist in this Graph

setAxis

public void setAxis(int pos,
                    Axis axis)
Set the specified axis. The default Axis is usually a plain NumericAxis, but this method can be used to override this to plot dates, currencies and so on. The "Z" axis can be useful when graphs are displayed in 3D - it can be set to a ZAxis object to show the names of each Series plotted on the graph

Parameters:
pos - which axis to set - one of Axis.LEFT, Axis.TOP, Axis.RIGHT Axis.BOTTOM or Axis.ZAXIS
axis - the axis to use
Throws:
IllegalArgumentException - if the specified Axis has already been used elsewhere
See Also:
getAxis(int)

getAxis

public Axis getAxis(int pos)

Get the axis that's currently in the specified position on the graph. If you've already called setAxis to set it, then that's the one that's returned. If one hasn't been set, a default axis is used - this will be a NullAxis if no series have been plotted against this axis, a NumericAxis if a series has been plotted, or in the case of the X-axis of a BarSeries, a BarAxis is returned.

Because the returned axis may change depending on which Series have been added to the graph, it's recommended that this method is called after all the Series have been added.

Parameters:
pos - which axis to get - one of Axis.LEFT, Axis.TOP, Axis.RIGHT Axis.BOTTOM or Axis.ZAXIS
Returns:
the Axis currently in use on the specified side of the Graph
See Also:
setAxis(int, org.faceless.graph2.Axis)

setBackWallPaint

public void setBackWallPaint(Paint paint)
Set the paint to use on the back wall. This method is intended for simple paints - for stripes, see the setBackWallPaint(Paint[], Color, int, int, double[]) method.

Parameters:
paint - the paint to use on the back wall, or null to not paint the back wall
See Also:
Axis.setWallPaint(java.awt.Paint)

setBackWallPaint

public void setBackWallPaint(Paint[] paints,
                             Color stripe,
                             int axis,
                             int alt,
                             double[] dash)

Set the paint to use on the back wall to a series of stripes. The stripes will be painted in the colors specified by paints, and if stripe is not null the stripes will be separated by lines of that color. The stripes will be aligned with the Axis specified by axis, and if alt is not 0, lines will also be drawn matching that axis (which must be perpendicular to axis).

Some examples to clarify: To draw horizontal stripes in blue and green:

 setBackWallPaint(new Paint[] { Color.blue, Color.green }, null, Axis.LEFT, 0, null);
 

To draw a grid of gray lines with no fill color

 setBackWallPaint(null, Color.gray, Axis.LEFT, Axis.BOTTOM, null);
 

Parameters:
paints - the colors to use to paint the background - may be null for no paint, or an array of one or more Paint objects which will be used to stripe the wall
stripe - the color to use to draw lines between the stripes, or null for no stripes
axis - The axis to align the stripes to. One of Axis.LEFT, Axis.RIGHT, Axis.TOP or Axis.BOTTOM
alt - The alternate axis to use when drawing a grid. If axis is Axis.LEFT or Axis.RIGHT, must be Axis.TOP or Axis.BOTTOM, and vice versa. If no grid is required this value may be -1.
dash - The dash pattern to use to draw the stripe - specified the same way as Style.setLineDash(double[]). If no stripe is to be drawn (or if it's not going to be dashed) this may be null.

setHorizontalScale

public void setHorizontalScale(double b1,
                               double t1,
                               double b2,
                               double t2)
Change the scaling ratio for the horizontal axes. When plotting different Series against the top and bottom axes, the library needs to work out how the two axes are scaled against eachother. This method allows the user to specify to "control points" on each axis which are aligned against eachother - one to the left, and one to the right. From these two points the two axes can be scaled.

Parameters:
b1 - first value on the bottom axis (aligned with t1)
t1 - first value on the top axis (aligned with b1)
b2 - second value on the bottom axis (aligned with t2)
t2 - second value on the top axis (aligned with b2)
Throws:
IllegalArgumentException - if b1<=b2 and t1>=t2
See Also:
setVerticalScale(double, double, double, double)

setVerticalScale

public void setVerticalScale(double l1,
                             double r1,
                             double l2,
                             double r2)
Change the scaling ratio for the vertical axes. When plotting series against the left and right axes, the library needs to work out how the two axes are scaled against eachother. This method allows the user to specify to "control points" on each axis which are aligned against eachother - one near the bottom, and one near the top. From these two points the two axes can be scaled.

Parameters:
l1 - first value on the left axis (aligned with r1)
r1 - first value on the right axis (aligned with l1)
l2 - second value on the left axis (aligned with r2)
r2 - second value on the right axis (aligned with r2)
Throws:
IllegalArgumentException - if l1<=l2 and r1>=r2
See Also:
setHorizontalScale(double, double, double, double)


Copyright © 2001-2011 Big Faceless Organization