mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-30 00:33:53 +00:00
Refactor Gantt and clean TitledDiagram
This commit is contained in:
parent
0e0f7ef258
commit
e6437ce908
@ -243,9 +243,10 @@ public class PSystemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileFormat.getFileFormat() == FileFormat.PNG) {
|
if (fileFormat.getFileFormat() == FileFormat.PNG) {
|
||||||
|
final int dpi = system.getSkinParam().getDpi();
|
||||||
result = new PngSplitter(suggestedFile, system.getHorizontalPages(), system.getVerticalPages(),
|
result = new PngSplitter(suggestedFile, system.getHorizontalPages(), system.getVerticalPages(),
|
||||||
system.getMetadata(), (int) (system.getScaleCoef(fileFormat) * 96), fileFormat.isWithMetadata(),
|
system.getMetadata(), dpi, fileFormat.isWithMetadata(), system.getSkinParam().getSplitParam())
|
||||||
system.getSkinParam().getSplitParam()).getFiles();
|
.getFiles();
|
||||||
}
|
}
|
||||||
final List<FileImageData> result2 = new ArrayList<FileImageData>();
|
final List<FileImageData> result2 = new ArrayList<FileImageData>();
|
||||||
for (SFile f : result) {
|
for (SFile f : result) {
|
||||||
@ -255,29 +256,6 @@ public class PSystemUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static private List<FileImageData> exportDiagramsGantt1(GanttDiagram system,
|
|
||||||
// SuggestedFile suggestedFile,
|
|
||||||
// FileFormatOption fileFormat) throws IOException {
|
|
||||||
// if (suggestedFile.getFile(0).exists() &&
|
|
||||||
// suggestedFile.getFile(0).isDirectory()) {
|
|
||||||
// throw new IllegalArgumentException("File is a directory " + suggestedFile);
|
|
||||||
// }
|
|
||||||
// OutputStream os = null;
|
|
||||||
// ImageData imageData = null;
|
|
||||||
// try {
|
|
||||||
// if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
|
|
||||||
// return Collections.emptyList();
|
|
||||||
// }
|
|
||||||
// os = SecurityUtils.BufferedOutputStream(suggestedFile.getFile(0)));
|
|
||||||
// imageData = system.exportDiagram(os, 0, fileFormat);
|
|
||||||
// } finally {
|
|
||||||
// if (os != null) {
|
|
||||||
// os.close();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return Arrays.asList(new FileImageData(suggestedFile.getFile(0), imageData));
|
|
||||||
// }
|
|
||||||
|
|
||||||
static private List<FileImageData> exportDiagramsGantt2(GanttDiagram system, SuggestedFile suggestedFile,
|
static private List<FileImageData> exportDiagramsGantt2(GanttDiagram system, SuggestedFile suggestedFile,
|
||||||
FileFormatOption fileFormat) throws IOException {
|
FileFormatOption fileFormat) throws IOException {
|
||||||
if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
|
if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
|
||||||
|
@ -37,6 +37,8 @@ package net.sourceforge.plantuml;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.anim.Animation;
|
import net.sourceforge.plantuml.anim.Animation;
|
||||||
import net.sourceforge.plantuml.anim.AnimationDecoder;
|
import net.sourceforge.plantuml.anim.AnimationDecoder;
|
||||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
@ -50,8 +52,6 @@ import net.sourceforge.plantuml.sprite.Sprite;
|
|||||||
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
||||||
import net.sourceforge.plantuml.style.StyleBuilder;
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||||
|
|
||||||
import javax.script.ScriptException;
|
|
||||||
|
|
||||||
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated {
|
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated {
|
||||||
|
|
||||||
public static final boolean FORCE_SMETANA = false;
|
public static final boolean FORCE_SMETANA = false;
|
||||||
@ -212,15 +212,6 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
|
|||||||
return useSmetana;
|
return useSmetana;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
// TODO Well I think it's deprecated - whatever uses it should be looked at closely
|
|
||||||
public final double getScaleCoef(FileFormatOption fileFormatOption) {
|
|
||||||
if (getSkinParam().getDpi() == 96) {
|
|
||||||
return fileFormatOption.getScaleCoef();
|
|
||||||
}
|
|
||||||
return getSkinParam().getDpi() * fileFormatOption.getScaleCoef() / 96.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is for backwards compatibility with earlier default margins
|
// This is for backwards compatibility with earlier default margins
|
||||||
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
||||||
return ClockwiseTopRightBottomLeft.same(10);
|
return ClockwiseTopRightBottomLeft.same(10);
|
||||||
|
@ -241,11 +241,9 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
|||||||
if (openClose.getCalendar() == null) {
|
if (openClose.getCalendar() == null) {
|
||||||
return new TimeHeaderSimple(min, max);
|
return new TimeHeaderSimple(min, max);
|
||||||
} else if (printScale == PrintScale.WEEKLY) {
|
} 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);
|
||||||
nameDays);
|
|
||||||
} else if (printScale == PrintScale.MONTHLY) {
|
} 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);
|
||||||
nameDays);
|
|
||||||
} else {
|
} else {
|
||||||
return new TimeHeaderDaily(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek,
|
return new TimeHeaderDaily(openClose.getCalendar(), min, max, openClose, colorDays, colorDaysOfWeek,
|
||||||
nameDays, printStart, printEnd);
|
nameDays, printStart, printEnd);
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://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.draw;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.project.LoadPlanable;
|
||||||
|
import net.sourceforge.plantuml.project.time.Day;
|
||||||
|
import net.sourceforge.plantuml.project.time.DayOfWeek;
|
||||||
|
import net.sourceforge.plantuml.project.timescale.TimeScale;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
|
||||||
|
public abstract class TimeHeaderCalendar extends TimeHeader {
|
||||||
|
|
||||||
|
protected final LoadPlanable defaultPlan;
|
||||||
|
protected final Map<Day, HColor> colorDays;
|
||||||
|
protected final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
||||||
|
|
||||||
|
public TimeHeaderCalendar(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||||
|
Map<DayOfWeek, HColor> colorDaysOfWeek, TimeScale timeScale) {
|
||||||
|
super(min, max, timeScale);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -49,7 +49,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public class TimeHeaderDaily extends TimeHeader {
|
public class TimeHeaderDaily extends TimeHeaderCalendar {
|
||||||
|
|
||||||
protected double getTimeHeaderHeight() {
|
protected double getTimeHeaderHeight() {
|
||||||
return Y_POS_ROW28() + 13;
|
return Y_POS_ROW28() + 13;
|
||||||
@ -60,17 +60,11 @@ public class TimeHeaderDaily extends TimeHeader {
|
|||||||
return 24 + 14;
|
return 24 + 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LoadPlanable defaultPlan;
|
|
||||||
private final Map<Day, HColor> colorDays;
|
|
||||||
private final Map<DayOfWeek, HColor> colorDaysOfWeek;
|
|
||||||
private final Map<Day, String> nameDays;
|
private final Map<Day, String> nameDays;
|
||||||
|
|
||||||
public TimeHeaderDaily(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
public TimeHeaderDaily(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays, Day printStart, Day printEnd) {
|
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays, Day printStart, Day printEnd) {
|
||||||
super(min, max, new TimeScaleDaily(calendar, printStart));
|
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek, new TimeScaleDaily(calendar, printStart));
|
||||||
this.defaultPlan = defaultPlan;
|
|
||||||
this.colorDays = colorDays;
|
|
||||||
this.colorDaysOfWeek = colorDaysOfWeek;
|
|
||||||
this.nameDays = nameDays;
|
this.nameDays = nameDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +75,8 @@ public class TimeHeaderDaily extends TimeHeader {
|
|||||||
drawTextDayOfMonth(ug.apply(UTranslate.dy(Y_POS_ROW28())));
|
drawTextDayOfMonth(ug.apply(UTranslate.dy(Y_POS_ROW28())));
|
||||||
drawMonths(ug);
|
drawMonths(ug);
|
||||||
drawVBars(ug, totalHeightWithoutFooter);
|
drawVBars(ug, totalHeightWithoutFooter);
|
||||||
drawVbar(ug, getTimeScale().getStartingPosition(max.increment()), 0, totalHeightWithoutFooter + getTimeFooterHeight());
|
drawVbar(ug, getTimeScale().getStartingPosition(max.increment()), 0,
|
||||||
|
totalHeightWithoutFooter + getTimeFooterHeight());
|
||||||
printNamedDays(ug);
|
printNamedDays(ug);
|
||||||
drawHline(ug, 0);
|
drawHline(ug, 0);
|
||||||
drawHline(ug, getFullHeaderHeight());
|
drawHline(ug, getFullHeaderHeight());
|
||||||
@ -96,26 +91,6 @@ public class TimeHeaderDaily extends TimeHeader {
|
|||||||
drawHline(ug, getTimeFooterHeight());
|
drawHline(ug, getTimeFooterHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) {
|
|
||||||
final double height = totalHeightWithoutFooter - getFullHeaderHeight();
|
|
||||||
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) {
|
|
||||||
drawRectangle(ug.apply(back.bg()), height, x1 + 1, x2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawTextsDayOfWeek(UGraphic ug) {
|
private void drawTextsDayOfWeek(UGraphic ug) {
|
||||||
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 x1 = getTimeScale().getStartingPosition(wink);
|
||||||
|
@ -50,12 +50,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
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 TimeHeaderCalendar {
|
||||||
|
|
||||||
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;
|
||||||
@ -66,62 +61,9 @@ 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) {
|
||||||
super(min, max, new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||||
this.defaultPlan = defaultPlan;
|
new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress()));
|
||||||
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
|
||||||
|
@ -50,11 +50,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public class TimeHeaderWeekly extends TimeHeader {
|
public class TimeHeaderWeekly extends TimeHeaderCalendar {
|
||||||
|
|
||||||
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;
|
||||||
@ -65,11 +61,9 @@ public class TimeHeaderWeekly extends TimeHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TimeHeaderWeekly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
public TimeHeaderWeekly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
|
||||||
Map<DayOfWeek, HColor> colorDaysOfWeek, Map<Day, String> nameDays) {
|
Map<DayOfWeek, HColor> colorDaysOfWeek) {
|
||||||
super(min, max, new TimeScaleCompressed(calendar, PrintScale.WEEKLY.getCompress()));
|
super(calendar, min, max, defaultPlan, colorDays, colorDaysOfWeek,
|
||||||
this.defaultPlan = defaultPlan;
|
new TimeScaleCompressed(calendar, PrintScale.WEEKLY.getCompress()));
|
||||||
this.colorDays = colorDays;
|
|
||||||
this.colorDaysOfWeek = colorDaysOfWeek;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,57 +75,6 @@ public class TimeHeaderWeekly extends TimeHeader {
|
|||||||
drawHline(ug, getFullHeaderHeight());
|
drawHline(ug, getFullHeaderHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
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 drawTimeFooter(UGraphic ug) {
|
public void drawTimeFooter(UGraphic ug) {
|
||||||
drawHline(ug, 0);
|
drawHline(ug, 0);
|
||||||
@ -145,12 +88,6 @@ public class TimeHeaderWeekly extends TimeHeader {
|
|||||||
printMonths(ug);
|
printMonths(ug);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBack(UGraphic ug, Day start, Day end, double height) {
|
|
||||||
final double x1 = getTimeScale().getStartingPosition(start);
|
|
||||||
final double x2 = getTimeScale().getStartingPosition(end);
|
|
||||||
drawRectangle(ug, height, x1, x2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printMonths(final UGraphic ug) {
|
private void printMonths(final UGraphic ug) {
|
||||||
MonthYear last = null;
|
MonthYear last = null;
|
||||||
double lastChangeMonth = -1;
|
double lastChangeMonth = -1;
|
||||||
|
@ -117,6 +117,8 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
|
|||||||
if (widthwarning != null && widthwarning.matches("\\d+")) {
|
if (widthwarning != null && widthwarning.matches("\\d+")) {
|
||||||
warningOrError = svek2.getWarningOrError(Integer.parseInt(widthwarning));
|
warningOrError = svek2.getWarningOrError(Integer.parseInt(widthwarning));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sorry about this hack. There is a side effect in SvekResult::calculateDimension()
|
||||||
result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off
|
result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off
|
||||||
|
|
||||||
final HColor backcolor = result.getBackcolor();
|
final HColor backcolor = result.getBackcolor();
|
||||||
|
Loading…
Reference in New Issue
Block a user