Class GanttSpecialDateRange
- java.lang.Object
-
- org.eclipse.nebula.widgets.ganttchart.GanttSpecialDateRange
-
public class GanttSpecialDateRange extends java.lang.ObjectThis class allows you to color a certain date range in a special background color, as well as set things such as if events should be allowed to be moved onto this range or not. You can also set a repeating range by setting certain days (Monday, Tuesday, etc) that will be repeatedly blocked. For example, to block all events from ending up on weekends, you would do:GanttSpecialDateRange weekends = new GanttSpecialDateRange(parentChart); weekends.addRecurDay(Calendar.SATURDAY); weekends.addRecurDay(Calendar.SUNDAY); weekends.setAllowEventsOnDates(false);
To block a Tuesday before 8.30am and after 5.30pm, 10 times, starting Jan 1, 2009, you would do:Calendar cal = Calendar.getInstance(Locale.getDefault()); cal.set(Calendar.YEAR, 2009); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DATE, 1); GanttSpecialDateRange blockPre = new GanttSpecialDateRange(parentChart); blockPre.setStart(cal); blockPre.addRecurDay(Calendar.SATURDAY); blockPre.setEndHour(8); blockPre.setEndMinute(29); blockPre.setEndAfter(10); GanttSpecialDateRange blockPost = new GanttSpecialDateRange(parentChart); blockPre.setStart(cal); blockPost.addRecurDay(Calendar.SATURDAY); blockPost.setStartHour(17); blockPost.setStartMinute(30); blockPost.setEndAfter(10); blockPre.setAllowEventsOnDates(false); blockPost.setAllowEventsOnDates(false);
For a D-Day calendar (which does not use actual dates (at least visibily)) a typical creation may look like this:Calendar start = (Calendar) _ddayRootCalendar.clone(); Calendar end = (Calendar) start.clone(); end.add(Calendar.DATE, 50); GanttSpecialDateRange range = new GanttSpecialDateRange(_ganttChart, start, end); // these need to be set to indicate that the range should adapt to D-Day logic range.setFrequency(GanttSpecialDateRange.REPEAT_DDAY); range.setDDayRepeatInterval(10); // -- range.setRecurCount(50); range.setBackgroundColorTop(ColorCache.getRandomColor()); range.setBackgroundColorBottom(ColorCache.getRandomColor());
-
-
Field Summary
Fields Modifier and Type Field Description private boolean_allowEventsOnDatesprivate org.eclipse.swt.graphics.Color_bgColorBottomprivate org.eclipse.swt.graphics.Color_bgColorTopprivate java.util.List_cachedRangesprivate int_ddayRepeatIntervalprivate java.util.Calendar_endprivate int_endAfterprivate int_endHourprivate int_endMinuteprivate int_endSecondprivate int_frequencyprivate java.util.Calendar_lastActualEndDateprivate GanttChart_parentChartprivate GanttComposite_parentCompositeprivate int_recurCountprivate java.util.List_recurDaysprivate java.util.Calendar_startprivate int_startHourprivate int_startMinuteprivate int_startSecondstatic intNO_ENDstatic intREPEAT_DAILYstatic intREPEAT_DDAYstatic intREPEAT_MONTHLYstatic intREPEAT_WEEKLYstatic intREPEAT_YEARLY
-
Constructor Summary
Constructors Constructor Description GanttSpecialDateRange()GanttSpecialDateRange(GanttChart parent)Creates a new Gantt Special Date Range that indicates a certain set of dates with colors.GanttSpecialDateRange(GanttChart parent, java.util.Calendar start, java.util.Calendar end)Creates a new Gantt Special Date Range that indicates a certain set of dates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddRecurDay(int day)Adds a date that will be always used as a range date.booleancanEventOccupy(java.util.Calendar start, java.util.Calendar end)Checks whether a set of dates overlap any of the dates in this range.(package private) java.util.CalendargetActualEndDate()(package private) java.util.CalendargetActualStartDate()org.eclipse.swt.graphics.ColorgetBackgroundColorBottom()Returns the gradient bottom color.org.eclipse.swt.graphics.ColorgetBackgroundColorTop()Returns the gradient top color.(package private) java.util.ListgetBlocks()(package private) java.util.ListgetBlocks(java.util.Calendar start, java.util.Calendar end)intgetDDayRepeatInterval()Returns the currently set DDay repeat interval.java.util.CalendargetEnd()Returns the end date.intgetEndAfter()Returns the end after value that defines the number of recurring repetitions of the event.intgetEndHour()Returns the end hour.intgetEndMinute()Returns the end minuteintgetFrequency()Returns the frequency.(package private) intgetHighestRecurDate()GanttChartgetParentChart()Returns the chart that this range is associated with.GanttCompositegetParentComposite()Returns the chart composite this range is associated with.intgetRecurCount()Returns the "recurs every" value.java.util.ListgetRecurDays()Returns the list of currently set recurring days.java.util.CalendargetStart()Returns the start date.intgetStartHour()Returns the start hour.intgetStartMinute()Returns the start minute.booleanisAllowEventsOnDates()Whether events can be resized or dropped on the date range specified in this class.(package private) booleanisUseable()(package private) booleanisVisible(java.util.Calendar start, java.util.Calendar end)booleanremoveRecurDay(int calDate)Removes a set date.voidsetAllowEventsOnDates(boolean allowEventsOnDates)Sets whether events can be resized or dropped on to the date range specified in this class.voidsetBackgroundColorBottom(org.eclipse.swt.graphics.Color backgroundColorBottom)Sets the gradient bottom color.voidsetBackgroundColorTop(org.eclipse.swt.graphics.Color backgroundColorTop)Sets the gradient top color.voidsetDDayRepeatInterval(int interval)Sets the custom DDay repeat interval.voidsetEnd(java.util.Calendar end)Sets the end date.voidsetEndAfter(int endAfter)Sets how many times an event should re-occur and then end.booleansetEndHour(int endHour)Sets the end hour.booleansetEndMinute(int endMinute)Sets the end minute.voidsetFrequency(int frequency)Sets the repeat frequency.voidsetParentChart(GanttChart parentChart)voidsetParentComposite(GanttComposite parentComposite)voidsetRecurCount(int recurMax)How often this event re-occurs.voidsetStart(java.util.Calendar start)Sets the start date.booleansetStartHour(int startHour)Sets the start hour.booleansetStartMinute(int startMinute)Sets the start minute.java.lang.StringtoString()private voidupdateCalculations()
-
-
-
Field Detail
-
REPEAT_DAILY
public static final int REPEAT_DAILY
- See Also:
- Constant Field Values
-
REPEAT_WEEKLY
public static final int REPEAT_WEEKLY
- See Also:
- Constant Field Values
-
REPEAT_MONTHLY
public static final int REPEAT_MONTHLY
- See Also:
- Constant Field Values
-
REPEAT_YEARLY
public static final int REPEAT_YEARLY
- See Also:
- Constant Field Values
-
REPEAT_DDAY
public static final int REPEAT_DDAY
- See Also:
- Constant Field Values
-
NO_END
public static final int NO_END
- See Also:
- Constant Field Values
-
_start
private java.util.Calendar _start
-
_end
private java.util.Calendar _end
-
_bgColorTop
private org.eclipse.swt.graphics.Color _bgColorTop
-
_bgColorBottom
private org.eclipse.swt.graphics.Color _bgColorBottom
-
_parentChart
private GanttChart _parentChart
-
_parentComposite
private GanttComposite _parentComposite
-
_allowEventsOnDates
private boolean _allowEventsOnDates
-
_frequency
private int _frequency
-
_recurCount
private int _recurCount
-
_recurDays
private java.util.List _recurDays
-
_startHour
private int _startHour
-
_startMinute
private int _startMinute
-
_startSecond
private final int _startSecond
- See Also:
- Constant Field Values
-
_endHour
private int _endHour
-
_endMinute
private int _endMinute
-
_endSecond
private final int _endSecond
- See Also:
- Constant Field Values
-
_endAfter
private int _endAfter
-
_lastActualEndDate
private java.util.Calendar _lastActualEndDate
-
_cachedRanges
private java.util.List _cachedRanges
-
_ddayRepeatInterval
private int _ddayRepeatInterval
-
-
Constructor Detail
-
GanttSpecialDateRange
GanttSpecialDateRange()
-
GanttSpecialDateRange
public GanttSpecialDateRange(GanttChart parent)
Creates a new Gantt Special Date Range that indicates a certain set of dates with colors.- Parameters:
parent- Parent chart
-
GanttSpecialDateRange
public GanttSpecialDateRange(GanttChart parent, java.util.Calendar start, java.util.Calendar end)
Creates a new Gantt Special Date Range that indicates a certain set of dates.- Parameters:
parent- Parent chartstart- Start dateend- End date
-
-
Method Detail
-
getStart
public java.util.Calendar getStart()
Returns the start date.- Returns:
- Start date
-
setStart
public void setStart(java.util.Calendar start)
Sets the start date.- Parameters:
start- Start date
-
getEnd
public java.util.Calendar getEnd()
Returns the end date.- Returns:
- End date
-
setEnd
public void setEnd(java.util.Calendar end)
Sets the end date.- Parameters:
end- End date
-
getBackgroundColorTop
public org.eclipse.swt.graphics.Color getBackgroundColorTop()
Returns the gradient top color.- Returns:
- Top color
-
setBackgroundColorTop
public void setBackgroundColorTop(org.eclipse.swt.graphics.Color backgroundColorTop)
Sets the gradient top color.- Parameters:
backgroundColorTop- Top color or null if none (transparent)
-
getBackgroundColorBottom
public org.eclipse.swt.graphics.Color getBackgroundColorBottom()
Returns the gradient bottom color.- Returns:
- Bottom color
-
setBackgroundColorBottom
public void setBackgroundColorBottom(org.eclipse.swt.graphics.Color backgroundColorBottom)
Sets the gradient bottom color.- Parameters:
backgroundColorBottom- Bottom color or null if none (transparent)
-
getParentChart
public GanttChart getParentChart()
Returns the chart that this range is associated with.- Returns:
GanttChartparent
-
getParentComposite
public GanttComposite getParentComposite()
Returns the chart composite this range is associated with.- Returns:
GanttCompositeparent
-
isAllowEventsOnDates
public boolean isAllowEventsOnDates()
Whether events can be resized or dropped on the date range specified in this class. Default is true.- Returns:
- true if allowed
-
setAllowEventsOnDates
public void setAllowEventsOnDates(boolean allowEventsOnDates)
Sets whether events can be resized or dropped on to the date range specified in this class. Default is true.- Parameters:
allowEventsOnDates- true if allowed
-
addRecurDay
public boolean addRecurDay(int day)
Adds a date that will be always used as a range date. The date is one of the Calendar dates, such asCalendar.MONDAY. This is purely for convenience instead of having to create multiple special date ranges to cover things such as weekends. Do note if you add specific hours, only the specified hour on the set days will be covered and not the full day itself. If the frequency is set to 5 this method does nothing and you should instead be usingsetDDayRepeatInterval(int)as DDay calendars has no notion of weekdates.- Parameters:
day- Calendar weekday to add- Returns:
- true if added, false if not
-
removeRecurDay
public boolean removeRecurDay(int calDate)
Removes a set date.- Parameters:
calDate- Date to remove- Returns:
- true if removed
-
getFrequency
public int getFrequency()
Returns the frequency.- Returns:
- frequency
-
setFrequency
public void setFrequency(int frequency)
Sets the repeat frequency. Options areREPEAT_DAILY,REPEAT_MONTHLY,REPEAT_WEEKLY,REPEAT_YEARLYorREPEAT_DDAYfor DDay calendars.- Parameters:
frequency- Frequency to set
-
getDDayRepeatInterval
public int getDDayRepeatInterval()
Returns the currently set DDay repeat interval. This is only used if frequency is set toREPEAT_DDAY.- Returns:
- repeat interval
-
setDDayRepeatInterval
public void setDDayRepeatInterval(int interval)
Sets the custom DDay repeat interval. This is only used if frequency is set toREPEAT_DDAY.- Parameters:
interval- Custom repeat interval of n DDays
-
getRecurCount
public int getRecurCount()
Returns the "recurs every" value.- Returns:
- recurs every value
-
setRecurCount
public void setRecurCount(int recurMax)
How often this event re-occurs. By default it's always 1. To end after a certain number of recurrences, usesetEndAfter(int).- Parameters:
recurMax- Recurrence frequency
-
getRecurDays
public java.util.List getRecurDays()
Returns the list of currently set recurring days.- Returns:
- List of recurring days
-
getStartHour
public int getStartHour()
Returns the start hour.- Returns:
- Start hour
-
setStartHour
public boolean setStartHour(int startHour)
Sets the start hour. Hour should be in a 24h format from 0 to 23.- Parameters:
startHour- start hour- Returns:
- true if set
-
getStartMinute
public int getStartMinute()
Returns the start minute.- Returns:
- start minute
-
setStartMinute
public boolean setStartMinute(int startMinute)
Sets the start minute. Minute should be between 0 and 59.- Parameters:
startMinute- start minute- Returns:
- true if set
-
getEndHour
public int getEndHour()
Returns the end hour.- Returns:
- end hour
-
setEndHour
public boolean setEndHour(int endHour)
Sets the end hour. Hour should be in a 24h format from 0 to 23.- Parameters:
endHour- end hour- Returns:
- true if set
-
getEndMinute
public int getEndMinute()
Returns the end minute- Returns:
- end minute
-
setEndMinute
public boolean setEndMinute(int endMinute)
Sets the end minute. Minute should be between 0 and 59.- Parameters:
endMinute- start minute- Returns:
- true if set
-
getEndAfter
public int getEndAfter()
Returns the end after value that defines the number of recurring repetitions of the event.- Returns:
- end after value
-
setEndAfter
public void setEndAfter(int endAfter)
Sets how many times an event should re-occur and then end. This is the end value. To set a no-end, useNO_ENDas value.- Parameters:
endAfter- After how many re-occurances to stop.
-
setParentChart
public void setParentChart(GanttChart parentChart)
-
setParentComposite
public void setParentComposite(GanttComposite parentComposite)
-
updateCalculations
private void updateCalculations()
-
canEventOccupy
public boolean canEventOccupy(java.util.Calendar start, java.util.Calendar end)Checks whether a set of dates overlap any of the dates in this range.- Parameters:
start- Start dateend- End date- Returns:
- true if no date is overlapping the dates of this range, false otherwise
-
isVisible
boolean isVisible(java.util.Calendar start, java.util.Calendar end)
-
getActualStartDate
java.util.Calendar getActualStartDate()
-
getActualEndDate
java.util.Calendar getActualEndDate()
-
getBlocks
java.util.List getBlocks()
-
getBlocks
java.util.List getBlocks(java.util.Calendar start, java.util.Calendar end)
-
getHighestRecurDate
int getHighestRecurDate()
-
isUseable
boolean isUseable()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-