com.moneydance.apps.md.model.time
Class GraphInterval

java.lang.Object
  extended by com.moneydance.apps.md.model.time.GraphInterval

public class GraphInterval
extends java.lang.Object

This class represents a single interval in a list of intervals. For example, if the user selects to group by week and picks an entire year, one instance of this class would exist for each week in the year.

Adapted from the budget report's intervals. This class is immutable.

Author:
Kevin Menningen - Mennē Software Solutions, LLC

Constructor Summary
GraphInterval(CustomDateFormat dateFormat, boolean useShortFormat, int startDate, int endDate)
           
 
Method Summary
 boolean contains(int date)
           
 int getEndDate()
           
static java.util.ArrayList<GraphInterval> getIntervalList(DateRange dateRange, TimeInterval groupBy, CustomDateFormat dateFormat, boolean useShortFormat)
          Generate a list of date intervals based upon a date range and a selected time interval.
 int getStartDate()
           
 java.lang.String toString()
           
 java.lang.String toTitleString(java.util.Locale locale)
          Determine if the date range matches a particular pre-defined range, such as a year, month or quarter, and return that string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphInterval

public GraphInterval(CustomDateFormat dateFormat,
                     boolean useShortFormat,
                     int startDate,
                     int endDate)
Method Detail

contains

public boolean contains(int date)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toTitleString

public java.lang.String toTitleString(java.util.Locale locale)
Determine if the date range matches a particular pre-defined range, such as a year, month or quarter, and return that string. As an example, this will shorten the range 04/01/2010 - 06/30/2010 (22 characters) down to Q2 2010 (7 characters), which is more favorable for certain purposes such as column headers in the reports.

Parameters:
locale - The currently selected locale by the user (for Moneydance).
Returns:
A shortened title string, or if no match is found, the same value as

getStartDate

public int getStartDate()

getEndDate

public int getEndDate()

getIntervalList

public static java.util.ArrayList<GraphInterval> getIntervalList(DateRange dateRange,
                                                                 TimeInterval groupBy,
                                                                 CustomDateFormat dateFormat,
                                                                 boolean useShortFormat)
Generate a list of date intervals based upon a date range and a selected time interval.

Parameters:
dateRange - The date range to break up by the time interval.
groupBy - The time interval to divide the range into.
dateFormat - The display formatter for dates.
useShortFormat - True to use a short date display (only the end date), false otherwise.
Returns:
A list of intervals representing the entire date range broken up into the requested intervals.