mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-23 05:22:05 +00:00
feat: several gantt improvement
This commit is contained in:
parent
f0b3e6900c
commit
e991c4699b
@ -375,6 +375,13 @@ ganttDiagram {
|
||||
timeline {
|
||||
BackgroundColor transparent
|
||||
LineColor #C0C0C0
|
||||
FontSize 10
|
||||
month {
|
||||
FontSize 12
|
||||
}
|
||||
year {
|
||||
FontSize 14
|
||||
}
|
||||
}
|
||||
closed {
|
||||
BackGroundColor #F1E5E5
|
||||
|
@ -117,7 +117,7 @@ import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
||||
import net.sourceforge.plantuml.svek.GraphvizCrash;
|
||||
import net.sourceforge.plantuml.text.BackSlash;
|
||||
|
||||
public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite {
|
||||
public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite, GanttStyle {
|
||||
|
||||
private final Map<Task, TaskDraw> draws = new LinkedHashMap<Task, TaskDraw>();
|
||||
private final Map<TaskCode, Task> tasks = new LinkedHashMap<TaskCode, Task>();
|
||||
@ -233,8 +233,9 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
this.min = printStart;
|
||||
this.max = printEnd;
|
||||
}
|
||||
final TimeHeader timeHeader = getTimeHeader();
|
||||
initTaskAndResourceDraws(timeHeader.getTimeScale(), timeHeader.getFullHeaderHeight(), stringBounder);
|
||||
final TimeHeader timeHeader = getTimeHeader(stringBounder);
|
||||
initTaskAndResourceDraws(timeHeader.getTimeScale(), timeHeader.getFullHeaderHeight(stringBounder),
|
||||
stringBounder);
|
||||
return new AbstractTextBlock() {
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
@ -250,12 +251,12 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
final HColor back = timelineStyle.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
|
||||
if (back.isTransparent() == false) {
|
||||
final URectangle rect1 = URectangle.build(calculateDimension(ug.getStringBounder()).getWidth(),
|
||||
timeHeader.getTimeHeaderHeight());
|
||||
timeHeader.getTimeHeaderHeight(ug.getStringBounder()));
|
||||
ug.apply(back.bg()).draw(rect1);
|
||||
if (showFootbox) {
|
||||
final URectangle rect2 = URectangle.build(
|
||||
calculateDimension(ug.getStringBounder()).getWidth(),
|
||||
timeHeader.getTimeFooterHeight());
|
||||
timeHeader.getTimeFooterHeight(ug.getStringBounder()));
|
||||
ug.apply(back.bg()).apply(UTranslate.dy(totalHeightWithoutFooter)).draw(rect2);
|
||||
}
|
||||
}
|
||||
@ -297,7 +298,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
|
||||
public XDimension2D calculateDimension(StringBounder stringBounder) {
|
||||
return new XDimension2D(getTitlesColumnWidth(stringBounder) + getBarsColumnWidth(timeHeader),
|
||||
getTotalHeight(timeHeader));
|
||||
getTotalHeight(stringBounder, timeHeader));
|
||||
}
|
||||
|
||||
private double getBarsColumnWidth(final TimeHeader timeHeader) {
|
||||
@ -309,28 +310,27 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
};
|
||||
}
|
||||
|
||||
private TimeHeader getTimeHeader() {
|
||||
private TimeHeader getTimeHeader(StringBounder stringBounder) {
|
||||
if (openClose.getStartingDay() == null)
|
||||
return new TimeHeaderSimple(thParam(), printScale);
|
||||
return new TimeHeaderSimple(stringBounder, thParam(), printScale);
|
||||
else if (printScale == PrintScale.DAILY)
|
||||
return new TimeHeaderDaily(thParam(), nameDays, printStart, printEnd);
|
||||
return new TimeHeaderDaily(stringBounder, thParam(), nameDays, printStart, printEnd);
|
||||
else if (printScale == PrintScale.WEEKLY)
|
||||
return new TimeHeaderWeekly(thParam(), weekNumberStrategy, withCalendarDate);
|
||||
return new TimeHeaderWeekly(stringBounder, thParam(), weekNumberStrategy, withCalendarDate);
|
||||
else if (printScale == PrintScale.MONTHLY)
|
||||
return new TimeHeaderMonthly(thParam());
|
||||
return new TimeHeaderMonthly(stringBounder, thParam());
|
||||
else if (printScale == PrintScale.QUARTERLY)
|
||||
return new TimeHeaderQuarterly(thParam());
|
||||
return new TimeHeaderQuarterly(stringBounder, thParam());
|
||||
else if (printScale == PrintScale.YEARLY)
|
||||
return new TimeHeaderYearly(thParam());
|
||||
return new TimeHeaderYearly(stringBounder, thParam());
|
||||
else
|
||||
throw new IllegalStateException();
|
||||
|
||||
}
|
||||
|
||||
private TimeHeaderParameters thParam() {
|
||||
return new TimeHeaderParameters(colorDays(), getFactorScale(), min, max, getIHtmlColorSet(), getTimelineStyle(),
|
||||
getClosedStyle(), locale, openClose, colorDaysOfWeek, verticalSeparatorBefore,
|
||||
getVerticalSeparatorStyle());
|
||||
return new TimeHeaderParameters(colorDays(), getFactorScale(), min, max, getIHtmlColorSet(), locale, openClose,
|
||||
colorDaysOfWeek, verticalSeparatorBefore, this);
|
||||
}
|
||||
|
||||
private Map<Day, HColor> colorDays() {
|
||||
@ -338,24 +338,21 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
return Collections.unmodifiableMap(colorDaysInternal);
|
||||
}
|
||||
|
||||
private Style getClosedStyle() {
|
||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.closed)
|
||||
@Override
|
||||
public final Style getStyle(SName param) {
|
||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param)
|
||||
.getMergedStyle(getCurrentStyleBuilder());
|
||||
}
|
||||
|
||||
private Style getTimelineStyle() {
|
||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.timeline)
|
||||
@Override
|
||||
public final Style getStyle(SName param1, SName param2) {
|
||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param1, param2)
|
||||
.getMergedStyle(getCurrentStyleBuilder());
|
||||
}
|
||||
|
||||
private Style getVerticalSeparatorStyle() {
|
||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.verticalSeparator)
|
||||
.getMergedStyle(getCurrentStyleBuilder());
|
||||
}
|
||||
|
||||
private double getTotalHeight(TimeHeader timeHeader) {
|
||||
private double getTotalHeight(StringBounder stringBounder, TimeHeader timeHeader) {
|
||||
if (showFootbox)
|
||||
return totalHeightWithoutFooter + timeHeader.getTimeFooterHeight();
|
||||
return totalHeightWithoutFooter + timeHeader.getTimeFooterHeight(stringBounder);
|
||||
|
||||
return totalHeightWithoutFooter;
|
||||
}
|
||||
|
@ -33,12 +33,15 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.project.lang;
|
||||
package net.sourceforge.plantuml.project;
|
||||
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
import net.sourceforge.plantuml.style.Style;
|
||||
|
||||
public interface Adverbial {
|
||||
public interface GanttStyle {
|
||||
|
||||
public IRegex toRegex();
|
||||
public Style getStyle(SName param);
|
||||
|
||||
public Style getStyle(SName param1, SName param2);
|
||||
|
||||
}
|
@ -43,41 +43,39 @@ import net.sourceforge.plantuml.klimt.UStroke;
|
||||
import net.sourceforge.plantuml.klimt.color.HColor;
|
||||
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.DayOfWeek;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
import net.sourceforge.plantuml.style.Style;
|
||||
|
||||
public class TimeHeaderParameters {
|
||||
public class TimeHeaderParameters implements GanttStyle {
|
||||
|
||||
private final Map<Day, HColor> colorDays;
|
||||
private final double scale;
|
||||
private final Day min;
|
||||
private final Day max;
|
||||
private final HColorSet colorSet;
|
||||
private final Style timelineStyle;
|
||||
private final Style closedStyle;
|
||||
private final Style verticalSeparatorStyle;
|
||||
private final GanttStyle ganttStyle;
|
||||
private final Locale locale;
|
||||
private final OpenClose openClose;
|
||||
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
||||
private final Set<Day> verticalSeparatorBefore;
|
||||
|
||||
public TimeHeaderParameters(Map<Day, HColor> colorDays, double scale, Day min, Day max, HColorSet colorSet,
|
||||
Style timelineStyle, Style closedStyle, Locale locale, OpenClose openClose,
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Set<Day> verticalSeparatorBefore, Style verticalSeparatorStyle) {
|
||||
Locale locale, OpenClose openClose, Map<DayOfWeek, HColor> colorDaysOfWeek,
|
||||
Set<Day> verticalSeparatorBefore, GanttStyle ganttStyle) {
|
||||
this.colorDays = colorDays;
|
||||
this.scale = scale;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.colorSet = colorSet;
|
||||
this.timelineStyle = timelineStyle;
|
||||
this.closedStyle = closedStyle;
|
||||
this.ganttStyle = ganttStyle;
|
||||
this.locale = locale;
|
||||
this.openClose = openClose;
|
||||
this.colorDaysOfWeek = colorDaysOfWeek;
|
||||
this.verticalSeparatorBefore = verticalSeparatorBefore;
|
||||
this.verticalSeparatorStyle = verticalSeparatorStyle;
|
||||
}
|
||||
|
||||
public HColor getColor(Day wink) {
|
||||
@ -105,11 +103,11 @@ public class TimeHeaderParameters {
|
||||
}
|
||||
|
||||
public final Style getTimelineStyle() {
|
||||
return timelineStyle;
|
||||
return getStyle(SName.timeline);
|
||||
}
|
||||
|
||||
public final Style getClosedStyle() {
|
||||
return closedStyle;
|
||||
return getStyle(SName.closed);
|
||||
}
|
||||
|
||||
public final Locale getLocale() {
|
||||
@ -129,9 +127,25 @@ public class TimeHeaderParameters {
|
||||
}
|
||||
|
||||
public final UGraphic forVerticalSeparator(UGraphic ug) {
|
||||
final HColor color = verticalSeparatorStyle.value(PName.LineColor).asColor(getColorSet());
|
||||
final UStroke stroke = verticalSeparatorStyle.getStroke();
|
||||
final Style style = getStyle(SName.verticalSeparator);
|
||||
final HColor color = style.value(PName.LineColor).asColor(getColorSet());
|
||||
final UStroke stroke = style.getStroke();
|
||||
return ug.apply(color).apply(stroke);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Style getStyle(SName param1, SName param2) {
|
||||
return ganttStyle.getStyle(param1, param2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Style getStyle(SName param) {
|
||||
return ganttStyle.getStyle(param);
|
||||
}
|
||||
|
||||
public double getCellWidth(StringBounder stringBounder) {
|
||||
final double w = getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
return w * 1.6;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,27 +43,42 @@ public abstract class AbstractTask implements Task {
|
||||
private final StyleBuilder styleBuilder;
|
||||
|
||||
private Task row;
|
||||
private String displayString;
|
||||
|
||||
protected AbstractTask(StyleBuilder styleBuilder, TaskCode code) {
|
||||
this.styleBuilder = styleBuilder;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void putInSameRowAs(Task row) {
|
||||
if (this != row)
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Task getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TaskCode getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final StyleBuilder getStyleBuilder() {
|
||||
return styleBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplay(String displayString) {
|
||||
this.displayString = displayString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString() {
|
||||
return this.displayString;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,4 +81,8 @@ public interface Task extends Moment {
|
||||
|
||||
public boolean isAssignedTo(Resource res);
|
||||
|
||||
public void setDisplay(String displayString);
|
||||
|
||||
public String getDisplayString();
|
||||
|
||||
}
|
||||
|
@ -134,29 +134,39 @@ public class TaskDrawDiamond extends AbstractTaskDraw {
|
||||
@Override
|
||||
public void drawU(UGraphic ug) {
|
||||
|
||||
if (url != null)
|
||||
ug.startUrl(url);
|
||||
|
||||
final String displayString = getTask().getDisplayString();
|
||||
|
||||
final Style style = getStyle();
|
||||
final ClockwiseTopRightBottomLeft margin = style.getMargin();
|
||||
ug = ug.apply(UTranslate.dy(margin.getTop()));
|
||||
|
||||
final double x1 = timeScale.getStartingPosition(start);
|
||||
final double x2 = timeScale.getEndingPosition(start);
|
||||
final double width = getDiamondHeight();
|
||||
final double delta = x2 - x1 - width;
|
||||
|
||||
if (url != null)
|
||||
ug.startUrl(url);
|
||||
|
||||
drawShape(applyColors(ug).apply(UTranslate.dx(x1 + delta / 2)));
|
||||
ug = ug.apply(UTranslate.dx(x1));
|
||||
|
||||
if (displayString == null) {
|
||||
final double x2 = timeScale.getEndingPosition(start);
|
||||
final double width = getDiamondHeight();
|
||||
final double delta = x2 - x1 - width;
|
||||
ug = ug.apply(UTranslate.dx(delta / 2));
|
||||
drawShape(applyColors(ug));
|
||||
} else {
|
||||
final TextBlock draw = Display.getWithNewlines(displayString).create(getFontConfiguration(),
|
||||
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
|
||||
draw.drawU(ug);
|
||||
}
|
||||
if (url != null)
|
||||
ug.closeUrl();
|
||||
}
|
||||
|
||||
private UGraphic applyColors(UGraphic ug) {
|
||||
final CenterBorderColor col = this.getColors();
|
||||
if (col != null && col.isOk()) {
|
||||
if (col != null && col.isOk())
|
||||
return col.apply(ug);
|
||||
}
|
||||
|
||||
return ug.apply(getLineColor()).apply(getBackgroundColor().bg());
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ import net.sourceforge.plantuml.klimt.color.HColors;
|
||||
import net.sourceforge.plantuml.klimt.creole.Display;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.font.UFont;
|
||||
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
@ -51,18 +52,11 @@ import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScale;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public abstract class TimeHeader {
|
||||
// ::remove folder when __HAXE__
|
||||
|
||||
protected final double Y_POS_ROW16() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
protected final double Y_POS_ROW28() {
|
||||
return 28;
|
||||
}
|
||||
|
||||
private final TimeScale timeScale;
|
||||
|
||||
protected final TimeHeaderParameters thParam;
|
||||
@ -100,15 +94,19 @@ public abstract class TimeHeader {
|
||||
return thParam.getTimelineStyle().value(PName.LineColor).asColor(thParam.getColorSet());
|
||||
}
|
||||
|
||||
public abstract double getTimeHeaderHeight();
|
||||
public abstract double getTimeHeaderHeight(StringBounder stringBounder);
|
||||
|
||||
public abstract double getTimeFooterHeight();
|
||||
public abstract double getTimeFooterHeight(StringBounder stringBounder);
|
||||
|
||||
public abstract double getFullHeaderHeight(StringBounder stringBounder);
|
||||
|
||||
public abstract void drawTimeHeader(UGraphic ug, double totalHeightWithoutFooter);
|
||||
|
||||
public abstract void drawTimeFooter(UGraphic ug);
|
||||
|
||||
public abstract double getFullHeaderHeight();
|
||||
public final TimeScale getTimeScale() {
|
||||
return timeScale;
|
||||
}
|
||||
|
||||
protected final void drawHline(UGraphic ug, double y) {
|
||||
final double xmin = getTimeScale().getStartingPosition(thParam.getMin());
|
||||
@ -122,20 +120,17 @@ public abstract class TimeHeader {
|
||||
ug.apply(new UTranslate(x, y1)).draw(vbar);
|
||||
}
|
||||
|
||||
final protected FontConfiguration getFontConfiguration(int size, boolean bold, HColor color) {
|
||||
UFont font = UFont.serif(size);
|
||||
final protected FontConfiguration getFontConfiguration(UFont font, boolean bold, HColor color) {
|
||||
if (bold)
|
||||
font = font.bold();
|
||||
|
||||
return FontConfiguration.create(font, color, color, null);
|
||||
}
|
||||
|
||||
public final TimeScale getTimeScale() {
|
||||
return timeScale;
|
||||
}
|
||||
|
||||
protected final TextBlock getTextBlock(String text, int size, boolean bold, HColor color) {
|
||||
return Display.getWithNewlines(text).create(getFontConfiguration(size, bold, color), HorizontalAlignment.LEFT,
|
||||
protected final TextBlock getTextBlock(SName param, String text, boolean bold, HColor color) {
|
||||
final UFont font = thParam.getStyle(SName.timeline, param).getUFont();
|
||||
final FontConfiguration fontConfiguration = getFontConfiguration(font, bold, color);
|
||||
return Display.getWithNewlines(text).create(fontConfiguration, HorizontalAlignment.LEFT,
|
||||
new SpriteContainerEmpty());
|
||||
}
|
||||
|
||||
@ -165,7 +160,7 @@ public abstract class TimeHeader {
|
||||
return;
|
||||
|
||||
ug = ug.apply(HColors.none());
|
||||
ug = ug.apply(new UTranslate(x1, getFullHeaderHeight()));
|
||||
ug = ug.apply(new UTranslate(x1, getFullHeaderHeight(ug.getStringBounder())));
|
||||
ug.draw(URectangle.build(x2 - x1, height));
|
||||
}
|
||||
|
||||
@ -173,8 +168,8 @@ public abstract class TimeHeader {
|
||||
ug = thParam.forVerticalSeparator(ug);
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment())
|
||||
if (isBold2(wink))
|
||||
drawVline(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(),
|
||||
totalHeightWithoutFooter);
|
||||
drawVline(ug, getTimeScale().getStartingPosition(wink),
|
||||
getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public abstract class TimeHeaderCalendar extends TimeHeader {
|
||||
|
||||
protected final void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
|
||||
|
||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
|
||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight(ug.getStringBounder());
|
||||
Pending pending = null;
|
||||
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) {
|
||||
|
@ -40,41 +40,79 @@ import java.util.Map;
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.color.HColor;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleDaily;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return Y_POS_ROW28() + 13;
|
||||
private double getH1(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 2;
|
||||
return h;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
// return 0;
|
||||
return 24 + 14;
|
||||
private double getH2(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 2;
|
||||
return getH1(stringBounder) + h;
|
||||
}
|
||||
|
||||
private double getH3(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 3;
|
||||
return getH2(stringBounder) + h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
return getH3(stringBounder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
final double h3 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + h3 + 8;
|
||||
}
|
||||
|
||||
private double getHeaderNameDayHeight() {
|
||||
if (nameDays.size() > 0) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 6;
|
||||
return h;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder) + getHeaderNameDayHeight();
|
||||
}
|
||||
|
||||
private final Map<Day, String> nameDays;
|
||||
|
||||
public TimeHeaderDaily(TimeHeaderParameters thParam, Map<Day, String> nameDays, Day printStart, Day printEnd) {
|
||||
super(thParam, new TimeScaleDaily(thParam.getStartingDay(), thParam.getScale(), printStart));
|
||||
public TimeHeaderDaily(StringBounder stringBounder, TimeHeaderParameters thParam, Map<Day, String> nameDays,
|
||||
Day printStart, Day printEnd) {
|
||||
super(thParam, new TimeScaleDaily(thParam.getCellWidth(stringBounder), thParam.getStartingDay(),
|
||||
thParam.getScale(), printStart));
|
||||
this.nameDays = nameDays;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||
drawTextsDayOfWeek(ug.apply(UTranslate.dy(Y_POS_ROW16())));
|
||||
drawTextDayOfMonth(ug.apply(UTranslate.dy(Y_POS_ROW28())));
|
||||
drawTextsDayOfWeek(ug.apply(UTranslate.dy(getH1(ug.getStringBounder()))));
|
||||
drawTextDayOfMonth(ug.apply(UTranslate.dy(getH2(ug.getStringBounder()))));
|
||||
drawMonths(ug);
|
||||
printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
|
||||
printNamedDays(ug);
|
||||
|
||||
drawHline(ug, getFullHeaderHeight());
|
||||
drawHline(ug, getFullHeaderHeight(ug.getStringBounder()));
|
||||
drawHline(ug, totalHeightWithoutFooter);
|
||||
}
|
||||
|
||||
@ -84,21 +122,22 @@ public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
final UGraphic ugLineColor = ug.apply(getLineColor());
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment())
|
||||
if (isBold2(wink))
|
||||
drawVline(ugVerticalSeparator, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(),
|
||||
totalHeightWithoutFooter);
|
||||
drawVline(ugVerticalSeparator, getTimeScale().getStartingPosition(wink),
|
||||
getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter);
|
||||
else
|
||||
drawVline(ugLineColor, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(),
|
||||
totalHeightWithoutFooter);
|
||||
drawVline(ugLineColor, getTimeScale().getStartingPosition(wink),
|
||||
getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter);
|
||||
|
||||
drawVline(ugLineColor, getTimeScale().getEndingPosition(getMax()), getFullHeaderHeight(),
|
||||
drawVline(ugLineColor, getTimeScale().getEndingPosition(getMax()), getFullHeaderHeight(ug.getStringBounder()),
|
||||
totalHeightWithoutFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeFooter(UGraphic ug) {
|
||||
drawTextDayOfMonth(ug.apply(UTranslate.dy(12)));
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 2;
|
||||
drawTextsDayOfWeek(ug);
|
||||
drawMonths(ug.apply(UTranslate.dy(24)));
|
||||
drawTextDayOfMonth(ug.apply(UTranslate.dy(h + 2)));
|
||||
drawMonths(ug.apply(UTranslate.dy(2 * h + 3)));
|
||||
}
|
||||
|
||||
private void drawTextsDayOfWeek(UGraphic ug) {
|
||||
@ -106,7 +145,8 @@ public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
final double x2 = getTimeScale().getEndingPosition(wink);
|
||||
final HColor textColor = getTextBackColor(wink);
|
||||
printCentered(ug, getTextBlock(wink.getDayOfWeek().shortName(locale()), 10, false, textColor), x1, x2);
|
||||
printCentered(ug, getTextBlock(SName.day, wink.getDayOfWeek().shortName(locale()), false, textColor), x1,
|
||||
x2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +155,7 @@ public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
final double x2 = getTimeScale().getEndingPosition(wink);
|
||||
final HColor textColor = getTextBackColor(wink);
|
||||
printCentered(ug, getTextBlock("" + wink.getDayOfMonth(), 10, false, textColor), x1, x2);
|
||||
printCentered(ug, getTextBlock(SName.day, "" + wink.getDayOfMonth(), false, textColor), x1, x2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,9 +186,9 @@ public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock tiny = getTextBlock(monthYear.shortName(locale()), 12, true, openFontColor());
|
||||
final TextBlock small = getTextBlock(monthYear.longName(locale()), 12, true, openFontColor());
|
||||
final TextBlock big = getTextBlock(monthYear.longNameYYYY(locale()), 12, true, openFontColor());
|
||||
final TextBlock tiny = getTextBlock(SName.month, monthYear.shortName(locale()), true, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.month, monthYear.longName(locale()), true, openFontColor());
|
||||
final TextBlock big = getTextBlock(SName.month, monthYear.longNameYYYY(locale()), true, openFontColor());
|
||||
printCentered(ug, false, start, end, tiny, small, big);
|
||||
}
|
||||
|
||||
@ -160,27 +200,17 @@ public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||
if (name != null && name.equals(last) == false) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
final double x2 = getTimeScale().getEndingPosition(wink);
|
||||
final TextBlock label = getTextBlock(name, 12, false, openFontColor());
|
||||
final TextBlock label = getTextBlock(SName.month, name, false, openFontColor());
|
||||
final double h = label.calculateDimension(ug.getStringBounder()).getHeight();
|
||||
double y1 = getTimeHeaderHeight();
|
||||
double y2 = getFullHeaderHeight();
|
||||
label.drawU(ug.apply(new UTranslate(x1, Y_POS_ROW28() + 11)));
|
||||
double y1 = getTimeHeaderHeight(ug.getStringBounder());
|
||||
double y2 = getFullHeaderHeight(ug.getStringBounder());
|
||||
|
||||
final double position = getH3(ug.getStringBounder());
|
||||
label.drawU(ug.apply(new UTranslate(x1, position)));
|
||||
}
|
||||
last = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight() + getHeaderNameDayHeight();
|
||||
}
|
||||
|
||||
private double getHeaderNameDayHeight() {
|
||||
if (nameDays.size() > 0)
|
||||
return 16;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,54 +37,76 @@ package net.sourceforge.plantuml.project.draw;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderMonthly extends TimeHeaderCalendar {
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return 16 + 13;
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + 5;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
return 16 + 13 - 1;
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + 5;
|
||||
}
|
||||
|
||||
public TimeHeaderMonthly(TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale()));
|
||||
@Override
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder);
|
||||
}
|
||||
|
||||
public TimeHeaderMonthly(StringBounder stringBounder, TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(),
|
||||
thParam.getScale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||
drawYears(ug);
|
||||
drawMonths(ug.apply(UTranslate.dy(16)));
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
drawMonths(ug.apply(UTranslate.dy(h1 + 2)));
|
||||
printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, 16);
|
||||
drawHline(ug, getFullHeaderHeight());
|
||||
drawHline(ug, h1 + 2);
|
||||
drawHline(ug, h1 + 2 + h2 + 2);
|
||||
// drawHline(ug, getFullHeaderHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeFooter(UGraphic ug) {
|
||||
ug = ug.apply(UTranslate.dy(3));
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
// ug = ug.apply(UTranslate.dy(3));
|
||||
drawMonths(ug);
|
||||
drawYears(ug.apply(UTranslate.dy(13)));
|
||||
drawYears(ug.apply(UTranslate.dy(h2 + 2)));
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, 13);
|
||||
drawHline(ug, getTimeFooterHeight());
|
||||
drawHline(ug, h2 + 2);
|
||||
drawHline(ug, h1 + 2 + h2 + 2);
|
||||
// drawHline(ug, getTimeFooterHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
private void drawYears(final UGraphic ug) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
MonthYear last = null;
|
||||
double lastChange = -1;
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (last == null || wink.monthYear().year() != last.year()) {
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, 15);
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2);
|
||||
if (last != null)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
@ -96,16 +118,17 @@ public class TimeHeaderMonthly extends TimeHeaderCalendar {
|
||||
if (x1 > lastChange)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, (double) 15);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2);
|
||||
}
|
||||
|
||||
private void drawMonths(UGraphic ug) {
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
MonthYear last = null;
|
||||
double lastChange = -1;
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (wink.monthYear().equals(last) == false) {
|
||||
drawVline(ug.apply(getLineColor()), x1, (double) 0, (double) 12);
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, h2 + 2);
|
||||
if (last != null)
|
||||
printMonth(ug, last, lastChange, x1);
|
||||
|
||||
@ -117,17 +140,17 @@ public class TimeHeaderMonthly extends TimeHeaderCalendar {
|
||||
if (x1 > lastChange)
|
||||
printMonth(ug, last, lastChange, x1);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, (double) 12);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h2 + 2);
|
||||
}
|
||||
|
||||
private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock small = getTextBlock("" + monthYear.year(), 12, true, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.month, "" + monthYear.year(), true, openFontColor());
|
||||
printCentered(ug, false, start, end, small);
|
||||
}
|
||||
|
||||
private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock small = getTextBlock(monthYear.shortName(locale()), 10, false, openFontColor());
|
||||
final TextBlock big = getTextBlock(monthYear.longName(locale()), 10, false, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.day, monthYear.shortName(locale()), false, openFontColor());
|
||||
final TextBlock big = getTextBlock(SName.day, monthYear.longName(locale()), false, openFontColor());
|
||||
printCentered(ug, false, start, end, small, big);
|
||||
}
|
||||
|
||||
@ -135,9 +158,4 @@ public class TimeHeaderMonthly extends TimeHeaderCalendar {
|
||||
text.drawU(ug.apply(UTranslate.dx(start)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,54 +37,76 @@ package net.sourceforge.plantuml.project.draw;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return 16 + 13;
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + 5;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
return 16 + 13 - 1;
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + 5;
|
||||
}
|
||||
|
||||
public TimeHeaderQuarterly(TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale()));
|
||||
@Override
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder);
|
||||
}
|
||||
|
||||
public TimeHeaderQuarterly(StringBounder stringBounder, TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(),
|
||||
thParam.getScale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||
drawYears(ug);
|
||||
drawQuarters(ug.apply(UTranslate.dy(16)));
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
drawQuarters(ug.apply(UTranslate.dy(h1 + 2)));
|
||||
printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, 16);
|
||||
drawHline(ug, getFullHeaderHeight());
|
||||
drawHline(ug, h1 + 2);
|
||||
drawHline(ug, h1 + 2 + h2 + 2);
|
||||
// drawHline(ug, getFullHeaderHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeFooter(UGraphic ug) {
|
||||
ug = ug.apply(UTranslate.dy(3));
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
// ug = ug.apply(UTranslate.dy(3));
|
||||
drawQuarters(ug);
|
||||
drawYears(ug.apply(UTranslate.dy(13)));
|
||||
drawYears(ug.apply(UTranslate.dy(h2 + 2)));
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, 13);
|
||||
drawHline(ug, getTimeFooterHeight());
|
||||
drawHline(ug, h2 + 2);
|
||||
drawHline(ug, h1 + 2 + h2 + 2);
|
||||
// drawHline(ug, getTimeFooterHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
private void drawYears(final UGraphic ug) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
MonthYear last = null;
|
||||
double lastChange = -1;
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (last == null || wink.monthYear().year() != last.year()) {
|
||||
drawVline(ug.apply(getLineColor()), x1, (double) 0, (double) 15);
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2);
|
||||
if (last != null)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
@ -96,16 +118,17 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
if (x1 > lastChange)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, (double) 15);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2);
|
||||
}
|
||||
|
||||
private void drawQuarters(UGraphic ug) {
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
String last = null;
|
||||
double lastChange = -1;
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (quarter(wink).equals(last) == false) {
|
||||
drawVline(ug.apply(getLineColor()), x1, (double) 0, (double) 12);
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, h2 + 2);
|
||||
if (last != null)
|
||||
printQuarter(ug, last, lastChange, x1);
|
||||
|
||||
@ -117,7 +140,7 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
if (x1 > lastChange)
|
||||
printQuarter(ug, last, lastChange, x1);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, (double) 12);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h2 + 2);
|
||||
}
|
||||
|
||||
private String quarter(Day day) {
|
||||
@ -125,12 +148,12 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock small = getTextBlock("" + monthYear.year(), 12, true, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.month, "" + monthYear.year(), true, openFontColor());
|
||||
printCentered(ug, false, start, end, small);
|
||||
}
|
||||
|
||||
private void printQuarter(UGraphic ug, String quarter, double start, double end) {
|
||||
final TextBlock small = getTextBlock(quarter, 10, false, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.day, quarter, false, openFontColor());
|
||||
printCentered(ug, false, start, end, small);
|
||||
}
|
||||
|
||||
@ -138,9 +161,4 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
text.drawU(ug.apply(UTranslate.dx(start)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.color.HColor;
|
||||
import net.sourceforge.plantuml.klimt.creole.Display;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.font.UFont;
|
||||
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.ULine;
|
||||
@ -48,30 +51,36 @@ import net.sourceforge.plantuml.project.core.PrintScale;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScale;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleWink;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderSimple extends TimeHeader {
|
||||
|
||||
private final PrintScale printScale;
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight() + getHeaderNameDayHeight();
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder) + getHeaderNameDayHeight();
|
||||
}
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return 16;
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
return h + 6;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
return 16;
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
return h + 6;
|
||||
}
|
||||
|
||||
private double getHeaderNameDayHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public TimeHeaderSimple(TimeHeaderParameters thParam, PrintScale printScale) {
|
||||
super(thParam, new TimeScaleWink(thParam.getScale(), printScale));
|
||||
public TimeHeaderSimple(StringBounder stringBounder, TimeHeaderParameters thParam, PrintScale printScale) {
|
||||
super(thParam, new TimeScaleWink(thParam.getCellWidth(stringBounder), thParam.getScale(), printScale));
|
||||
this.printScale = printScale;
|
||||
}
|
||||
|
||||
@ -91,9 +100,10 @@ public class TimeHeaderSimple extends TimeHeader {
|
||||
value = i.getAbsoluteDayNum() / 7 + 1;
|
||||
else
|
||||
value = i.getAbsoluteDayNum() + 1;
|
||||
final TextBlock num = Display.getWithNewlines("" + value).create(
|
||||
getFontConfiguration(10, false, openFontColor()), HorizontalAlignment.LEFT,
|
||||
new SpriteContainerEmpty());
|
||||
final UFont font = thParam.getStyle(SName.timeline, SName.day).getUFont();
|
||||
final FontConfiguration fontConfiguration = getFontConfiguration(font, false, openFontColor());
|
||||
final TextBlock num = Display.getWithNewlines("" + value).create(fontConfiguration,
|
||||
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
|
||||
final double x1 = timeScale.getStartingPosition(i);
|
||||
final double x2;
|
||||
if (printScale == PrintScale.WEEKLY)
|
||||
@ -110,15 +120,15 @@ public class TimeHeaderSimple extends TimeHeader {
|
||||
|
||||
@Override
|
||||
public void drawTimeHeader(UGraphic ug, double totalHeightWithoutFooter) {
|
||||
drawTextsBackground(ug.apply(UTranslate.dy(-3)), totalHeightWithoutFooter + 6);
|
||||
// drawTextsBackground(ug.apply(UTranslate.dy(-3)), totalHeightWithoutFooter + 6);
|
||||
final double xmin = getTimeScale().getStartingPosition(getMin());
|
||||
final double xmax = getTimeScale().getEndingPosition(getMax());
|
||||
drawSmallVlinesDay(ug, getTimeScale(), totalHeightWithoutFooter + 2);
|
||||
printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
drawSimpleDayCounter(ug, getTimeScale());
|
||||
ug = ug.apply(getLineColor());
|
||||
ug.draw(ULine.hline(xmax - xmin));
|
||||
ug.apply(UTranslate.dy(getFullHeaderHeight() - 3)).draw(ULine.hline(xmax - xmin));
|
||||
// ug = ug.apply(getLineColor());
|
||||
// ug.draw(ULine.hline(xmax - xmin));
|
||||
// ug.apply(UTranslate.dy(getFullHeaderHeight(ug.getStringBounder()) - 3)).draw(ULine.hline(xmax - xmin));
|
||||
|
||||
}
|
||||
|
||||
@ -127,9 +137,9 @@ public class TimeHeaderSimple extends TimeHeader {
|
||||
final double xmin = getTimeScale().getStartingPosition(getMin());
|
||||
final double xmax = getTimeScale().getEndingPosition(getMax());
|
||||
ug = ug.apply(UTranslate.dy(3));
|
||||
drawSmallVlinesDay(ug, getTimeScale(), getTimeFooterHeight() - 3);
|
||||
drawSmallVlinesDay(ug, getTimeScale(), getTimeFooterHeight(ug.getStringBounder()) - 3);
|
||||
drawSimpleDayCounter(ug, getTimeScale());
|
||||
ug.apply(getLineColor()).draw(ULine.hline(xmax - xmin));
|
||||
// ug.apply(getLineColor()).draw(ULine.hline(xmax - xmin));
|
||||
}
|
||||
|
||||
// Duplicate in TimeHeaderDaily
|
||||
@ -151,7 +161,7 @@ public class TimeHeaderSimple extends TimeHeader {
|
||||
|
||||
protected final void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
|
||||
|
||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
|
||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight(ug.getStringBounder());
|
||||
Pending pending = null;
|
||||
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) {
|
||||
|
@ -37,29 +37,48 @@ package net.sourceforge.plantuml.project.draw;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.time.WeekNumberStrategy;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
|
||||
private final WeekNumberStrategy weekNumberStrategy;
|
||||
private final boolean withCalendarDate;
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return 16 + 13;
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble();
|
||||
final double h2 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble();
|
||||
return h1 + h2 + 5;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
return 16;
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 4;
|
||||
return h;
|
||||
}
|
||||
|
||||
public TimeHeaderWeekly(TimeHeaderParameters thParam, WeekNumberStrategy weekNumberStrategy,
|
||||
boolean withCalendarDate) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale()));
|
||||
@Override
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder);
|
||||
}
|
||||
|
||||
private double getH1(StringBounder stringBounder) {
|
||||
final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 4;
|
||||
return h;
|
||||
}
|
||||
|
||||
public TimeHeaderWeekly(StringBounder stringBounder, TimeHeaderParameters thParam,
|
||||
WeekNumberStrategy weekNumberStrategy, boolean withCalendarDate) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(),
|
||||
thParam.getScale()));
|
||||
this.weekNumberStrategy = weekNumberStrategy;
|
||||
this.withCalendarDate = withCalendarDate;
|
||||
}
|
||||
@ -69,15 +88,15 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
drawTextsBackground(ug, totalHeightWithoutFooter);
|
||||
drawCalendar(ug, totalHeightWithoutFooter);
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, Y_POS_ROW16());
|
||||
drawHline(ug, getFullHeaderHeight());
|
||||
drawHline(ug, getH1(ug.getStringBounder()));
|
||||
drawHline(ug, getFullHeaderHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeFooter(UGraphic ug) {
|
||||
drawHline(ug, 0);
|
||||
printMonths(ug);
|
||||
drawHline(ug, getTimeFooterHeight());
|
||||
drawHline(ug, getTimeFooterHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
private void drawCalendar(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||
@ -92,7 +111,7 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (wink.monthYear().equals(last) == false) {
|
||||
drawVline(ug.apply(getLineColor()), x1, (double) 0, Y_POS_ROW16());
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, getH1(ug.getStringBounder()));
|
||||
if (last != null)
|
||||
printMonth(ug, last, lastChangeMonth, x1);
|
||||
|
||||
@ -100,9 +119,10 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
last = wink.monthYear();
|
||||
}
|
||||
}
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, Y_POS_ROW16());
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0,
|
||||
getH1(ug.getStringBounder()));
|
||||
final double x1 = getTimeScale().getStartingPosition(getMax().increment());
|
||||
if (x1 > lastChangeMonth)
|
||||
if (last != null && x1 > lastChangeMonth)
|
||||
printMonth(ug, last, lastChangeMonth, x1);
|
||||
|
||||
}
|
||||
@ -111,9 +131,11 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
protected void printVerticalSeparators(final UGraphic ug, double totalHeightWithoutFooter) {
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment())
|
||||
if (wink.getDayOfWeek() == weekNumberStrategy.getFirstDayOfWeek())
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getStartingPosition(wink), Y_POS_ROW16(), totalHeightWithoutFooter);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getStartingPosition(wink),
|
||||
getH1(ug.getStringBounder()), totalHeightWithoutFooter);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), Y_POS_ROW16(), totalHeightWithoutFooter);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), getH1(ug.getStringBounder()),
|
||||
totalHeightWithoutFooter);
|
||||
super.printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
}
|
||||
|
||||
@ -125,16 +147,16 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
num = "" + wink.getDayOfMonth();
|
||||
else
|
||||
num = "" + wink.getWeekOfYear(weekNumberStrategy);
|
||||
final TextBlock textBlock = getTextBlock(num, 10, false, openFontColor());
|
||||
printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16())), textBlock,
|
||||
final TextBlock textBlock = getTextBlock(SName.day, num, false, openFontColor());
|
||||
printLeft(ug.apply(UTranslate.dy(getH1(ug.getStringBounder()))), textBlock,
|
||||
getTimeScale().getStartingPosition(wink) + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock small = getTextBlock(monthYear.shortName(locale()), 12, true, openFontColor());
|
||||
final TextBlock big = getTextBlock(monthYear.shortNameYYYY(locale()), 12, true, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.month, monthYear.shortName(locale()), true, openFontColor());
|
||||
final TextBlock big = getTextBlock(SName.month, monthYear.shortNameYYYY(locale()), true, openFontColor());
|
||||
printCentered(ug, false, start, end, small, big);
|
||||
}
|
||||
|
||||
@ -142,9 +164,4 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
text.drawU(ug.apply(UTranslate.dx(start)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,24 +37,37 @@ package net.sourceforge.plantuml.project.draw;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.project.TimeHeaderParameters;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.MonthYear;
|
||||
import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public class TimeHeaderYearly extends TimeHeaderCalendar {
|
||||
|
||||
public double getTimeHeaderHeight() {
|
||||
return 20;
|
||||
@Override
|
||||
public double getTimeHeaderHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
return h1 + 3;
|
||||
}
|
||||
|
||||
public double getTimeFooterHeight() {
|
||||
return 20 - 1;
|
||||
@Override
|
||||
public double getTimeFooterHeight(StringBounder stringBounder) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
return h1 + 3;
|
||||
}
|
||||
|
||||
public TimeHeaderYearly(TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale()));
|
||||
@Override
|
||||
public double getFullHeaderHeight(StringBounder stringBounder) {
|
||||
return getTimeHeaderHeight(stringBounder);
|
||||
}
|
||||
|
||||
public TimeHeaderYearly(StringBounder stringBounder, TimeHeaderParameters thParam) {
|
||||
super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(),
|
||||
thParam.getScale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,24 +76,26 @@ public class TimeHeaderYearly extends TimeHeaderCalendar {
|
||||
drawYears(ug);
|
||||
printVerticalSeparators(ug, totalHeightWithoutFooter);
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, getFullHeaderHeight());
|
||||
drawHline(ug, getFullHeaderHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTimeFooter(UGraphic ug) {
|
||||
ug = ug.apply(UTranslate.dy(3));
|
||||
// ug = ug.apply(UTranslate.dy(3));
|
||||
drawYears(ug);
|
||||
drawHline(ug, 0);
|
||||
drawHline(ug, getTimeFooterHeight());
|
||||
drawHline(ug, getTimeFooterHeight(ug.getStringBounder()));
|
||||
}
|
||||
|
||||
private void drawYears(final UGraphic ug) {
|
||||
final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble();
|
||||
|
||||
MonthYear last = null;
|
||||
double lastChange = -1;
|
||||
for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) {
|
||||
final double x1 = getTimeScale().getStartingPosition(wink);
|
||||
if (last == null || wink.monthYear().year() != last.year()) {
|
||||
drawVline(ug.apply(getLineColor()), x1, (double) 0, (double) 19);
|
||||
drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2);
|
||||
if (last != null)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
@ -92,17 +107,12 @@ public class TimeHeaderYearly extends TimeHeaderCalendar {
|
||||
if (x1 > lastChange)
|
||||
printYear(ug, last, lastChange, x1);
|
||||
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, (double) 19);
|
||||
drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2);
|
||||
}
|
||||
|
||||
private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) {
|
||||
final TextBlock small = getTextBlock("" + monthYear.year(), 14, true, openFontColor());
|
||||
final TextBlock small = getTextBlock(SName.year, "" + monthYear.year(), true, openFontColor());
|
||||
printCentered(ug, true, start, end, small);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFullHeaderHeight() {
|
||||
return getTimeHeaderHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.project.lang;
|
||||
|
||||
import net.sourceforge.plantuml.project.Failable;
|
||||
import net.sourceforge.plantuml.project.GanttDiagram;
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.regex.RegexResult;
|
||||
|
||||
public class ComplementAnything implements Something {
|
||||
|
||||
public IRegex toRegex(String suffix) {
|
||||
return new RegexLeaf("ANYTHING" + suffix, "(.*?)");
|
||||
}
|
||||
|
||||
public Failable<String> getMe(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
final String value = arg.get("ANYTHING" + suffix, 0);
|
||||
return Failable.ok(value);
|
||||
}
|
||||
}
|
@ -38,7 +38,6 @@ package net.sourceforge.plantuml.project.lang;
|
||||
import net.sourceforge.plantuml.project.Failable;
|
||||
import net.sourceforge.plantuml.project.GanttDiagram;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.Month;
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||
@ -70,40 +69,14 @@ public class ComplementDate implements Something {
|
||||
}
|
||||
|
||||
public IRegex toRegex(String suffix) {
|
||||
final DayPattern dayPattern = new DayPattern(suffix);
|
||||
switch (type) {
|
||||
case ONLY_ABSOLUTE:
|
||||
return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix));
|
||||
return dayPattern.toRegex();
|
||||
case ONLY_RELATIVE:
|
||||
return new RegexOr(toRegexD(suffix), toRegexE(suffix));
|
||||
}
|
||||
return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix), toRegexD(suffix), toRegexE(suffix));
|
||||
}
|
||||
|
||||
private IRegex toRegexA(String suffix) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("ADAY" + suffix, "([\\d]+)"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf("AMONTH" + suffix, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf("AYEAR" + suffix, "([\\d]{4})"));
|
||||
}
|
||||
|
||||
private IRegex toRegexB(String suffix) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("BYEAR" + suffix, "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH" + suffix, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY" + suffix, "([\\d]{1,2})"));
|
||||
}
|
||||
|
||||
private IRegex toRegexC(String suffix) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("CMONTH" + suffix, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf("CDAY" + suffix, "([\\d]+)"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf("CYEAR" + suffix, "([\\d]{4})"));
|
||||
return new RegexOr(dayPattern.toRegex(), toRegexD(suffix), toRegexE(suffix));
|
||||
}
|
||||
|
||||
private IRegex toRegexD(String suffix) {
|
||||
@ -126,14 +99,11 @@ public class ComplementDate implements Something {
|
||||
}
|
||||
|
||||
public Failable<Day> getMe(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
if (arg.get("ADAY" + suffix, 0) != null)
|
||||
return Failable.ok(resultA(arg, suffix));
|
||||
final DayPattern dayPattern = new DayPattern(suffix);
|
||||
final Day result = dayPattern.getDay(arg);
|
||||
|
||||
if (arg.get("BDAY" + suffix, 0) != null)
|
||||
return Failable.ok(resultB(arg, suffix));
|
||||
|
||||
if (arg.get("CDAY" + suffix, 0) != null)
|
||||
return Failable.ok(resultC(arg, suffix));
|
||||
if (result != null)
|
||||
return Failable.ok(result);
|
||||
|
||||
if (arg.get("DCOUNT" + suffix, 0) != null)
|
||||
return Failable.ok(resultD(system, arg, suffix));
|
||||
@ -144,27 +114,6 @@ public class ComplementDate implements Something {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private Day resultA(RegexResult arg, String suffix) {
|
||||
final int day = Integer.parseInt(arg.get("ADAY" + suffix, 0));
|
||||
final String month = arg.get("AMONTH" + suffix, 0);
|
||||
final int year = Integer.parseInt(arg.get("AYEAR" + suffix, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
private Day resultB(RegexResult arg, String suffix) {
|
||||
final int day = Integer.parseInt(arg.get("BDAY" + suffix, 0));
|
||||
final int month = Integer.parseInt(arg.get("BMONTH" + suffix, 0));
|
||||
final int year = Integer.parseInt(arg.get("BYEAR" + suffix, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
private Day resultC(RegexResult arg, String suffix) {
|
||||
final int day = Integer.parseInt(arg.get("CDAY" + suffix, 0));
|
||||
final String month = arg.get("CMONTH" + suffix, 0);
|
||||
final int year = Integer.parseInt(arg.get("CYEAR" + suffix, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
private Day resultD(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
final int day = Integer.parseInt(arg.get("DCOUNT" + suffix, 0));
|
||||
return system.getStartingDate().addDays(day);
|
||||
|
@ -52,20 +52,14 @@ public class ComplementDates implements Something {
|
||||
}
|
||||
|
||||
private IRegex toRegexB(String suffix) {
|
||||
final DayPattern dayPattern1 = new DayPattern("1");
|
||||
final DayPattern dayPattern2 = new DayPattern("2");
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("BYEAR1" + suffix, "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH1" + suffix, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY1" + suffix, "([\\d]{1,2})"), //
|
||||
dayPattern1.toRegex(), //
|
||||
Words.exactly(Words.TO), //
|
||||
Words.zeroOrMore(Words.THE), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("BYEAR2" + suffix, "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH2" + suffix, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY2" + suffix, "([\\d]{1,2})") //
|
||||
dayPattern2.toRegex() //
|
||||
);
|
||||
}
|
||||
|
||||
@ -82,30 +76,19 @@ public class ComplementDates implements Something {
|
||||
}
|
||||
|
||||
public Failable<DaysAsDates> getMe(GanttDiagram project, RegexResult arg, String suffix) {
|
||||
if (arg.get("BDAY1" + suffix, 0) != null) {
|
||||
return Failable.ok(resultB(arg, suffix));
|
||||
final Day d1 = new DayPattern("1").getDay(arg);
|
||||
if (d1 != null) {
|
||||
final Day d2 = new DayPattern("2").getDay(arg);
|
||||
return Failable.ok(new DaysAsDates(d1, d2));
|
||||
}
|
||||
if (arg.get("ECOUNT1" + suffix, 0) != null) {
|
||||
|
||||
if (arg.get("ECOUNT1" + suffix, 0) != null)
|
||||
return Failable.ok(resultE(project, arg, suffix));
|
||||
}
|
||||
|
||||
throw new IllegalStateException();
|
||||
|
||||
}
|
||||
|
||||
private DaysAsDates resultB(RegexResult arg, String suffix) {
|
||||
final int day1 = Integer.parseInt(arg.get("BDAY1" + suffix, 0));
|
||||
final int month1 = Integer.parseInt(arg.get("BMONTH1" + suffix, 0));
|
||||
final int year1 = Integer.parseInt(arg.get("BYEAR1" + suffix, 0));
|
||||
final Day date1 = Day.create(year1, month1, day1);
|
||||
|
||||
final int day2 = Integer.parseInt(arg.get("BDAY2" + suffix, 0));
|
||||
final int month2 = Integer.parseInt(arg.get("BMONTH2" + suffix, 0));
|
||||
final int year2 = Integer.parseInt(arg.get("BYEAR2" + suffix, 0));
|
||||
final Day date2 = Day.create(year2, month2, day2);
|
||||
|
||||
return new DaysAsDates(date1, date2);
|
||||
}
|
||||
|
||||
private DaysAsDates resultE(GanttDiagram project, RegexResult arg, String suffix) {
|
||||
final int day1 = Integer.parseInt(arg.get("ECOUNT1" + suffix, 0));
|
||||
final Day date1 = project.getStartingDate().addDays(day1);
|
||||
|
136
src/net/sourceforge/plantuml/project/lang/DayPattern.java
Normal file
136
src/net/sourceforge/plantuml/project/lang/DayPattern.java
Normal file
@ -0,0 +1,136 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.project.lang;
|
||||
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
import net.sourceforge.plantuml.project.time.Month;
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.regex.RegexOr;
|
||||
import net.sourceforge.plantuml.regex.RegexResult;
|
||||
|
||||
public class DayPattern {
|
||||
|
||||
private final String id;
|
||||
private final String yearKeyA;
|
||||
private final String yearKeyB;
|
||||
private final String yearKeyC;
|
||||
private final String monthKeyA;
|
||||
private final String monthKeyB;
|
||||
private final String monthKeyC;
|
||||
private final String dayKeyA;
|
||||
private final String dayKeyB;
|
||||
private final String dayKeyC;
|
||||
|
||||
public DayPattern(String id) {
|
||||
this.id = id;
|
||||
this.yearKeyA = "AYEAR" + id;
|
||||
this.yearKeyB = "BYEAR" + id;
|
||||
this.yearKeyC = "CYEAR" + id;
|
||||
this.monthKeyA = "AMONTH" + id;
|
||||
this.monthKeyB = "BMONTH" + id;
|
||||
this.monthKeyC = "CMONTH" + id;
|
||||
this.dayKeyA = "ADAY" + id;
|
||||
this.dayKeyB = "BDAY" + id;
|
||||
this.dayKeyC = "CDAY" + id;
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexOr(toRegexA_DD_MONTH_YYYY(), toRegexB_YYYY_MM_DD(), toRegexC_MONTH_DD_YYYY());
|
||||
}
|
||||
|
||||
public Day getDay(RegexResult arg) {
|
||||
if (arg.get(dayKeyA, 0) != null)
|
||||
return resultA(arg);
|
||||
|
||||
if (arg.get(dayKeyB, 0) != null)
|
||||
return resultB(arg);
|
||||
|
||||
if (arg.get(dayKeyC, 0) != null)
|
||||
return resultC(arg);
|
||||
return null;
|
||||
}
|
||||
|
||||
private IRegex toRegexA_DD_MONTH_YYYY() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(dayKeyA, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(monthKeyA, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(yearKeyA, "([\\d]{1,4})"));
|
||||
}
|
||||
|
||||
private Day resultA(RegexResult arg) {
|
||||
final int day = Integer.parseInt(arg.get(dayKeyA, 0));
|
||||
final String month = arg.get(monthKeyA, 0);
|
||||
final int year = Integer.parseInt(arg.get(yearKeyA, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
private IRegex toRegexB_YYYY_MM_DD() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(yearKeyB, "([\\d]{1,4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf(monthKeyB, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf(dayKeyB, "([\\d]{1,2})"));
|
||||
}
|
||||
|
||||
private Day resultB(RegexResult arg) {
|
||||
final int day = Integer.parseInt(arg.get(dayKeyB, 0));
|
||||
final int month = Integer.parseInt(arg.get(monthKeyB, 0));
|
||||
final int year = Integer.parseInt(arg.get(yearKeyB, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
private IRegex toRegexC_MONTH_DD_YYYY() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(monthKeyC, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(dayKeyC, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(yearKeyC, "([\\d]{1,4})"));
|
||||
}
|
||||
|
||||
private Day resultC(RegexResult arg) {
|
||||
final int day = Integer.parseInt(arg.get(dayKeyC, 0));
|
||||
final String month = arg.get(monthKeyC, 0);
|
||||
final int year = Integer.parseInt(arg.get(yearKeyC, 0));
|
||||
return Day.create(year, month, day);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.project.lang;
|
||||
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.project.GanttDiagram;
|
||||
import net.sourceforge.plantuml.project.core.Task;
|
||||
|
||||
public class SentenceIsDisplayedAs extends SentenceSimple {
|
||||
|
||||
public SentenceIsDisplayedAs() {
|
||||
super(SubjectTask.ME, Verbs.isDisplayedAs, new ComplementAnything());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) {
|
||||
final Task task = (Task) subject;
|
||||
final String displayString = (String) complement;
|
||||
task.setDisplay(displayString);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
@ -138,12 +138,7 @@ public class SubjectDayAsDate implements Subject {
|
||||
}
|
||||
|
||||
private IRegex toRegexB() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("BYEAR", "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH", "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY", "([\\d]{1,2})"));
|
||||
return TimeResolution.toRegexB_YYYY_MM_DD("BYEAR", "BMONTH", "BDAY");
|
||||
}
|
||||
|
||||
private IRegex toRegexE() {
|
||||
|
@ -63,19 +63,10 @@ public class SubjectDaysAsDates implements Subject {
|
||||
|
||||
private IRegex toRegexB() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("BYEAR1", "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH1", "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY1", "([\\d]{1,2})"), //
|
||||
TimeResolution.toRegexB_YYYY_MM_DD("BYEAR1", "BMONTH1", "BDAY1"), //
|
||||
Words.exactly(Words.TO), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("to"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("BYEAR2", "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH2", "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY2", "([\\d]{1,2})") //
|
||||
TimeResolution.toRegexB_YYYY_MM_DD("BYEAR2", "BMONTH2", "BDAY2") //
|
||||
);
|
||||
}
|
||||
|
||||
@ -83,8 +74,7 @@ public class SubjectDaysAsDates implements Subject {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("[dD]\\+"), //
|
||||
new RegexLeaf("ECOUNT1", "([\\d]+)"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("to"), //
|
||||
Words.exactly(Words.TO), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("[dD]\\+"), //
|
||||
new RegexLeaf("ECOUNT2", "([\\d]+)") //
|
||||
@ -93,13 +83,8 @@ public class SubjectDaysAsDates implements Subject {
|
||||
|
||||
private IRegex andRegex() {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf("BYEAR3", "([\\d]{4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BMONTH3", "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf("BDAY3", "([\\d]{1,2})"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("and"), //
|
||||
TimeResolution.toRegexB_YYYY_MM_DD("BYEAR3", "BMONTH3", "BDAY3"), //
|
||||
Words.exactly(Words.AND), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("COUNT_AND", "([\\d]+)"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
|
@ -96,7 +96,7 @@ public class SubjectTask implements Subject {
|
||||
new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsColoredForCompletion(),
|
||||
new SentenceIsDeleted(), new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(),
|
||||
new SentenceDisplayOnSameRowAs(), new SentencePausesDate(), new SentencePausesDates(),
|
||||
new SentencePausesDayOfWeek());
|
||||
new SentencePausesDayOfWeek(), new SentenceIsDisplayedAs());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
@ -106,8 +106,7 @@ public class SubjectTask implements Subject {
|
||||
new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\](?:[%s]+as[%s]+\\[([^\\[\\]]+?)\\])?"), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("on"), //
|
||||
Words.exactly(Words.ON), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("RESOURCE", "((?:\\{[^{}]+\\}[%s]*)+)") //
|
||||
))));
|
||||
|
@ -0,0 +1,72 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.project.lang;
|
||||
|
||||
import net.sourceforge.plantuml.project.time.Month;
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||
|
||||
public abstract class TimeResolution {
|
||||
|
||||
public static IRegex toRegexA_DD_MONTH_YYYY(String year, String month, String day) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(day, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(month, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(year, "([\\d]{1,4})"));
|
||||
}
|
||||
|
||||
public static IRegex toRegexB_YYYY_MM_DD(String year, String month, String day) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(year, "([\\d]{1,4})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf(month, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("\\D"), //
|
||||
new RegexLeaf(day, "([\\d]{1,2})"));
|
||||
}
|
||||
|
||||
public static IRegex toRegexC_MONTH_DD_YYYY(String year, String month, String day) {
|
||||
return new RegexConcat( //
|
||||
new RegexLeaf(month, "(" + Month.getRegexString() + ")"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(day, "([\\d]{1,2})"), //
|
||||
new RegexLeaf("[\\w, ]*?"), //
|
||||
new RegexLeaf(year, "([\\d]{1,4})"));
|
||||
}
|
||||
|
||||
}
|
@ -48,6 +48,7 @@ public class Verbs {
|
||||
public static IRegex is = new RegexLeaf("is");
|
||||
public static IRegex isColored = new RegexLeaf("is[%s]+colou?red");
|
||||
public static IRegex isDeleted = new RegexLeaf("is[%s]+deleted");
|
||||
public static IRegex isDisplayedAs = new RegexLeaf("is[%s]+displayed[%s]+as");
|
||||
public static IRegex isOff = new RegexLeaf("is[%s]+off");
|
||||
public static IRegex isOn = new RegexLeaf("is[%s]+on");
|
||||
public static IRegex isOrAre = new RegexLeaf("(is|are)");
|
||||
|
@ -44,6 +44,7 @@ import net.sourceforge.plantuml.regex.RegexRepeatedZeroOrMore;
|
||||
public class Words {
|
||||
|
||||
public final static String AFTER = "after";
|
||||
public final static String AND = "and";
|
||||
public final static String AT = "at";
|
||||
public final static String BEFORE = "before";
|
||||
public final static String COMPLETION = "completion";
|
||||
|
@ -42,8 +42,8 @@ public class TimeScaleCompressed implements TimeScale {
|
||||
|
||||
private final TimeScale daily;
|
||||
|
||||
public TimeScaleCompressed(Day calendar, double scale) {
|
||||
this.daily = new TimeScaleDaily(calendar, scale, null);
|
||||
public TimeScaleCompressed(double size, Day calendar, double scale) {
|
||||
this.daily = new TimeScaleDaily(size, calendar, scale, null);
|
||||
}
|
||||
|
||||
public double getStartingPosition(Day instant) {
|
||||
|
@ -39,13 +39,13 @@ import net.sourceforge.plantuml.project.core.PrintScale;
|
||||
import net.sourceforge.plantuml.project.time.Day;
|
||||
|
||||
public final class TimeScaleDaily implements TimeScale {
|
||||
// ::remove folder when __HAXE__
|
||||
// ::remove folder when __HAXE__
|
||||
|
||||
private final TimeScaleWink basic;
|
||||
private final double delta;
|
||||
|
||||
public TimeScaleDaily(Day startingDay, double scale, Day zeroDay) {
|
||||
this.basic = new TimeScaleWink(scale, PrintScale.DAILY);
|
||||
public TimeScaleDaily(double size, Day startingDay, double scale, Day zeroDay) {
|
||||
this.basic = new TimeScaleWink(size, scale, PrintScale.DAILY);
|
||||
if (zeroDay == null)
|
||||
this.delta = basic.getStartingPosition(startingDay);
|
||||
else
|
||||
|
@ -40,17 +40,17 @@ import net.sourceforge.plantuml.project.time.Day;
|
||||
|
||||
public class TimeScaleWink implements TimeScale {
|
||||
|
||||
private final double scale;
|
||||
private final double cellWidth;
|
||||
private final PrintScale printScale;
|
||||
|
||||
public TimeScaleWink(double scale, PrintScale printScale) {
|
||||
this.scale = 16.0 * scale;
|
||||
public TimeScaleWink(double size, double scale, PrintScale printScale) {
|
||||
this.cellWidth = size * scale;
|
||||
this.printScale = printScale;
|
||||
}
|
||||
|
||||
public double getStartingPosition(Day instant) {
|
||||
final long wink = instant.getMillis();
|
||||
return wink * scale / Day.MILLISECONDS_PER_DAY;
|
||||
return wink * cellWidth / Day.MILLISECONDS_PER_DAY;
|
||||
}
|
||||
|
||||
public double getEndingPosition(Day instant) {
|
||||
@ -58,7 +58,7 @@ public class TimeScaleWink implements TimeScale {
|
||||
}
|
||||
|
||||
public double getWidth(Day instant) {
|
||||
return scale;
|
||||
return cellWidth;
|
||||
}
|
||||
|
||||
public boolean isBreaking(Day instant) {
|
||||
|
@ -69,6 +69,7 @@ public enum SName {
|
||||
constraintArrow, //
|
||||
control, //
|
||||
database, //
|
||||
day, //
|
||||
delay, //
|
||||
destroy, //
|
||||
diamond, //
|
||||
@ -100,6 +101,7 @@ public enum SName {
|
||||
map, //
|
||||
milestone, //
|
||||
mindmapDiagram, //
|
||||
month, //
|
||||
network, //
|
||||
node, //
|
||||
note, //
|
||||
@ -139,6 +141,7 @@ public enum SName {
|
||||
unstarted, //
|
||||
usecase, //
|
||||
verticalSeparator, //
|
||||
year, //
|
||||
|
||||
visibilityIcon, //
|
||||
private_, //
|
||||
|
Loading…
Reference in New Issue
Block a user