jas.plot
Class TimeAxis

java.lang.Object
  |
  +--jas.plot.AxisType
        |
        +--jas.plot.TimeAxis
All Implemented Interfaces:
CoordinateTransformation, java.io.Externalizable, java.io.Serializable, TimeCoordinateTransformation

public final class TimeAxis
extends AxisType
implements TimeCoordinateTransformation

An axis type for representing times.

Note that this is not the same as dates. A date represents a particular point in time (e.g., when an event took place). This axis represents time values, such as the time between two events. Therefore, while a date value may be represented as "Jan 31, 1994", a time value might be represented as "3 weeks".

See Also:
DateAxis, Serialized Form

Field Summary
static int DAYS
          The integer code for day units.
static int HOURS
          The integer code for hour units.
static int MILLISECONDS
          The integer code for millisecond units.
static int MINUTES
          The integer code for minute units.
static int MONTHS
          The integer code for month units.
static long OMIT
          Set OMIT as the length of a time unit to have that unit not considered as a candidate for axis units.
static int SECONDS
          The integer code for second units.
static int WEEKS
          The integer code for week units.
static int YEARS
          The integer code for year units.
 
Fields inherited from class jas.plot.AxisType
axis
 
Constructor Summary
TimeAxis()
           
 
Method Summary
 double convert(long time)
          Returns a pixel value for a time value.
 long getAxisMax()
          Returns the maximum value on the axis range.
 long getAxisMin()
          Returns the minimum value on the axis range.
 long getDataMax()
          Returns the maximum value on the axis range, as set by the method setMax(long).
 long getDataMin()
          Returns the minimum value on the data range, as set by the method setMin(long).
 long getUnitLength(int unit)
          Returns the number of milliseconds for this unit, or OMIT.
 java.lang.String getUnits()
          Returns a string representation of the units showing on the axis.
 void readExternal(java.io.ObjectInput in)
           
 void setMax(long max)
          Sets the maximum value for the axis data.
 void setMin(long min)
          Sets the minimum value for the axis data.
 void setUnitLength(int unit, long length)
          Allows units to be viewed as valued different from the default.
 void setUseSuggestedRange(boolean useSuggestedRange)
          Sets whether this object should round the minimum down and the maximum up to make labels land exactly on the min and max of the axis range.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class jas.plot.AxisType
getAxis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLISECONDS

public static final int MILLISECONDS
The integer code for millisecond units.

SECONDS

public static final int SECONDS
The integer code for second units.

MINUTES

public static final int MINUTES
The integer code for minute units.

HOURS

public static final int HOURS
The integer code for hour units.

DAYS

public static final int DAYS
The integer code for day units.

WEEKS

public static final int WEEKS
The integer code for week units.

MONTHS

public static final int MONTHS
The integer code for month units.

YEARS

public static final int YEARS
The integer code for year units.

OMIT

public static final long OMIT
Set OMIT as the length of a time unit to have that unit not considered as a candidate for axis units.
Constructor Detail

TimeAxis

public TimeAxis()
Method Detail

setUnitLength

public void setUnitLength(int unit,
                          long length)
Allows units to be viewed as valued different from the default. For example, a year by default is 1000L * 60L * 60L * 24L * 365L milliseconds, but a call such as this may be desirable:
setUnitLength(TimeAxis.YEARS, (long) (1000 * 60 * 60 * 24 * 365.24));

getUnitLength

public long getUnitLength(int unit)
Returns the number of milliseconds for this unit, or OMIT.
See Also:
OMIT

getUnits

public java.lang.String getUnits()
Returns a string representation of the units showing on the axis.

setUseSuggestedRange

public void setUseSuggestedRange(boolean useSuggestedRange)
Sets whether this object should round the minimum down and the maximum up to make labels land exactly on the min and max of the axis range.

setMin

public void setMin(long min)
Sets the minimum value for the axis data.

setMax

public void setMax(long max)
Sets the maximum value for the axis data.

getAxisMin

public long getAxisMin()
Returns the minimum value on the axis range. This value may be smaller than the data minimum if the axis has been told to use the suggested range.
See Also:
setUseSuggestedRange(boolean), setMin(long), getDataMin()

getAxisMax

public long getAxisMax()
Returns the maximum value on the axis range. This value may be larger than the data maximum if the axis has been told to use the suggested range.
See Also:
setUseSuggestedRange(boolean), setMax(long), getDataMax()

getDataMin

public long getDataMin()
Returns the minimum value on the data range, as set by the method setMin(long). This value may be larger than the axis minimum if the axis has been told to use the suggested range.
See Also:
setMin(long), setUseSuggestedRange(boolean), getAxisMin()

getDataMax

public long getDataMax()
Returns the maximum value on the axis range, as set by the method setMax(long). This value may be smaller than the axis maximum if the axis has been told to use the suggested range.
See Also:
setMax(long), setUseSuggestedRange(boolean), getAxisMax()

convert

public double convert(long time)
Description copied from interface: TimeCoordinateTransformation
Returns a pixel value for a time value.
Specified by:
convert in interface TimeCoordinateTransformation

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException