Package com.storedobject.chart
Class AbstractProject
java.lang.Object
com.storedobject.chart.AbstractProject
- Direct Known Subclasses:
ActivityList,Project
An abstract base class that implements some useful attributes and methods for defining a project.
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Stringencode(LocalDateTime time) Encode time data according to the duration type.intGet the font-size used to render the activity details.protected StringgetAxisLabel(AbstractTask task) Get the axis label for the task/activity task or group.final ChronoUnitGet the duration type of this project.abstract LocalDateTimegetEnd()Get the project end.protected abstract StringGet the extra axis label for the task/activity.intGet the font-size used to render the extra information of group.intGet the font-size used to render the task/activity group.protected StringgetLabel(AbstractTask task) Get the label of the given task/activity (Will be used for displaying the label on the task/activity bar).final StringgetName()Get the name of the project.getStart()Get the project start.intGet the font-size used to render the task detailsfinal LocalDateTimegetToday()Get today/now.protected StringgetTooltipLabel(AbstractTask task) Get the tooltip label of the given task/activity (Will be used for displaying the tooltip label).<T> Iterable<T> iterable(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Get an iterable of some type derived from each task/activity and its index.abstract <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.protected static LocalDateTimemax(LocalDateTime one, LocalDateTime two) Get max of 2 time values.voidsetActivityFontSize(int activityFontSize) Set the font size used to render the activity details.voidsetExtraFontSize(int extraFontSize) Set the font size used to render the extra information of group.voidsetGroupFontSize(int groupFontSize) Set the font size used to render the group name.voidSet the name of the project.final voidSet the start of the project.final voidSet the start of the project.voidsetStart(LocalDateTime start) Set the start of the project.voidsetTaskBandColors(Color bandColorOdd, Color bandColorEven) Set the colors of the task/activity bands.voidsetTaskFontSize(int taskFontSize) Set the font size used to render the task details.voidsetTimeNow(LocalDateTime now) Set time-now.voidsetTimeNowColor(Color color) Set the color for time-now-marker on the Gantt chart.voidSet today.voidsetTodayColor(Color color) Set the color for today-marker on the Gantt chart.voidsetTodayFormat(Function<LocalDateTime, String> todayFormat) Set a formatter function to format the today-marker.voidsetTooltipTimeFormat(Function<LocalDateTime, String> tooltipTimeFormat) Set a formatter function to format the tooltip of tasks/activities.<T> Stream<T> stream(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Get a stream of some type derived from each task/activity and its index.protected static Stringtrim(double v) Trim a double value to remove unnecessary decimals.protected LocalDateTimetrim(LocalDateTime dateTime) Trim down aLocalDateTimeto aLocalDate.
-
Constructor Details
-
AbstractProject
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
-
getDurationType
Get the duration type of this project.- Returns:
- Duration type.
-
setName
Set the name of the project.- Parameters:
name- Name of the project.
-
getName
-
trim
Trim down aLocalDateTimeto aLocalDate.- Parameters:
dateTime- Time to trim.- Returns:
- Local date.
-
setStart
Set 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.- Parameters:
start- Start of the project.
-
setStart
Set 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.- Parameters:
start- Start of the project.
-
setStart
Set 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.- Parameters:
start- Start of the project.
-
getStart
-
getEnd
-
max
Get max of 2 time values.- Parameters:
one- First value.two- Second value.- Returns:
- Max of the 2.
-
encode
Encode time data according to the duration type.- Parameters:
time- Time.- Returns:
- Formatted value.
-
trim
Trim a double value to remove unnecessary decimals.- Parameters:
v- Value to trim.- Returns:
- Trimmed value as a string.
-
getLabel
Get the label of the given task/activity (Will be used for displaying the label on the task/activity bar). The default implementation returnsAbstractTask.getName()+ " (" +AbstractTask.getCompleted()+ "%)".In the case of a milestone (
AbstractTask.isMilestone()), it returns just the milestone name.- Parameters:
task- Task/activity.- Returns:
- Label.
-
getToday
-
getExtraAxisLabel
Get the extra axis label for the task/activity. (Will be used for displaying the 2nd line of the axis label).- Parameters:
task- Task.- Returns:
- Label.
-
getAxisLabel
Get the axis label for the task/activity task or group. (Will be used for displaying the axis label).The default implementation returns the name of the task/activity.
- Parameters:
task- Task/activity.- Returns:
- Label.
-
getTooltipLabel
Get the tooltip label of the given task/activity (Will be used for displaying the tooltip label).- Parameters:
task- Task/activity.- Returns:
- Label.
-
setToday
Set today. By default, today =LocalDate.now(). However, it is possible to set another date. (Used in date-based projects).- Parameters:
today- Value of today.
-
setTodayColor
Set the color for today-marker on the Gantt chart. (Used in date-based projects).- Parameters:
color- Color.
-
setTimeNow
Set time-now. By default, now =LocalDateTime.now(). However, it is possible to set another date or time. (Used in time-based projects).- Parameters:
now- Value of time-now.
-
setTimeNowColor
Set the color for time-now-marker on the Gantt chart. (Used in time-based projects).- Parameters:
color- Color.
-
setTodayFormat
Set a formatter function to format the today-marker. By default, today is formatted as follows:Today: Jan 23, 1998
- Parameters:
todayFormat- Formatter function.
-
setTooltipTimeFormat
Set a formatter function to format the tooltip of tasks/activities. By default, it is formatted as follows:Aug 07, 2002
- Parameters:
tooltipTimeFormat- Formatter function.
-
setTaskBandColors
-
getExtraFontSize
public int getExtraFontSize()Get the font-size used to render the extra information of group.- Returns:
- Font-size. Default is 12.
-
setExtraFontSize
public void setExtraFontSize(int extraFontSize) Set the font size used to render the extra information of group.Note: You can also set different values for individual groups. See
AbstractTask.setFontSize(int)- Parameters:
extraFontSize- Font-size to set (in pixels). Default is 9.
-
getGroupFontSize
public int getGroupFontSize()Get the font-size used to render the task/activity group.- Returns:
- Font-size. Default is 12.
-
setGroupFontSize
public void setGroupFontSize(int groupFontSize) Set the font size used to render the group name.Note: You can also set different values for individual groups. See
AbstractTask.setFontSize(int)- Parameters:
groupFontSize- Font-size to set (in pixels). Default is 12.
-
getTaskFontSize
public int getTaskFontSize()Get the font-size used to render the task details- Returns:
- Font-size. Default is 12.
-
setTaskFontSize
public void setTaskFontSize(int taskFontSize) Set the font size used to render the task details.Note: You can also set different values for individual tasks. See
AbstractTask.setFontSize(int)- Parameters:
taskFontSize- Font-size to set (in pixels). Default is 12.
-
getActivityFontSize
public int getActivityFontSize()Get the font-size used to render the activity details.- Returns:
- Font-size. Default is 12.
-
setActivityFontSize
public void setActivityFontSize(int activityFontSize) Set the font size used to render the activity details.Note: You can also set different values for individual activities. See
AbstractTask.setFontSize(int)- Parameters:
activityFontSize- Font-size to set (in pixels). Default is 12.
-
stream
public <T> Stream<T> stream(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Get a stream of some type derived from each task/activity and its index.- Type Parameters:
T- Element type of the returning stream.- 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:
- Stream of derived instances.
-
iterable
public <T> Iterable<T> iterable(BiFunction<AbstractTask, Integer, T> function, Predicate<AbstractTask> taskFilter) Get an iterable of some type derived from each task/activity and its index.- Type Parameters:
T- Element type of the returning iterable.- 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:
- Iterable of the derived instances.
-
iterator
public abstract <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.- 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.
-