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 Details

  • Constructor Details

    • 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 chart
      start - Start date
      end - 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

      public GanttChart getParentChart()
      Returns the chart that this range is associated with.
      Returns:
      GanttChart parent
    • getParentComposite

      public GanttComposite 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 as Calendar.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 using setDDayRepeatInterval(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 are REPEAT_DAILY, REPEAT_MONTHLY, REPEAT_WEEKLY, REPEAT_YEARLY or REPEAT_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 to REPEAT_DDAY.
      Returns:
      repeat interval
    • setDDayRepeatInterval

      public void setDDayRepeatInterval​(int interval)
      Sets the custom DDay repeat interval. This is only used if frequency is set to REPEAT_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, use setEndAfter(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, use NO_END as value.
      Parameters:
      endAfter - After how many re-occurances to stop.
    • setParentChart

      public void setParentChart​(GanttChart parentChart)
    • setParentComposite

      public void setParentComposite​(GanttComposite parentComposite)
    • 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 date
      end - 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 class java.lang.Object