Package org.jfree.chart.axis
Class DateTickUnit
java.lang.Object
org.jfree.chart.axis.TickUnit
org.jfree.chart.axis.DateTickUnit
- All Implemented Interfaces:
Serializable,Comparable
public class DateTickUnit extends TickUnit implements Serializable
A tick unit for use by subclasses of
DateAxis.
Instances of this class are immutable.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static intDAYA constant for days.static intHOURA constant for hours.static intMILLISECONDA constant for milliseconds.static intMINUTEA constant for minutes.static intMONTHA constant for months.static intSECONDA constant for seconds.static intYEARA constant for years. -
Constructor Summary
Constructors Constructor Description DateTickUnit(int unit, int count)Creates a new date tick unit.DateTickUnit(int unit, int count, int rollUnit, int rollCount, DateFormat formatter)Creates a new unit.DateTickUnit(int unit, int count, DateFormat formatter)Creates a new date tick unit. -
Method Summary
Modifier and Type Method Description DateaddToDate(Date base)Calculates a new date by adding this unit to the base date.StringdateToString(Date date)Formats a date using the tick unit's formatter.booleanequals(Object obj)Tests this unit for equality with another object.intgetCalendarField()Returns a field code that can be used with theCalendarclass.intgetCount()Returns the unit count.intgetRollCount()Returns the roll count.intgetRollUnit()Returns the roll unit.intgetUnit()Returns the date unit.DaterollDate(Date base)Rolls the date forward by the amount specified by the roll unit and count.StringvalueToString(double milliseconds)Formats a value.
-
Field Details
-
YEAR
public static final int YEARA constant for years.- See Also:
- Constant Field Values
-
MONTH
public static final int MONTHA constant for months.- See Also:
- Constant Field Values
-
DAY
public static final int DAYA constant for days.- See Also:
- Constant Field Values
-
HOUR
public static final int HOURA constant for hours.- See Also:
- Constant Field Values
-
MINUTE
public static final int MINUTEA constant for minutes.- See Also:
- Constant Field Values
-
SECOND
public static final int SECONDA constant for seconds.- See Also:
- Constant Field Values
-
MILLISECOND
public static final int MILLISECONDA constant for milliseconds.- See Also:
- Constant Field Values
-
-
Constructor Details
-
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
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 (defaults to DateFormat.SHORT).
-
DateTickUnit
Creates a new unit.- Parameters:
unit- the unit.count- the count.rollUnit- the roll unit.rollCount- the roll count.formatter- the date formatter (defaults to DateFormat.SHORT).
-
-
Method Details
-
getUnit
public int getUnit()Returns the date unit. This will be one of the constantsYEAR,MONTH,DAY,HOUR,MINUTE,SECONDorMILLISECOND, defined by this class. Note that these constants do NOT correspond to those defined in Java'sCalendarclass.- Returns:
- the date unit.
-
getCount
public int getCount()Returns the unit count.- Returns:
- the unit count.
-
getRollUnit
public int getRollUnit()Returns the roll unit. This is the amount by which the tick advances if it is "hidden" when displayed on a segmented date axis. Typically the roll will be smaller than the regular tick unit (for example, a 7 day tick unit might use a 1 day roll).- Returns:
- the roll unit.
-
getRollCount
public int getRollCount()Returns the roll count.- Returns:
- the roll count.
-
valueToString
Formats a value.- Overrides:
valueToStringin classTickUnit- Parameters:
milliseconds- date in milliseconds since 01-01-1970.- Returns:
- the formatted date.
-
dateToString
Formats a date using the tick unit's formatter.- Parameters:
date- the date.- Returns:
- the formatted date.
-
addToDate
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.
-
rollDate
Rolls the date forward by the amount specified by the roll unit and count.- Parameters:
base- the base date.- Returns:
- the rolled date.
-
getCalendarField
public int getCalendarField()Returns a field code that can be used with theCalendarclass.- Returns:
- the field code.
-
equals
Tests this unit for equality with another object.
-