mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-26 14:56:28 +00:00
Add Gantt bugfix
This commit is contained in:
parent
69645c8e1e
commit
756225dee0
@ -36,6 +36,7 @@
|
|||||||
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
||||||
|
|
||||||
import java.awt.geom.Dimension2D;
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -69,6 +70,11 @@ public class FtileDiamondSquare extends AbstractFtile {
|
|||||||
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
|
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
|
||||||
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
|
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Ftile> getMyChildren() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public FtileDiamondSquare withNorth(TextBlock north) {
|
public FtileDiamondSquare withNorth(TextBlock north) {
|
||||||
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
|
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
|
||||||
|
@ -51,6 +51,11 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
|
|||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public class TimeHeaderMonthly extends TimeHeader {
|
public class TimeHeaderMonthly extends TimeHeader {
|
||||||
|
|
||||||
|
private final LoadPlanable defaultPlan;
|
||||||
|
private final Map<Day, HColor> colorDays;
|
||||||
|
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
||||||
|
|
||||||
|
|
||||||
protected double getTimeHeaderHeight() {
|
protected double getTimeHeaderHeight() {
|
||||||
return 16 + 13;
|
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,
|
public TimeHeaderMonthly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
|
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
|
||||||
super(min, max, new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
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
|
@Override
|
||||||
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||||
|
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||||
drawYears(ug);
|
drawYears(ug);
|
||||||
drawMonths(ug.apply(UTranslate.dy(16)));
|
drawMonths(ug.apply(UTranslate.dy(16)));
|
||||||
drawHline(ug, 0);
|
drawHline(ug, 0);
|
||||||
|
@ -74,32 +74,37 @@ public class TimeHeaderWeekly extends TimeHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||||
|
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||||
drawCalendar(ug, totalHeightWithoutFooter);
|
drawCalendar(ug, totalHeightWithoutFooter);
|
||||||
drawHline(ug, 0);
|
drawHline(ug, 0);
|
||||||
drawHline(ug, Y_POS_ROW16());
|
drawHline(ug, Y_POS_ROW16());
|
||||||
drawHline(ug, getFullHeaderHeight());
|
drawHline(ug, getFullHeaderHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
class Pending {
|
||||||
public void drawTimeFooter(UGraphic ug) {
|
final double x1;
|
||||||
drawHline(ug, 0);
|
double x2;
|
||||||
printMonths(ug);
|
final HColor color;
|
||||||
drawHline(ug, getTimeFooterHeight());
|
|
||||||
|
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 drawCalendar(final UGraphic ug, double totalHeightWithoutFooter) {
|
private void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
|
||||||
drawTexts(ug, totalHeightWithoutFooter);
|
|
||||||
printDaysOfMonth(ug);
|
|
||||||
printSmallVbars(ug, totalHeightWithoutFooter);
|
|
||||||
printMonths(ug);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawTexts(final UGraphic ug, double totalHeightWithoutFooter) {
|
|
||||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
|
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
|
||||||
Day firstDay = null;
|
Pending pending = null;
|
||||||
HColor lastColor = null;
|
|
||||||
|
|
||||||
for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) {
|
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);
|
HColor back = colorDays.get(wink);
|
||||||
// Day of week should be stronger than period of time (back color).
|
// Day of week should be stronger than period of time (back color).
|
||||||
final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
|
final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek());
|
||||||
@ -110,22 +115,36 @@ public class TimeHeaderWeekly extends TimeHeader {
|
|||||||
back = veryLightGray;
|
back = veryLightGray;
|
||||||
}
|
}
|
||||||
if (back == null) {
|
if (back == null) {
|
||||||
if (lastColor != null)
|
if (pending != null)
|
||||||
drawBack(ug.apply(lastColor.bg()), firstDay, wink, height);
|
pending.draw(ug, height);
|
||||||
firstDay = null;
|
pending = null;
|
||||||
lastColor = null;
|
|
||||||
} else {
|
} else {
|
||||||
assert back != null;
|
if (pending != null && pending.color.equals(back) == false) {
|
||||||
if (lastColor != null && lastColor.equals(back) == false) {
|
pending.draw(ug, height);
|
||||||
drawBack(ug.apply(lastColor.bg()), firstDay, wink, height);
|
pending = null;
|
||||||
|
}
|
||||||
|
if (pending == null) {
|
||||||
|
pending = new Pending(back, x1, x2);
|
||||||
|
} else {
|
||||||
|
pending.x2 = x2;
|
||||||
}
|
}
|
||||||
if (firstDay == null)
|
|
||||||
firstDay = wink;
|
|
||||||
lastColor = back;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private void drawBack(UGraphic ug, Day start, Day end, double height) {
|
||||||
final double x1 = getTimeScale().getStartingPosition(start);
|
final double x1 = getTimeScale().getStartingPosition(start);
|
||||||
final double x2 = getTimeScale().getStartingPosition(end);
|
final double x2 = getTimeScale().getStartingPosition(end);
|
||||||
|
Loading…
Reference in New Issue
Block a user