mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-22 04:55:10 +00:00
Merge pull request #440 from Nordes/feature/432-gantt_color_DaysOfWeek
[GANTT] Implement "[day] are colored in #AAAAFF"
This commit is contained in:
commit
3a7e935cec
@ -118,6 +118,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
|
||||
private final Map<String, Resource> resources = new LinkedHashMap<String, Resource>();
|
||||
private final Map<Day, HColor> colorDays = new HashMap<Day, HColor>();
|
||||
private final Map<DayOfWeek, HColor> colorDaysOfWeek = new HashMap<DayOfWeek, HColor>();
|
||||
private final Map<Day, String> nameDays = new HashMap<Day, String>();
|
||||
|
||||
private PrintScale printScale = PrintScale.DAILY;
|
||||
@ -260,12 +261,12 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
if (openClose.getCalendar() == null) {
|
||||
return new TimeHeaderSimple(min, max);
|
||||
} else if (printScale == PrintScale.WEEKLY) {
|
||||
return new TimeHeaderWeekly(openClose.getCalendar(), min, max, openClose, colorDays, nameDays);
|
||||
return new TimeHeaderWeekly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, nameDays);
|
||||
} else if (printScale == PrintScale.MONTHLY) {
|
||||
return new TimeHeaderMonthly(openClose.getCalendar(), min, max, openClose, colorDays, nameDays);
|
||||
return new TimeHeaderMonthly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, nameDays);
|
||||
} else {
|
||||
return new TimeHeaderDaily(openClose.getCalendar(), min, max, openClose, colorDays, nameDays, printStart,
|
||||
printEnd);
|
||||
return new TimeHeaderDaily(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, nameDays,
|
||||
printStart, printEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,6 +674,10 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
colorDays.put(day, color);
|
||||
}
|
||||
|
||||
public void colorDay(DayOfWeek day, HColor color) {
|
||||
colorDaysOfWeek.put(day, color);
|
||||
}
|
||||
|
||||
public void nameDay(Day day, String name) {
|
||||
nameDays.put(day, name);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import java.util.Map;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.project.LoadPlanable;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.DayOfWeek;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleDaily;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
@ -61,13 +62,15 @@ public class TimeHeaderDaily extends TimeHeader {
|
||||
|
||||
private final LoadPlanable defaultPlan;
|
||||
private final Map<Day, HColor> colorDays;
|
||||
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
||||
private final Map<Day, String> nameDays;
|
||||
|
||||
public TimeHeaderDaily(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<Day, String> nameDays, Day printStart, Day printEnd) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays, Day printStart, Day printEnd) {
|
||||
super(min, max, new TimeScaleDaily(calendar, printStart));
|
||||
this.defaultPlan = defaultPlan;
|
||||
this.colorDays = colorDays;
|
||||
this.colorDaysOfWeek = colorDaysOfWeek;
|
||||
this.nameDays = nameDays;
|
||||
}
|
||||
|
||||
@ -99,6 +102,11 @@ public class TimeHeaderDaily extends TimeHeader {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
final double x2 = getTimeScale().getEndingPosition(wink);
|
||||
HColor back = colorDays.get(wink);
|
||||
// Day of week should be stronger than period of time (back color).
|
||||
HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
|
||||
if (backDoW != null) {
|
||||
back = backDoW;
|
||||
}
|
||||
if (back == null && defaultPlan.getLoadAt(wink) == 0) {
|
||||
back = veryLightGray;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.project.LoadPlanable;
|
||||
import net.sourceforge.plantuml.project.core.PrintScale;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.DayOfWeek;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
@ -60,7 +61,7 @@ public class TimeHeaderMonthly extends TimeHeader {
|
||||
}
|
||||
|
||||
public TimeHeaderMonthly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<Day, String> nameDays) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
|
||||
super(min, max, new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class TimeHeaderWeekly extends TimeHeader {
|
||||
|
||||
private final LoadPlanable defaultPlan;
|
||||
private final Map<Day, HColor> colorDays;
|
||||
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
||||
|
||||
protected double getTimeHeaderHeight() {
|
||||
return 16 + 13;
|
||||
@ -64,10 +65,11 @@ public class TimeHeaderWeekly extends TimeHeader {
|
||||
}
|
||||
|
||||
public TimeHeaderWeekly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<Day, String> nameDays) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
|
||||
super(min, max, new TimeScaleCompressed(calendar, PrintScale.WEEKLY.getCompress()));
|
||||
this.defaultPlan = defaultPlan;
|
||||
this.colorDays = colorDays;
|
||||
this.colorDaysOfWeek = colorDaysOfWeek;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,8 +100,12 @@ public class TimeHeaderWeekly extends TimeHeader {
|
||||
HColor lastColor = null;
|
||||
|
||||
for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) {
|
||||
|
||||
HColor back = colorDays.get(wink);
|
||||
// Day of week should be stronger than period of time (back color).
|
||||
HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
|
||||
if (backDoW != null) {
|
||||
back = backDoW;
|
||||
}
|
||||
if (back == null && defaultPlan.getLoadAt(wink) == 0) {
|
||||
back = veryLightGray;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.project.Failable;
|
||||
import net.sourceforge.plantuml.project.GanttDiagram;
|
||||
import net.sourceforge.plantuml.project.time.DayOfWeek;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
|
||||
public class SubjectDayOfWeek implements Subject {
|
||||
|
||||
@ -58,7 +59,7 @@ public class SubjectDayOfWeek implements Subject {
|
||||
}
|
||||
|
||||
public Collection<? extends SentenceSimple> getSentences() {
|
||||
return Arrays.asList(new AreClose());
|
||||
return Arrays.asList(new AreClose(), new InColor());
|
||||
}
|
||||
|
||||
class AreClose extends SentenceSimple {
|
||||
@ -76,4 +77,21 @@ public class SubjectDayOfWeek implements Subject {
|
||||
|
||||
}
|
||||
|
||||
class InColor extends SentenceSimple {
|
||||
|
||||
public InColor() {
|
||||
super(SubjectDayOfWeek.this, Verbs.isOrAre(), new ComplementInColors2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) {
|
||||
final HColor color = ((CenterBorderColor) complement).getCenter();
|
||||
final DayOfWeek day = (DayOfWeek) subject;
|
||||
project.colorDay(day, color);
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user