1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 23:06:30 +00:00

Add Gantt bugfix

This commit is contained in:
Arnaud Roques 2021-03-18 22:38:00 +01:00
parent 69645c8e1e
commit 756225dee0
3 changed files with 109 additions and 24 deletions

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@ -70,6 +71,11 @@ public class FtileDiamondSquare extends AbstractFtile {
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
@Override
public Collection<Ftile> getMyChildren() {
return Collections.emptyList();
}
public FtileDiamondSquare withNorth(TextBlock north) {
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
}

View File

@ -52,6 +52,11 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class TimeHeaderMonthly extends TimeHeader {
private final LoadPlanable defaultPlan;
private final Map<Day, HColor> colorDays;
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
protected double getTimeHeaderHeight() {
return 16 + 13;
}
@ -63,10 +68,65 @@ public class TimeHeaderMonthly extends TimeHeader {
public TimeHeaderMonthly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
super(min, max, new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
this.defaultPlan = defaultPlan;
this.colorDays = colorDays;
this.colorDaysOfWeek = colorDaysOfWeek;
}
class Pending {
final double x1;
double x2;
final HColor color;
Pending(HColor color, double x1, double x2) {
this.x1 = x1;
this.x2 = x2;
this.color = color;
}
public void draw(UGraphic ug, double height) {
drawRectangle(ug.apply(color.bg()), height, x1, x2);
}
}
private void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
Pending pending = null;
for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) {
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).
final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
if (backDoW != null) {
back = backDoW;
}
if (back == null && defaultPlan.getLoadAt(wink) == 0) {
back = veryLightGray;
}
if (back == null) {
if (pending != null)
pending.draw(ug, height);
pending = null;
} else {
if (pending != null && pending.color.equals(back) == false) {
pending.draw(ug, height);
pending = null;
}
if (pending == null) {
pending = new Pending(back, x1, x2);
} else {
pending.x2 = x2;
}
}
}
}
@Override
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
drawTextsBackground(ug, totalHeightWithoutFooter);
drawYears(ug);
drawMonths(ug.apply(UTranslate.dy(16)));
drawHline(ug, 0);

View File

@ -74,32 +74,37 @@ public class TimeHeaderWeekly extends TimeHeader {
@Override
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
drawTextsBackground(ug, totalHeightWithoutFooter);
drawCalendar(ug, totalHeightWithoutFooter);
drawHline(ug, 0);
drawHline(ug, Y_POS_ROW16());
drawHline(ug, getFullHeaderHeight());
}
@Override
public void drawTimeFooter(UGraphic ug) {
drawHline(ug, 0);
printMonths(ug);
drawHline(ug, getTimeFooterHeight());
class Pending {
final double x1;
double x2;
final HColor color;
Pending(HColor color, double x1, double x2) {
this.x1 = x1;
this.x2 = x2;
this.color = color;
}
private void drawCalendar(final UGraphic ug, double totalHeightWithoutFooter) {
drawTexts(ug, totalHeightWithoutFooter);
printDaysOfMonth(ug);
printSmallVbars(ug, totalHeightWithoutFooter);
printMonths(ug);
public void draw(UGraphic ug, double height) {
drawRectangle(ug.apply(color.bg()), height, x1, x2);
}
}
private void drawTexts(final UGraphic ug, double totalHeightWithoutFooter) {
private void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
Day firstDay = null;
HColor lastColor = null;
Pending pending = null;
for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) {
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).
final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
@ -110,21 +115,35 @@ public class TimeHeaderWeekly extends TimeHeader {
back = veryLightGray;
}
if (back == null) {
if (lastColor != null)
drawBack(ug.apply(lastColor.bg()), firstDay, wink, height);
firstDay = null;
lastColor = null;
if (pending != null)
pending.draw(ug, height);
pending = null;
} else {
assert back != null;
if (lastColor != null && lastColor.equals(back) == false) {
drawBack(ug.apply(lastColor.bg()), firstDay, wink, height);
if (pending != null && pending.color.equals(back) == false) {
pending.draw(ug, height);
pending = null;
}
if (firstDay == null)
firstDay = wink;
lastColor = back;
if (pending == null) {
pending = new Pending(back, x1, x2);
} else {
pending.x2 = x2;
}
}
}
}
@Override
public void drawTimeFooter(UGraphic ug) {
drawHline(ug, 0);
printMonths(ug);
drawHline(ug, getTimeFooterHeight());
}
private void drawCalendar(final UGraphic ug, double totalHeightWithoutFooter) {
printDaysOfMonth(ug);
printSmallVbars(ug, totalHeightWithoutFooter);
printMonths(ug);
}
private void drawBack(UGraphic ug, Day start, Day end, double height) {
final double x1 = getTimeScale().getStartingPosition(start);