com.dlsc.flexgantt.policy.layer
Class TimeGranularityGridPolicy

java.lang.Object
  extended by com.dlsc.flexgantt.policy.AbstractPolicy
      extended by com.dlsc.flexgantt.policy.layer.AbstractGridPolicy<TimeGranularity>
          extended by com.dlsc.flexgantt.policy.layer.TimeGranularityGridPolicy
All Implemented Interfaces:
IPolicy, IGridPolicy<TimeGranularity>

public class TimeGranularityGridPolicy
extends AbstractGridPolicy<TimeGranularity>

A grid policy that uses the TimeGranularity class to adjust start and end times.

Since:
1.0
Author:
Dirk Lemmermann

Constructor Summary
TimeGranularityGridPolicy()
          Constructs a new policy that will support the following granularities: TimeGranularity.MONTH_SHORT TimeGranularity.WEEK TimeGranularity.DAY_SHORT TimeGranularity.HOUR TimeGranularity.MINUTE TimeGranularity.SECOND The policy will round start and end times.
TimeGranularityGridPolicy(boolean adjustingStartTimes, boolean adjustingEndTimes, TimeGranularity... granularities)
          Constructs a new policy.
TimeGranularityGridPolicy(TimeGranularity... granularities)
          Constructs a new policy, which will round start and end times.
 
Method Summary
 long getGridAdjustedEndTime(TimeGranularity tg, long endTime, IDatelineModel<TimeGranularity> datelineModel, boolean autoGrid)
          Returns a grid adjusted time point for the given unadjusted end time.
 long getGridAdjustedStartTime(TimeGranularity tg, long startTime, IDatelineModel<TimeGranularity> datelineModel, boolean autoGrid)
          Returns a grid adjusted time point for the given unadjusted start time.
 ITimeSpan getGridAdjustedTimeSpan(TimeGranularity tg, ITimeSpan timeSpan, IDatelineModel<TimeGranularity> datelineModel, boolean autoGrid)
          Returns a grid adjusted time span for the given unadjusted time span.
 
Methods inherited from class com.dlsc.flexgantt.policy.layer.AbstractGridPolicy
getGridGranularities, isAdjustingEndTimes, isAdjustingStartTimes
 
Methods inherited from class com.dlsc.flexgantt.policy.AbstractPolicy
assertClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeGranularityGridPolicy

public TimeGranularityGridPolicy(boolean adjustingStartTimes,
                                 boolean adjustingEndTimes,
                                 TimeGranularity... granularities)
Constructs a new policy.

Parameters:
adjustingStartTimes - if TRUE the start times will be rounded based on the given grid granularity
adjustingEndTimes - if TRUE the end times will be rounded based on the given grid granularity
granularities - the supported grid granularities
Since:
1.0

TimeGranularityGridPolicy

public TimeGranularityGridPolicy(TimeGranularity... granularities)
Constructs a new policy, which will round start and end times.

Parameters:
granularities - the supported grid granularities
Since:
1.0

TimeGranularityGridPolicy

public TimeGranularityGridPolicy()
Constructs a new policy that will support the following granularities: The policy will round start and end times.

Since:
1.0
See Also:
AbstractGridPolicy.getGridGranularities()
Method Detail

getGridAdjustedTimeSpan

public ITimeSpan getGridAdjustedTimeSpan(TimeGranularity tg,
                                         ITimeSpan timeSpan,
                                         IDatelineModel<TimeGranularity> datelineModel,
                                         boolean autoGrid)
Description copied from interface: IGridPolicy
Returns a grid adjusted time span for the given unadjusted time span. How the adjustment happens depends on the policy implementation.

Parameters:
tg - the granularity for which to return an adjusted time point
timeSpan - the original time span that needs adjustment
datelineModel - the model used by the dateline (needed for the auto grid feature)
autoGrid - if TRUE the grid calculations will be based on the minor granularity shown by the dateline
Returns:
a grid adjusted time span

getGridAdjustedStartTime

public long getGridAdjustedStartTime(TimeGranularity tg,
                                     long startTime,
                                     IDatelineModel<TimeGranularity> datelineModel,
                                     boolean autoGrid)
Description copied from interface: IGridPolicy
Returns a grid adjusted time point for the given unadjusted start time. How the adjustment happens depends on the policy implementation.

Parameters:
tg - the granularity for which to return an adjusted time point
startTime - the original time that needs adjustment
datelineModel - the model used by the dateline (needed for the auto grid feature)
autoGrid - if TRUE the grid calculations will be based on the minor granularity shown by the dateline
Returns:
a grid adjusted start time

getGridAdjustedEndTime

public long getGridAdjustedEndTime(TimeGranularity tg,
                                   long endTime,
                                   IDatelineModel<TimeGranularity> datelineModel,
                                   boolean autoGrid)
Description copied from interface: IGridPolicy
Returns a grid adjusted time point for the given unadjusted end time. How the adjustment happens depends on the policy implementation.

Parameters:
tg - the granularity for which to return an adjusted time point
endTime - the original time that needs adjustment
datelineModel - the model used by the dateline (needed for the auto grid feature)
autoGrid - if TRUE the grid calculations will be based on the minor granularity shown by the dateline
Returns:
a grid adjusted end time