uk.ac.starlink.ttools.plot
Class AxisLabels

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.AxisLabels

public class AxisLabels
extends Object

Contains 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
AxisLabels(double[] ticks, String[] labels)
          Sets up a new AxisLabels.
 
Method Summary
 int getCount()
          Returns the number of ticks on the axis.
 String getLabel(int itick)
          Returns the label for one of the tick marks.
 double getTick(int itick)
          Returns the axis position of one of the tick marks.
static AxisLabels labelLinearAxis(double lo, double hi, int approxTicks)
          Sets up axis labels for a linearly scaled axis.
static AxisLabels labelLogAxis(double lo, double hi, int approxTicks)
          Sets up axis labels for a logarithmically scaled axis.
static void main(String[] args)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AxisLabels

public AxisLabels(double[] ticks,
                  String[] labels)
Sets up a new AxisLabels.

Parameters:
ticks - numeric values of the ticks
labels - string values for each of the elements of ticks
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 String getLabel(int itick)
Returns the label for one of the tick marks. This is essentially a stringification of getTick(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 String toString()
Overrides:
toString in class 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 axis
hi - upper bound of the axis
approxTicks - 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 axis
hi - upper bound of axis
approxTicks - the approximate number of ticks you'd like to see

main

public static void main(String[] args)


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.