Class Project
GanttChart uses data from this class.
A project consists of instances of Project.Tasks (can be created via createTask(String, int)).
You can also have Project.TaskGroups and specify that a Project.Task instance belongs to a specific Project.TaskGroup
instance while creating it via createTask(TaskGroup, String, int) and Project.TaskGroups can be created
via createTaskGroup(String). Alternatively, a Project.Task can be created under a Project.TaskGroup via
Project.TaskGroup.createTask(String, int).
Dependencies between Project.Tasks and/or Project.TaskGroups can be specified via
dependsOn(ProjectTask, ProjectTask).
Note: Even though this class is designed to provide data for the GanttChart, it can be used
independently for scheduling tasks / task groups involved in a typical project. Once you defined the project by
adding all the task groups, tasks and dependencies, you can just use methods like streamGroups(),
streamTasks(TaskGroup) and streamDependencies(ProjectTask) to retrieve the data related to
the project. All those methods return data after auto-scheduling the tasks in the project.
- Author:
- Syam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn abstract base class for the representation of a Task or Task Group.classRepresents a task in a project.classRepresents a group ofProject.Tasks. -
Constructor Summary
ConstructorsConstructorDescriptionProject()Constructor for a date-based project.Project(ChronoUnit durationType) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreateTask(Project.TaskGroup taskGroup, String taskName, int duration) Create and add aProject.Taskto the project.createTask(String name, int duration) Create and add aProject.Taskto the project.createTaskGroup(String name) Create and add aProject.TaskGroupto the project.voiddelete(Project.Task... tasks) DeleteProject.Tasks from the project.voiddelete(Project.TaskGroup... taskGroups) DeleteProject.TaskGroups from the project.protected AbstractDataProvider<String> voiddependsOn(Project.ProjectTask dependent, Project.ProjectTask predecessor) Specify that a task/group depends on another task/group.final LocalDateTimegetEnd()Get the project end.protected StringGet the extra axis label for the task.final intGet the number ofProject.Taskbelonging to this group.final intfinal Project.TaskGroupgetTaskGroup(int groupIndex) Get theProject.TaskGroupof this project.booleanisEmpty()<T> Iterator<T> iterator(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Get an iterator of some type derived from each task/activity and its index.voidReset the earliest start set via one of the "setEarliestStart" methods so that the constraint is no more applicable.voidsetEarliestStart(Project.ProjectTask task, Instant start) Set the "earliest start" possible for a task/group.voidsetEarliestStart(Project.ProjectTask task, LocalDate start) Set the "earliest start" possible for a task/group.voidsetEarliestStart(Project.ProjectTask task, LocalDateTime start) Set the "earliest start" possible for a task/group.final voidsetStart(LocalDateTime start) Set the start of the project.Get all dependencies of the given task or group.Get all task groups of this project.streamTasks(Project.TaskGroup taskGroup) Get all tasks in the given task group.Methods inherited from class com.storedobject.chart.AbstractProject
encode, getActivityFontSize, getAxisLabel, getDurationType, getExtraFontSize, getGroupFontSize, getLabel, getName, getStart, getTaskFontSize, getToday, getTooltipLabel, iterable, max, setActivityFontSize, setExtraFontSize, setGroupFontSize, setName, setStart, setStart, setTaskBandColors, setTaskFontSize, setTimeNow, setTimeNowColor, setToday, setTodayColor, setTodayFormat, setTooltipTimeFormat, stream, trim, trim
-
Constructor Details
-
Project
public Project()Constructor for a date-based project. -
Project
Constructor.- Parameters:
durationType- Type of duration to be used for this project. (Note:ChronoUnit.ERASandChronoUnit.FOREVERare not supported and if used, will be considered asChronoUnit.MILLIS).
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
createTaskGroup
Create and add aProject.TaskGroupto the project.- Parameters:
name- Name of the task group.- Returns:
- Task group created.
-
createTask
Create and add aProject.Taskto the project. (This method should be used only if there is no need of "grouping of tasks".)- Parameters:
name- Name of the task.duration- Duration of the task. (A duration of zero denotes a project milestone).- Returns:
- Task created.
-
createTask
Create and add aProject.Taskto the project.- Parameters:
taskGroup- Group to which the task to be added.taskName- Name of the task.duration- Duration of the task. (A duration of zero denotes a project milestone).- Returns:
- Task created. (Returns
nullif theProject.TaskGrouppassed doesn't belong to this project).
-
delete
DeleteProject.TaskGroups from the project. (All tasks and dependencies related to these groups will be dropped).- Parameters:
taskGroups-Project.TaskGroups to delete.
-
delete
DeleteProject.Tasks from the project. (All dependencies related to these tasks will be dropped).- Parameters:
tasks-Project.Tasks to delete.
-
dependsOn
Specify that a task/group depends on another task/group.- Parameters:
dependent- Dependent.predecessor- Predecessor.
-
setStart
Description copied from class:AbstractProjectSet the start of the project. Depending on the duration type, one of the "setStart" methods can be used. However, the start value will be appropriately trimmed if you try to set a higher resolution value.- Overrides:
setStartin classAbstractProject- Parameters:
start- Start of the project.
-
getEnd
Description copied from class:AbstractProjectGet the project end.- Specified by:
getEndin classAbstractProject- Returns:
- End date/time.
-
resetEarliestStart
Reset the earliest start set via one of the "setEarliestStart" methods so that the constraint is no more applicable.- Parameters:
task- Task for which "earliest start" needs to be reset.
-
setEarliestStart
Set the "earliest start" possible for a task/group. Depending on the duration type, one of the "setEarliestStart" methods can be used. However, the value will be appropriately trimmed if you try to set a higher resolution value. This is applied as a constraint when tasks are scheduled.Note: You can use
resetEarliestStart(ProjectTask)to undo the effect of this constraint.- Parameters:
task- Task/group for which the "earliest start" should be set.start- Earliest start possible for the task/group.
-
setEarliestStart
Set the "earliest start" possible for a task/group. Depending on the duration type, one of the "setEarliestStart" methods can be used. However, the value will be appropriately trimmed if you try to set a higher resolution value. This is applied as a constraint when tasks are scheduled.Note: You can use
resetEarliestStart(ProjectTask)to undo the effect of this constraint.- Parameters:
task- Task/group for which the "earliest start" should be set.start- Earliest start possible for the task/group.
-
setEarliestStart
Set the "earliest start" possible for a task/group. Depending on the duration type, one of the "setEarliestStart" methods can be used. However, the value will be appropriately trimmed if you try to set a higher resolution value. This is applied as a constraint when tasks are scheduled.Note: You can use
resetEarliestStart(ProjectTask)to undo the effect of this constraint.- Parameters:
task- Task/group for which the "earliest start" should be set.start- Earliest start possible for the task/group.
-
getRowCount
public final int getRowCount() -
getTaskGroup
Get theProject.TaskGroupof this project.- Parameters:
groupIndex- Index of the task group to be retrieved.- Returns:
Project.TaskGroup.
-
getGroupCount
public final int getGroupCount()Get the number ofProject.Taskbelonging to this group.- Returns:
- Task count.
-
streamGroups
Get all task groups of this project.Note: Null will be returned if the project contains inconsistencies.
- Returns:
- Stream of task groups.
-
streamTasks
Get all tasks in the given task group.Note: Null will be returned if the project contains inconsistencies.
- Parameters:
taskGroup- Task group.- Returns:
- Stream of tasks.
-
streamDependencies
Get all dependencies of the given task or group.Note: Null will be returned if the project contains inconsistencies.
- Parameters:
task- Task.- Returns:
- Stream of tasks/groups.
-
iterator
public <T> Iterator<T> iterator(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Description copied from class:AbstractProjectGet an iterator of some type derived from each task/activity and its index.- Specified by:
iteratorin classAbstractProject- Type Parameters:
T- Element type of the returning iterator.- Parameters:
function- Function to create desired output instance. (A function that takes the task/activity and the index as the input).taskFilter- Filter to apply while selecting the task/activity. This could be null.- Returns:
- Iterator of the derived instances.
-
dependencies
-
getExtraAxisLabel
Get the extra axis label for the task. (Will be used for displaying the 2nd line of the axis label).The default implementation returns the description of the time-left to work on the task.
- Specified by:
getExtraAxisLabelin classAbstractProject- Parameters:
task- Task.- Returns:
- Label.
-