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
A tick unit for use by subclasses of
DateAxis
. Instances of this
class are immutable.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The unit count.static final int
Deprecated.private DateFormat
The date formatter.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead.private int
The roll count.private int
Deprecated.As of version 1.0.13, use the rollUnitType field.private DateTickUnitType
The roll unit type.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead.private static final long
For serialization.private int
Deprecated.As of version 1.0.13, use the unitType field.private DateTickUnitType
The units.static final int
Deprecated.As of version 1.0.13, useDateTickUnitType
instead. -
Constructor Summary
ConstructorsConstructorDescriptionDateTickUnit
(int unit, int count) Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int)
.DateTickUnit
(int unit, int count, int rollUnit, int rollCount, DateFormat formatter) Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int, DateTickUnitType, int, DateFormat)
.DateTickUnit
(int unit, int count, DateFormat formatter) Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int, DateFormat)
.DateTickUnit
(DateTickUnitType unitType, int multiple) Creates a new date tick unit.DateTickUnit
(DateTickUnitType unitType, int multiple, DateFormat formatter) Creates a new date tick unit.DateTickUnit
(DateTickUnitType unitType, int multiple, DateTickUnitType rollUnitType, int rollMultiple, DateFormat formatter) Creates a new unit. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.As of JFreeChart 1.0.10, this method is deprecated - you should useaddToDate(Date, TimeZone)
instead.Calculates a new date by adding this unit to the base date.dateToString
(Date date) Formats a date using the tick unit's formatter.boolean
Tests this unit for equality with another object.int
Returns a field code that can be used with theCalendar
class.int
getCount()
Deprecated.As of version 1.0.13, usegetMultiple()
.private static long
getMillisecondCount
(DateTickUnitType unit, int count) Returns the (approximate) number of milliseconds for the given unit and unit count.int
Returns the unit multiple.int
Deprecated.As of version 1.0.13, use thegetRollMultiple()
int
Returns the roll unit multiple.int
Deprecated.As of version 1.0.13, usegetRollUnitType()
.Returns the roll unit type.int
getUnit()
Deprecated.As of 1.0.13, use the getUnitType() method.Returns the unit type.int
hashCode()
Returns a hash code for this object.private static DateTickUnitType
intToUnitType
(int unit) A utility method that is used internally to convert the old unit constants into the corresponding enumerated value.private static DateFormat
notNull
(DateFormat formatter) A utility method to put a default in place if a null formatter is supplied.Rolls the date forward by the amount specified by the roll unit and count.Rolls the date forward by the amount specified by the roll unit and count.toString()
Returns a string representation of this instance, primarily used for debugging purposes.private static int
unitTypeToInt
(DateTickUnitType unitType) Converts a unit type to the corresponding deprecated integer constant.valueToString
(double milliseconds) Formats a value.Methods inherited from class org.jfree.chart.axis.TickUnit
compareTo, getMinorTickCount, getSize
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization.- See Also:
-
unitType
The units.- Since:
- 1.0.13
-
count
private int countThe unit count. -
rollUnitType
The roll unit type.- Since:
- 1.0.13
-
rollCount
private int rollCountThe roll count. -
formatter
The date formatter. -
YEAR
public static final int YEARDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for years.- See Also:
-
MONTH
public static final int MONTHDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for months.- See Also:
-
DAY
public static final int DAYDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for days.- See Also:
-
HOUR
public static final int HOURDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for hours.- See Also:
-
MINUTE
public static final int MINUTEDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for minutes.- See Also:
-
SECOND
public static final int SECONDDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for seconds.- See Also:
-
MILLISECOND
public static final int MILLISECONDDeprecated.As of version 1.0.13, useDateTickUnitType
instead.A constant for milliseconds.- See Also:
-
unit
private int unitDeprecated.As of version 1.0.13, use the unitType field.The unit. -
rollUnit
private int rollUnitDeprecated.As of version 1.0.13, use the rollUnitType field.The roll unit.
-
-
Constructor Details
-
DateTickUnit
Creates a new date tick unit.- Parameters:
unitType
- the unit type (null
not permitted).multiple
- the multiple (of the unit type, must be > 0).- Since:
- 1.0.13
-
DateTickUnit
Creates a new date tick unit.- Parameters:
unitType
- the unit type (null
not permitted).multiple
- the multiple (of the unit type, must be > 0).formatter
- the date formatter (null
not permitted).- Since:
- 1.0.13
-
DateTickUnit
public DateTickUnit(DateTickUnitType unitType, int multiple, DateTickUnitType rollUnitType, int rollMultiple, DateFormat formatter) Creates a new unit.- Parameters:
unitType
- the unit.multiple
- the multiple.rollUnitType
- the roll unit.rollMultiple
- the roll multiple.formatter
- the date formatter (null
not permitted).- Since:
- 1.0.13
-
DateTickUnit
Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int, DateFormat)
.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
public DateTickUnit(int unit, int count) Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int)
.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
Deprecated.As of version 1.0.13, useDateTickUnit(DateTickUnitType, int, DateTickUnitType, int, DateFormat)
.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
-
getUnitType
Returns the unit type.- Returns:
- The unit type (never
null
). - Since:
- 1.0.13
-
getMultiple
public int getMultiple()Returns the unit multiple.- Returns:
- The unit multiple (always > 0).
-
getRollUnitType
Returns the roll unit type.- Returns:
- The roll unit type (never
null
). - Since:
- 1.0.13
-
getRollMultiple
public int getRollMultiple()Returns the roll unit multiple.- Returns:
- The roll unit multiple.
- Since:
- 1.0.13
-
valueToString
Formats a value.- Overrides:
valueToString
in 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.zone
- the time zone for the date calculation.- Returns:
- A new date one unit after the base date.
- Since:
- 1.0.6
-
rollDate
Rolls the date forward by the amount specified by the roll unit and count.- Parameters:
base
- the base date.- Returns:
- The rolled date.
- See Also:
-
rollDate
Rolls the date forward by the amount specified by the roll unit and count.- Parameters:
base
- the base date.zone
- the time zone.- Returns:
- The rolled date.
- Since:
- 1.0.6
-
getCalendarField
public int getCalendarField()Returns a field code that can be used with theCalendar
class.- Returns:
- The field code.
-
getMillisecondCount
Returns the (approximate) number of milliseconds for the given unit and unit count.This value is an approximation some of the time (e.g. months are assumed to have 31 days) but this shouldn't matter.
- Parameters:
unit
- the unit.count
- the unit count.- Returns:
- The number of milliseconds.
- Since:
- 1.0.13
-
intToUnitType
A utility method that is used internally to convert the old unit constants into the corresponding enumerated value.- Parameters:
unit
- the unit specified using the deprecated integer codes.- Returns:
- The unit type.
- Since:
- 1.0.13
-
unitTypeToInt
Converts a unit type to the corresponding deprecated integer constant.- Parameters:
unitType
- the unit type (null
not permitted).- Returns:
- The int code.
- Since:
- 1.0.13
-
notNull
A utility method to put a default in place if a null formatter is supplied.- Parameters:
formatter
- the formatter (null
permitted).- Returns:
- The formatter if it is not null, otherwise a default.
-
equals
Tests this unit for equality with another object. -
hashCode
public int hashCode()Returns a hash code for this object. -
toString
Returns a string representation of this instance, primarily used for debugging purposes. -
getUnit
public int getUnit()Deprecated.As of 1.0.13, use the getUnitType() method.Returns the date unit. This will be one of the constantsYEAR
,MONTH
,DAY
,HOUR
,MINUTE
,SECOND
orMILLISECOND
, defined by this class. Note that these constants do NOT correspond to those defined in Java'sCalendar
class.- Returns:
- The date unit.
-
getCount
public int getCount()Deprecated.As of version 1.0.13, usegetMultiple()
.Returns the unit count.- Returns:
- The unit count.
-
getRollUnit
public int getRollUnit()Deprecated.As of version 1.0.13, usegetRollUnitType()
.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()Deprecated.As of version 1.0.13, use thegetRollMultiple()
Returns the roll count.- Returns:
- The roll count.
-
addToDate
Deprecated.As of JFreeChart 1.0.10, this method is deprecated - you should useaddToDate(Date, TimeZone)
instead.Calculates a new date by adding this unit to the base date, with calculations performed in the default timezone and locale.- Parameters:
base
- the base date.- Returns:
- A new date one unit after the base date.
- See Also:
-
DateTickUnitType
instead.