Package uk.ac.starlink.ttools.plot
Class AxisLabels
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.AxisLabels
-
public class AxisLabels extends java.lang.ObjectContains labels for an axis. The instance methods of this class don't do anything clever, but factory methods are provided which can perform sensible axis labelling.- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description AxisLabels(double[] ticks, java.lang.String[] labels)Sets up a new AxisLabels.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCount()Returns the number of ticks on the axis.java.lang.StringgetLabel(int itick)Returns the label for one of the tick marks.doublegetTick(int itick)Returns the axis position of one of the tick marks.static AxisLabelslabelLinearAxis(double lo, double hi, int approxTicks)Sets up axis labels for a linearly scaled axis.static AxisLabelslabelLogAxis(double lo, double hi, int approxTicks)Sets up axis labels for a logarithmically scaled axis.static voidmain(java.lang.String[] args)java.lang.StringtoString()
-
-
-
Method Detail
-
getCount
public int getCount()
Returns the number of ticks on the axis.- Returns:
- tick count
-
getTick
public double getTick(int itick)
Returns the axis position of one of the tick marks.- Parameters:
itick- index of the tick- Returns:
- tick value
-
getLabel
public java.lang.String getLabel(int itick)
Returns the label for one of the tick marks. This is essentially a stringification ofgetTick(itick), but some attempt may be made to make the representation compact and tidy.- Parameters:
itick- index of the tick- Returns:
- tick label
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
labelLinearAxis
public static AxisLabels labelLinearAxis(double lo, double hi, int approxTicks)
Sets up axis labels for a linearly scaled axis.- Parameters:
lo- lower bound of the axishi- upper bound of the axisapproxTicks- the approximate number of ticks you'd like to see
-
labelLogAxis
public static AxisLabels labelLogAxis(double lo, double hi, int approxTicks)
Sets up axis labels for a logarithmically scaled axis.- Parameters:
lo- lower bound of axishi- upper bound of axisapproxTicks- the approximate number of ticks you'd like to see
-
main
public static void main(java.lang.String[] args)
-
-