com.jrefinery.chart
Class DateTickUnit

java.lang.Object
  |
  +--com.jrefinery.chart.TickUnit
        |
        +--com.jrefinery.chart.DateTickUnit
All Implemented Interfaces:
java.lang.Comparable

public class DateTickUnit
extends TickUnit

Represents a tick unit for a date axis.

Author:
DG

Field Summary
static int DAY
          A constant for days.
static int HOUR
          A constant for hours.
static int MILLISECOND
          A constant for milliseconds.
static int MINUTE
          A constant for minutes.
static int MONTH
          A constant for months.
static int SECOND
          A constant for seconds.
static int YEAR
          A constant for years.
 
Constructor Summary
DateTickUnit(int unit, int count)
          Creates a new date tick unit.
DateTickUnit(int unit, int count, java.text.DateFormat formatter)
          Creates a new date tick unit.
 
Method Summary
 java.util.Date addToDate(java.util.Date base)
          Calculates a new date by adding this unit to the base date.
 java.lang.String dateToString(java.util.Date date)
          Formats a date.
 int getCalendarField()
          Returns a field code that can be used with the Calendar class.
 int getCount()
          Returns the unit count.
 int getUnit()
          Returns the date unit.
 java.lang.String valueToString(double milliseconds)
          Formats a value.
 
Methods inherited from class com.jrefinery.chart.TickUnit
compareTo, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YEAR

public static final int YEAR
A constant for years.

MONTH

public static final int MONTH
A constant for months.

DAY

public static final int DAY
A constant for days.

HOUR

public static final int HOUR
A constant for hours.

MINUTE

public static final int MINUTE
A constant for minutes.

SECOND

public static final int SECOND
A constant for seconds.

MILLISECOND

public static final int MILLISECOND
A constant for milliseconds.
Constructor Detail

DateTickUnit

public DateTickUnit(int unit,
                    int count)
Creates a new date tick unit. The dates will be formatted using a SHORT format for the default locale.
Parameters:
unit - the unit.
count - the unit count.

DateTickUnit

public DateTickUnit(int unit,
                    int count,
                    java.text.DateFormat formatter)
Creates a new date tick unit.

You can specify the units using one of the constants YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or MILLISECOND. In addition, you can specify a unit count, and a date format.

Parameters:
unit - the unit.
count - the unit count.
formatter - the date formatter.
Method Detail

getUnit

public int getUnit()
Returns the date unit. This will be one of the constants YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or MILLISECOND (defined by this class).
Returns:
the date unit.

getCount

public int getCount()
Returns the unit count.
Returns:
the unit count.

valueToString

public java.lang.String valueToString(double milliseconds)
Formats a value.
Overrides:
valueToString in class TickUnit
Parameters:
milliseconds - date in milliseconds since 01-01-1970.
Returns:
the formatted date.

dateToString

public java.lang.String dateToString(java.util.Date date)
Formats a date.
Parameters:
date - the date.
Returns:
the formatted date.

addToDate

public java.util.Date addToDate(java.util.Date base)
Calculates a new date by adding this unit to the base date.
Parameters:
base - the base date.
Returns:
a new date one unit after the base date.

getCalendarField

public int getCalendarField()
Returns a field code that can be used with the Calendar class.
Returns:
the field code.