Class GanttBlockCluster<T>

java.lang.Object
overit.geocallapp.utilities.ux.ui.container.gantt.data.GanttBlockCluster<T>
All Implemented Interfaces:
Iterable<GanttBlock<T>>

public class GanttBlockCluster<T> extends Object implements Iterable<GanttBlock<T>>
This class will be used to cluster overlapped GanttBlocks. The main idea is to have and object with a temporal range that grows when a new block is added to it. So this object will store the GanttBlocks that are overlapped (totally or partially) and be able to say the whole covered time interval.
  • Constructor Details

    • GanttBlockCluster

      public GanttBlockCluster()
  • Method Details

    • setId

      public void setId(String id)
      Parameters:
      id - the id of this cluster
    • getId

      public String getId()
      Returns:
      the id of this cluster
    • add

      public boolean add(GanttBlock<T> block)
      Method to add a block to the cluster. Remember that if the block is not overlapped to the already in blocks, the block will be discarded.
      Parameters:
      block - the GanttBlock to add
      Returns:
      true if the block was added, false if the block was discarded.
    • getBegin

      public Date getBegin()
      Returns:
      the begin date of this cluster, calculated as the minimum begin date between the clustered blocks
    • getEnd

      public Date getEnd()
      Returns:
      the end date of this cluster, calculated as the maximum end date between the clustered blocks
    • getMiddle

      public Date getMiddle()
      Returns:
      the Date in the middle between begin and end of this cluster
    • getBlocks

      public Collection<GanttBlock<T>> getBlocks()
      Returns:
      an unmodifiable Collection with the blocks clustered in this cluster
    • getSize

      public int getSize()
      Returns:
      the number of GanttBlock in this cluster
    • iterator

      public Iterator<GanttBlock<T>> iterator()
      Iterator to iterate over the clustered GanttBlocks
      Specified by:
      iterator in interface Iterable<T>
    • isBetween

      protected boolean isBetween(Date date)
      Parameters:
      date - a date to test
      Returns:
      true if the given date is between the cluster range dates
    • expandToInclude

      protected void expandToInclude(GanttBlock<T> block)
      Expand the cluster begin and end dates to include the given block
      Parameters:
      block - the GanttBlock to include