ilog.views.gantt.graphic
Class IlvLinearTimeConverter

java.lang.Object
  extended by ilog.views.gantt.graphic.IlvLinearTimeConverter
All Implemented Interfaces:
IlvTimeConverter

public class IlvLinearTimeConverter
extends Object
implements IlvTimeConverter

A linear time converter. An IlvLinearTimeConverter is capable of converting a Date to a double value, and a double value to a Date in a linear way.

The converter is defined by a reference time and a unit duration. The reference time represents the time where the double value is 0, and the unit duration is the duration of a double value of 1.

Here is the conversion formula:

double value = ( time value - reference time ) / unit duration

It is strongly recommended that the reference time should be evenly divisible by the unit duration. In other words, getReferenceTime().getTime() % getUnitDuration().getMillis() = 0. This ensures the highest level of precision during the conversion calculations.


Constructor Summary
IlvLinearTimeConverter()
          Creates an IlvLinearTimeConverter with a default unit duration of one hour.
IlvLinearTimeConverter(Date refTime, IlvDuration unit)
          Creates a linear time converter.
 
Method Summary
 Date getReferenceTime()
          Returns the reference time.
 Date getTime(double units)
          Converts a double value to a Date.
 IlvDuration getUnitDuration()
          Returns the unit duration.
 double getUnits(Date time)
          Converts a Date to a double.
 boolean isLinear()
          Returns whether the time converter is continuous and linear.
 void setReferenceTime(Date time)
          Sets the reference time.
 void setUnitDuration(IlvDuration unit)
          Sets the unit duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvLinearTimeConverter

public IlvLinearTimeConverter(Date refTime,
                              IlvDuration unit)
Creates a linear time converter.

Parameters:
refTime - Gives the reference time for the new converter. It is strongly recommended that the reference time should be evenly divisible by the unit duration. In other words, refTime.getTime() % unit.getMillis() = 0.
unit - Defines the unit time used for the conversion. The value provided should not be 0.

IlvLinearTimeConverter

public IlvLinearTimeConverter()
Creates an IlvLinearTimeConverter with a default unit duration of one hour.

Method Detail

getUnits

public double getUnits(Date time)
Converts a Date to a double.

Specified by:
getUnits in interface IlvTimeConverter
Parameters:
time - The Date to be converted.
Returns:
The converted value.

getTime

public Date getTime(double units)
Converts a double value to a Date.

Specified by:
getTime in interface IlvTimeConverter
Parameters:
units - The double value to be converted.
Returns:
The converted Date.

getReferenceTime

public Date getReferenceTime()
Returns the reference time.

See Also:
setReferenceTime(java.util.Date)

setReferenceTime

public void setReferenceTime(Date time)
Sets the reference time.

Parameters:
time - The new reference time It is strongly recommended that the reference time should be evenly divisible by the unit duration. In other words, time.getTime() % getUnitDuration().getMillis() = 0.
See Also:
getReferenceTime()

getUnitDuration

public IlvDuration getUnitDuration()
Returns the unit duration.

See Also:
setUnitDuration(ilog.views.gantt.IlvDuration)

setUnitDuration

public void setUnitDuration(IlvDuration unit)
Sets the unit duration.

Parameters:
unit - The new unit duration. It is strongly recommended that the reference time should be evenly divisible by the unit duration. In other words, getReferenceTime().getTime() % unit.getMillis() = 0. The value provided must not be 0.
See Also:
getUnitDuration()

isLinear

public boolean isLinear()
Returns whether the time converter is continuous and linear. This implementation returns true.

Specified by:
isLinear in interface IlvTimeConverter
Since:
JViews 6.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.