edu.mines.jtk.util
Class AxisTics

java.lang.Object
  extended by edu.mines.jtk.util.AxisTics

public class AxisTics
extends java.lang.Object

Tics for annotating an axis. Given values at the endpoints of the axis, axes tics are constructed by computing parameters for both major and minor tics. Major tics are a subset of minor tics. Typically, major tics are labeled with character strings that represent their values.

Axes tics can be constructed in two ways, by specifying either (1) the interval between major tics or (2) the maximum number of major tics.

In the first case, when the major tic interval (a positive number) is specified, other tic parameters are easily computed. For example, the value of the first major tic equals the smallest multiple of the major tic interval that is not less than the minimum of the axis endpoint values. Likewise, the number of major tics is computed so that the value of the last major tic is not greater than the maximum of the axis endpoint values.

In the second case, when the maximum number of major tics is specified, the major tic interval is computed to be 2, 5, or 10 times some power of 10. Then, other tic parameters are computed as in the first case. The tricky part in this second case is choosing the best number from the set {2,5,10}. That best number is called the tic multiple, and is computed so that the number of major tics is close to, but not greater than, the specified maximum number of major tics.

After construction, the counts, increments, and first values of both major and minor tics are available.

Version:
2004.12.14
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
AxisTics(double x1, double x2, double dtic)
          Constructs axis tics for a specified major tic interval.
AxisTics(double x1, double x2, int ntic)
          Constructs axis tics for a specified maximum number of major tics.
 
Method Summary
 int getCountMajor()
          Gets the number of major tics.
 int getCountMinor()
          Gets the number of minor tics.
 double getDeltaMajor()
          Gets major tic interval.
 double getDeltaMinor()
          Gets minor tic interval.
 double getFirstMajor()
          Gets the value of the first major tic.
 double getFirstMinor()
          Gets the value of the first minor tic.
 int getMultiple()
          Gets the tic multiple.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AxisTics

public AxisTics(double x1,
                double x2,
                double dtic)
Constructs axis tics for a specified major tic interval.

Parameters:
x1 - the value at one end of the axis.
x2 - the value at the other end of the axis.
dtic - the major tic interval; a positive number.

AxisTics

public AxisTics(double x1,
                double x2,
                int ntic)
Constructs axis tics for a specified maximum number of major tics.

Parameters:
x1 - the value at one end of the axis.
x2 - the value at the other end of the axis.
ntic - the maximum number of major tics.
Method Detail

getCountMajor

public int getCountMajor()
Gets the number of major tics.

Returns:
the number of major tics.

getDeltaMajor

public double getDeltaMajor()
Gets major tic interval.

Returns:
the major tic interval.

getFirstMajor

public double getFirstMajor()
Gets the value of the first major tic.

Returns:
the value of the first major tic.

getCountMinor

public int getCountMinor()
Gets the number of minor tics.

Returns:
the number of minor tics.

getDeltaMinor

public double getDeltaMinor()
Gets minor tic interval.

Returns:
the minor tic interval.

getFirstMinor

public double getFirstMinor()
Gets the value of the first minor tic.

Returns:
the value of the first minor tic.

getMultiple

public int getMultiple()
Gets the tic multiple. The tic multiple is the number of (major and minor) tics per major tic, except near the ends of the axis. Between any pair of major tics there are multiple-1 minor tics.

Returns:
the tic multiple.