jas.plot
Class StringAxis
java.lang.Object
|
+--jas.plot.AxisType
|
+--jas.plot.StringAxis
- All Implemented Interfaces:
- CoordinateTransformation, java.io.Externalizable, java.io.Serializable, StringCoordinateTransformation
- public final class StringAxis
- extends AxisType
- implements StringCoordinateTransformation
This class simply displays a given array of strings. Use for a histogram with a string
partition, or if there are very specific labels (numeric or other) you want on the axis.
This class displays strings in two formats, represented by two static constants:
CENTER_TEXT_IN_DIVISION
: a tick mark and label will be centered in a division
TEXT_BESIDE_DIVISION
: a tick mark and label will be on either side of a division
Use the method setLabelPlacementStyle(int)
to change the setting.
Labels are displayed in the order as they appear in the array given to the method
setLabels(String[])
from left to right on a horizontal axis and from bottom to top
on a vertical axis.
- See Also:
CENTER_TEXT_IN_DIVISION
,
TEXT_BESIDE_DIVISION
,
setLabelPlacementStyle(int)
,
setLabels(String[])
, Serialized Form
Field Summary |
static int |
CENTER_TEXT_IN_DIVISION
Represents a display style where a tick and label are centered in a division. |
static int |
TEXT_BESIDE_DIVISION
Represents a display style where a tick and label are on either side of a division. |
Constructor Summary |
StringAxis()
Creates a new string axis type object, with labels and ticks centered in a division. |
StringAxis(int labelPlacementStyle)
Creates a new string axis type object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CENTER_TEXT_IN_DIVISION
public static final int CENTER_TEXT_IN_DIVISION
- Represents a display style where a tick and label are centered in a division.
TEXT_BESIDE_DIVISION
public static final int TEXT_BESIDE_DIVISION
- Represents a display style where a tick and label are on either side of a division.
StringAxis
public StringAxis()
- Creates a new string axis type object, with labels and ticks centered in a division.
- See Also:
CENTER_TEXT_IN_DIVISION
StringAxis
public StringAxis(int labelPlacementStyle)
- Creates a new string axis type object.
- Parameters:
labelPlacementStyle
- how to place labels (supply either CENTER_TEXT_IN_DIVISION
or
TEXT_BESIDE_DIVISION
)- See Also:
CENTER_TEXT_IN_DIVISION
,
TEXT_BESIDE_DIVISION
setLabelPlacementStyle
public void setLabelPlacementStyle(int labelPlacementStyle)
- Sets the label placement style. Supply either
CENTER_TEXT_IN_DIVISION
or
TEXT_BESIDE_DIVISION
.
- See Also:
CENTER_TEXT_IN_DIVISION
,
TEXT_BESIDE_DIVISION
getLabelPlacementStyle
public int getLabelPlacementStyle()
- Returns the label placement style: either
CENTER_TEXT_IN_DIVISION
or
TEXT_BESIDE_DIVISION
.
- See Also:
CENTER_TEXT_IN_DIVISION
,
TEXT_BESIDE_DIVISION
setLabels
public void setLabels(java.lang.String[] labels)
- Sets the labels to display.
getLabels
public java.lang.String[] getLabels()
- Returns the labels used for this axis.
convert
public double convert(java.lang.String s)
- Specified by:
convert
in interface StringCoordinateTransformation
binWidth
public double binWidth()
- Specified by:
binWidth
in interface StringCoordinateTransformation
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException