mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
Merge pull request #518 from nicerloop/gantt-scale-compress
Add compress parameter to print scale command in gantt diagram
This commit is contained in:
commit
33ba37318c
@ -118,6 +118,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
private final Map<Day, String> nameDays = new HashMap<Day, String>();
|
||||
|
||||
private PrintScale printScale = PrintScale.DAILY;
|
||||
private Integer compress;
|
||||
private Day today;
|
||||
private double totalHeightWithoutFooter;
|
||||
private Day min = Day.create(0);
|
||||
@ -176,6 +177,17 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
this.printScale = printScale;
|
||||
}
|
||||
|
||||
|
||||
public void setCompress(int compress) {
|
||||
this.compress = compress;
|
||||
}
|
||||
|
||||
private int getCompress() {
|
||||
if (this.compress != null) {
|
||||
return this.compress;
|
||||
}
|
||||
return printScale.getCompress();
|
||||
}
|
||||
private boolean isHidden(Task task) {
|
||||
if (printStart == null || task instanceof TaskSeparator) {
|
||||
return false;
|
||||
@ -235,13 +247,13 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
if (openClose.getCalendar() == null) {
|
||||
return new TimeHeaderSimple(min, max);
|
||||
} else if (printScale == PrintScale.WEEKLY) {
|
||||
return new TimeHeaderWeekly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek);
|
||||
return new TimeHeaderWeekly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, getCompress());
|
||||
} else if (printScale == PrintScale.MONTHLY) {
|
||||
return new TimeHeaderMonthly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek);
|
||||
return new TimeHeaderMonthly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, getCompress());
|
||||
} else if (printScale == PrintScale.QUARTERLY) {
|
||||
return new TimeHeaderQuarterly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek);
|
||||
return new TimeHeaderQuarterly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, getCompress());
|
||||
} else if (printScale == PrintScale.YEARLY) {
|
||||
return new TimeHeaderYearly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek);
|
||||
return new TimeHeaderYearly(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek, getCompress());
|
||||
} else {
|
||||
return new TimeHeaderDaily(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek,
|
||||
nameDays, printStart, printEnd);
|
||||
|
@ -41,7 +41,9 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOr;
|
||||
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.project.GanttDiagram;
|
||||
import net.sourceforge.plantuml.project.core.PrintScale;
|
||||
@ -64,6 +66,11 @@ public class CommandPrintScale extends SingleLineCommand2<GanttDiagram> {
|
||||
new RegexLeaf("monthly"), //
|
||||
new RegexLeaf("daily"), //
|
||||
new RegexLeaf("weekly")), //
|
||||
new RegexOptional(new RegexConcat( //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("compress"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("COMPRESS", "(\\d+)"))), //
|
||||
RegexLeaf.end()); //
|
||||
}
|
||||
|
||||
@ -72,6 +79,10 @@ public class CommandPrintScale extends SingleLineCommand2<GanttDiagram> {
|
||||
final String scaleString = arg.get("SCALE", 0);
|
||||
final PrintScale scale = PrintScale.fromString(scaleString);
|
||||
diagram.setPrintScale(scale);
|
||||
RegexPartialMatch compress = arg.get("COMPRESS");
|
||||
if (compress.size() > 0 && compress.get(0) != null) {
|
||||
diagram.setCompress(Integer.parseInt(compress.get(0)));
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,9 @@ public class TimeHeaderMonthly extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
public TimeHeaderMonthly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, int compress) {
|
||||
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||
new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
||||
new TimeScaleCompressed(calendar, compress));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,9 +61,9 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
public TimeHeaderQuarterly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, int compress) {
|
||||
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||
new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
||||
new TimeScaleCompressed(calendar, compress));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,9 +61,9 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
public TimeHeaderWeekly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, int compress) {
|
||||
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||
new TimeScaleCompressed(calendar, PrintScale.WEEKLY.getCompress()));
|
||||
new TimeScaleCompressed(calendar, compress));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,9 +61,9 @@ public class TimeHeaderYearly extends TimeHeaderCalendar {
|
||||
}
|
||||
|
||||
public TimeHeaderYearly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek) {
|
||||
Map<DayOfWeek, HColor> colorDaysOfWeek, int compress) {
|
||||
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||
new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
||||
new TimeScaleCompressed(calendar, compress));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user