JIDE 3.5.15

com.jidesoft.scale
Class AbstractScaleModel<T>

java.lang.Object
  extended by com.jidesoft.scale.AbstractScaleModel<T>
Type Parameters:
T - The type of the bases unit of the scale, for example Date or Integer.
All Implemented Interfaces:
ScaleModel<T>, Serializable
Direct Known Subclasses:
DateScaleModel, NumberScaleModel

public abstract class AbstractScaleModel<T>
extends Object
implements ScaleModel<T>, Serializable

Abstract implementation of ScaleModel. It implements all other methods except ScaleModel.getPosition(Object), ScaleModel.getInstantAt(long), ScaleModel.getPeriodStart(Period, Object) and ScaleModel.getPeriodEnd(Period, Object).

See Also:
Serialized Form

Constructor Summary
AbstractScaleModel(T defaultStart, T defaultEnd, Period... periods)
           
 
Method Summary
 T getDefaultEnd()
           
 T getDefaultStart()
           
 List<T> getPeriodBoundaries(Period period, T startInstant, T endInstant)
          Default implementation using getPeriodStart/End(Period, T) and getPosition(T).
 List<Period> getPeriods()
          The returned list should contain at least one Period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jidesoft.scale.ScaleModel
getInstantAt, getPeriodEnd, getPeriodStart, getPosition
 

Constructor Detail

AbstractScaleModel

public AbstractScaleModel(T defaultStart,
                          T defaultEnd,
                          Period... periods)
Parameters:
defaultStart - The default start instant used if the user doesn't specify any.
defaultEnd - The default end instant used if the user doesn't specify any.
periods - The periods from smallest to largest. There must be at least one Period.
Throws:
IllegalArgumentException - If no period is given.
See Also:
ScaleModel.getPeriods()
Method Detail

getDefaultEnd

public T getDefaultEnd()
Specified by:
getDefaultEnd in interface ScaleModel<T>
Returns:
a reasonable end instant when showing an empty gantt chart.

getDefaultStart

public T getDefaultStart()
Specified by:
getDefaultStart in interface ScaleModel<T>
Returns:
a reasonable start instant when showing an empty gantt chart.

getPeriods

public List<Period> getPeriods()
Description copied from interface: ScaleModel
The returned list should contain at least one Period. The list should be ordered from smaller to larger Periods.

Specified by:
getPeriods in interface ScaleModel<T>
Returns:
the different scales of this model.

getPeriodBoundaries

public List<T> getPeriodBoundaries(Period period,
                                   T startInstant,
                                   T endInstant)
Default implementation using getPeriodStart/End(Period, T) and getPosition(T).

Calculates the periods start/end instants which completely include the specified start and end instant. This means the first and last instant in the returned list are smaller or equal respectively greater or equal to the given start and end instant.

Specified by:
getPeriodBoundaries in interface ScaleModel<T>
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