JIDE 3.5.15

com.jidesoft.scale
Class DateScaleModel

java.lang.Object
  extended by com.jidesoft.scale.AbstractScaleModel<Date>
      extended by com.jidesoft.scale.DateScaleModel
All Implemented Interfaces:
ScaleModel<Date>, Serializable

public class DateScaleModel
extends AbstractScaleModel<Date>

An implementation of ScaleModel for Date. The periods are defined by DatePeriods.

See Also:
Serialized Form

Constructor Summary
DateScaleModel()
          Creates a ScaleModel with a default range of one year from now with default periods of day, week, month, quarter and year.
DateScaleModel(DatePeriod... periods)
          Creates a ScaleModel with a default range of one year from now with the specified periods.
DateScaleModel(Locale locale, Date defaultStartDate, Date defaultEndDate, DatePeriod... periods)
           
 
Method Summary
 Date getInstantAt(long position)
          Maps the position to a instant on the scale.
 Locale getLocale()
           
 List<Date> getPeriodBoundaries(Period period, Date startInstant, Date endInstant)
          Optimized calculation which only creates one Calendar.
 Date getPeriodEnd(Period period, Date instant)
          This method returns the end of period in which the instant falls, which is the start instant of the next period.
 Date getPeriodStart(Period period, Date instant)
           
 long getPosition(Date instant)
          Maps the unit to a long so it can be gives a position in the UI.
 
Methods inherited from class com.jidesoft.scale.AbstractScaleModel
getDefaultEnd, getDefaultStart, getPeriods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateScaleModel

public DateScaleModel()
Creates a ScaleModel with a default range of one year from now with default periods of day, week, month, quarter and year.


DateScaleModel

public DateScaleModel(DatePeriod... periods)
Creates a ScaleModel with a default range of one year from now with the specified periods.

Parameters:
periods - The periods from smallest to longest.

DateScaleModel

public DateScaleModel(Locale locale,
                      Date defaultStartDate,
                      Date defaultEndDate,
                      DatePeriod... periods)
Parameters:
locale - the locale
defaultStartDate - the default start date
defaultEndDate - the default end date
periods - The periods from smallest to longest.
Method Detail

getLocale

public Locale getLocale()

getInstantAt

public Date getInstantAt(long position)
Description copied from interface: ScaleModel
Maps the position to a instant on the scale.

Parameters:
position - The position to get the instant for.
Returns:
the instant at the specified position on the scale.

getPeriodEnd

public Date getPeriodEnd(Period period,
                         Date instant)
Description copied from interface: ScaleModel
This method returns the end of period in which the instant falls, which is the start instant of the next period. This means that calling getPeriodStart on a periodEnd should return the same instant.
T periodEnd = getPeriodsEnd(period, instant);
 assertTrue(periodEnd == getPeriodStart(period, periodEnd));

Parameters:
period - A period which was returned from getPeriods().
instant - The instant to get the period end for.
Returns:
the instant on or after the specified instant which marks a end of the specified period type.

getPeriodStart

public Date getPeriodStart(Period period,
                           Date instant)
Parameters:
period - A period which was returned from getPeriods().
instant - The instant to get the period start for.
Returns:
the instant on or before the specified instant which marks a start of the specified period type.

getPosition

public long getPosition(Date instant)
Description copied from interface: ScaleModel
Maps the unit to a long so it can be gives a position in the UI.

Parameters:
instant - The instant to get the position for.
Returns:
the position of the instant on the scale.

getPeriodBoundaries

public List<Date> getPeriodBoundaries(Period period,
                                      Date startInstant,
                                      Date endInstant)
Optimized calculation which only creates one Calendar.

Specified by:
getPeriodBoundaries in interface ScaleModel<Date>
Overrides:
getPeriodBoundaries in class AbstractScaleModel<Date>
Parameters:
period - The period for when the start and end instants should be calculated.
startInstant - The start instant.
endInstant - The end instant.
Returns:
the instants where a periods start and the previous period ended.

JIDE 3.5.15