Class GanttSpecialDateRange
java.lang.Object
org.eclipse.nebula.widgets.ganttchart.GanttSpecialDateRange
public class GanttSpecialDateRange
extends java.lang.Object
This 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 static int
NO_END
static int
REPEAT_DAILY
static int
REPEAT_DDAY
static int
REPEAT_MONTHLY
static int
REPEAT_WEEKLY
static int
REPEAT_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
Modifier and Type Method Description boolean
addRecurDay(int day)
Adds a date that will be always used as a range date.boolean
canEventOccupy(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.Calendar
getActualEndDate()
(package private) java.util.Calendar
getActualStartDate()
org.eclipse.swt.graphics.Color
getBackgroundColorBottom()
Returns the gradient bottom color.org.eclipse.swt.graphics.Color
getBackgroundColorTop()
Returns the gradient top color.(package private) java.util.List
getBlocks()
(package private) java.util.List
getBlocks(java.util.Calendar start, java.util.Calendar end)
int
getDDayRepeatInterval()
Returns the currently set DDay repeat interval.java.util.Calendar
getEnd()
Returns the end date.int
getEndAfter()
Returns the end after value that defines the number of recurring repetitions of the event.int
getEndHour()
Returns the end hour.int
getEndMinute()
Returns the end minuteint
getFrequency()
Returns the frequency.(package private) int
getHighestRecurDate()
GanttChart
getParentChart()
Returns the chart that this range is associated with.GanttComposite
getParentComposite()
Returns the chart composite this range is associated with.int
getRecurCount()
Returns the "recurs every" value.java.util.List
getRecurDays()
Returns the list of currently set recurring days.java.util.Calendar
getStart()
Returns the start date.int
getStartHour()
Returns the start hour.int
getStartMinute()
Returns the start minute.boolean
isAllowEventsOnDates()
Whether events can be resized or dropped on the date range specified in this class.(package private) boolean
isUseable()
(package private) boolean
isVisible(java.util.Calendar start, java.util.Calendar end)
boolean
removeRecurDay(int calDate)
Removes a set date.void
setAllowEventsOnDates(boolean allowEventsOnDates)
Sets whether events can be resized or dropped on to the date range specified in this class.void
setBackgroundColorBottom(org.eclipse.swt.graphics.Color backgroundColorBottom)
Sets the gradient bottom color.void
setBackgroundColorTop(org.eclipse.swt.graphics.Color backgroundColorTop)
Sets the gradient top color.void
setDDayRepeatInterval(int interval)
Sets the custom DDay repeat interval.void
setEnd(java.util.Calendar end)
Sets the end date.void
setEndAfter(int endAfter)
Sets how many times an event should re-occur and then end.boolean
setEndHour(int endHour)
Sets the end hour.boolean
setEndMinute(int endMinute)
Sets the end minute.void
setFrequency(int frequency)
Sets the repeat frequency.void
setParentChart(GanttChart parentChart)
void
setParentComposite(GanttComposite parentComposite)
void
setRecurCount(int recurMax)
How often this event re-occurs.void
setStart(java.util.Calendar start)
Sets the start date.boolean
setStartHour(int startHour)
Sets the start hour.boolean
setStartMinute(int startMinute)
Sets the start minute.java.lang.String
toString()
-
Field Details
-
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
-
-
Constructor Details
-
GanttSpecialDateRange
GanttSpecialDateRange() -
GanttSpecialDateRange
Creates a new Gantt Special Date Range that indicates a certain set of dates with colors.- Parameters:
parent
- Parent chart
-
GanttSpecialDateRange
Creates a new Gantt Special Date Range that indicates a certain set of dates.- Parameters:
parent
- Parent chartstart
- Start dateend
- End date
-
-
Method Details
-
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
Returns the chart that this range is associated with.- Returns:
GanttChart
parent
-
getParentComposite
Returns the chart composite this range is associated with.- Returns:
GanttComposite
parent
-
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_YEARLY
orREPEAT_DDAY
for 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_END
as value.- Parameters:
endAfter
- After how many re-occurances to stop.
-
setParentChart
-
setParentComposite
-
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:
toString
in classjava.lang.Object
-