com.ijchart.xychart.tickunit
Class DateTickUnit

java.lang.Object
  extended by com.ijchart.xychart.tickunit.DateTickUnit
All Implemented Interfaces:
INumberTickUnit, java.io.Serializable, java.lang.Cloneable

public class DateTickUnit
extends java.lang.Object
implements INumberTickUnit, java.lang.Cloneable, java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

Calculate the tick unit for date data.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static long ONE_HOUR_MILLSECONDS
           The millisecond of 1 hour.
 
Constructor Summary
DateTickUnit(DateTickUnitType unitType)
           Constructor.
DateTickUnit(DateTickUnitType unitType, java.text.DateFormat formatter)
           Constructor.
 
Method Summary
static DateTickUnitType calculateDateTickUnitType(double minMillis, double maxMillis, int maxCount)
           Calculate the tick unit type of date value,the unit is constant value defined in class DateTickUnitType.
 java.lang.Object clone()
          Returns a clone of the object.
 boolean equals(java.lang.Object obj)
           Tests the axis for equality with an arbitrary object.
static java.text.DateFormat getDataFormatter(DateTickUnitType unitType)
           Returns the DateFormat by date unit type.
 java.text.DateFormat getDateFormatter()
           Returns the date formatter.
 java.lang.String[] getTickUnits(double minValue, double maxValue, int maxCount, boolean includeZero)
           According to the minimum and maximum data and the largest number of coordinates to determine the scale of axis,all values are integer.
 java.util.TimeZone getTimeZone()
           Returns the time zone.
 DateTickUnitType getUnitType()
           Returns the unit type of date.
 int hashCode()
           Returns a hash code value for the object.
 void setDateFormatter(java.text.DateFormat dateFormatter)
           Sets the date formatter.
 void setTimeZone(java.util.TimeZone timeZone)
           Sets the time zone.
 void setUnitType(DateTickUnitType unitType)
           Sets the unit type of date.
 java.lang.String toString()
           Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE_HOUR_MILLSECONDS

public static final long ONE_HOUR_MILLSECONDS
The millisecond of 1 hour.

See Also:
Constant Field Values
Constructor Detail

DateTickUnit

public DateTickUnit(DateTickUnitType unitType)
Constructor.

Parameters:
unitType - DateTickUnitType The unit type of date,the unit type will be auto select for null value.(null permitted).

DateTickUnit

public DateTickUnit(DateTickUnitType unitType,
                    java.text.DateFormat formatter)
Constructor.

Parameters:
unitType - DateTickUnitType The unit type of date,the unit type will be auto select for null value.(null permitted).
formatter - DateFormat The date formatter,the unit type will be auto select for null value.(null not permitted).
Method Detail

getUnitType

public DateTickUnitType getUnitType()
Returns the unit type of date.

Returns:
DateTickUnitType The unit type of date (maybe null).

setUnitType

public void setUnitType(DateTickUnitType unitType)
Sets the unit type of date.

Parameters:
unitType - DateTickUnitType The unit type of date (maybe null).

getDateFormatter

public java.text.DateFormat getDateFormatter()
Returns the date formatter.

Returns:
DateFormat The date formatter (never null).

setDateFormatter

public void setDateFormatter(java.text.DateFormat dateFormatter)
Sets the date formatter.

Parameters:
dateFormatter - DateFormat The date formatter (never null).

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone.

Returns:
TimeZone The time zone.

setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone.

Parameters:
timeZone - TimeZone The time zone.

getTickUnits

public java.lang.String[] getTickUnits(double minValue,
                                       double maxValue,
                                       int maxCount,
                                       boolean includeZero)
According to the minimum and maximum data and the largest number of coordinates to determine the scale of axis,all values are integer.

Specified by:
getTickUnits in interface INumberTickUnit
Parameters:
minValue - double The minimum value.
maxValue - double The max value.
maxCount - int The maximum count of tick units (must great than 0).
includeZero - boolean A boolean flag indicates whether or not include zero value.This parameter is not used.
Returns:
String[] An array of tick units,the values are sorted ascending. All elements in array is number (never null).

calculateDateTickUnitType

public static DateTickUnitType calculateDateTickUnitType(double minMillis,
                                                         double maxMillis,
                                                         int maxCount)
Calculate the tick unit type of date value,the unit is constant value defined in class DateTickUnitType.

Parameters:
minMillis - double The minimum value.
maxMillis - double The maximum value.
maxCount - int The maximum count of tick units (must great than 0).
Returns:
int The tick unit type.

getDataFormatter

public static java.text.DateFormat getDataFormatter(DateTickUnitType unitType)
Returns the DateFormat by date unit type.

Parameters:
unitType - DateTickUnitType The date tick unit type (null not permitted).
Returns:
DateFormat The date formatter.

equals

public boolean equals(java.lang.Object obj)
Tests the axis for equality with an arbitrary object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object (null permitted).
Returns:
true or false.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the object.

Overrides:
clone in class java.lang.Object
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - if some component of the axis does not support cloning.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this object.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object.