public abstract class Axis extends Object
An Axis is what a Series
is plotted against on an AxesGraph
. There are
up to five Axes on an AxesGraph
, one on the bottom, left, top and right (and the
Z-axis, which is a bit different), and each Series is plotted against two adjacent axes -
bottom and left, top and right and so on.
The Axis itself consists of a "spine", which has several "teeth" coming off it showing it's
scale. These teeth usually have some text next to them, the format of which is controlled
by the format(double)
method, which (along with the steps(double, double)
method) is commonly overridden
by those wanting to create their own subclasses of Axis. The source code to the NumericAxis
and DateAxis
classes is supplied in the "docs" directory of the download
package, which is where to start if you do plan on creating your own subclass.
Modifier and Type | Field and Description |
---|---|
static int |
BOTTOM
A constant which can be passed into
AxesGraph.setAxis to set the bottom axis |
static int |
DENSITY_MINIMAL
A constant used by many subclasses of Axis to control how many teeth are placed
on the graph.
|
static int |
DENSITY_NORMAL
A constant used by many subclasses of Axis to control how many teeth are placed
on the graph.
|
static int |
DENSITY_SPARSE
A constant used by many subclasses of Axis to control how many teeth are placed
on the graph.
|
static int |
LEFT
A constant which can be passed into
AxesGraph.setAxis to set the left axis |
static int |
RIGHT
A constant which can be passed into
AxesGraph.setAxis to set the right axis |
protected Style |
spinestyle |
static int |
TOP
A constant which can be passed into
AxesGraph.setAxis to set the top axis |
static int |
ZAXIS
A constant which can be passed into
AxesGraph.setAxis to set the Z-Axis. |
Modifier | Constructor and Description |
---|---|
protected |
Axis() |
Modifier and Type | Method and Description |
---|---|
abstract String |
format(double in)
Given the specified number, return the text that should be placed against the
tooth at that position.
|
void |
setLabel(String text,
TextStyle style)
Set a label to be displayed next to the axis.
|
void |
setMaxValue(double max)
Set the maximum value to be plotted on the Axis.
|
void |
setMinValue(double min)
Set the minimum value to be plotted on the Axis.
|
void |
setSpineStyle(Style style)
Set the style used to draw the spine of the axis.
|
void |
setToothLength(double toothlength)
Set the length of the teeth that come off the spine of the axis.
|
void |
setToothTextStyle(TextStyle style)
Set the style used to draw the labels on the teeth.
|
void |
setWallPaint(Paint paint)
Set the paint to be used on the wall next to this axis.
|
void |
setWallPaint(Paint[] paints,
Color color,
double[] dash)
Set the paint to be used on the wall next to this axis to a series of stripes.
|
void |
setWallPaint(StripedPaint paint)
Set the paint to be used on the wall to a
StripedPaint |
void |
setZeroIntersection(boolean zero)
Whether this axis should cross it's adjacent axis where that axis is zero.
|
abstract double[] |
steps(double min,
double max)
The
steps method controls where the teeth are placed on the spine. |
String |
toString() |
public static final int DENSITY_NORMAL
public static final int DENSITY_SPARSE
public static final int DENSITY_MINIMAL
public static final int LEFT
AxesGraph.setAxis
to set the left axispublic static final int RIGHT
AxesGraph.setAxis
to set the right axispublic static final int BOTTOM
AxesGraph.setAxis
to set the bottom axispublic static final int TOP
AxesGraph.setAxis
to set the top axispublic static final int ZAXIS
AxesGraph.setAxis
to set the Z-Axis.protected Style spinestyle
public void setZeroIntersection(boolean zero)
zero
- whether to cross the adjacent axis at zero. The default is falsepublic void setSpineStyle(Style style)
style
- the style to draw the spine and teeth in - the default is a solid black line.public void setToothLength(double toothlength)
toothlength
- the length of the teeth as a proportion of the width of the graph. The default is 0.01public void setToothTextStyle(TextStyle style)
setPadding...
methods can be used to increase the space between the teeth and their text,
and the TextStyle.setAlign(int)
method used to control the position of the
text relative to the teeth.style
- the style to display the teeth labels in.public void setWallPaint(Paint paint)
X-Rotation
or Y-Rotation
these walls would be invisible.paint
- the Paint to use on the wall running into the graph from
this axis, or null
to not paint the wallAxesGraph.setBackWallPaint(Paint)
public void setWallPaint(Paint[] paints, Color color, double[] dash)
setWallPaint(Paint)
method, but
can be used to draw stripes on the wall.paints
- an Array of Paint
objects which will be used to paint the wallcolor
- the color of the line to seperate the stripes, or null
for no linedash
- an array of doubles specifying the dashing pattern for the line, or null
if no line is drawn (or if it's not to be dashed)AxesGraph.setBackWallPaint(Paint[]...)
public void setWallPaint(StripedPaint paint)
StripedPaint
public abstract double[] steps(double min, double max)
The steps
method controls where the teeth are placed on the spine.
Each subclass of Axis has a different strategy - for instance, the
DateAxis
will try and place ticks on the 1st of the month, the
NumericAxis
will try and place them evenly across the range and so on.
The returned array should consist of a range of numbers, ordered from low to high,
which mark the locations of the teeth on the spine. min
and max
are the minimum and maximum values of the data to plot, and these values will usually
be the first and last values in the returned array.
Those wanting to create their own custom axis will typically override this method and
format(double)
.
min
- the minimum value of the data to plotmax
- the maximum value of the data to plotpublic abstract String format(double in)
Given the specified number, return the text that should be placed against the
tooth at that position. For example, an Axis that simply plotted integer
values might return Integer.toString((int)in)
Those wanting to create their own custom axis will typically override this
method and steps(double, double)
.
in
- the value to formatpublic void setLabel(String text, TextStyle style)
TextStyle.setPaddingBottom(double)
and TextStyle.setPaddingTop(double)
settings
of the style to control the distance between the label and the axis.text
- the text to displaystyle
- the style to draw the text inpublic void setMinValue(double min)
setMaxValue(double)
this value will be expanded if required to fit the values
from the various series.min
- the minimum value to plot on this axispublic void setMaxValue(double max)
max
- the maximum value to plot on this axisCopyright © 2001-2016 Big Faceless Organization