From 55d1d81055262ad460383d2fd04e46d2c9d34f6e Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 25 Aug 2020 19:24:17 +0200 Subject: [PATCH] Import version 1.2020.16 --- pom.xml | 4 +- skin/plantuml.skin | 18 ++ src/net/sourceforge/plantuml/Option.java | 7 +- src/net/sourceforge/plantuml/Pipe.java | 2 +- src/net/sourceforge/plantuml/Run.java | 19 +-- src/net/sourceforge/plantuml/SkinParam.java | 3 + src/net/sourceforge/plantuml/Stdrpt.java | 5 + src/net/sourceforge/plantuml/StdrptNull.java | 14 ++ src/net/sourceforge/plantuml/StdrptPipe0.java | 14 ++ src/net/sourceforge/plantuml/StdrptV1.java | 14 ++ src/net/sourceforge/plantuml/StdrptV2.java | 95 +++++++++++ .../sourceforge/plantuml/TitledDiagram.java | 96 +++++++++-- src/net/sourceforge/plantuml/UmlDiagram.java | 71 +------- .../sourceforge/plantuml/UmlDiagramType.java | 5 +- src/net/sourceforge/plantuml/Url.java | 3 +- .../activitydiagram3/InstructionRepeat.java | 24 ++- .../command/CommandCreateClass.java | 45 ++--- .../command/CommandCreateClassMultilines.java | 1 + .../command/CommandLinkClass.java | 30 +++- .../plantuml/cucadiagram/GroupRoot.java | 11 +- .../plantuml/cucadiagram/IEntity.java | 8 +- .../plantuml/cucadiagram/Ident.java | 8 +- .../plantuml/cucadiagram/Link.java | 18 +- .../cucadiagram/entity/EntityImpl.java | 17 +- .../command/CommandLinkElement.java | 14 +- .../plantuml/donors/PSystemDonors.java | 40 ++--- .../plantuml/graphic/QuoteUtils.java | 3 +- .../plantuml/graphic/USymbolFrame.java | 2 +- .../plantuml/graphic/USymbolNode.java | 4 +- .../plantuml/nwdiag/DiagElement.java | 23 ++- .../nwdiag/GridTextBlockDecorated.java | 58 +++++-- .../plantuml/nwdiag/GridTextBlockSimple.java | 9 +- .../plantuml/nwdiag/LinkedElement.java | 83 +++++++--- .../plantuml/nwdiag/NwDiagram.java | 49 ++++-- .../plantuml/nwdiag/VerticalLine.java | 96 +++++++++++ .../sourceforge/plantuml/posimo/DotPath.java | 7 +- .../plantuml/project/Completion.java | 4 +- .../plantuml/project/DaysAsDates.java | 4 +- .../plantuml/project/GanttArrow.java | 39 +++-- .../plantuml/project/GanttConstraint.java | 26 ++- .../plantuml/project/GanttDiagram.java | 82 +++++++--- .../plantuml/project/GanttDiagramFactory.java | 77 ++++----- .../sourceforge/plantuml/project/Load.java | 4 +- .../project/{Solver3.java => Solver.java} | 4 +- .../{lang/Complement.java => ToTaskDraw.java} | 8 +- .../sourceforge/plantuml/project/Today.java | 4 +- .../project/command/CommandColorTask.java | 4 +- .../project/command/CommandGanttArrow.java | 11 +- .../project/command/CommandGanttArrow2.java | 9 +- .../project/command/CommandNoteBottom.java | 65 ++++++++ .../project/command/CommandPrintBetween.java | 4 +- .../project/command/NaturalCommand.java | 62 ++----- .../project/command/NaturalCommandAnd.java | 116 ------------- .../project/command/NaturalCommandAndAnd.java | 127 --------------- .../plantuml/project/core/AbstractTask.java | 28 +--- .../plantuml/project/core/Resource.java | 3 +- .../plantuml/project/core/Task.java | 20 ++- .../plantuml/project/core/TaskImpl.java | 112 +++++++++---- .../plantuml/project/core/TaskInstant.java | 16 +- .../plantuml/project/core/TaskSeparator.java | 17 +- .../project/draw/AbstractTaskDraw.java | 66 +++++++- .../plantuml/project/draw/ResourceDraw.java | 52 +++--- .../plantuml/project/draw/TaskDraw.java | 11 +- .../project/draw/TaskDrawDiamond.java | 33 ++-- .../project/draw/TaskDrawRegular.java | 141 +++++++++++----- .../project/draw/TaskDrawSeparator.java | 16 +- .../plantuml/project/draw/TimeHeader.java | 12 +- .../project/draw/TimeHeaderDaily.java | 33 ++-- .../project/draw/TimeHeaderMonthly.java | 6 +- .../project/draw/TimeHeaderSimple.java | 2 +- .../project/draw/TimeHeaderWeekly.java | 6 +- ...mentColors.java => CenterBorderColor.java} | 16 +- ...lementBeforeOrAfterOrAtTaskStartOrEnd.java | 8 +- .../project/lang/ComplementClose.java | 9 +- .../project/lang/ComplementCompleted.java | 6 +- .../plantuml/project/lang/ComplementDate.java | 22 +-- .../project/lang/ComplementDates.java | 19 +-- .../project/lang/ComplementDayOfWeek.java | 6 +- .../project/lang/ComplementEmpty.java | 7 +- ...rbIsDeleted.java => ComplementFromTo.java} | 28 +--- .../project/lang/ComplementInColors.java | 8 +- .../project/lang/ComplementInColors2.java | 9 +- .../project/lang/ComplementNamed.java | 6 +- .../plantuml/project/lang/ComplementOpen.java | 10 +- .../project/lang/ComplementSeveralDays.java | 6 +- .../plantuml/project/lang/ComplementUrl.java | 6 +- ...bAre.java => ComplementWithColorLink.java} | 34 ++-- ...erbIsForTask.java => PairOfSomething.java} | 46 +++--- .../{SubjectPattern.java => Sentence.java} | 11 +- .../lang/{VerbIsOn.java => SentenceAnd.java} | 73 +++++---- .../plantuml/project/lang/SentenceAndAnd.java | 111 +++++++++++++ .../lang/SentenceDisplayOnSameRowAs.java | 59 +++++++ .../{VerbIsColored.java => SentenceEnds.java} | 35 ++-- .../{VerbLasts.java => SentenceHappens.java} | 34 ++-- .../project/lang/SentenceHappensDate.java | 64 ++++++++ .../project/lang/SentenceIsColored.java | 56 +++++++ ...erbPattern.java => SentenceIsDeleted.java} | 20 ++- .../project/lang/SentenceIsForTask.java | 57 +++++++ .../plantuml/project/lang/SentenceLasts.java | 57 +++++++ .../project/lang/SentenceLinksTo.java | 57 +++++++ .../plantuml/project/lang/SentenceOccurs.java | 74 +++++++++ .../project/lang/SentencePausesDate.java | 62 +++++++ .../project/lang/SentencePausesDayOfWeek.java | 57 +++++++ .../{VerbIsOff.java => SentenceSimple.java} | 85 +++++----- ...day.java => SentenceTaskEndsAbsolute.java} | 34 ++-- ...{VerbEnds.java => SentenceTaskStarts.java} | 41 ++--- ...o.java => SentenceTaskStartsAbsolute.java} | 37 ++--- ....java => SentenceTaskStartsWithColor.java} | 47 +++--- ...{ComplementPattern.java => Something.java} | 6 +- .../plantuml/project/lang/Subject.java | 12 ++ .../project/lang/SubjectDayAsDate.java | 63 +++++-- .../project/lang/SubjectDayOfWeek.java | 31 +++- .../project/lang/SubjectDaysAsDates.java | 90 +++++++++- ...ColoredForToday.java => SubjectLinks.java} | 40 +++-- .../plantuml/project/lang/SubjectProject.java | 33 +++- .../project/lang/SubjectResource.java | 100 +++++++++++- .../plantuml/project/lang/SubjectTask.java | 50 +++--- .../plantuml/project/lang/SubjectToday.java | 49 +++++- .../{ComplementName.java => TwoNames.java} | 18 +- .../plantuml/project/lang/Verb.java | 4 +- .../plantuml/project/lang/VerbHappens.java | 85 ---------- .../plantuml/project/lang/VerbIsOrAre.java | 121 -------------- .../project/lang/VerbIsOrAreNamed.java | 73 --------- .../project/lang/VerbProjectStarts.java | 85 ---------- .../project/lang/VerbTaskEndsAbsolute.java | 74 --------- .../project/lang/VerbTaskStartsAbsolute.java | 74 --------- .../plantuml/project/lang/Verbs.java | 154 ++++++++++++++++++ .../plantuml/project/time/Day.java | 5 +- .../plantuml/project/time/DayOfWeek.java | 4 +- .../plantuml/project/timescale/TimeScale.java | 2 + .../timescale/TimeScaleCompressed.java | 9 + .../project/timescale/TimeScaleDaily.java | 4 + .../project/timescale/TimeScaleWink.java | 4 + .../UnusedTimeScaleWithoutWeekEnd.java | 4 + .../sequencediagram/command/CommandArrow.java | 15 +- .../plantuml/style/CommandStyleImport.java | 6 +- .../style/CommandStyleMultilinesCSS.java | 8 +- src/net/sourceforge/plantuml/style/SName.java | 3 + src/net/sourceforge/plantuml/svek/Line.java | 2 +- .../plantuml/svek/image/EntityImageClass.java | 2 +- .../sourceforge/plantuml/svg/SvgGraphics.java | 18 +- .../sourceforge/plantuml/ugraphic/UPath.java | 15 +- .../plantuml/ugraphic/URectangle.java | 29 ++-- .../ugraphic/svg/DriverRectangleSvg.java | 11 +- .../plantuml/ugraphic/svg/DriverTextSvg.java | 6 +- .../sourceforge/plantuml/version/Version.java | 4 +- 146 files changed, 2932 insertions(+), 1842 deletions(-) create mode 100644 src/net/sourceforge/plantuml/StdrptV2.java create mode 100644 src/net/sourceforge/plantuml/nwdiag/VerticalLine.java rename src/net/sourceforge/plantuml/project/{Solver3.java => Solver.java} (97%) rename src/net/sourceforge/plantuml/project/{lang/Complement.java => ToTaskDraw.java} (85%) create mode 100644 src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java delete mode 100644 src/net/sourceforge/plantuml/project/command/NaturalCommandAnd.java delete mode 100644 src/net/sourceforge/plantuml/project/command/NaturalCommandAndAnd.java rename src/net/sourceforge/plantuml/project/lang/{ComplementColors.java => CenterBorderColor.java} (84%) rename src/net/sourceforge/plantuml/project/lang/{VerbIsDeleted.java => ComplementFromTo.java} (69%) rename src/net/sourceforge/plantuml/project/lang/{VerbAre.java => ComplementWithColorLink.java} (64%) rename src/net/sourceforge/plantuml/project/lang/{VerbIsForTask.java => PairOfSomething.java} (59%) rename src/net/sourceforge/plantuml/project/lang/{SubjectPattern.java => Sentence.java} (89%) rename src/net/sourceforge/plantuml/project/lang/{VerbIsOn.java => SentenceAnd.java} (53%) create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java rename src/net/sourceforge/plantuml/project/lang/{VerbIsColored.java => SentenceEnds.java} (63%) rename src/net/sourceforge/plantuml/project/lang/{VerbLasts.java => SentenceHappens.java} (65%) create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java rename src/net/sourceforge/plantuml/project/lang/{VerbPattern.java => SentenceIsDeleted.java} (74%) create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceLasts.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java create mode 100644 src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java rename src/net/sourceforge/plantuml/project/lang/{VerbIsOff.java => SentenceSimple.java} (53%) rename src/net/sourceforge/plantuml/project/lang/{VerbIsForToday.java => SentenceTaskEndsAbsolute.java} (65%) rename src/net/sourceforge/plantuml/project/lang/{VerbEnds.java => SentenceTaskStarts.java} (63%) rename src/net/sourceforge/plantuml/project/lang/{VerbLinksTo.java => SentenceTaskStartsAbsolute.java} (64%) rename src/net/sourceforge/plantuml/project/lang/{VerbTaskStarts.java => SentenceTaskStartsWithColor.java} (62%) rename src/net/sourceforge/plantuml/project/lang/{ComplementPattern.java => Something.java} (92%) rename src/net/sourceforge/plantuml/project/lang/{VerbIsColoredForToday.java => SubjectLinks.java} (68%) rename src/net/sourceforge/plantuml/project/lang/{ComplementName.java => TwoNames.java} (82%) delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbHappens.java delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbIsOrAre.java delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbIsOrAreNamed.java delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbProjectStarts.java delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbTaskEndsAbsolute.java delete mode 100644 src/net/sourceforge/plantuml/project/lang/VerbTaskStartsAbsolute.java create mode 100644 src/net/sourceforge/plantuml/project/lang/Verbs.java diff --git a/pom.xml b/pom.xml index 332008c48..31fe6c66b 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ net.sourceforge.plantuml plantuml - 1.2020.15-SNAPSHOT + 1.2020.16-SNAPSHOT jar PlantUML @@ -136,7 +136,7 @@ 1.7 1.7 - false + true diff --git a/skin/plantuml.skin b/skin/plantuml.skin index ebe7fe99f..94e3fe514 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -260,3 +260,21 @@ circle { LineColor black Shadowing 3.0 } + + +task { + FontSize 11 +} + +milestone { + FontSize 11 + BackGroundColor black + LineColor black +} + +ganttDiagram { + note { + FontSize 9 + Shadowing 0.0 + } +} diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index e6dcd9bad..7104fada8 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -348,8 +348,10 @@ public class Option { checkMetadata = true; } else if (s.equalsIgnoreCase("-stdrpt:1")) { stdrpt = 1; + } else if (s.equalsIgnoreCase("-stdrpt:2")) { + stdrpt = 2; } else if (s.equalsIgnoreCase("-stdrpt")) { - stdrpt = 1; + stdrpt = 2; } else if (s.equalsIgnoreCase("-pipeimageindex")) { i++; if (i == arg.length) { @@ -379,6 +381,9 @@ public class Option { if (stdrpt == 1) { return new StdrptV1(); } + if (stdrpt == 2) { + return new StdrptV2(); + } // Legacy case if (isPipe() || isPipeMap() || isSyntax()) { return new StdrptPipe0(); diff --git a/src/net/sourceforge/plantuml/Pipe.java b/src/net/sourceforge/plantuml/Pipe.java index 2034e4c01..d5413912a 100644 --- a/src/net/sourceforge/plantuml/Pipe.java +++ b/src/net/sourceforge/plantuml/Pipe.java @@ -164,7 +164,7 @@ public class Pipe { } } String source = sb.toString().trim(); - if (source.length() == 0) { + if (sb.length() == 0) { return null; } if (source.startsWith("@start") == false) { diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 9b981355f..284efe355 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -199,12 +199,8 @@ public class Run { } if (OptionFlags.getInstance().isGui() == false) { - if (error.hasError()) { - Log.error("Some diagram description contains errors"); - System.exit(error.getExitCode()); - } - if (error.isNoData()) { - Log.error("No diagram found"); + if (error.hasError() || error.isNoData()) { + option.getStdrpt().finalMessage(error); System.exit(error.getExitCode()); } @@ -539,7 +535,7 @@ public class Run { rpt.printInfo(System.err, s.getDiagram()); } - hasErrors(f, result, error); + hasErrors(f, result, error, rpt); } private static void extractPreproc(Option option, final ISourceFileReader sourceFileReader) throws IOException { @@ -570,15 +566,16 @@ public class Run { } } - private static void hasErrors(File f, final List list, ErrorStatus error) throws IOException { + private static void hasErrors(File file, final List list, ErrorStatus error, Stdrpt stdrpt) + throws IOException { if (list.size() == 0) { // error.goNoData(); return; } - for (GeneratedImage i : list) { - final int lineError = i.lineErrorRaw(); + for (GeneratedImage image : list) { + final int lineError = image.lineErrorRaw(); if (lineError != -1) { - Log.error("Error line " + lineError + " in file: " + f.getPath()); + stdrpt.errorLine(lineError, file); error.goWithError(); return; } diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index d773d2657..e683e68d5 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -99,6 +99,9 @@ public class SkinParam implements ISkinParam { if (type == UmlDiagramType.WBS) { USE_STYLE2.set(true); } + if (type == UmlDiagramType.GANTT) { + USE_STYLE2.set(true); + } if (type == UmlDiagramType.SEQUENCE) { // skin = "debug.skin"; // USE_STYLE2.set(true); diff --git a/src/net/sourceforge/plantuml/Stdrpt.java b/src/net/sourceforge/plantuml/Stdrpt.java index ab3ed6f33..0d196284a 100644 --- a/src/net/sourceforge/plantuml/Stdrpt.java +++ b/src/net/sourceforge/plantuml/Stdrpt.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml; +import java.io.File; import java.io.PrintStream; import net.sourceforge.plantuml.core.Diagram; @@ -43,4 +44,8 @@ public interface Stdrpt { public void printInfo(PrintStream output, Diagram sys); + public void finalMessage(ErrorStatus error); + + public void errorLine(int lineError, File file); + } diff --git a/src/net/sourceforge/plantuml/StdrptNull.java b/src/net/sourceforge/plantuml/StdrptNull.java index 19b11487e..d5e780424 100644 --- a/src/net/sourceforge/plantuml/StdrptNull.java +++ b/src/net/sourceforge/plantuml/StdrptNull.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml; +import java.io.File; import java.io.PrintStream; import net.sourceforge.plantuml.core.Diagram; @@ -44,4 +45,17 @@ public class StdrptNull implements Stdrpt { public void printInfo(final PrintStream output, final Diagram sys) { } + public void finalMessage(ErrorStatus error) { + if (error.hasError()) { + Log.error("Some diagram description contains errors"); + } + if (error.isNoData()) { + Log.error("No diagram found"); + } + } + + public void errorLine(int lineError, File file) { + Log.error("Error line " + lineError + " in file: " + file.getPath()); + } + } diff --git a/src/net/sourceforge/plantuml/StdrptPipe0.java b/src/net/sourceforge/plantuml/StdrptPipe0.java index 7254bb1b2..90bffcfe4 100644 --- a/src/net/sourceforge/plantuml/StdrptPipe0.java +++ b/src/net/sourceforge/plantuml/StdrptPipe0.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml; +import java.io.File; import java.io.PrintStream; import net.sourceforge.plantuml.core.Diagram; @@ -54,4 +55,17 @@ public class StdrptPipe0 implements Stdrpt { } } + public void finalMessage(ErrorStatus error) { + if (error.hasError()) { + Log.error("Some diagram description contains errors"); + } + if (error.isNoData()) { + Log.error("No diagram found"); + } + } + + public void errorLine(int lineError, File file) { + Log.error("Error line " + lineError + " in file: " + file.getPath()); + } + } diff --git a/src/net/sourceforge/plantuml/StdrptV1.java b/src/net/sourceforge/plantuml/StdrptV1.java index 83f0015d0..7eb67cd92 100644 --- a/src/net/sourceforge/plantuml/StdrptV1.java +++ b/src/net/sourceforge/plantuml/StdrptV1.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml; +import java.io.File; import java.io.PrintStream; import net.sourceforge.plantuml.command.PSystemAbstractFactory; @@ -53,6 +54,10 @@ public class StdrptV1 implements Stdrpt { } } + public void errorLine(int lineError, File file) { + Log.error("Error line " + lineError + " in file: " + file.getPath()); + } + private void out(final PrintStream output, final PSystemError err) { output.println("protocolVersion=1"); if (empty(err)) { @@ -78,4 +83,13 @@ public class StdrptV1 implements Stdrpt { return false; } + public void finalMessage(ErrorStatus error) { + if (error.hasError()) { + Log.error("Some diagram description contains errors"); + } + if (error.isNoData()) { + Log.error("No diagram found"); + } + } + } diff --git a/src/net/sourceforge/plantuml/StdrptV2.java b/src/net/sourceforge/plantuml/StdrptV2.java new file mode 100644 index 000000000..d54b6aa96 --- /dev/null +++ b/src/net/sourceforge/plantuml/StdrptV2.java @@ -0,0 +1,95 @@ +/* ======================================================================== + * 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; + +import java.io.File; +import java.io.PrintStream; + +import net.sourceforge.plantuml.command.PSystemAbstractFactory; +import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.eggs.PSystemWelcome; +import net.sourceforge.plantuml.error.PSystemError; + +public class StdrptV2 implements Stdrpt { + + public void finalMessage() { + } + + public void finalMessage(ErrorStatus error) { + } + + public void errorLine(int lineError, File file) { + } + + public void printInfo(final PrintStream output, Diagram sys) { + if (sys instanceof PSystemWelcome) { + sys = null; + } + if (sys == null || sys instanceof PSystemError) { + out(output, (PSystemError) sys); + } + } + + private void out(final PrintStream output, final PSystemError err) { + final StringBuilder line = new StringBuilder(); + if (empty(err)) { + } else { + line.append(err.getLineLocation().getDescription()); + line.append(":"); + line.append(err.getLineLocation().getPosition()); + line.append(":"); + line.append("error"); + line.append(":"); + for (ErrorUml er : err.getErrorsUml()) { + line.append(er.getError()); + } + } + output.println(line); + output.flush(); + } + + private boolean empty(final PSystemError err) { + if (err == null) { + return true; + } + for (ErrorUml er : err.getErrorsUml()) { + if (PSystemAbstractFactory.EMPTY_DESCRIPTION.equals(er.getError())) + return true; + } + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 078d93058..9de2ceb7a 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -35,12 +35,19 @@ */ package net.sourceforge.plantuml; +import java.io.IOException; + +import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandControl; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.CommandSkinParamMultilines; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; +import net.sourceforge.plantuml.sprite.Sprite; public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated { @@ -52,7 +59,82 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, private final DisplaySection footer = DisplaySection.none(); private Display mainFrame; - + private final SkinParam skinParam; + + public TitledDiagram() { + this.skinParam = SkinParam.create(getUmlDiagramType()); + } + + public TitledDiagram(ISkinSimple orig) { + this(); + if (orig != null) { + this.skinParam.copyAllFrom(orig); + } + } + + abstract public UmlDiagramType getUmlDiagramType(); + + public final ISkinParam getSkinParam() { + return skinParam; + } + + public void setParam(String key, String value) { + skinParam.setParam(StringUtils.goLowerCase(key), value); + } + + public void addSprite(String name, Sprite sprite) { + skinParam.addSprite(name, sprite); + } + + public CommandExecutionResult loadSkin(String newSkin) throws IOException { + getSkinParam().setDefaultSkin(newSkin + ".skin"); + return CommandExecutionResult.ok(); + // final String res = "/skin/" + filename + ".skin"; + // final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res); + // if (internalIs != null) { + // final BlocLines lines2 = BlocLines.load(internalIs, new + // LineLocationImpl(filename, null)); + // return loadSkinInternal(lines2); + // } + // if (OptionFlags.ALLOW_INCLUDE == false) { + // return CommandExecutionResult.ok(); + // } + // final File f = FileSystem.getInstance().getFile(filename + ".skin"); + // if (f == null || f.exists() == false || f.canRead() == false) { + // return CommandExecutionResult.error("Cannot load skin from " + filename); + // } + // final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), + // null)); + // return loadSkinInternal(lines); + } + + // private CommandExecutionResult loadSkinInternal(final BlocLines lines) { + // final CommandSkinParam cmd1 = new CommandSkinParam(); + // final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines(); + // for (int i = 0; i < lines.size(); i++) { + // final BlocLines ext1 = lines.subList(i, i + 1); + // if (cmd1.isValid(ext1) == CommandControl.OK) { + // cmd1.execute(this, ext1); + // } else if (cmd2.isValid(ext1) == CommandControl.OK_PARTIAL) { + // i = tryMultilines(cmd2, i, lines); + // } + // } + // return CommandExecutionResult.ok(); + // } + +// private int tryMultilines(CommandSkinParamMultilines cmd2, int i, BlocLines lines) { +// for (int j = i + 1; j <= lines.size(); j++) { +// final BlocLines ext1 = lines.subList(i, j); +// if (cmd2.isValid(ext1) == CommandControl.OK) { +// cmd2.execute(this, ext1); +// return j; +// } else if (cmd2.isValid(ext1) == CommandControl.NOT_OK) { +// return j; +// } +// } +// return i; +// } + final public void setTitle(DisplayPositionned title) { if (title.isNull() || title.getDisplay().isWhite()) { return; @@ -64,7 +146,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, final public DisplayPositionned getTitle() { return title; } - + final public void setMainFrame(Display mainFrame) { this.mainFrame = mainFrame; } @@ -76,7 +158,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, final public DisplayPositionned getCaption() { return caption; } - + final public DisplaySection getHeader() { return header; } @@ -84,7 +166,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, final public DisplaySection getFooter() { return footer; } - + final public DisplayPositionned getLegend() { return legend; } @@ -97,10 +179,4 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return mainFrame; } - - - - - - } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 21060c589..615f2efc4 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -100,17 +100,12 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot private final Pragma pragma = new Pragma(); private Animation animation; - private final SkinParam skinParam; - public UmlDiagram() { - this.skinParam = SkinParam.create(getUmlDiagramType()); + super(); } public UmlDiagram(ISkinSimple orig) { - this(); - if (orig != null) { - this.skinParam.copyAllFrom(orig); - } + super(orig); } final public int getMinwidth() { @@ -129,14 +124,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot this.rotation = rotation; } - public final ISkinParam getSkinParam() { - return skinParam; - } - - public void setParam(String key, String value) { - skinParam.setParam(StringUtils.goLowerCase(key), value); - } - public final DisplaySection getFooterOrHeaderTeoz(FontParam param) { if (param == FontParam.FOOTER) { return getFooter(); @@ -147,8 +134,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot throw new IllegalArgumentException(); } - abstract public UmlDiagramType getUmlDiagramType(); - public Pragma getPragma() { return pragma; } @@ -399,10 +384,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return null; } - public void addSprite(String name, Sprite sprite) { - skinParam.addSprite(name, sprite); - } - private boolean useJDot; public void setUseJDot(boolean useJDot) { @@ -417,54 +398,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return useJDot; } - public CommandExecutionResult loadSkin(String newSkin) throws IOException { - getSkinParam().setDefaultSkin(newSkin + ".skin"); - return CommandExecutionResult.ok(); - // final String res = "/skin/" + filename + ".skin"; - // final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res); - // if (internalIs != null) { - // final BlocLines lines2 = BlocLines.load(internalIs, new - // LineLocationImpl(filename, null)); - // return loadSkinInternal(lines2); - // } - // if (OptionFlags.ALLOW_INCLUDE == false) { - // return CommandExecutionResult.ok(); - // } - // final File f = FileSystem.getInstance().getFile(filename + ".skin"); - // if (f == null || f.exists() == false || f.canRead() == false) { - // return CommandExecutionResult.error("Cannot load skin from " + filename); - // } - // final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), - // null)); - // return loadSkinInternal(lines); - } - - // private CommandExecutionResult loadSkinInternal(final BlocLines lines) { - // final CommandSkinParam cmd1 = new CommandSkinParam(); - // final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines(); - // for (int i = 0; i < lines.size(); i++) { - // final BlocLines ext1 = lines.subList(i, i + 1); - // if (cmd1.isValid(ext1) == CommandControl.OK) { - // cmd1.execute(this, ext1); - // } else if (cmd2.isValid(ext1) == CommandControl.OK_PARTIAL) { - // i = tryMultilines(cmd2, i, lines); - // } - // } - // return CommandExecutionResult.ok(); - // } - - private int tryMultilines(CommandSkinParamMultilines cmd2, int i, BlocLines lines) { - for (int j = i + 1; j <= lines.size(); j++) { - final BlocLines ext1 = lines.subList(i, j); - if (cmd2.isValid(ext1) == CommandControl.OK) { - cmd2.execute(this, ext1); - return j; - } else if (cmd2.isValid(ext1) == CommandControl.NOT_OK) { - return j; - } - } - return i; - } public void setHideEmptyDescription(boolean hideEmptyDescription) { } diff --git a/src/net/sourceforge/plantuml/UmlDiagramType.java b/src/net/sourceforge/plantuml/UmlDiagramType.java index 4d93c28e1..d6482a84a 100644 --- a/src/net/sourceforge/plantuml/UmlDiagramType.java +++ b/src/net/sourceforge/plantuml/UmlDiagramType.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.style.SName; public enum UmlDiagramType { SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE, - HELP; + HELP, GANTT; public SName getStyleName() { if (this == SEQUENCE) { @@ -69,6 +69,9 @@ public enum UmlDiagramType { if (this == WBS) { return SName.wbsDiagram; } + if (this == GANTT) { + return SName.ganttDiagram; + } return SName.activityDiagram; } } diff --git a/src/net/sourceforge/plantuml/Url.java b/src/net/sourceforge/plantuml/Url.java index e6c07daa8..b6c36ef79 100644 --- a/src/net/sourceforge/plantuml/Url.java +++ b/src/net/sourceforge/plantuml/Url.java @@ -38,9 +38,8 @@ package net.sourceforge.plantuml; import java.util.Comparator; import net.sourceforge.plantuml.cucadiagram.dot.DotMaker2; -import net.sourceforge.plantuml.project.lang.Complement; -public class Url implements EnsureVisible, Complement { +public class Url implements EnsureVisible { private final String url; private final String tooltip; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 72c745f34..09fa40353 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.activitydiagram3; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; @@ -60,6 +62,7 @@ public class InstructionRepeat implements Instruction { private final BoxStyle boxStyleIn; private Display backward = Display.NULL; + private List backwardNotes = new ArrayList(); private Display test = Display.NULL; private Display yes = Display.NULL; private Display out = Display.NULL; @@ -104,8 +107,7 @@ public class InstructionRepeat implements Instruction { } public Ftile createFtile(FtileFactory factory) { - final Ftile back = Display.isNull(backward) ? null - : factory.activity(backward, swimlane, boxStyle, Colors.empty()); + final Ftile back = getBackward(factory); final Ftile decorateOut = factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering); final Ftile result = factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, decorateOut, test, yes, out, colors, backRepeatLinkRendering, back, isLastOfTheParent()); @@ -115,6 +117,17 @@ public class InstructionRepeat implements Instruction { return result; } + private Ftile getBackward(FtileFactory factory) { + if (Display.isNull(backward)) { + return null; + } + Ftile result = factory.activity(backward, swimlane, boxStyle, Colors.empty()); + if (backwardNotes.size() > 0) { + result = factory.addNote(result, swimlane, backwardNotes); + } + return result; + } + public Instruction getParent() { return parent; } @@ -152,7 +165,12 @@ public class InstructionRepeat implements Instruction { } public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote) { - return repeatList.addNote(note, position, type, colors, swimlaneNote); + if (Display.isNull(backward)) { + return repeatList.addNote(note, position, type, colors, swimlaneNote); + } + this.backwardNotes.add(new PositionedNote(note, position, type, colors, swimlaneNote)); + return true; + } public Set getSwimlanes() { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index ed36719f1..10f152b9d 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -77,8 +77,7 @@ public class CommandCreateClass extends SingleLineCommand2 { } private static IRegex getRegexConcat() { - return RegexConcat.build(CommandCreateClass.class.getName(), - RegexLeaf.start(), // + return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", // "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond)"), // RegexLeaf.spaceOneOrMore(), // @@ -97,8 +96,8 @@ public class CommandCreateClass extends SingleLineCommand2 { new RegexLeaf("DISPLAY2", DISPLAY_WITH_GENERIC)), // new RegexLeaf("CODE3", "(" + CODE + ")"), // new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), // - new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("GENERIC", "\\<(" - + GenericRegexProducer.PATTERN + ")\\>"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), + new RegexLeaf("GENERIC", "\\<(" + GenericRegexProducer.PATTERN + ")\\>"))), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // RegexLeaf.spaceZeroOrMore(), // @@ -108,14 +107,14 @@ public class CommandCreateClass extends SingleLineCommand2 { RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // - new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexLeaf("LINECOLOR", - "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // - new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("EXTENDS", - "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // - new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("IMPLEMENTS", - "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // - new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"), RegexLeaf - .spaceZeroOrMore(), new RegexLeaf("\\}"))), // + new RegexOptional(new RegexConcat(new RegexLeaf("##"), + new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), + new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), + new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"), + RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), // RegexLeaf.end()); } @@ -156,9 +155,9 @@ public class CommandCreateClass extends SingleLineCommand2 { } } if (stereotype != null) { - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram - .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam() - .getIHtmlColorSet())); + entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), + diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), + diagram.getSkinParam().getIHtmlColorSet())); } if (generic != null) { entity.setGeneric(generic); @@ -170,6 +169,7 @@ public class CommandCreateClass extends SingleLineCommand2 { final Url url = urlBuilder.getUrl(urlString); entity.addUrl(url); } + entity.setCodeLine(location); Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); @@ -183,7 +183,8 @@ public class CommandCreateClass extends SingleLineCommand2 { entity.setColors(colors); // entity.setSpecificColorTOBEREMOVED(ColorType.LINE, lineColor); - // entity.setSpecificColorTOBEREMOVED(ColorType.HEADER, colors.getColor(ColorType.HEADER)); + // entity.setSpecificColorTOBEREMOVED(ColorType.HEADER, + // colors.getColor(ColorType.HEADER)); // // if (colors.getLineStyle() != null) { // entity.setSpecificLineStroke(LinkStyle.getStroke(colors.getLineStyle())); @@ -200,9 +201,11 @@ public class CommandCreateClass extends SingleLineCommand2 { return CommandExecutionResult.ok(); } - // public static void manageExtends(ClassDiagram system, RegexResult arg, final IEntity entity) { + // public static void manageExtends(ClassDiagram system, RegexResult arg, final + // IEntity entity) { // if (arg.get("EXTENDS", 1) != null) { - // final Mode mode = arg.get("EXTENDS", 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS; + // final Mode mode = arg.get("EXTENDS", 1).equalsIgnoreCase("extends") ? + // Mode.EXTENDS : Mode.IMPLEMENTS; // final Code other = diagram.buildCode(arg.get("EXTENDS", 2)); // LeafType type2 = LeafType.CLASS; // if (mode == Mode.IMPLEMENTS) { @@ -213,10 +216,12 @@ public class CommandCreateClass extends SingleLineCommand2 { // } // final IEntity cl2 = system.getOrCreateLeaf(other, type2, null); // LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS); - // if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) { + // if (type2 == LeafType.INTERFACE && entity.getEntityType() != + // LeafType.INTERFACE) { // typeLink = typeLink.getDashed(); // } - // final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, system.getLabeldistance(), + // final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, + // system.getLabeldistance(), // system.getLabelangle()); // system.addLink(link); // } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index f2dd9aca2..0b6c9ea51 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -150,6 +150,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 1) { + entity.setCodeLine(lines.getAt(0).getLocation()); lines = lines.subExtract(1, 1); // final Url url = null; // if (lines.size() > 0) { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index 30f2b5609..ec18915ed 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -89,7 +89,7 @@ final public class CommandLinkClass extends SingleLineCommand2\\>?|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // + "([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // RegexLeaf.spaceZeroOrMore(), new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // RegexLeaf.spaceZeroOrMore(), // new RegexOr( // @@ -213,6 +213,7 @@ final public class CommandLinkClass extends SingleLineCommand2 stereotags(); - + public boolean isAloneAndUnlinked(); public void setThisIsTogether(); + public String getCodeLine(); + + public void setCodeLine(LineLocation codeLine); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Ident.java b/src/net/sourceforge/plantuml/cucadiagram/Ident.java index 54faf3639..07c003408 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Ident.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Ident.java @@ -234,15 +234,15 @@ public class Ident implements Code { final String last = parts.get(parts.size() - 1); if (separator == null) { if (code.getName().equals(last) != true && code.getName().equals(toString(separator)) == false) { - System.err.println("code1=" + code); - System.err.println("this1=" + this); +// System.err.println("code1=" + code); +// System.err.println("this1=" + this); EntityFactory.bigError(); } } else { if (getLastPart(code.getName(), separator).equals(last) != true && code.getName().equals(toString(separator)) == false) { - System.err.println("code2=" + code); - System.err.println("this2=" + this); +// System.err.println("code2=" + code); +// System.err.println("this2=" + this); EntityFactory.bigError(); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 38e34f4f1..b7d3c91fd 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Removeable; import net.sourceforge.plantuml.UmlDiagramType; @@ -102,14 +103,14 @@ public class Link extends WithLinkType implements Hideable, Removeable { public String idCommentForSvg() { if (type.looksLikeRevertedForSvg()) { - final String comment = getEntity1().getCodeGetName() + "<-" + getEntity2().getCodeGetName(); + final String comment = getEntity1().getCodeGetName() + "-backto-" + getEntity2().getCodeGetName(); return comment; } if (type.looksLikeNoDecorAtAllSvg()) { final String comment = getEntity1().getCodeGetName() + "-" + getEntity2().getCodeGetName(); return comment; } - final String comment = getEntity1().getCodeGetName() + "->" + getEntity2().getCodeGetName(); + final String comment = getEntity1().getCodeGetName() + "-to-" + getEntity2().getCodeGetName(); return comment; } @@ -581,4 +582,17 @@ public class Link extends WithLinkType implements Hideable, Removeable { return linkConstraint; } + private LineLocation codeLine; + + public String getCodeLine() { + if (codeLine == null) { + return null; + } + return "" + codeLine.getPosition(); + } + + public void setCodeLine(LineLocation location) { + this.codeLine = location; + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java index 4a0ef172b..3f4cd8653 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java @@ -30,7 +30,8 @@ * * * Original Author: Arnaud Roques - * Contribution : Hisashi Miyashita * + * Contribution: Hisashi Miyashita + * Contribution: Miguel Esteves * */ package net.sourceforge.plantuml.cucadiagram.entity; @@ -48,6 +49,7 @@ import java.util.Set; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Bodier; @@ -114,6 +116,7 @@ final public class EntityImpl implements ILeaf, IGroup { private USymbol symbol; private final int rawLayout; private char concurrentSeparator; + private LineLocation codeLine; private Set tags = new LinkedHashSet(); @@ -807,7 +810,17 @@ final public class EntityImpl implements ILeaf, IGroup { public void setThisIsTogether() { this.together = true; - // System.err.println("setThisIsTogether"); + } + + public String getCodeLine() { + if (this.codeLine == null) { + return null; + } + return "" + this.codeLine.getPosition(); + } + + public void setCodeLine(LineLocation codeLine) { + this.codeLine = codeLine; } } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index a420b7798..ee0010316 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -80,14 +80,14 @@ public class CommandLinkElement extends SingleLineCommand2 { RegexLeaf.spaceZeroOrMore(), // new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("HEAD2", "(0\\)|<<|[<^*+#0@)]|<\\|[\\|\\:]?|[%s]+o)?"), // + new RegexLeaf("HEAD2", "(0\\)|<<|<_|[<^*+#0@)]|<\\|[\\|\\:]?|[%s]+o)?"), // new RegexLeaf("BODY1", "([-=.~]+)"), // new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + LINE_STYLE_MUTILPLES + ")\\])?"), // new RegexOptional(new RegexLeaf("DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)(?=[-=.~0()])")), // new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), // new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + LINE_STYLE + ")\\])?"), // new RegexLeaf("BODY2", "([-=.~]*)"), // - new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0@(]|[\\:\\|]?\\|>|\\\\\\\\|o[%s]+)?"), // + new RegexLeaf("HEAD1", "(\\(0|>>|_>|[>^*+#0@(]|[\\:\\|]?\\|>|\\\\\\\\|o[%s]+)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // RegexLeaf.spaceZeroOrMore(), // @@ -103,9 +103,15 @@ public class CommandLinkElement extends SingleLineCommand2 { return ColorParser.simpleColor(ColorType.LINE); } + private String getHead(RegexResult arg, final String key) { + String result = arg.get(key, 0); + result = trimAndLowerCase(result); + return result.replace("_", ""); + } + private LinkType getLinkType(RegexResult arg) { - final String head1 = trimAndLowerCase(arg.get("HEAD1", 0)); - final String head2 = trimAndLowerCase(arg.get("HEAD2", 0)); + final String head1 = getHead(arg, "HEAD1"); + final String head2 = getHead(arg, "HEAD2"); LinkDecor d1 = LinkDecor.NONE; LinkDecor d2 = LinkDecor.NONE; diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index ca4e8f507..71a2115d4 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -74,26 +74,26 @@ public class PSystemDonors extends AbstractPSystem { private static final int COLS = 6; private static final int FREE_LINES = 6; - public static final String DONORS = "6y8B02mFk3cOSJIBSEBLlhdPHgj_M8aA4IpF4uh3m2AUxWR47-3UwN6_aVuYkjAzRveHRVbhZfzd3DL0" - + "qEFnwshOvdzxy6_EaXV1DrE22qW1-V5gD_8XxyXnUgJAa1B4Kj7zbudRqwtZGcMSg4Oe1ufR6zvtnkRP" - + "QNpnwj44RGH-3Eoh_pTrbNLvLHMc1TsjC0QZeX4kOoh6dWhScl-V2gXm2lOT2lJqOpfrSHqELLIYkRcy" - + "LjAS3BZHDSwXmvAg6AE9b5njf90p1pFqv6JqK_gXZzw_j0leq5fTGpndGF6OAJssRdixikzW-hMAWqGw" - + "n8BD0dSevQWyGV5pqus7j0WIkdQHZMquyfidCHXgO8M--KCpET9xI6IN8SL3HWqKvBoD0TBer6C9Psk_" - + "1bJVWor6D0ZLvN7ZxhyEorDkDXfU0HOP7jG2MWZoFzW9dz5NNZ8vvwQ85V8snNFOLipNaW_JDXLzYu-c" - + "G3XjFpIBn5McR3saSUHrpBywEkHTGrPU_MQCKSWZcClBN0hkbnQe7u4UMXEHuckLNnOI4AuZzQ9tdTkl" - + "r2p2AHqg5UlqIsnvpVr3bpBOZ6Zk3XPp7_svt9K8zj2LIJNqXbPzcdK-KP8Qwk-7lBfqlWkkgLUxTvpM" - + "PzgSP_zttTBCK0xGcILcGRS21CBLj1ekDX31OQ7BG-u2j07bq-HMF2qVOeyyGV3cCeEki97I2_4y2Nd8" - + "HGWpqA4xKbG0iwUCUlAGTOE7PXk2RaMLV7gvktw6ISksPMDccRJ1Uhl36CKndT0ySR_C1HvXM6yMpUvk" - + "xIFi4jpcS9fFtRMQLmbjR-6zu2AqVyY0ds7EY4YbwPhxddQ9UwWZC4kmuAakjfVRmJyFtR_W58jMCADD" - + "EsGET2uaewRTelIXmV2t2bd7jkr5VO2juJe_X9cH1i-N9hUqv18FQTjPJe8l05NMuXExLE4y8PfMaCpH" - + "jOJ94Qid8KD-f_e4bgfoOUd6Z-cknZEcHq4UpdjarQs-JIbk2wWbfWdoia9OCwGemjO26RXMqhFS1zZz" - + "r8u5VvkV7DXoABvjekt63HQcm7GNxeq4aMXs92LwYIbHmFV-U4ezCzV1ndVtj68Sf1QI6AZ27Cx_mHXf" - + "l6vJqrYlqVzjhRqiEt_-lOviSkhrUrzT43q7cV4VfG0TvGHcy3RmDUGpoTiBArcX76IuSgtIqq1XmNvw" - + "vqVKrJAZVoUAvPRaebMq3rN_tOzo39oD3IikyYcAsPSOQUsb7bIgxVk_M2no4Folg38dawktRZL6GcUG" - + "nRaRkyrKp7sj3YnO7PC9WZtrsUaQJnbpRv4g3JU0VBz7GvBHGmjRQjeyJmIsg_Fpti8s93BwRp2Ydwgr" - + "UtohX-63z76g23HyXqCQ5ym4mqNoWGAvEUT4Wsw-yP0NrK8DBEsOOPSANkXlvaT48U6ORNmWo6qkbhkz" - + "a4Fsa7rcDOeEAAeB3RIms69d4WjLZWSgae8visKyZzf1ct1rxm0wHS7vVzw6S6wY-GMPLURP6ybSuRaN" - + "Pn3fS7ucYLrJjcwqOTzekMphYjoHjKY7jVzt0000"; + public static final String DONORS = "6omC02mFkBap0p4nqLYNlhbPJVbOScQJ29Rd2SLXO15FTmFY3t3lzBZVI7yHNUdUDys8jcnDSPung1O4" + + "FPwQQuPjxks1q5RAY-189RY0513Vnibv7ploFdrIPKW9Ogde_il4xUdMSQ4oJbGZb0F5hGtlEsFpx3I-" + + "UFLeWZO2FmRsrVzTqygwUrKLXdHPrPWQTRh28Oo87E7_KRUfMzJ6oTIcqGCwbNC5DzMfYDFX0Gjea1Ku" + + "P6qTvwLPawgOI1Cfdjf8mIC6CxJdPFLvyaCVT7wf5z2bjRg6UEw0uZ5JUdJTDjg_xs3x5H8l4ixW2pOB" + + "pA6Kmtg2ukUc6nqd3n9QTv6DhRxoboSc6FpGGj_yeKYkz1uIsML8qN6fWGAFjp50CYQrQyBPeJy3gkh1" + + "5lqQXEfolt5thSFoL38R3RU0XOi5jO0QWlmFUi9dz9MNJEwvAM89UPh4Sza6rA-Izz4s5NqphoQ1yBRz" + + "qCpWLvcozP36bTSn_-hea7SDMRdwpLYZa4SmbvUv5CmlBL0_0Zqq9oA9hob_B2GWN5VgHUywDvtKBC8f" + + "7L8grkcNsF9QyWzTWSN6HNCwMABFng_BJObW2rsPL4DlQ5MbMUSJ9QcX_dx8ewNpNN1DbTgzGxGUQNEU" + + "_TzrIpD3SO2EJp4BkXOG2AjfrLTi88B3GfU7t0J81fHFarl-j7o8FV83WZUN2Bh2Hae7-FDDo4CEBin0" + + "bsvEKG7CdbBgISVjW8Sw7O9kHPLyUfcxVeP9oxPbOsQPjC5rky4O-J6TK9ouN-O2Zp2iKelcv6xj8-mI" + + "FCxBQLvrhy6yYcvx2-zf5w7zGmRy37D6H2fDL-nxsYNkeOx0BDg2fxhOdcu71m_TjU0KYrOmeqqxP0cO" + + "N4X6JRr5wKE3uUyWP1DsRohg2smDrwd1pOmqUBuqkQKcHtISjhCS6ri0lERY5Rk2mYb2j2qjcQjh2PCZ" + + "Laz2XlnEzGaibNLXQSEExQx6Cr6FWZoSzyYgexvDAMuBg3wc2VBIGfWpfCZ3rW8PM2lfMMu3x7vgnuAw" + + "pKyk77CelcsYxSODCKo1wIdS6maYCJgHbEWb9ea2lklZL-f5SnriV7TFAyP1qa8I0rL4brD_C5OQgbje" + + "6kir-h-jjPTbvy-_rv5DJXr-xsiAekSWBW0HNg2Zd404JmDVR_cYvAs4bQnG3Z9SkLRfQI1XmIvwvrVK" + + "WsL6zOuNoytAHIjl7whgkxjo39pr3IikyYdosPSOQUsb7bH1stUziLZa8FWFKMLI9bUZoMgCXCuWYtCt" + + "TfkfcEV69h1WTamcqFQhpvffF6NCVKTIQNW4oFTxP4WoUcXXJKthuaHWatH-trlOXaH6_mr6z0jgdJmU" + + "rKFxGUvkj0WqVEj36XT4Wk4Y-K21t9npea4ttoZ8YsgX32pjc67d25ReR_n7H27Xc6ry8CWn5yjfB-IG" + + "BMGVdusY5-GrXGQoi5YlPn8BfHmFf4WAvioMyJpI3jg6VRq3w1G5u_zz6y8b4yqloAmopzv8vjBFlJY3" + + "I8VxiqbichAr8Hls8osNRLsHspyNwR1J_vtOSRxp4PMuY55oBX4yeGIViVncv3Wkqt4m-Ka0"; /* * Special thanks to our sponsors and donors: diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 88c8cd069..53a618831 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -275,7 +275,8 @@ public class QuoteUtils { "Znxr hf nyy fnsr. Tb onpx gb lbhe ohaxre", "Gh z'nf qrph, Ongzna", "Gurerfr, p'rfg har pngnfgebcur", "Vs lbh ner abg rzoneenffrq ol gur svefg irefvba bs lbhe cebqhpg, lbh'ir ynhapurq gbb yngr", "Zvfgnxrf znqr zl fhpprff: V znxr ehoore renfre", "Ovt Oebgure vf Jngpuvat Lbh.", - "Ab bar'f gnyxvat nobhg yrnivat gur fvatyr znexrg"); + "Ab bar'f gnyxvat nobhg yrnivat gur fvatyr znexrg", "...rnfvrfg oht gb svk va uhzna uvfgbel", + "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index 080a752c2..a98871701 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -77,7 +77,7 @@ class USymbolFrame extends USymbol { final UPath polygon = new UPath(); polygon.setIgnoreForCompressionOnX(); - polygon.moveTo(textWidth, 1); + polygon.moveTo(textWidth, 0); polygon.lineTo(textWidth, textHeight - cornersize); polygon.lineTo(textWidth - cornersize, textHeight); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolNode.java b/src/net/sourceforge/plantuml/graphic/USymbolNode.java index e6750ae95..8486f34e9 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolNode.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolNode.java @@ -80,7 +80,9 @@ class USymbolNode extends USymbol { } ug.draw(shape); - ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(9, -9)); + ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(10, -10)); + + ug.apply(UTranslate.dy(10)).draw(ULine.hline(width - 10)); ug.apply(new UTranslate(width - 10, 10)).draw(ULine.vline(height - 10)); if (SkinParam.USE_STYLES()) { diff --git a/src/net/sourceforge/plantuml/nwdiag/DiagElement.java b/src/net/sourceforge/plantuml/nwdiag/DiagElement.java index 0a46979c3..941156a02 100644 --- a/src/net/sourceforge/plantuml/nwdiag/DiagElement.java +++ b/src/net/sourceforge/plantuml/nwdiag/DiagElement.java @@ -34,9 +34,13 @@ */ package net.sourceforge.plantuml.nwdiag; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; + import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ComponentStyle; -import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -55,16 +59,18 @@ public class DiagElement { private final String name; private String description; private final Network mainNetwork; + private final ISkinSimple spriteContainer; @Override public String toString() { return name; } - public DiagElement(String name, Network network) { + public DiagElement(String name, Network network, ISkinSimple spriteContainer) { this.description = name; this.mainNetwork = network; this.name = name; + this.spriteContainer = spriteContainer; } private TextBlock toTextBlock(String s) { @@ -75,8 +81,7 @@ public class DiagElement { return TextBlockUtils.empty(0, 0); } s = s.replace(", ", "\\n"); - return Display.getWithNewlines(s).create(getFontConfiguration(), HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + return Display.getWithNewlines(s).create(getFontConfiguration(), HorizontalAlignment.LEFT, spriteContainer); } private FontConfiguration getFontConfiguration() { @@ -84,15 +89,17 @@ public class DiagElement { return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); } - public LinkedElement asTextBlock(final String adress1, final String adress2) { - final TextBlock ad1 = toTextBlock(adress1); - final TextBlock ad2 = toTextBlock(adress2); + public LinkedElement asTextBlock(Map conns, Network next) { + final Map conns2 = new LinkedHashMap(); + for (Entry ent : conns.entrySet()) { + conns2.put(ent.getKey(), toTextBlock(ent.getValue())); + } final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(), ColorParam.activityBorder.getDefaultValue()).withShadow(3); final TextBlock desc = toTextBlock(description); final TextBlock box = shape.asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0), symbolContext, HorizontalAlignment.CENTER); - return new LinkedElement(ad1, box, ad2, mainNetwork, this); + return new LinkedElement(this, box, mainNetwork, next, conns2); } public String getDescription() { diff --git a/src/net/sourceforge/plantuml/nwdiag/GridTextBlockDecorated.java b/src/net/sourceforge/plantuml/nwdiag/GridTextBlockDecorated.java index b67fffeeb..cf10ca2fc 100644 --- a/src/net/sourceforge/plantuml/nwdiag/GridTextBlockDecorated.java +++ b/src/net/sourceforge/plantuml/nwdiag/GridTextBlockDecorated.java @@ -35,6 +35,9 @@ package net.sourceforge.plantuml.nwdiag; import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.MinMax; @@ -51,18 +54,37 @@ public class GridTextBlockDecorated extends GridTextBlockSimple { public static final int NETWORK_THIN = 5; private final Collection groups; + private final List networks; - public GridTextBlockDecorated(int lines, int cols, Collection groups) { + public GridTextBlockDecorated(int lines, int cols, Collection groups, List networks) { super(lines, cols); this.groups = groups; + this.networks = networks; } @Override - public void drawGrid(UGraphic ug) { + protected void drawGrid(UGraphic ug) { for (DiagGroup group : groups) { drawGroups(ug, group); } - drawNetworkTube(ug); + final Map pos = drawNetworkTube(ug); + drawLinks(ug, pos); + } + + private void drawLinks(UGraphic ug, Map pos) { + final StringBounder stringBounder = ug.getStringBounder(); + for (int i = 0; i < data.length; i++) { + final double lineHeight = lineHeight(stringBounder, i); + double x = 0; + for (int j = 0; j < data[i].length; j++) { + final double colWidth = colWidth(stringBounder, j); + if (data[i][j] != null) { + data[i][j].drawLinks(ug.apply(UTranslate.dx(x)), colWidth, lineHeight, pos); + } + x += colWidth; + } + } + } private void drawGroups(UGraphic ug, DiagGroup group) { @@ -77,8 +99,8 @@ public class GridTextBlockDecorated extends GridTextBlockSimple { final double colWidth = colWidth(stringBounder, j); final LinkedElement element = data[i][j]; if (element != null && group.matches(element)) { - final MinMax minMax = element.getMinMax(stringBounder, colWidth, lineHeight).translate( - new UTranslate(x, y)); + final MinMax minMax = element.getMinMax(stringBounder, colWidth, lineHeight) + .translate(new UTranslate(x, y)); size = size == null ? minMax : size.addMinMax(minMax); } x += colWidth; @@ -95,7 +117,18 @@ public class GridTextBlockDecorated extends GridTextBlockSimple { } - private void drawNetworkTube(final UGraphic ug) { + private boolean isThereALink(int j, Network network) { + for (int i = 0; i < data.length; i++) { + final LinkedElement element = data[i][j]; + if (element != null && element.isLinkedTo(network)) { + return true; + } + } + return false; + } + + private Map drawNetworkTube(final UGraphic ug) { + final Map pos = new HashMap(); final StringBounder stringBounder = ug.getStringBounder(); double y = 0; for (int i = 0; i < data.length; i++) { @@ -104,7 +137,7 @@ public class GridTextBlockDecorated extends GridTextBlockSimple { double xmin = -1; double xmax = 0; for (int j = 0; j < data[i].length; j++) { - final boolean hline = isPresent(i, j) || isPresent(i - 1, j); + final boolean hline = isThereALink(j, network); if (hline && xmin < 0) { xmin = x; } @@ -119,17 +152,16 @@ public class GridTextBlockDecorated extends GridTextBlockSimple { if (network != null && network.getColor() != null) { ug2 = ug2.apply(network.getColor().bg()); } + if (network != null) { + pos.put(network, y); + } ug2.draw(rect); y += lineHeight(stringBounder, i); } + return pos; } private Network getNetwork(int i) { - for (int j = 0; j < data[i].length; j++) { - if (isPresent(i, j)) { - return data[i][j].getNetwork(); - } - } - return null; + return networks.get(i); } } diff --git a/src/net/sourceforge/plantuml/nwdiag/GridTextBlockSimple.java b/src/net/sourceforge/plantuml/nwdiag/GridTextBlockSimple.java index 3bba2ca13..2151092a7 100644 --- a/src/net/sourceforge/plantuml/nwdiag/GridTextBlockSimple.java +++ b/src/net/sourceforge/plantuml/nwdiag/GridTextBlockSimple.java @@ -53,14 +53,7 @@ public class GridTextBlockSimple implements TextBlock { this.data = new LinkedElement[lines][cols]; } - protected boolean isPresent(int i, int j) { - if (i == -1) { - return false; - } - return data[i][j] != null; - } - - public void drawGrid(UGraphic ug) { + protected void drawGrid(UGraphic ug) { } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/nwdiag/LinkedElement.java b/src/net/sourceforge/plantuml/nwdiag/LinkedElement.java index 83c71f6c0..a4bd8ee61 100644 --- a/src/net/sourceforge/plantuml/nwdiag/LinkedElement.java +++ b/src/net/sourceforge/plantuml/nwdiag/LinkedElement.java @@ -35,6 +35,9 @@ package net.sourceforge.plantuml.nwdiag; import java.awt.geom.Dimension2D; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeSet; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; @@ -42,25 +45,29 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.utils.MathUtils; public class LinkedElement { - private final TextBlock ad1; private final TextBlock box; - private final TextBlock ad2; private final Network network; + private final Network next; private final DiagElement element; + private final Map conns; - public LinkedElement(TextBlock ad1, TextBlock box, TextBlock ad2, Network network, DiagElement element) { - this.ad1 = ad1; + public LinkedElement(DiagElement element, TextBlock box, Network network, Network next, + Map conns) { this.box = box; - this.ad2 = ad2; this.network = network; this.element = element; + this.conns = conns; + this.next = next; + } + + public boolean isLinkedTo(Network some) { + return conns.containsKey(some); } private final double marginAd = 10; @@ -81,25 +88,59 @@ public class LinkedElement { public void drawMe(UGraphic ug, double width, double height) { final double xMiddle = width / 2; final double yMiddle = height / 2; + drawCenter(ug, box, xMiddle, yMiddle); + } + + public void drawLinks(UGraphic ug, double width, double height, Map pos) { + final double ynet1 = pos.get(network); + final double yMiddle = height / 2; final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimBox = box.calculateDimension(stringBounder); - final double y1 = yMiddle - dimBox.getHeight() / 2; - final double y2 = yMiddle + dimBox.getHeight() / 2; - - drawCenter(ug, box, xMiddle, yMiddle); + final double alpha = yMiddle - dimBox.getHeight() / 2; final HColor color = ColorParam.activityBorder.getDefaultValue(); ug = ug.apply(color); - drawHLine(ug, xMiddle, GridTextBlockDecorated.NETWORK_THIN, y1); - if (ad2 != null) { - drawHLine(ug, xMiddle, y2, height); + + final double xMiddle = width / 2; + + final TreeSet skip = new TreeSet(pos.values()); + new VerticalLine(ynet1 + GridTextBlockDecorated.NETWORK_THIN, ynet1 + alpha, skip) + .drawU(ug.apply(UTranslate.dx(xMiddle))); + drawCenter(ug, link1(), xMiddle, ynet1 + alpha / 2); + + final double seven = 7.0; + double x = xMiddle - (conns.size() - 2) * seven / 2; + boolean first = true; + for (Entry ent : conns.entrySet()) { + if (ent.getKey() == network) { + continue; + } + final Double ynet2 = pos.get(ent.getKey()); + new VerticalLine(ynet1 + yMiddle + dimBox.getHeight() / 2, ynet2, skip).drawU(ug.apply(UTranslate.dx(x))); + final double xtext; + if (first && conns.size() > 2) { + xtext = x - ent.getValue().calculateDimension(stringBounder).getWidth() / 2; + } else { + xtext = x; + } + drawCenter(ug, ent.getValue(), xtext, ynet2 - alpha / 2); + x += seven; + first = false; + } - drawCenter(ug, ad1, xMiddle, (GridTextBlockDecorated.NETWORK_THIN + y1) / 2); - if (ad2 != null) { - drawCenter(ug, ad2, xMiddle, (y2 + height - GridTextBlockDecorated.NETWORK_THIN) / 2); + } + + private TextBlock link1() { + return conns.get(network); + } + + private TextBlock link2() { + if (next == null) { + return null; } + return conns.get(next); } private void drawCenter(UGraphic ug, TextBlock block, double x, double y) { @@ -108,15 +149,11 @@ public class LinkedElement { } - private void drawHLine(UGraphic ug, double x, double y1, double y2) { - final ULine line = ULine.vline(y2 - y1); - ug.apply(new UTranslate(x, y1)).draw(line); - } - public Dimension2D naturalDimension(StringBounder stringBounder) { - final Dimension2D dim1 = ad1.calculateDimension(stringBounder); + final Dimension2D dim1 = link1().calculateDimension(stringBounder); final Dimension2D dimBox = box.calculateDimension(stringBounder); - final Dimension2D dim2 = ad2 == null ? new Dimension2DDouble(0, 0) : ad2.calculateDimension(stringBounder); + final Dimension2D dim2 = link2() == null ? new Dimension2DDouble(0, 0) + : link2().calculateDimension(stringBounder); final double width = MathUtils.max(dim1.getWidth() + 2 * marginAd, dimBox.getWidth() + 2 * marginBox, dim2.getWidth() + 2 * marginAd); final double height = dim1.getHeight() + 2 * marginAd + dimBox.getHeight() + 2 * marginBox + dim2.getHeight() diff --git a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java index a9311d45e..044384e93 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java @@ -142,7 +142,7 @@ public class NwDiagram extends UmlDiagram { if (currentNetwork() != null) { DiagElement element = elements.get(name); if (element == null) { - element = new DiagElement(name, currentNetwork()); + element = new DiagElement(name, currentNetwork(), this.getSkinParam()); elements.put(name, element); } final Map props = toSet(definition); @@ -256,22 +256,7 @@ public class NwDiagram extends UmlDiagram { ug = ug.apply(new UTranslate(margin, margin)); final StringBounder stringBounder = ug.getStringBounder(); - final GridTextBlockDecorated grid = new GridTextBlockDecorated(networks.size(), elements.size(), groups); - - for (int i = 0; i < networks.size(); i++) { - final Network current = networks.get(i); - final Network next = i + 1 < networks.size() ? networks.get(i + 1) : null; - int j = 0; - for (Map.Entry ent : elements.entrySet()) { - final DiagElement element = ent.getValue(); - if (element.getMainNetwork() == current && current.constainsLocally(ent.getKey())) { - final String ad1 = current.getAdress(element); - final String ad2 = next == null ? null : next.getAdress(element); - grid.add(i, j, element.asTextBlock(ad1, ad2)); - } - j++; - } - } + final GridTextBlockDecorated grid = buildGrid(); double deltaX = 0; double deltaY = 0; @@ -306,6 +291,36 @@ public class NwDiagram extends UmlDiagram { } + private Map getLinks(DiagElement element) { + final Map result = new LinkedHashMap(); + for (Network network : networks) { + final String s = network.getAdress(element); + if (s != null) { + result.put(network, s); + } + } + return result; + } + + private GridTextBlockDecorated buildGrid() { + final GridTextBlockDecorated grid = new GridTextBlockDecorated(networks.size(), elements.size(), groups, networks); + + for (int i = 0; i < networks.size(); i++) { + final Network current = networks.get(i); + final Network next = i + 1 < networks.size() ? networks.get(i + 1) : null; + int j = 0; + for (Map.Entry ent : elements.entrySet()) { + final DiagElement element = ent.getValue(); + if (element.getMainNetwork() == current) { + final Map conns = getLinks(element); + grid.add(i, j, element.asTextBlock(conns, next)); + } + j++; + } + } + return grid; + } + public CommandExecutionResult setProperty(String property, String value) { if (initDone == false) { return error(); diff --git a/src/net/sourceforge/plantuml/nwdiag/VerticalLine.java b/src/net/sourceforge/plantuml/nwdiag/VerticalLine.java new file mode 100644 index 000000000..a983cfb57 --- /dev/null +++ b/src/net/sourceforge/plantuml/nwdiag/VerticalLine.java @@ -0,0 +1,96 @@ +/* ======================================================================== + * 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.nwdiag; + +import java.util.TreeSet; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class VerticalLine implements UDrawable { + + private final double y1; + private final double y2; + private final TreeSet skip; + + public VerticalLine(double y1, double y2, TreeSet skip) { + this.y1 = Math.min(y1, y2); + this.y2 = Math.max(y1, y2); + this.skip = skip; + } + + public void drawU(UGraphic ug) { + boolean drawn = false; + double current = y1; + for (Double step : skip) { + if (step < y1) { + continue; + } + assert step >= y1; + drawn = true; + if (step == y2) { + drawVLine(ug, current, y2); + } else { + drawVLine(ug, current, Math.min(y2, step - 3)); + if (y2 > step) { + drawArc(ug, step - 3); + } + } + current = step + 9; + if (current >= y2) { + break; + } + } + if (drawn == false) { + drawVLine(ug, y1, y2); + } + + } + + private void drawArc(UGraphic ug, double y) { + final UEllipse arc = new UEllipse(11, 11, 90, -180); + ug.apply(new UTranslate(-5, y)).draw(arc); + + } + + private void drawVLine(UGraphic ug, double start, double end) { + final ULine line = ULine.vline(end - start); + ug.apply(UTranslate.dy(start)).draw(line); + } + +} diff --git a/src/net/sourceforge/plantuml/posimo/DotPath.java b/src/net/sourceforge/plantuml/posimo/DotPath.java index 49016688d..5d77fb03b 100644 --- a/src/net/sourceforge/plantuml/posimo/DotPath.java +++ b/src/net/sourceforge/plantuml/posimo/DotPath.java @@ -30,6 +30,7 @@ * * * Original Author: Arnaud Roques + * Contribution: Miguel Esteves * * */ @@ -94,6 +95,7 @@ public class DotPath implements UShape, Moveable { private final List beziers = new ArrayList(); private String comment; + private String codeLine; public DotPath() { this(new ArrayList()); @@ -427,7 +429,7 @@ public class DotPath implements UShape, Moveable { } public UPath toUPath() { - final UPath result = new UPath(comment); + final UPath result = new UPath(comment, codeLine); boolean start = true; for (CubicCurve2D.Double bez : beziers) { if (start) { @@ -689,8 +691,9 @@ public class DotPath implements UShape, Moveable { return Collections.unmodifiableList(result); } - public void setComment(String comment) { + public void setCommentAndCodeLine(String comment, String codeLine) { this.comment = comment; + this.codeLine = codeLine; } } diff --git a/src/net/sourceforge/plantuml/project/Completion.java b/src/net/sourceforge/plantuml/project/Completion.java index 7158898de..8809a91e1 100644 --- a/src/net/sourceforge/plantuml/project/Completion.java +++ b/src/net/sourceforge/plantuml/project/Completion.java @@ -35,9 +35,7 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.lang.Complement; - -public class Completion implements Complement { +public class Completion { private final int completion; diff --git a/src/net/sourceforge/plantuml/project/DaysAsDates.java b/src/net/sourceforge/plantuml/project/DaysAsDates.java index 3828f377d..9fb8f7560 100644 --- a/src/net/sourceforge/plantuml/project/DaysAsDates.java +++ b/src/net/sourceforge/plantuml/project/DaysAsDates.java @@ -37,11 +37,9 @@ package net.sourceforge.plantuml.project; import java.util.Iterator; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.Subject; import net.sourceforge.plantuml.project.time.Day; -public class DaysAsDates implements Subject, Complement, Iterable { +public class DaysAsDates implements Iterable { private final Day date1; private final Day date2; diff --git a/src/net/sourceforge/plantuml/project/GanttArrow.java b/src/net/sourceforge/plantuml/project/GanttArrow.java index 3e30b9a3f..fda24c1c9 100644 --- a/src/net/sourceforge/plantuml/project/GanttArrow.java +++ b/src/net/sourceforge/plantuml/project/GanttArrow.java @@ -36,16 +36,18 @@ package net.sourceforge.plantuml.project; import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; +import net.sourceforge.plantuml.project.draw.TaskDraw; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.ugraphic.color.HColor; public class GanttArrow implements UDrawable { @@ -54,13 +56,20 @@ public class GanttArrow implements UDrawable { private final TaskInstant source; private final Direction atEnd; private final TaskInstant dest; + private final HColor color; + private final LinkType style; + private final ToTaskDraw toTaskDraw; - public GanttArrow(TimeScale timeScale, TaskInstant source, TaskInstant dest) { + public GanttArrow(TimeScale timeScale, TaskInstant source, TaskInstant dest, HColor color, LinkType style, + ToTaskDraw toTaskDraw) { + this.toTaskDraw = toTaskDraw; + this.style = style; + this.color = color; this.timeScale = timeScale; this.source = source; this.dest = dest; if (source.getAttribute() == TaskAttribute.END && dest.getAttribute() == TaskAttribute.START) { - this.atStart = Direction.DOWN; + this.atStart = source.sameRowAs(dest) ? Direction.LEFT : Direction.DOWN; this.atEnd = Direction.RIGHT; } else if (source.getAttribute() == TaskAttribute.END && dest.getAttribute() == TaskAttribute.END) { this.atStart = Direction.RIGHT; @@ -69,28 +78,33 @@ public class GanttArrow implements UDrawable { this.atStart = Direction.LEFT; this.atEnd = Direction.RIGHT; } else if (source.getAttribute() == TaskAttribute.START && dest.getAttribute() == TaskAttribute.END) { - this.atStart = Direction.DOWN; + this.atStart = source.sameRowAs(dest) ? Direction.RIGHT : Direction.DOWN; this.atEnd = Direction.LEFT; } else { throw new IllegalArgumentException(); } + } + private TaskDraw getSource() { + return toTaskDraw.getTaskDraw((Task) source.getMoment()); + } + + private TaskDraw getDestination() { + return toTaskDraw.getTaskDraw((Task) dest.getMoment()); } public void drawU(UGraphic ug) { - ug = ug.apply(HColorUtils.RED_DARK.bg()).apply(HColorUtils.RED_DARK).apply(new UStroke(1.5)); - - final Task draw1 = (Task) source.getMoment(); - final Task draw2 = (Task) dest.getMoment(); + // ug = ug.apply(color.bg()).apply(color).apply(new UStroke(1.5)); + ug = ug.apply(color.bg()).apply(color).apply(style.getStroke3(new UStroke(1.5))); double x1 = getX(source.withDelta(0), atStart); - double y1 = draw1.getY(atStart); + double y1 = getSource().getY(atStart); final double x2 = getX(dest, atEnd.getInv()); - final double y2 = draw2.getY(atEnd); + final double y2 = getDestination().getY(atEnd); if (atStart == Direction.DOWN && y2 < y1) { - y1 = draw1.getY(atStart.getInv()); + y1 = getSource().getY(atStart.getInv()); } if (this.atStart == Direction.DOWN && this.atEnd == Direction.RIGHT) { @@ -101,7 +115,7 @@ public class GanttArrow implements UDrawable { drawLine(ug, x1, y1, x1, y2, x2, y2); } else { x1 = getX(source.withDelta(0), Direction.RIGHT); - y1 = draw1.getY(Direction.RIGHT); + y1 = getSource().getY(Direction.RIGHT); drawLine(ug, x1, y1, x1 + 6, y1, x1 + 6, y1 + 8, x2 - 8, y1 + 8, x2 - 8, y2, x2, y2); } } else if (this.atStart == Direction.RIGHT && this.atEnd == Direction.LEFT) { @@ -116,6 +130,7 @@ public class GanttArrow implements UDrawable { throw new IllegalArgumentException(); } + ug = ug.apply(new UStroke(1.5)); ug.apply(new UTranslate(x2, y2)).draw(Arrows.asTo(atEnd)); } diff --git a/src/net/sourceforge/plantuml/project/GanttConstraint.java b/src/net/sourceforge/plantuml/project/GanttConstraint.java index 5b094221b..53fa4cf39 100644 --- a/src/net/sourceforge/plantuml/project/GanttConstraint.java +++ b/src/net/sourceforge/plantuml/project/GanttConstraint.java @@ -35,20 +35,29 @@ */ package net.sourceforge.plantuml.project; +import net.sourceforge.plantuml.cucadiagram.LinkDecor; +import net.sourceforge.plantuml.cucadiagram.LinkType; +import net.sourceforge.plantuml.cucadiagram.WithLinkType; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.project.core.TaskInstant; -import net.sourceforge.plantuml.project.lang.Complement; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class GanttConstraint implements Complement { +public class GanttConstraint extends WithLinkType { private final TaskInstant source; private final TaskInstant dest; - public GanttConstraint(TaskInstant source, TaskInstant dest) { + public GanttConstraint(TaskInstant source, TaskInstant dest, HColor forcedColor) { this.source = source; this.dest = dest; + this.type = new LinkType(LinkDecor.NONE, LinkDecor.NONE); + this.setSpecificColor(forcedColor); + } + + public GanttConstraint(TaskInstant source, TaskInstant dest) { + this(source, dest, null); } @Override @@ -56,8 +65,11 @@ public class GanttConstraint implements Complement { return source.toString() + " --> " + dest.toString(); } - public UDrawable getUDrawable(final TimeScale timeScale) { - return new GanttArrow(timeScale, source, dest); + public UDrawable getUDrawable(TimeScale timeScale, HColor color, ToTaskDraw toTaskDraw) { + if (getSpecificColor() == null) { + return new GanttArrow(timeScale, source, dest, color, getType(), toTaskDraw); + } + return new GanttArrow(timeScale, source, dest, getSpecificColor(), getType(), toTaskDraw); } public boolean isHidden(Wink min, Wink max) { @@ -79,4 +91,8 @@ public class GanttConstraint implements Complement { } return false; } + + @Override + public void goNorank() { + } } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index 42fd0f99c..a2a4bd4e5 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -83,8 +84,7 @@ import net.sourceforge.plantuml.project.draw.TimeHeaderDaily; import net.sourceforge.plantuml.project.draw.TimeHeaderMonthly; import net.sourceforge.plantuml.project.draw.TimeHeaderSimple; import net.sourceforge.plantuml.project.draw.TimeHeaderWeekly; -import net.sourceforge.plantuml.project.lang.ComplementColors; -import net.sourceforge.plantuml.project.lang.Subject; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.GCalendar; @@ -101,7 +101,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; -public class GanttDiagram extends TitledDiagram implements Subject { +public class GanttDiagram extends TitledDiagram implements ToTaskDraw { private final Map tasks = new LinkedHashMap(); private final Map byShortName = new HashMap(); @@ -126,10 +126,17 @@ public class GanttDiagram extends TitledDiagram implements Subject { private Day printStart; private Day printEnd; + private HColor linksColor = HColorUtils.RED_DARK; + public DiagramDescription getDescription() { return new DiagramDescription("(Project)"); } + @Override + public UmlDiagramType getUmlDiagramType() { + return UmlDiagramType.GANTT; + } + private int horizontalPages = 1; private int verticalPages = 1; @@ -175,10 +182,9 @@ public class GanttDiagram extends TitledDiagram implements Subject { final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); final ImageBuilder imageBuilder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, getMetadata(), "", dpiFactor, null); - final SkinParam skinParam = SkinParam.create(UmlDiagramType.TIMING); TextBlock result = getTextBlock(); - result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result); + result = new AnnotatedWorker(this, getSkinParam(), fileFormatOption.getDefaultStringBounder()).addAdd(result); imageBuilder.setUDrawable(result); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os); @@ -264,7 +270,7 @@ public class GanttDiagram extends TitledDiagram implements Subject { if (printStart != null && constraint.isHidden(min, max)) { continue; } - constraint.getUDrawable(timeScale).drawU(ug); + constraint.getUDrawable(timeScale, linksColor, this).drawU(ug); } } @@ -326,26 +332,37 @@ public class GanttDiagram extends TitledDiagram implements Subject { private void initTaskAndResourceDraws(TimeScale timeScale, double headerHeight) { double y = headerHeight; - for (Task task : tasks.values()) { - task.setY(y); - y += task.getHeight(); - - } +// for (Task task : tasks.values()) { +// if (task instanceof TaskImpl) { +// final TaskImpl taskImpl = (TaskImpl) task; +// if (taskImpl.getRow() != null) { +// continue; +// } +// } +// task.setY5757(y); +// y += task.getHeight(); +// +// } +// double y2 = headerHeight; for (Task task : tasks.values()) { final TaskDraw draw; if (task instanceof TaskSeparator) { - draw = new TaskDrawSeparator(((TaskSeparator) task).getName(), timeScale, task.getY(), min, max); + draw = new TaskDrawSeparator(((TaskSeparator) task).getName(), timeScale, y, min, max); } else { final TaskImpl tmp = (TaskImpl) task; if (tmp.isDiamond()) { - draw = new TaskDrawDiamond(timeScale, task.getY(), tmp.getPrettyDisplay(), getStart(tmp)); + draw = new TaskDrawDiamond(timeScale, y, tmp.getPrettyDisplay(), getStart(tmp), getSkinParam(), + task, this); } else { final boolean oddStart = printStart != null && min.compareTo(getStart(tmp)) == 0; final boolean oddEnd = printStart != null && max.compareTo(getEnd(tmp)) == 0; - draw = new TaskDrawRegular(timeScale, task.getY(), tmp.getPrettyDisplay(), getStart(tmp), - getEnd(tmp), oddStart, oddEnd); + draw = new TaskDrawRegular(timeScale, y, tmp.getPrettyDisplay(), getStart(tmp), getEnd(tmp), + oddStart, oddEnd, getSkinParam(), task, this); } - draw.setColorsAndCompletion(tmp.getColors(), tmp.getCompletion(), tmp.getUrl()); + draw.setColorsAndCompletion(tmp.getColors(), tmp.getCompletion(), tmp.getUrl(), tmp.getNote()); + } + if (task.getRow() == null) { + y += draw.getHeight(); } draws.put(task, draw); } @@ -434,10 +451,12 @@ public class GanttDiagram extends TitledDiagram implements Subject { return tasks.get(code); } - public void setTaskOrder(final Task task1, final Task task2) { + public GanttConstraint forceTaskOrder(Task task1, Task task2) { final TaskInstant end1 = new TaskInstant(task1, TaskAttribute.END); task2.setStart(end1.getInstantPrecise()); - addContraint(new GanttConstraint(end1, new TaskInstant(task2, TaskAttribute.START))); + final GanttConstraint result = new GanttConstraint(end1, new TaskInstant(task2, TaskAttribute.START)); + addContraint(result); + return result; } public Task getOrCreateTask(String codeOrShortName, String shortName, boolean linkedToPrevious) { @@ -459,13 +478,13 @@ public class GanttDiagram extends TitledDiagram implements Subject { if (linkedToPrevious) { previous = getLastCreatedTask(); } - result = new TaskImpl(code, getDefaultPlan()); + result = new TaskImpl(code, getDefaultPlan(), calendar); tasks.put(code, result); if (byShortName != null) { byShortName.put(shortName, result); } if (previous != null) { - setTaskOrder(previous, result); + forceTaskOrder(previous, result); } } return result; @@ -606,7 +625,7 @@ public class GanttDiagram extends TitledDiagram implements Subject { nameDays.put(day, name); } - public void setTodayColors(ComplementColors colors) { + public void setTodayColors(CenterBorderColor colors) { if (today == null) { this.today = Day.today(); } @@ -619,7 +638,7 @@ public class GanttDiagram extends TitledDiagram implements Subject { } public CommandExecutionResult deleteTask(Task task) { - task.setColors(new ComplementColors(HColorUtils.WHITE, HColorUtils.BLACK)); + task.setColors(new CenterBorderColor(HColorUtils.WHITE, HColorUtils.BLACK)); return CommandExecutionResult.ok(); } @@ -628,4 +647,23 @@ public class GanttDiagram extends TitledDiagram implements Subject { this.printEnd = end; } + public void setLinksColor(HColor color) { + this.linksColor = color; + } + + public TaskDraw getTaskDraw(Task task) { + return draws.get(task); + } + + public CommandExecutionResult addNote(Display note) { + Task last = null; + for (Task current : tasks.values()) + last = current; + if (last == null) { + return CommandExecutionResult.error("No task defined"); + } + last.setNote(note); + return CommandExecutionResult.ok(); + } + } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java index 5699ae807..1b9c6d2c1 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java @@ -48,29 +48,33 @@ import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.project.command.CommandColorTask; import net.sourceforge.plantuml.project.command.CommandGanttArrow; import net.sourceforge.plantuml.project.command.CommandGanttArrow2; +import net.sourceforge.plantuml.project.command.CommandNoteBottom; import net.sourceforge.plantuml.project.command.CommandPage; import net.sourceforge.plantuml.project.command.CommandPrintBetween; import net.sourceforge.plantuml.project.command.CommandPrintScale; import net.sourceforge.plantuml.project.command.CommandSeparator; import net.sourceforge.plantuml.project.command.NaturalCommand; -import net.sourceforge.plantuml.project.command.NaturalCommandAnd; -import net.sourceforge.plantuml.project.command.NaturalCommandAndAnd; -import net.sourceforge.plantuml.project.lang.ComplementPattern; +import net.sourceforge.plantuml.project.lang.SentenceAnd; +import net.sourceforge.plantuml.project.lang.SentenceAndAnd; +import net.sourceforge.plantuml.project.lang.SentenceSimple; +import net.sourceforge.plantuml.project.lang.Subject; import net.sourceforge.plantuml.project.lang.SubjectDayAsDate; import net.sourceforge.plantuml.project.lang.SubjectDayOfWeek; import net.sourceforge.plantuml.project.lang.SubjectDaysAsDates; -import net.sourceforge.plantuml.project.lang.SubjectPattern; +import net.sourceforge.plantuml.project.lang.SubjectLinks; import net.sourceforge.plantuml.project.lang.SubjectProject; import net.sourceforge.plantuml.project.lang.SubjectResource; import net.sourceforge.plantuml.project.lang.SubjectTask; import net.sourceforge.plantuml.project.lang.SubjectToday; -import net.sourceforge.plantuml.project.lang.VerbPattern; +import net.sourceforge.plantuml.style.CommandStyleImport; +import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; public class GanttDiagramFactory extends UmlDiagramFactory { - static private final List subjects() { - return Arrays.asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(), - new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday()); + static private final List subjects() { + return Arrays.asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(), + new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday(), + new SubjectLinks()); } public GanttDiagramFactory(DiagramType type) { @@ -81,6 +85,10 @@ public class GanttDiagramFactory extends UmlDiagramFactory { protected List createCommands() { final List cmds = new ArrayList(); addTitleCommands(cmds); + + cmds.add(new CommandStyleMultilinesCSS()); + cmds.add(new CommandStyleImport()); + // addCommonCommands(cmds); cmds.add(new CommandNope()); // cmds.add(new CommandComment()); @@ -95,6 +103,8 @@ public class GanttDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandPrintBetween()); cmds.add(new CommandScale()); cmds.add(new CommandPage()); + cmds.add(new CommandNoteBottom()); + // cmds.add(new CommandScaleWidthAndHeight()); // cmds.add(new CommandScaleWidthOrHeight()); // cmds.add(new CommandScaleMaxWidth()); @@ -109,44 +119,27 @@ public class GanttDiagramFactory extends UmlDiagramFactory { private static Collection getLanguageCommands() { synchronized (cache) { if (cache.size() == 0) { - for (SubjectPattern subject : subjects()) { - for (VerbPattern verb : subject.getVerbs()) { - for (ComplementPattern complement : verb.getComplements()) { - cache.add(NaturalCommand.create(subject, verb, complement)); + + for (Subject subject : subjects()) { + for (SentenceSimple sentenceA : subject.getSentences()) { + cache.add(NaturalCommand.create(sentenceA)); + for (SentenceSimple sentenceB : subject.getSentences()) { + if (sentenceA.getVerbPattern().equals(sentenceB.getVerbPattern()) == false) { + cache.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB))); + } } } } - for (SubjectPattern subject : subjects()) { - final Collection verbs = subject.getVerbs(); - for (VerbPattern verb1 : verbs) { - for (VerbPattern verb2 : verbs) { - if (verb1 == verb2) { - continue; - } - for (ComplementPattern complement1 : verb1.getComplements()) { - for (ComplementPattern complement2 : verb2.getComplements()) { + + for (Subject subject : subjects()) { + for (SentenceSimple sentenceA : subject.getSentences()) { + for (SentenceSimple sentenceB : subject.getSentences()) { + for (SentenceSimple sentenceC : subject.getSentences()) { + if (sentenceA.getVerbPattern().equals(sentenceB.getVerbPattern()) == false + && sentenceA.getVerbPattern().equals(sentenceC.getVerbPattern()) == false + && sentenceC.getVerbPattern().equals(sentenceB.getVerbPattern()) == false) { cache.add( - NaturalCommandAnd.create(subject, verb1, complement1, verb2, complement2)); - } - } - } - } - } - for (SubjectPattern subject : subjects()) { - final Collection verbs = subject.getVerbs(); - for (VerbPattern verb1 : verbs) { - for (VerbPattern verb2 : verbs) { - for (VerbPattern verb3 : verbs) { - if (verb1 == verb2 || verb1 == verb3 || verb2 == verb3) { - continue; - } - for (ComplementPattern complement1 : verb1.getComplements()) { - for (ComplementPattern complement2 : verb2.getComplements()) { - for (ComplementPattern complement3 : verb3.getComplements()) { - cache.add(NaturalCommandAndAnd.create(subject, verb1, complement1, verb2, - complement2, verb3, complement3)); - } - } + NaturalCommand.create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC))); } } } diff --git a/src/net/sourceforge/plantuml/project/Load.java b/src/net/sourceforge/plantuml/project/Load.java index 74d807464..a2d9a160a 100644 --- a/src/net/sourceforge/plantuml/project/Load.java +++ b/src/net/sourceforge/plantuml/project/Load.java @@ -35,9 +35,7 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.lang.Complement; - -public class Load implements Value, Complement { +public class Load implements Value { private final int winks; diff --git a/src/net/sourceforge/plantuml/project/Solver3.java b/src/net/sourceforge/plantuml/project/Solver.java similarity index 97% rename from src/net/sourceforge/plantuml/project/Solver3.java rename to src/net/sourceforge/plantuml/project/Solver.java index 530bf0ef7..a6b7679d1 100644 --- a/src/net/sourceforge/plantuml/project/Solver3.java +++ b/src/net/sourceforge/plantuml/project/Solver.java @@ -43,13 +43,13 @@ import java.util.Map.Entry; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.time.Wink; -public class Solver3 { +public class Solver { private final Map values = new LinkedHashMap(); private final LoadPlanable loadPlanable; - public Solver3(LoadPlanable loadPlanable) { + public Solver(LoadPlanable loadPlanable) { this.loadPlanable = loadPlanable; } diff --git a/src/net/sourceforge/plantuml/project/lang/Complement.java b/src/net/sourceforge/plantuml/project/ToTaskDraw.java similarity index 85% rename from src/net/sourceforge/plantuml/project/lang/Complement.java rename to src/net/sourceforge/plantuml/project/ToTaskDraw.java index b20145e45..18b9c3959 100644 --- a/src/net/sourceforge/plantuml/project/lang/Complement.java +++ b/src/net/sourceforge/plantuml/project/ToTaskDraw.java @@ -33,9 +33,13 @@ * * */ -package net.sourceforge.plantuml.project.lang; +package net.sourceforge.plantuml.project; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.draw.TaskDraw; -public interface Complement { +public interface ToTaskDraw { + + public TaskDraw getTaskDraw(Task task); } diff --git a/src/net/sourceforge/plantuml/project/Today.java b/src/net/sourceforge/plantuml/project/Today.java index f7c03b3d5..e00a8d1ee 100644 --- a/src/net/sourceforge/plantuml/project/Today.java +++ b/src/net/sourceforge/plantuml/project/Today.java @@ -35,8 +35,6 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.lang.Subject; - -public class Today implements Subject { +public class Today { } diff --git a/src/net/sourceforge/plantuml/project/command/CommandColorTask.java b/src/net/sourceforge/plantuml/project/command/CommandColorTask.java index a3ecb0af2..00a204a7f 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandColorTask.java +++ b/src/net/sourceforge/plantuml/project/command/CommandColorTask.java @@ -44,7 +44,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.ugraphic.color.HColor; public class CommandColorTask extends SingleLineCommand2 { @@ -74,7 +74,7 @@ public class CommandColorTask extends SingleLineCommand2 { final String color2 = arg.get("COLORS", 1); final HColor col1 = diagram.getIHtmlColorSet().getColorIfValid(color1); final HColor col2 = diagram.getIHtmlColorSet().getColorIfValid(color2); - task.setColors(new ComplementColors(col1, col2)); + task.setColors(new CenterBorderColor(col1, col2)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java index 72416d7f8..409ed7706 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java +++ b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java @@ -42,6 +42,7 @@ 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.RegexResult; +import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; @@ -58,7 +59,9 @@ public class CommandGanttArrow extends SingleLineCommand2 { return RegexConcat.build(CommandGanttArrow.class.getName(), RegexLeaf.start(), // new RegexLeaf("CODE1", "([\\p{L}0-9_.]+)"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("ARROW", "(-+)"), // + new RegexLeaf("(-+)"), // + new RegexLeaf("ARROW_STYLE", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // + new RegexLeaf("(-*)"), // new RegexLeaf("\\>"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)"), // @@ -79,10 +82,8 @@ public class CommandGanttArrow extends SingleLineCommand2 { return CommandExecutionResult.error("No such task " + code2); } - final TaskInstant end1 = new TaskInstant(task1, TaskAttribute.END); - - task2.setStart(end1.getInstantPrecise()); - diagram.addContraint(new GanttConstraint(end1, new TaskInstant(task2, TaskAttribute.START))); + final GanttConstraint link = diagram.forceTaskOrder(task1, task2); + link.applyStyle(arg.get("ARROW_STYLE", 0)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow2.java b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow2.java index 900dfce8c..6e019bfb3 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow2.java +++ b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow2.java @@ -42,6 +42,8 @@ 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.RegexResult; +import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; +import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; @@ -57,7 +59,9 @@ public class CommandGanttArrow2 extends SingleLineCommand2 { new RegexLeaf("TASK1", "([^\\[\\]]+?)"), // new RegexLeaf("\\]"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("ARROW", "(-+)"), // + new RegexLeaf("(-+)"), // + new RegexLeaf("ARROW_STYLE", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // + new RegexLeaf("(-*)"), // new RegexLeaf("\\>"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("\\["), // @@ -75,7 +79,8 @@ public class CommandGanttArrow2 extends SingleLineCommand2 { final Task task1 = diagram.getOrCreateTask(name1, null, false); final Task task2 = diagram.getOrCreateTask(name2, null, false); - diagram.setTaskOrder(task1, task2); + final GanttConstraint link = diagram.forceTaskOrder(task1, task2); + link.applyStyle(arg.get("ARROW_STYLE", 0)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java b/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java new file mode 100644 index 000000000..d71917686 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java @@ -0,0 +1,65 @@ +/* ======================================================================== + * 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.command; + +import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.CommandMultilines; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.project.GanttDiagram; + +public class CommandNoteBottom extends CommandMultilines { + + public CommandNoteBottom() { + super("(?i)^note[%s]*bottom$"); + } + + @Override + public String getPatternEnd() { + return "(?i)^end[%s]*note$"; + } + + public CommandExecutionResult execute(GanttDiagram diagram, BlocLines lines) { + lines = lines.subExtract(1, 1); + lines = lines.removeEmptyColumns(); + final Display strings = lines.toDisplay(); + if (strings.size() > 0) { + return diagram.addNote(strings); + } + return CommandExecutionResult.error("No note defined"); + } + +} diff --git a/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java b/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java index ceca8be26..d9162a621 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java +++ b/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java @@ -71,8 +71,8 @@ public class CommandPrintBetween extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) { - final Day start = (Day) pattern.getComplement(diagram, arg, "START").get(); - final Day end = (Day) pattern.getComplement(diagram, arg, "END").get(); + final Day start = (Day) pattern.getMe(diagram, arg, "START").get(); + final Day end = (Day) pattern.getMe(diagram, arg, "END").get(); diagram.setPrintInterval(start, end); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/command/NaturalCommand.java b/src/net/sourceforge/plantuml/project/command/NaturalCommand.java index 4266907ae..cd3625d90 100644 --- a/src/net/sourceforge/plantuml/project/command/NaturalCommand.java +++ b/src/net/sourceforge/plantuml/project/command/NaturalCommand.java @@ -36,71 +36,29 @@ package net.sourceforge.plantuml.project.command; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.command.regex.RegexConcat; -import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.ComplementEmpty; -import net.sourceforge.plantuml.project.lang.ComplementPattern; -import net.sourceforge.plantuml.project.lang.Subject; -import net.sourceforge.plantuml.project.lang.SubjectPattern; -import net.sourceforge.plantuml.project.lang.Verb; -import net.sourceforge.plantuml.project.lang.VerbPattern; +import net.sourceforge.plantuml.project.lang.Sentence; public class NaturalCommand extends SingleLineCommand2 { - private final SubjectPattern subjectPattern; - private final VerbPattern verbPattern; - private final ComplementPattern complementPattern; + private final Sentence sentence; - private NaturalCommand(RegexConcat pattern, SubjectPattern subject, VerbPattern verb, ComplementPattern complement) { - super(pattern); - this.subjectPattern = subject; - this.verbPattern = verb; - this.complementPattern = complement; + public NaturalCommand(Sentence sentence) { + super(sentence.toRegex()); + this.sentence = sentence; } @Override - public String toString() { - return subjectPattern.toString() + " " + verbPattern.toString() + " " + complementPattern.toString(); + final protected CommandExecutionResult executeArg(GanttDiagram system, LineLocation location, RegexResult arg) { + return sentence.execute(system, arg); } - @Override - protected CommandExecutionResult executeArg(GanttDiagram system, LineLocation location, RegexResult arg) { - final Subject subject = subjectPattern.getSubject(system, arg); - final Verb verb = verbPattern.getVerb(system, arg); - final Failable complement = complementPattern.getComplement(system, arg, "0"); - if (complement.isFail()) { - return CommandExecutionResult.error(complement.getError()); - } - return verb.execute(subject, complement.get()); + public static NaturalCommand create(Sentence sentence) { + return new NaturalCommand(sentence); + } - public static Command create(SubjectPattern subject, VerbPattern verb, ComplementPattern complement) { - final RegexConcat pattern; - if (complement instanceof ComplementEmpty) { - pattern = new RegexConcat(// - RegexLeaf.start(), // - subject.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - verb.toRegex(), // - RegexLeaf.end()); - } else { - pattern = new RegexConcat(// - RegexLeaf.start(), // - subject.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - verb.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement.toRegex("0"), // - RegexLeaf.end()); - } - // System.err.println("NaturalCommand="+pattern.getPattern()); - return new NaturalCommand(pattern, subject, verb, complement); - } } diff --git a/src/net/sourceforge/plantuml/project/command/NaturalCommandAnd.java b/src/net/sourceforge/plantuml/project/command/NaturalCommandAnd.java deleted file mode 100644 index 663c0d8b1..000000000 --- a/src/net/sourceforge/plantuml/project/command/NaturalCommandAnd.java +++ /dev/null @@ -1,116 +0,0 @@ -/* ======================================================================== - * 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.command; - -import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.command.regex.RegexConcat; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.ComplementPattern; -import net.sourceforge.plantuml.project.lang.Subject; -import net.sourceforge.plantuml.project.lang.SubjectPattern; -import net.sourceforge.plantuml.project.lang.Verb; -import net.sourceforge.plantuml.project.lang.VerbPattern; - -public class NaturalCommandAnd extends SingleLineCommand2 { - - private final SubjectPattern subjectPattern; - private final VerbPattern verbPattern1; - private final ComplementPattern complementPattern1; - private final VerbPattern verbPattern2; - private final ComplementPattern complementPattern2; - - private NaturalCommandAnd(RegexConcat pattern, SubjectPattern subject, VerbPattern verb1, - ComplementPattern complement1, VerbPattern verb2, ComplementPattern complement2) { - super(pattern); - this.subjectPattern = subject; - this.verbPattern1 = verb1; - this.complementPattern1 = complement1; - this.verbPattern2 = verb2; - this.complementPattern2 = complement2; - } - - @Override - public String toString() { - return subjectPattern.toString() + " " + verbPattern1.toString() + " " + complementPattern1.toString() - + " and " + verbPattern2.toString() + " " + complementPattern2.toString(); - } - - @Override - protected CommandExecutionResult executeArg(GanttDiagram system, LineLocation location, RegexResult arg) { - final Subject subject = subjectPattern.getSubject(system, arg); - final Verb verb1 = verbPattern1.getVerb(system, arg); - final Failable complement1 = complementPattern1.getComplement(system, arg, "1"); - if (complement1.isFail()) { - return CommandExecutionResult.error(complement1.getError()); - } - final CommandExecutionResult result1 = verb1.execute(subject, complement1.get()); - if (result1.isOk() == false) { - return result1; - } - final Verb verb2 = verbPattern2.getVerb(system, arg); - final Failable complement2 = complementPattern2.getComplement(system, arg, "2"); - if (complement2.isFail()) { - return CommandExecutionResult.error(complement2.getError()); - } - return verb2.execute(subject, complement2.get()); - } - - public static Command create(SubjectPattern subject, VerbPattern verb1, ComplementPattern complement1, - VerbPattern verb2, ComplementPattern complement2) { - final RegexConcat pattern = new RegexConcat(// - RegexLeaf.start(), // - subject.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - verb1.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement1.toRegex("1"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // - verb2.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement2.toRegex("2"), // - RegexLeaf.end()); - return new NaturalCommandAnd(pattern, subject, verb1, complement1, verb2, complement2); - } -} diff --git a/src/net/sourceforge/plantuml/project/command/NaturalCommandAndAnd.java b/src/net/sourceforge/plantuml/project/command/NaturalCommandAndAnd.java deleted file mode 100644 index 63b0d8080..000000000 --- a/src/net/sourceforge/plantuml/project/command/NaturalCommandAndAnd.java +++ /dev/null @@ -1,127 +0,0 @@ -/* ======================================================================== - * 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.command; - -import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.command.regex.RegexConcat; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.ComplementPattern; -import net.sourceforge.plantuml.project.lang.Subject; -import net.sourceforge.plantuml.project.lang.SubjectPattern; -import net.sourceforge.plantuml.project.lang.Verb; -import net.sourceforge.plantuml.project.lang.VerbPattern; - -public class NaturalCommandAndAnd extends SingleLineCommand2 { - - private final SubjectPattern subjectPattern; - private final VerbPattern verbPattern1; - private final ComplementPattern complementPattern1; - private final VerbPattern verbPattern2; - private final ComplementPattern complementPattern2; - private final VerbPattern verbPattern3; - private final ComplementPattern complementPattern3; - - private NaturalCommandAndAnd(RegexConcat pattern, SubjectPattern subject, VerbPattern verb1, - ComplementPattern complement1, VerbPattern verb2, ComplementPattern complement2, VerbPattern verb3, - ComplementPattern complement3) { - super(pattern); - this.subjectPattern = subject; - this.verbPattern1 = verb1; - this.complementPattern1 = complement1; - this.verbPattern2 = verb2; - this.complementPattern2 = complement2; - this.verbPattern3 = verb3; - this.complementPattern3 = complement3; - } - - @Override - public String toString() { - return subjectPattern.toString() + " " + verbPattern1.toString() + " " + complementPattern1.toString() - + " and " + verbPattern2.toString() + " " + complementPattern2.toString() + " and " - + verbPattern3.toString() + " " + complementPattern3.toString(); - } - - @Override - protected CommandExecutionResult executeArg(GanttDiagram system, LineLocation location, RegexResult arg) { - final Subject subject = subjectPattern.getSubject(system, arg); - final Verb verb1 = verbPattern1.getVerb(system, arg); - final Complement complement1 = complementPattern1.getComplement(system, arg, "1").get(); - final CommandExecutionResult result1 = verb1.execute(subject, complement1); - if (result1.isOk() == false) { - return result1; - } - final Verb verb2 = verbPattern2.getVerb(system, arg); - final Complement complement2 = complementPattern2.getComplement(system, arg, "2").get(); - final CommandExecutionResult result2 = verb2.execute(subject, complement2); - if (result2.isOk() == false) { - return result2; - } - final Verb verb3 = verbPattern3.getVerb(system, arg); - final Complement complement3 = complementPattern3.getComplement(system, arg, "3").get(); - return verb3.execute(subject, complement3); - } - - public static Command create(SubjectPattern subject, VerbPattern verb1, ComplementPattern complement1, - VerbPattern verb2, ComplementPattern complement2, VerbPattern verb3, ComplementPattern complement3) { - final RegexConcat pattern = new RegexConcat(// - RegexLeaf.start(), // - subject.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - verb1.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement1.toRegex("1"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // - verb2.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement2.toRegex("2"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // - verb3.toRegex(), // - RegexLeaf.spaceOneOrMore(), // - complement3.toRegex("3"), // - RegexLeaf.end()); - return new NaturalCommandAndAnd(pattern, subject, verb1, complement1, verb2, complement2, verb3, complement3); - } -} diff --git a/src/net/sourceforge/plantuml/project/core/AbstractTask.java b/src/net/sourceforge/plantuml/project/core/AbstractTask.java index 5c8ebe566..c526f4da5 100644 --- a/src/net/sourceforge/plantuml/project/core/AbstractTask.java +++ b/src/net/sourceforge/plantuml/project/core/AbstractTask.java @@ -35,39 +35,21 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.Direction; - public abstract class AbstractTask implements Task { - public static final double HEIGHT = 16; - - public double getHeight() { - return HEIGHT; - } - protected final TaskCode code; - private double y; + private Task row; protected AbstractTask(TaskCode code) { this.code = code; } - public final double getY() { - return y; + public void putInSameRowAs(Task row) { + this.row = row; } - public final void setY(double y) { - this.y = y; - } - - public double getY(Direction direction) { - if (direction == Direction.UP) { - return y; - } - if (direction == Direction.DOWN) { - return y + getHeight(); - } - return y + getHeight() / 2; + public final Task getRow() { + return row; } } diff --git a/src/net/sourceforge/plantuml/project/core/Resource.java b/src/net/sourceforge/plantuml/project/core/Resource.java index b169728a0..e6234e07e 100644 --- a/src/net/sourceforge/plantuml/project/core/Resource.java +++ b/src/net/sourceforge/plantuml/project/core/Resource.java @@ -42,13 +42,12 @@ import java.util.TreeSet; import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.draw.ResourceDraw; -import net.sourceforge.plantuml.project.lang.Subject; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.Wink; -public class Resource implements Subject { +public class Resource { private final String name; private ResourceDraw draw; diff --git a/src/net/sourceforge/plantuml/project/core/Task.java b/src/net/sourceforge/plantuml/project/core/Task.java index 8575ea403..c2e323e86 100644 --- a/src/net/sourceforge/plantuml/project/core/Task.java +++ b/src/net/sourceforge/plantuml/project/core/Task.java @@ -35,14 +35,14 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.Load; -import net.sourceforge.plantuml.project.lang.ComplementColors; -import net.sourceforge.plantuml.project.lang.Subject; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.Wink; -public interface Task extends Subject, Moment { +public interface Task extends Moment { public TaskCode getCode(); @@ -58,7 +58,7 @@ public interface Task extends Subject, Moment { public void setEnd(Wink end); - public void setColors(ComplementColors colors); + public void setColors(CenterBorderColor colors); public void addResource(Resource resource, int percentage); @@ -70,12 +70,14 @@ public interface Task extends Subject, Moment { public void setUrl(Url url); - public double getHeight(); + public void putInSameRowAs(Task row); - public double getY(); + public Task getRow(); - public void setY(double y); + public void addPause(Wink pause); - public double getY(Direction direction); + public void addPause(DayOfWeek pause); + + public void setNote(Display note); } diff --git a/src/net/sourceforge/plantuml/project/core/TaskImpl.java b/src/net/sourceforge/plantuml/project/core/TaskImpl.java index b0c6126c9..653b23a25 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskImpl.java +++ b/src/net/sourceforge/plantuml/project/core/TaskImpl.java @@ -35,76 +35,108 @@ */ package net.sourceforge.plantuml.project.core; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.PlanUtils; -import net.sourceforge.plantuml.project.Solver3; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.Solver; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.DayOfWeek; +import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.Wink; public class TaskImpl extends AbstractTask implements Task, LoadPlanable { - private final Solver3 solver; - private final Map resources2 = new LinkedHashMap(); + private final SortedSet pausedDay = new TreeSet(); + private final Set pausedDayOfWeek = new HashSet(); + private final Solver solver; + private final Map resources = new LinkedHashMap(); private final LoadPlanable defaultPlan; + private final GCalendar calendar; private boolean diamond; + private int completion = 100; + private Display note; + private Url url; - private ComplementColors colors; + private CenterBorderColor colors; public void setUrl(Url url) { this.url = url; } - public TaskImpl(TaskCode code, LoadPlanable defaultPlan) { + public TaskImpl(TaskCode code, LoadPlanable defaultPlan, GCalendar calendar) { super(code); + this.calendar = calendar; this.defaultPlan = defaultPlan; - this.solver = new Solver3(this); + this.solver = new Solver(this); setStart(new Wink(0)); setLoad(Load.inWinks(1)); } public int getLoadAt(Wink instant) { + if (pausedDay.contains(instant)) { + return 0; + } + if (pausedDayOfWeek(instant)) { + return 0; + } + LoadPlanable result = defaultPlan; - if (resources2.size() > 0) { + if (resources.size() > 0) { result = PlanUtils.multiply(defaultPlan, getRessourcePlan()); } return result.getLoadAt(instant); - // return PlanUtils.minOf(getLoad(), plan1).getLoadAt(instant); + } + + private boolean pausedDayOfWeek(Wink instant) { + for (DayOfWeek dayOfWeek : pausedDayOfWeek) { + if (calendar.toDayAsDate(instant).getDayOfWeek() == dayOfWeek) { + return true; + } + } + return false; } public int loadForResource(Resource res, Wink instant) { - if (resources2.keySet().contains(res) && instant.compareTo(getStart()) >= 0 + if (resources.keySet().contains(res) && instant.compareTo(getStart()) >= 0 && instant.compareTo(getEnd()) <= 0) { if (res.isClosedAt(instant)) { return 0; } - // int size = 0; - return resources2.get(res); - // for (Resource r : resources) { - // if (r.getLoadAt(i) > 0) { - // size++; - // } - // } - // return getLoadAt(instant) / size; + return resources.get(res); } return 0; } + public void addPause(Wink pause) { + this.pausedDay.add(pause); + } + + public void addPause(DayOfWeek pause) { + this.pausedDayOfWeek.add(pause); + } + private LoadPlanable getRessourcePlan() { - if (resources2.size() == 0) { + if (resources.size() == 0) { throw new IllegalStateException(); } return new LoadPlanable() { - public int getLoadAt(Wink instant) { int result = 0; - for (Map.Entry ent : resources2.entrySet()) { + for (Map.Entry ent : resources.entrySet()) { final Resource res = ent.getKey(); if (res.isClosedAt(instant)) { continue; @@ -118,10 +150,10 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { } public String getPrettyDisplay() { - if (resources2.size() > 0) { + if (resources.size() > 0) { final StringBuilder result = new StringBuilder(code.getSimpleDisplay()); result.append(" "); - for (Iterator> it = resources2.entrySet().iterator(); it.hasNext();) { + for (Iterator> it = resources.entrySet().iterator(); it.hasNext();) { final Map.Entry ent = it.next(); result.append("{"); result.append(ent.getKey().getName()); @@ -180,12 +212,12 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { solver.setData(TaskAttribute.END, end); } - public void setColors(ComplementColors colors) { + public void setColors(CenterBorderColor colors) { this.colors = colors; } public void addResource(Resource resource, int percentage) { - this.resources2.put(resource, percentage); + this.resources.put(resource, percentage); } public void setDiamond(boolean diamond) { @@ -196,8 +228,6 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return this.diamond; } - private int completion = 100; - public void setCompletion(int completion) { this.completion = completion; } @@ -206,7 +236,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return url; } - public final ComplementColors getColors() { + public final CenterBorderColor getColors() { return colors; } @@ -214,4 +244,30 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return completion; } + public final Collection getAllPaused() { + final SortedSet result = new TreeSet(pausedDay); + for (DayOfWeek dayOfWeek : pausedDayOfWeek) { + addAll(result, dayOfWeek); + } + return Collections.unmodifiableCollection(result); + } + + private void addAll(SortedSet result, DayOfWeek dayOfWeek) { + final Day start = calendar.toDayAsDate(getStart()); + final Day end = calendar.toDayAsDate(getEnd()); + for (Day current = start; current.compareTo(end) <= 0; current = current.next()) { + if (current.getDayOfWeek() == dayOfWeek) { + result.add(calendar.fromDayAsDate(current)); + } + } + } + + public void setNote(Display note) { + this.note = note; + } + + public Display getNote() { + return note; + } + } diff --git a/src/net/sourceforge/plantuml/project/core/TaskInstant.java b/src/net/sourceforge/plantuml/project/core/TaskInstant.java index 78b1a2e55..d28942515 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskInstant.java +++ b/src/net/sourceforge/plantuml/project/core/TaskInstant.java @@ -35,10 +35,9 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.project.lang.Complement; import net.sourceforge.plantuml.project.time.Wink; -public class TaskInstant implements Complement { +public class TaskInstant { private final Moment task; private final TaskAttribute attribute; @@ -105,11 +104,22 @@ public class TaskInstant implements Complement { } public final boolean isTask() { - return task instanceof Task; + return task instanceof AbstractTask; } public final TaskAttribute getAttribute() { return attribute; } + public boolean sameRowAs(TaskInstant dest) { + if (this.isTask() && dest.isTask()) { + final AbstractTask t1 = (AbstractTask) this.getMoment(); + final AbstractTask t2 = (AbstractTask) dest.getMoment(); + if (t1 == t2.getRow() || t2 == t1.getRow()) { + return true; + } + } + return false; + } + } diff --git a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java index a5ff90ce8..65e895b88 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java +++ b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java @@ -36,8 +36,10 @@ package net.sourceforge.plantuml.project.core; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.Load; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.Wink; public class TaskSeparator extends AbstractTask implements Task { @@ -69,7 +71,7 @@ public class TaskSeparator extends AbstractTask implements Task { throw new UnsupportedOperationException(); } - public void setColors(ComplementColors colors) { + public void setColors(CenterBorderColor colors) { throw new UnsupportedOperationException(); } @@ -105,4 +107,15 @@ public class TaskSeparator extends AbstractTask implements Task { throw new UnsupportedOperationException(); } + public void addPause(Wink pause) { + throw new UnsupportedOperationException(); + } + + public void addPause(DayOfWeek pause) { + throw new UnsupportedOperationException(); + } + + public void setNote(Display note) { + } + } diff --git a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java index 3302dca9e..a8585beea 100644 --- a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java @@ -35,39 +35,95 @@ */ package net.sourceforge.plantuml.project.draw; +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.project.core.AbstractTask; +import net.sourceforge.plantuml.project.ToTaskDraw; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.ugraphic.color.HColor; public abstract class AbstractTaskDraw implements TaskDraw { + protected CenterBorderColor colors; + protected int completion = 100; + protected Url url; + protected Display note; protected final TimeScale timeScale; protected final double y; protected final String prettyDisplay; protected final Wink start; + protected final ISkinParam skinParam; + private final Task task; + private final ToTaskDraw toTaskDraw; protected final double margin = 2; - public AbstractTaskDraw(TimeScale timeScale, double y, String prettyDisplay, Wink start) { + final public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note) { + this.colors = colors; + this.completion = completion; + this.url = url; + this.note = note; + } + + public AbstractTaskDraw(TimeScale timeScale, double y, String prettyDisplay, Wink start, ISkinParam skinParam, + Task task, ToTaskDraw toTaskDraw) { this.y = y; + this.toTaskDraw = toTaskDraw; this.start = start; this.prettyDisplay = prettyDisplay; this.timeScale = timeScale; + this.skinParam = skinParam; + this.task = task; } - abstract protected FontConfiguration getFontConfiguration(); + final protected HColor getLineColor() { + return getStyle().value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + } + + final protected HColor getBackgroundColor() { + return getStyle().value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); + } + + final protected FontConfiguration getFontConfiguration() { + return getStyle().getFontConfiguration(skinParam.getIHtmlColorSet()); + } + + abstract protected Style getStyle(); final protected double getShapeHeight() { return getHeight() - 2 * margin; } final public double getHeight() { - return AbstractTask.HEIGHT; + return getFontConfiguration().getFont().getSize2D() + 5; } final public double getY() { - return y; + if (task.getRow() == null) { + return y; + } + return toTaskDraw.getTaskDraw(task.getRow()).getY(); + } + + public final Task getTask() { + return task; + } + + public final double getY(Direction direction) { + if (direction == Direction.UP) { + return getY(); + } + if (direction == Direction.DOWN) { + return getY() + getHeight(); + } + return getY() + getHeight() / 2; } } diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java index 962808961..1401c6c16 100644 --- a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.core.Resource; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; @@ -75,20 +76,37 @@ public class ResourceDraw implements UDrawable { HorizontalAlignment.LEFT, new SpriteContainerEmpty()); title.drawU(ug); final ULine line = ULine.hline(timeScale.getEndingPosition(max) - timeScale.getStartingPosition(min)); - ug.apply(HColorUtils.BLACK) - .apply(UTranslate.dy(title.calculateDimension(ug.getStringBounder()).getHeight())).draw(line); - for (Wink i = min; i.compareTo(max) <= 0; i = i.increment()) { - final int load = gantt.getLoadForResource(res, i); - if (load > 0) { - final FontConfiguration fontConfiguration = getFontConfiguration(9, load > 100 ? HColorUtils.RED - : HColorUtils.BLACK); - final TextBlock value = Display.getWithNewlines("" + load).create(fontConfiguration, - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - final double start = (timeScale.getStartingPosition(i) + timeScale.getEndingPosition(i)) / 2 - - value.calculateDimension(ug.getStringBounder()).getWidth() / 2; - value.drawU(ug.apply(new UTranslate(start, 16))); - } + ug.apply(HColorUtils.BLACK).apply(UTranslate.dy(title.calculateDimension(ug.getStringBounder()).getHeight())) + .draw(line); + double startingPosition = -1; + int totalLoad = 0; + int totalLimit = 0; + for (Wink i = min; i.compareTo(max) <= 0; i = i.increment()) { + final boolean isBreaking = timeScale.isBreaking(i); + totalLoad += gantt.getLoadForResource(res, i); + totalLimit += 100; + if (isBreaking) { + if (totalLoad > 0) { + final boolean over = totalLoad > totalLimit; + final FontConfiguration fontConfiguration = getFontConfiguration(9, + over ? HColorUtils.RED : HColorUtils.BLACK); + final TextBlock value = Display.getWithNewlines("" + totalLoad).create(fontConfiguration, + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + if (startingPosition == -1) + startingPosition = timeScale.getStartingPosition(i); + final double endingPosition = timeScale.getEndingPosition(i); + final double start = (startingPosition + endingPosition) / 2 + - value.calculateDimension(ug.getStringBounder()).getWidth() / 2; + value.drawU(ug.apply(new UTranslate(start, 16))); + } + startingPosition = -1; + totalLoad = 0; + totalLimit = 0; + } else { + if (startingPosition == -1) + startingPosition = timeScale.getStartingPosition(i); + } } } @@ -102,14 +120,6 @@ public class ResourceDraw implements UDrawable { return new FontConfiguration(font, color, color, false); } - // public void setColors(ComplementColors colors); - // - // public double getY(); - // - // public double getY(Direction direction); - // - // public void drawTitle(UGraphic ug); - public double getHeight() { return 16 * 2; } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDraw.java b/src/net/sourceforge/plantuml/project/draw/TaskDraw.java index b5e844b95..cd4fd43ce 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDraw.java @@ -35,19 +35,26 @@ */ package net.sourceforge.plantuml.project.draw; +import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.ugraphic.UGraphic; public interface TaskDraw extends UDrawable { - public void setColorsAndCompletion(ComplementColors colors, int completion, Url url); + public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note); public double getY(); + public double getY(Direction direction); + public void drawTitle(UGraphic ug); public double getHeight(); + public Task getTask(); + } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java index 90f4b085c..9087ca76b 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java @@ -35,36 +35,40 @@ */ package net.sourceforge.plantuml.project.draw; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.ToTaskDraw; +import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; -import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class TaskDrawDiamond extends AbstractTaskDraw { - private ComplementColors colors; - - public TaskDrawDiamond(TimeScale timeScale, double y, String prettyDisplay, Wink start) { - super(timeScale, y, prettyDisplay, start); + public TaskDrawDiamond(TimeScale timeScale, double y, String prettyDisplay, Wink start, ISkinParam skinParam, + Task task, ToTaskDraw toTaskDraw) { + super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw); } @Override - protected FontConfiguration getFontConfiguration() { - final UFont font = UFont.serif(11); - return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); + protected Style getStyle() { + final Style style = StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.milestone) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + return style; } +// final UFont font = UFont.serif(11); +// return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); + final public void drawTitle(UGraphic ug) { final TextBlock title = Display.getWithNewlines(prettyDisplay).create(getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); @@ -85,7 +89,7 @@ public class TaskDrawDiamond extends AbstractTaskDraw { if (colors != null && colors.isOk()) { return colors.apply(ug); } - return ug.apply(HColorUtils.BLACK).apply(HColorUtils.BLACK.bg()); + return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); } private void drawShape(UGraphic ug) { @@ -102,7 +106,4 @@ public class TaskDrawDiamond extends AbstractTaskDraw { return result; } - public void setColorsAndCompletion(ComplementColors colors, int completion, Url url) { - this.colors = colors; - } } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index bf515e3bc..5295d03cf 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -35,44 +35,55 @@ */ package net.sourceforge.plantuml.project.draw; +import java.util.Collection; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.ToTaskDraw; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskImpl; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; -import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.svek.image.Opale; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorNone; -import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class TaskDrawRegular extends AbstractTaskDraw { - private static final HColor defaultColor = HColorSet.instance().getColorIfValid("GreenYellow"); - - private ComplementColors colors; - private int completion = 100; - private Url url; private final Wink end; private final boolean oddStart; private final boolean oddEnd; + private final Collection paused; private final double margin = 2; public TaskDrawRegular(TimeScale timeScale, double y, String prettyDisplay, Wink start, Wink end, boolean oddStart, - boolean oddEnd) { - super(timeScale, y, prettyDisplay, start); + boolean oddEnd, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw) { + super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw); this.end = end; this.oddStart = oddStart; this.oddEnd = oddEnd; - + this.paused = ((TaskImpl) task).getAllPaused(); } public void drawTitle(UGraphic ug) { @@ -84,24 +95,53 @@ public class TaskDrawRegular extends AbstractTaskDraw { title.drawU(ug.apply(new UTranslate(endingPosition, h))); } +// final UFont font = UFont.serif(11); +// return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); + @Override - protected FontConfiguration getFontConfiguration() { - final UFont font = UFont.serif(11); - return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); + protected Style getStyle() { + final Style style = StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.task) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + return style; } - public void drawU(UGraphic ug1) { + public void drawU(UGraphic ug) { + drawNote(ug.apply(UTranslate.dy(getShapeHeight() + margin * 3))); + final double startPos = timeScale.getStartingPosition(start); - ug1 = applyColors(ug1); - UGraphic ug2 = ug1.apply(new UTranslate(startPos + margin, margin)); - drawShape(ug2); + ug = applyColors(ug); + ug = ug.apply(new UTranslate(startPos + margin, margin)); + drawShape(ug); + } + + private void drawNote(UGraphic ug) { + if (note == null) { + return; + } + + final Style style = StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.note) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + FontConfiguration fc = new FontConfiguration(style, skinParam, null, FontParam.NOTE); + + final Sheet sheet = Parser + .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + .createSheet(note); + final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); + + final HColor noteBackgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); + final HColor borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + final double shadowing = style.value(PName.Shadowing).asDouble(); + + Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, sheet1, false); + opale.drawU(ug); + } private UGraphic applyColors(UGraphic ug) { if (colors != null && colors.isOk()) { return colors.apply(ug); } - return ug.apply(HColorUtils.BLUE).apply(defaultColor.bg()); + return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); } private void drawShape(UGraphic ug) { @@ -117,37 +157,54 @@ public class TaskDrawRegular extends AbstractTaskDraw { } if (oddStart && !oddEnd) { ug.draw(PathUtils.UtoRight(fullLength, getShapeHeight())); - return; - } - if (!oddStart && oddEnd) { + } else if (!oddStart && oddEnd) { ug.draw(PathUtils.UtoLeft(fullLength, getShapeHeight())); - return; - } - final URectangle full = new URectangle(fullLength, getShapeHeight()).rounded(8); - if (completion == 100) { - ug.draw(full); } else { - final double partialLength = fullLength * completion / 100.; - ug.apply(HColorUtils.WHITE).apply(HColorUtils.WHITE.bg()) - .draw(full); - if (partialLength > 2) { - final URectangle partial = new URectangle(partialLength, getShapeHeight()).rounded(8); - ug.apply(new HColorNone()).draw(partial); + final URectangle full = new URectangle(fullLength, getShapeHeight()).rounded(8); + if (completion == 100) { + ug.draw(full); + } else { + final double partialLength = fullLength * completion / 100.; + ug.apply(HColorUtils.WHITE).apply(HColorUtils.WHITE.bg()).draw(full); + if (partialLength > 2) { + final URectangle partial = new URectangle(partialLength, getShapeHeight()).rounded(8); + ug.apply(new HColorNone()).draw(partial); + } + if (partialLength > 10 && partialLength < fullLength - 10) { + final URectangle patch = new URectangle(8, getShapeHeight()); + ug.apply(new HColorNone()).apply(UTranslate.dx(partialLength - 8)).draw(patch); + } + ug.apply(new HColorNone().bg()).draw(full); } - if (partialLength > 10 && partialLength < fullLength - 10) { - final URectangle patch = new URectangle(8, getShapeHeight()); - ug.apply(new HColorNone()).apply(UTranslate.dx(partialLength - 8)).draw(patch); + } + Wink begin = null; + for (Wink pause : paused) { + if (paused.contains(pause.increment())) { + if (begin == null) + begin = pause; + } else { + if (begin == null) + drawPause(ug, pause, pause); + else + drawPause(ug, begin, pause); + begin = null; } - ug.apply(new HColorNone().bg()).draw(full); } if (url != null) { ug.closeUrl(); } } - public void setColorsAndCompletion(ComplementColors colors, int completion, Url url) { - this.colors = colors; - this.completion = completion; - this.url = url; + private void drawPause(UGraphic ug, Wink start1, Wink end) { + final double x1 = timeScale.getStartingPosition(start1); + final double x2 = timeScale.getEndingPosition(end); + final URectangle small = new URectangle(x2 - x1 - 1, getShapeHeight() + 1); + final ULine line = ULine.hline(x2 - x1 - 1); + ug = ug.apply(UTranslate.dx(x1 - 1)); + ug.apply(HColorUtils.WHITE).apply(HColorUtils.WHITE.bg()).draw(small); + final UGraphic ugLine = ug.apply(new UStroke(2, 3, 1)); + ugLine.draw(line); + ugLine.apply(UTranslate.dy(getShapeHeight())).draw(line); } + } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java index 717ff0886..f45accecf 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.project.draw; +import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; @@ -43,7 +44,8 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.project.core.AbstractTask; -import net.sourceforge.plantuml.project.lang.ComplementColors; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.UFont; @@ -108,14 +110,22 @@ public class TaskDrawSeparator implements TaskDraw { } public double getHeight() { - return AbstractTask.HEIGHT; + return 16; } public double getY() { return y; } - public void setColorsAndCompletion(ComplementColors colors, int completion, Url url) { + public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note) { + } + + public Task getTask() { + throw new UnsupportedOperationException(); + } + + public double getY(Direction direction) { + throw new UnsupportedOperationException(); } } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java index 808f83722..80bc698ba 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java @@ -46,14 +46,14 @@ import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public abstract class TimeHeader { - + protected static final int Y_POS_ROW16 = 16; protected static final int Y_POS_ROW28 = 28; - private final TimeScale timeScale; protected final Wink min; protected final Wink max; @@ -75,20 +75,20 @@ public abstract class TimeHeader { ug.apply(HColorUtils.LIGHT_GRAY).apply(UTranslate.dy(y)).draw(hline); } - final protected FontConfiguration getFontConfiguration(int size, boolean bold) { + final protected FontConfiguration getFontConfiguration(int size, boolean bold, HColor color) { UFont font = UFont.serif(size); if (bold) { font = font.bold(); } - return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false); + return new FontConfiguration(font, color, color, false); } public final TimeScale getTimeScale() { return timeScale; } - protected final TextBlock getTextBlock(final String text, int size, boolean bold) { - return Display.getWithNewlines(text).create(getFontConfiguration(size, bold), HorizontalAlignment.LEFT, + protected final TextBlock getTextBlock(String text, int size, boolean bold, HColor color) { + return Display.getWithNewlines(text).create(getFontConfiguration(size, bold, color), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java index 5fc4f43a7..7a3db976e 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java @@ -60,14 +60,15 @@ public class TimeHeaderDaily extends TimeHeader { } private final HColor veryLightGray = HColorSet.instance().getColorIfValid("#E0E8E8"); + private final HColor lightGray = HColorSet.instance().getColorIfValid("#909898"); private final GCalendar calendar; private final LoadPlanable defaultPlan; private final Map colorDays; private final Map nameDays; - public TimeHeaderDaily(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, - Map colorDays, Map nameDays, Day printStart, Day printEnd) { + public TimeHeaderDaily(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, Map colorDays, + Map nameDays, Day printStart, Day printEnd) { super(min, max, new TimeScaleDaily(calendar, printStart)); this.calendar = calendar; this.defaultPlan = defaultPlan; @@ -99,16 +100,18 @@ public class TimeHeaderDaily extends TimeHeader { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); final Day day = calendar.toDayAsDate(wink); - if (defaultPlan.getLoadAt(wink) > 0) { - final HColor back = colorDays.get(day); - if (back != null) { - drawRectangle(ug.apply(back.bg()), height, x1, x2); - } - printCentered(ug.apply(UTranslate.dy(Y_POS_ROW16)), - getTextBlock(day.getDayOfWeek().shortName(), 10, false), x1, x2); - printCentered(ug.apply(UTranslate.dy(Y_POS_ROW28)), getTextBlock("" + day.getDayOfMonth(), 10, false), - x1, x2); + HColor textColor = HColorUtils.BLACK; + if (defaultPlan.getLoadAt(wink) <= 0) { + textColor = lightGray; } + final HColor back = colorDays.get(day); + if (back != null) { + drawRectangle(ug.apply(back.bg()), height, x1, x2); + } + printCentered(ug.apply(UTranslate.dy(Y_POS_ROW16)), + getTextBlock(day.getDayOfWeek().shortName(), 10, false, textColor), x1, x2); + printCentered(ug.apply(UTranslate.dy(Y_POS_ROW28)), + getTextBlock("" + day.getDayOfMonth(), 10, false, textColor), x1, x2); } } @@ -166,9 +169,9 @@ public class TimeHeaderDaily extends TimeHeader { } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock tiny = getTextBlock(monthYear.shortName(), 12, true); - final TextBlock small = getTextBlock(monthYear.longName(), 12, true); - final TextBlock big = getTextBlock(monthYear.longNameYYYY(), 12, true); + final TextBlock tiny = getTextBlock(monthYear.shortName(), 12, true, HColorUtils.BLACK); + final TextBlock small = getTextBlock(monthYear.longName(), 12, true, HColorUtils.BLACK); + final TextBlock big = getTextBlock(monthYear.longNameYYYY(), 12, true, HColorUtils.BLACK); printCentered(ug, start, end, tiny, small, big); } @@ -186,7 +189,7 @@ public class TimeHeaderDaily extends TimeHeader { 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); + final TextBlock label = getTextBlock(name, 12, false, HColorUtils.BLACK); final double h = label.calculateDimension(ug.getStringBounder()).getHeight(); double y1 = getTimeHeaderHeight(); double y2 = getFullHeaderHeight(); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java index 11ce081a0..8261b4888 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java @@ -122,13 +122,13 @@ public class TimeHeaderMonthly extends TimeHeader { } private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock("" + monthYear.year(), 12, true); + final TextBlock small = getTextBlock("" + monthYear.year(), 12, true, HColorUtils.BLACK); printCentered(ug, start, end, small); } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock(monthYear.shortName(), 10, false); - final TextBlock big = getTextBlock(monthYear.longName(), 10, false); + final TextBlock small = getTextBlock(monthYear.shortName(), 10, false, HColorUtils.BLACK); + final TextBlock big = getTextBlock(monthYear.longName(), 10, false, HColorUtils.BLACK); printCentered(ug, start, end, small, big); } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java index 07dee9d2a..671838c1c 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java @@ -80,7 +80,7 @@ public class TimeHeaderSimple extends TimeHeader { private void drawSimpleDayCounter(final UGraphic ug, TimeScale timeScale, double totalHeight) { final ULine vbar = ULine.vline(totalHeight); for (Wink i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) { - final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(10, false), + final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(10, false, HColorUtils.BLACK), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final double x1 = timeScale.getStartingPosition(i); final double x2 = timeScale.getEndingPosition(i); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java index a6c1ce7a1..3fbdf9691 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java @@ -114,15 +114,15 @@ public class TimeHeaderWeekly extends TimeHeader { for (Wink wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { final Day day = calendar.toDayAsDate(wink); if (day.getDayOfWeek() == DayOfWeek.MONDAY) { - printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16)), getTextBlock("" + day.getDayOfMonth(), 10, false), + printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16)), getTextBlock("" + day.getDayOfMonth(), 10, false, HColorUtils.BLACK), getTimeScale().getStartingPosition(wink) + 5); } } } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock(monthYear.shortName(), 12, true); - final TextBlock big = getTextBlock(monthYear.shortNameYYYY(), 12, true); + final TextBlock small = getTextBlock(monthYear.shortName(), 12, true, HColorUtils.BLACK); + final TextBlock big = getTextBlock(monthYear.shortNameYYYY(), 12, true, HColorUtils.BLACK); printCentered(ug, start, end, small, big); } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementColors.java b/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java similarity index 84% rename from src/net/sourceforge/plantuml/project/lang/ComplementColors.java rename to src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java index 88b70a9bb..19ef120df 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementColors.java +++ b/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java @@ -38,14 +38,20 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class ComplementColors implements Complement { +public class CenterBorderColor { private final HColor center; private final HColor border; + private final String style; - public ComplementColors(HColor center, HColor border) { + public CenterBorderColor(HColor center, HColor border) { + this(center, border, null); + } + + public CenterBorderColor(HColor center, HColor border, String style) { this.center = center; this.border = border; + this.style = style; } public UGraphic apply(UGraphic ug) { @@ -65,7 +71,11 @@ public class ComplementColors implements Complement { return center != null; } - public HColor getCenter() { + public final HColor getCenter() { return center; } + + public final String getStyle() { + return style; + } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java b/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java index f08595b83..f784363a1 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java @@ -44,7 +44,7 @@ import net.sourceforge.plantuml.project.core.Moment; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; -public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPattern { +public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements Something { private static final int POS_NB1 = 0; private static final int POS_DAY_OR_WEEK1 = 1; @@ -61,12 +61,12 @@ public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPatt "[%s]+(before|after))[%s]+\\[([^\\[\\]]+?)\\].?s[%s]+(start|end)"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String code = arg.get("COMPLEMENT" + suffix, POS_CODE_OTHER); final String startOrEnd = arg.get("COMPLEMENT" + suffix, POS_START_OR_END); final Moment task = system.getExistingMoment(code); if (task == null) { - return Failable.error("No such task " + code); + return Failable.error("No such task " + code); } TaskInstant result = new TaskInstant(task, TaskAttribute.fromString(startOrEnd)); final String nb1 = arg.get("COMPLEMENT" + suffix, POS_NB1); @@ -90,6 +90,6 @@ public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPatt } result = result.withDelta(delta); } - return Failable.ok(result); + return Failable.ok(result); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementClose.java b/src/net/sourceforge/plantuml/project/lang/ComplementClose.java index e66247aa5..268b4d814 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementClose.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementClose.java @@ -41,16 +41,13 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementClose implements ComplementPattern { - - public static final Complement CLOSE = new Complement() { - }; +public class ComplementClose implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("CLOSED" + suffix, "(closed?)"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { - return Failable. ok(CLOSE); + public Failable getMe(GanttDiagram project, RegexResult arg, String suffix) { + return Failable.ok(new Object()); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java b/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java index e6ff4b7f8..b54241333 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java @@ -42,14 +42,14 @@ import net.sourceforge.plantuml.project.Completion; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementCompleted implements ComplementPattern { +public class ComplementCompleted implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "(\\d+).*completed?"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String value = arg.get("COMPLEMENT" + suffix, 0); - return Failable.ok(new Completion(Integer.parseInt(value))); + return Failable.ok(new Completion(Integer.parseInt(value))); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDate.java b/src/net/sourceforge/plantuml/project/lang/ComplementDate.java index 1285d6c5b..393b637a5 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDate.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDate.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.Month; -public class ComplementDate implements ComplementPattern { +public class ComplementDate implements Something { public IRegex toRegex(String suffix) { return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix), toRegexD(suffix)); @@ -87,45 +87,45 @@ public class ComplementDate implements ComplementPattern { new RegexLeaf("after"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("start") // - ); + ); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { if (arg.get("ADAY" + suffix, 0) != null) { - return Failable. ok(resultA(arg, suffix)); + return Failable.ok(resultA(arg, suffix)); } if (arg.get("BDAY" + suffix, 0) != null) { - return Failable. ok(resultB(arg, suffix)); + return Failable.ok(resultB(arg, suffix)); } if (arg.get("CDAY" + suffix, 0) != null) { - return Failable. ok(resultC(arg, suffix)); + return Failable.ok(resultC(arg, suffix)); } if (arg.get("DCOUNT" + suffix, 0) != null) { - return Failable. ok(resultD(system, arg, suffix)); + return Failable.ok(resultD(system, arg, suffix)); } throw new IllegalStateException(); } - private Complement resultD(GanttDiagram system, RegexResult arg, String suffix) { + private Day resultD(GanttDiagram system, RegexResult arg, String suffix) { final int day = Integer.parseInt(arg.get("DCOUNT" + suffix, 0)); return system.getStartingDate(day); } - private Complement resultA(RegexResult arg, String suffix) { + 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 Complement resultB(RegexResult arg, String suffix) { + 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 Complement resultC(RegexResult arg, String suffix) { + 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)); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDates.java b/src/net/sourceforge/plantuml/project/lang/ComplementDates.java index 398ec934b..8e512071d 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDates.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDates.java @@ -44,7 +44,7 @@ import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.Day; -public class ComplementDates implements ComplementPattern { +public class ComplementDates implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // @@ -65,20 +65,7 @@ public class ComplementDates implements ComplementPattern { ); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { - final Day date1 = getDate(arg, "1"); - final Day date2 = getDate(arg, "2"); - return new DaysAsDates(date1, date2); - } - - private Day getDate(RegexResult arg, String suffix) { - final int day = Integer.parseInt(arg.get("DAY" + suffix, 0)); - final int month = Integer.parseInt(arg.get("MONTH" + suffix, 0)); - final int year = Integer.parseInt(arg.get("YEAR" + suffix, 0)); - return Day.create(year, month, day); - } - - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram project, RegexResult arg, String suffix) { final int day1 = Integer.parseInt(arg.get("DAY1" + suffix, 0)); final int month1 = Integer.parseInt(arg.get("MONTH1" + suffix, 0)); @@ -90,7 +77,7 @@ public class ComplementDates implements ComplementPattern { final int year2 = Integer.parseInt(arg.get("YEAR2" + suffix, 0)); final Day date2 = Day.create(year2, month2, day2); - return Failable. ok(new DaysAsDates(date1, date2)); + return Failable.ok(new DaysAsDates(date1, date2)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java index bd365d2e3..606f05a57 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java @@ -43,16 +43,16 @@ import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.DayOfWeek; -public class ComplementDayOfWeek implements ComplementPattern { +public class ComplementDayOfWeek implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // new RegexLeaf("COMPLEMENT" + suffix, "(" + DayOfWeek.getRegexString() + ")")); // } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram project, RegexResult arg, String suffix) { final String s = arg.get("COMPLEMENT" + suffix, 0); - return Failable. ok(DayOfWeek.fromString(s)); + return Failable.ok(DayOfWeek.fromString(s)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java b/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java index ef9a03c4c..c8bfee5d8 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java @@ -41,14 +41,13 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementEmpty implements ComplementPattern { +public class ComplementEmpty implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf(""); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { - return Failable. ok(new Complement() { - }); + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { + return Failable.ok(new Object()); } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsDeleted.java b/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java similarity index 69% rename from src/net/sourceforge/plantuml/project/lang/VerbIsDeleted.java rename to src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java index b17519734..0f53b727a 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsDeleted.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java @@ -35,33 +35,21 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Task; -public class VerbIsDeleted implements VerbPattern { +public class ComplementFromTo implements Something { - public Collection getComplements() { - return Arrays. asList(new ComplementEmpty()); + public IRegex toRegex(String suffix) { + return new RegexLeaf("COMPLEMENT" + suffix, "from[%s]+\\[([^\\[\\]]+)\\][%s]+to[%s]+\\[([^\\[\\]]+)\\]"); } - public IRegex toRegex() { - return new RegexLeaf("is[%s]+deleted"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - return project.deleteTask(task); - } - - }; + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { + final String name1 = arg.get("COMPLEMENT" + suffix, 0); + final String name2 = arg.get("COMPLEMENT" + suffix, 1); + return Failable.ok(new TwoNames(name1, name2)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java index 289c0b5d5..d013e3c2e 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java @@ -42,17 +42,17 @@ import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class ComplementInColors implements ComplementPattern { +public class ComplementInColors implements Something { public IRegex toRegex(String suffix) { - return new RegexLeaf("COMPLEMENT" + suffix, "in[%s+](#?\\w+)(?:/(#?\\w+))?"); + return new RegexLeaf("COMPLEMENT" + suffix, "in[%s]+(#?\\w+)(?:/(#?\\w+))?"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String color1 = arg.get("COMPLEMENT" + suffix, 0); final String color2 = arg.get("COMPLEMENT" + suffix, 1); final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); final HColor col2 = system.getIHtmlColorSet().getColorIfValid(color2); - return Failable. ok(new ComplementColors(col1, col2)); + return Failable.ok(new CenterBorderColor(col1, col2)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java index 5dea97234..131457fd5 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java @@ -42,17 +42,18 @@ import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class ComplementInColors2 implements ComplementPattern { +public class ComplementInColors2 implements Something { public IRegex toRegex(String suffix) { - return new RegexLeaf("COMPLEMENT" + suffix, "colou?red[%s]+(?:in[%s+])?(#?\\w+)(?:/(#?\\w+))?"); + return new RegexLeaf("COMPLEMENT" + suffix, "colou?red[%s]+(?:in[%s]+)?(#?\\w+)(?:/(#?\\w+))?"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String color1 = arg.get("COMPLEMENT" + suffix, 0); final String color2 = arg.get("COMPLEMENT" + suffix, 1); final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); final HColor col2 = system.getIHtmlColorSet().getColorIfValid(color2); - return Failable. ok(new ComplementColors(col1, col2)); + return Failable.ok(new CenterBorderColor(col1, col2)); } + } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java b/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java index 55ee6fd6e..2844210f8 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java @@ -41,14 +41,14 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementNamed implements ComplementPattern { +public class ComplementNamed implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "\\[([^\\[\\]]+)\\]"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String name = arg.get("COMPLEMENT" + suffix, 0); - return Failable. ok(new ComplementName(name)); + return Failable.ok(name); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java b/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java index 69fd6bec0..095c82ba6 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java @@ -41,16 +41,14 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementOpen implements ComplementPattern { - - public static final Complement OPEN = new Complement() { - }; +public class ComplementOpen implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("OPEN" + suffix, "(opene?d?)"); } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { - return Failable. ok(OPEN); + public Failable getMe(GanttDiagram project, RegexResult arg, String suffix) { + return Failable.ok(new Object()); } + } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java b/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java index 3adeb6f10..61c02f7ab 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.Load; -public class ComplementSeveralDays implements ComplementPattern { +public class ComplementSeveralDays implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // @@ -52,7 +52,7 @@ public class ComplementSeveralDays implements ComplementPattern { )); // } - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String nb1 = arg.get("COMPLEMENT" + suffix, 0); final int factor1 = arg.get("COMPLEMENT" + suffix, 1).startsWith("w") ? system.daysInWeek() : 1; final int days1 = Integer.parseInt(nb1) * factor1; @@ -64,7 +64,7 @@ public class ComplementSeveralDays implements ComplementPattern { days2 = Integer.parseInt(nb2) * factor2; } - return Failable.ok(Load.inWinks(days1 + days2)); + return Failable.ok(Load.inWinks(days1 + days2)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java b/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java index 0cead8588..bac34c295 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java @@ -45,18 +45,18 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public class ComplementUrl implements ComplementPattern { +public class ComplementUrl implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // new RegexLeaf("COMPLEMENT" + suffix, "(" + UrlBuilder.getRegexp() + ")")); // } - public Failable getComplement(GanttDiagram diagram, RegexResult arg, String suffix) { + public Failable getMe(GanttDiagram diagram, RegexResult arg, String suffix) { final String urlString = arg.get("COMPLEMENT" + suffix, 0); final UrlBuilder urlBuilder = new UrlBuilder("", ModeUrl.STRICT); final Url url = urlBuilder.getUrl(urlString); - return Failable.ok(url); + return Failable.ok(url); } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbAre.java b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java similarity index 64% rename from src/net/sourceforge/plantuml/project/lang/VerbAre.java rename to src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java index 82d341320..db7137ae1 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbAre.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java @@ -35,33 +35,27 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.time.DayOfWeek; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class VerbAre implements VerbPattern { +public class ComplementWithColorLink implements Something { - public Collection getComplements() { - return Arrays. asList(new ComplementClose()); + public IRegex toRegex(String suffix) { + final String optionalStyle = "(?:(dotted|bold|dashed)[%s]+)?"; + return new RegexLeaf("COMPLEMENT" + suffix, + "with[%s]+" + optionalStyle + "(#?\\w+)[%s]+" + optionalStyle + "link"); } - public IRegex toRegex() { - return new RegexLeaf("are"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final DayOfWeek day = (DayOfWeek) subject; - project.closeDayOfWeek(day); - return CommandExecutionResult.ok(); - } - }; + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { + final String style0 = arg.get("COMPLEMENT" + suffix, 0); + final String color1 = arg.get("COMPLEMENT" + suffix, 1); + final String style2 = arg.get("COMPLEMENT" + suffix, 2); + final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); + final String style = style0 == null ? style2 : style0; + return Failable.ok(new CenterBorderColor(col1, col1, style)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsForTask.java b/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java similarity index 59% rename from src/net/sourceforge/plantuml/project/lang/VerbIsForTask.java rename to src/net/sourceforge/plantuml/project/lang/PairOfSomething.java index 800473f5e..971f7d0de 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsForTask.java +++ b/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java @@ -35,36 +35,40 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexResult; -import net.sourceforge.plantuml.project.Completion; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Task; -public class VerbIsForTask implements VerbPattern { +public class PairOfSomething implements Something { - public Collection getComplements() { - return Arrays.asList(new ComplementCompleted()); + private final Something complement1; + private final Something complement2; + + public PairOfSomething(Something complement1, Something complement2) { + this.complement1 = complement1; + this.complement2 = complement2; } - public IRegex toRegex() { - return new RegexLeaf("is"); + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { + final Failable r1 = complement1.getMe(system, arg, "A" + suffix); + final Failable r2 = complement2.getMe(system, arg, "B" + suffix); + if (r1.isFail()) { + return r1; + } + if (r2.isFail()) { + return r2; + } + final Object[] result = new Object[] { r1.get(), r2.get() }; + return Failable.ok(result); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final Completion completed = (Completion) complement; - task.setCompletion(completed.getCompletion()); - return CommandExecutionResult.ok(); - } - - }; + public IRegex toRegex(String suffix) { + final IRegex pattern1 = complement1.toRegex("A" + suffix); + final IRegex pattern2 = complement2.toRegex("B" + suffix); + return new RegexConcat(pattern1, new RegexLeaf("[%s]+"), pattern2); } + } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectPattern.java b/src/net/sourceforge/plantuml/project/lang/Sentence.java similarity index 89% rename from src/net/sourceforge/plantuml/project/lang/SubjectPattern.java rename to src/net/sourceforge/plantuml/project/lang/Sentence.java index 155f4719b..42bd0f775 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectPattern.java +++ b/src/net/sourceforge/plantuml/project/lang/Sentence.java @@ -35,18 +35,15 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Collection; - +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; -public interface SubjectPattern { - - public Collection getVerbs(); - - public Subject getSubject(GanttDiagram project, RegexResult arg); +public interface Sentence { public IRegex toRegex(); + public CommandExecutionResult execute(GanttDiagram project, RegexResult arg); + } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsOn.java b/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java similarity index 53% rename from src/net/sourceforge/plantuml/project/lang/VerbIsOn.java rename to src/net/sourceforge/plantuml/project/lang/SentenceAnd.java index 1fba48b3b..eec711cd1 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsOn.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java @@ -35,55 +35,60 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.DaysAsDates; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Resource; -import net.sourceforge.plantuml.project.time.Day; -public class VerbIsOn implements VerbPattern { +public class SentenceAnd implements Sentence { - public Collection getComplements() { - return Arrays. asList(new ComplementDate(), new ComplementDates()); + private final SentenceSimple sentence1; + private final SentenceSimple sentence2; + + public SentenceAnd(SentenceSimple sentence1, SentenceSimple sentence2) { + this.sentence1 = sentence1; + this.sentence2 = sentence2; } public IRegex toRegex() { - return new RegexConcat(new RegexLeaf("is"), // + return new RegexConcat(// + RegexLeaf.start(), // + sentence1.subjectii.toRegex(), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("on"), // + sentence1.getVerbRegex(), // RegexLeaf.spaceOneOrMore(), // - new RegexOr(// - new RegexLeaf("on"),// - new RegexLeaf("for"),// - new RegexLeaf("the"),// - new RegexLeaf("at") // - ) // - ); + sentence1.complementii.toRegex("1"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("and"), // + RegexLeaf.spaceOneOrMore(), // + sentence2.getVerbRegex(), // + RegexLeaf.spaceOneOrMore(), // + sentence2.complementii.toRegex("2"), // + RegexLeaf.end()); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Resource resource = (Resource) subject; - if (complement instanceof DaysAsDates) { - for (Day when : (DaysAsDates) complement) { - resource.addForceOnDay(project.convert(when)); - } - } else { - final Day when = (Day) complement; - resource.addForceOnDay(project.convert(when)); - } - return CommandExecutionResult.ok(); - } + public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { + final Failable subject = sentence1.subjectii.getMe(project, arg); + if (subject.isFail()) { + return CommandExecutionResult.error(subject.getError()); + } + final Failable complement1 = sentence1.complementii.getMe(project, arg, "1"); + if (complement1.isFail()) { + return CommandExecutionResult.error(complement1.getError()); + } + final CommandExecutionResult result1 = sentence1.execute(project, subject.get(), complement1.get()); + if (result1.isOk() == false) { + return result1; + } + final Failable complement2 = sentence2.complementii.getMe(project, arg, "2"); + if (complement2.isFail()) { + return CommandExecutionResult.error(complement2.getError()); + } + return sentence2.execute(project, subject.get(), complement2.get()); - }; } + } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java b/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java new file mode 100644 index 000000000..a0555a810 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java @@ -0,0 +1,111 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +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.RegexResult; +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.GanttDiagram; + +public class SentenceAndAnd implements Sentence { + + private final SentenceSimple sentence1; + private final SentenceSimple sentence2; + private final SentenceSimple sentence3; + + public SentenceAndAnd(SentenceSimple sentence1, SentenceSimple sentence2, SentenceSimple sentence3) { + this.sentence1 = sentence1; + this.sentence2 = sentence2; + this.sentence3 = sentence3; + } + + public IRegex toRegex() { + return new RegexConcat(// + RegexLeaf.start(), // + sentence1.subjectii.toRegex(), // + RegexLeaf.spaceOneOrMore(), // + sentence1.getVerbRegex(), // + RegexLeaf.spaceOneOrMore(), // + sentence1.complementii.toRegex("1"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("and"), // + RegexLeaf.spaceOneOrMore(), // + sentence2.getVerbRegex(), // + RegexLeaf.spaceOneOrMore(), // + sentence2.complementii.toRegex("2"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("and"), // + RegexLeaf.spaceOneOrMore(), // + sentence3.getVerbRegex(), // + RegexLeaf.spaceOneOrMore(), // + sentence3.complementii.toRegex("3"), // + RegexLeaf.end()); + } + + public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { + final Failable subject = sentence1.subjectii.getMe(project, arg); + if (subject.isFail()) { + return CommandExecutionResult.error(subject.getError()); + } + final Failable complement1 = sentence1.complementii.getMe(project, arg, "1"); + if (complement1.isFail()) { + return CommandExecutionResult.error(complement1.getError()); + } + final CommandExecutionResult result1 = sentence1.execute(project, subject.get(), complement1.get()); + if (result1.isOk() == false) { + return result1; + } + final Failable complement2 = sentence2.complementii.getMe(project, arg, "2"); + if (complement2.isFail()) { + return CommandExecutionResult.error(complement2.getError()); + } + final CommandExecutionResult result2 = sentence2.execute(project, subject.get(), complement2.get()); + if (result2.isOk() == false) { + return result2; + } + final Failable complement3 = sentence3.complementii.getMe(project, arg, "3"); + if (complement3.isFail()) { + return CommandExecutionResult.error(complement3.getError()); + } + final CommandExecutionResult result3 = sentence3.execute(project, subject.get(), complement3.get()); + return result3; + + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java b/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java new file mode 100644 index 000000000..0d37bb334 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java @@ -0,0 +1,59 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceDisplayOnSameRowAs extends SentenceSimple { + + public SentenceDisplayOnSameRowAs() { + super(new SubjectTask(), Verbs.displayOnSameRowAs(), new ComplementNamed()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task1 = (Task) subject; + final Task task2 = project.getExistingTask((String) complement); + if (task2 == null) { + return CommandExecutionResult.error("No such task " + task2); + } + task1.putInSameRowAs(task2); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsColored.java b/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java similarity index 63% rename from src/net/sourceforge/plantuml/project/lang/VerbIsColored.java rename to src/net/sourceforge/plantuml/project/lang/SentenceEnds.java index a20d65314..c3f452c84 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsColored.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java @@ -35,35 +35,26 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskAttribute; +import net.sourceforge.plantuml.project.core.TaskInstant; -public class VerbIsColored implements VerbPattern { +public class SentenceEnds extends SentenceSimple { - public Collection getComplements() { - return Arrays. asList(new ComplementInColors()); + public SentenceEnds() { + super(new SubjectTask(), Verbs.ends(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); } - public IRegex toRegex() { - return new RegexLeaf("is[%s]+colou?red"); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final TaskInstant when = (TaskInstant) complement; + task.setEnd(when.getInstantPrecise().decrement()); + project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.END))); + return CommandExecutionResult.ok(); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final ComplementColors colors = (ComplementColors) complement; - task.setColors(colors); - return CommandExecutionResult.ok(); - } - - }; - } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbLasts.java b/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java similarity index 65% rename from src/net/sourceforge/plantuml/project/lang/VerbLasts.java rename to src/net/sourceforge/plantuml/project/lang/SentenceHappens.java index 71a0705f1..a7bb83cec 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbLasts.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java @@ -35,36 +35,26 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskInstant; -public class VerbLasts implements VerbPattern { +public class SentenceHappens extends SentenceSimple { - public Collection getComplements() { - return Arrays. asList(new ComplementSeveralDays()); + public SentenceHappens() { + super(new SubjectTask(), Verbs.happens(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); } - public IRegex toRegex() { - return new RegexLeaf("lasts"); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + task.setLoad(Load.inWinks(1)); + final TaskInstant when = (TaskInstant) complement; + task.setStart(when.getInstantTheorical()); + task.setDiamond(true); + return CommandExecutionResult.ok(); } - public Verb getVerb(GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final Load duration = (Load) complement; - task.setLoad(duration); - return CommandExecutionResult.ok(); - } - - }; - } } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java new file mode 100644 index 000000000..79b7fa52a --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java @@ -0,0 +1,64 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.Load; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.Day; + +public class SentenceHappensDate extends SentenceSimple { + + public SentenceHappensDate() { + super(new SubjectTask(), Verbs.happens(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + task.setLoad(Load.inWinks(1)); + final Day start = (Day) complement; + final Day startingDate = project.getStartingDate(); + if (startingDate == null) { + return CommandExecutionResult.error("No starting date for the project"); + } + task.setStart(start.asInstantDay(startingDate)); + task.setDiamond(true); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java new file mode 100644 index 000000000..4948bcf32 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java @@ -0,0 +1,56 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceIsColored extends SentenceSimple { + + public SentenceIsColored() { + super(new SubjectTask(), Verbs.isColored(), new ComplementInColors()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final CenterBorderColor colors = (CenterBorderColor) complement; + task.setColors(colors); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbPattern.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java similarity index 74% rename from src/net/sourceforge/plantuml/project/lang/VerbPattern.java rename to src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java index 8360b4bb1..dcbf54e89 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbPattern.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java @@ -35,18 +35,20 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Collection; - -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; -public interface VerbPattern { +public class SentenceIsDeleted extends SentenceSimple { - public Collection getComplements(); + public SentenceIsDeleted() { + super(new SubjectTask(), Verbs.isDeleted(), new ComplementEmpty()); + } - public Verb getVerb(GanttDiagram project, RegexResult arg); - - public IRegex toRegex(); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + return project.deleteTask(task); + } } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java new file mode 100644 index 000000000..a4212708c --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.Completion; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceIsForTask extends SentenceSimple { + + public SentenceIsForTask() { + super(new SubjectTask(), Verbs.is(), new ComplementCompleted()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Completion completed = (Completion) complement; + task.setCompletion(completed.getCompletion()); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceLasts.java b/src/net/sourceforge/plantuml/project/lang/SentenceLasts.java new file mode 100644 index 000000000..015dfcfa0 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceLasts.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.Load; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceLasts extends SentenceSimple { + + public SentenceLasts() { + super(new SubjectTask(), Verbs.lasts(), new ComplementSeveralDays()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Load duration = (Load) complement; + task.setLoad(duration); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java b/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java new file mode 100644 index 000000000..ef2de94cc --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceLinksTo extends SentenceSimple { + + public SentenceLinksTo() { + super(new SubjectTask(), Verbs.linksTo(), new ComplementUrl()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Url url = (Url) complement; + task.setUrl(url); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java b/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java new file mode 100644 index 000000000..717bb81d8 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java @@ -0,0 +1,74 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttConstraint; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskAttribute; +import net.sourceforge.plantuml.project.core.TaskInstant; + +public class SentenceOccurs extends SentenceSimple { + + public SentenceOccurs() { + super(new SubjectTask(), Verbs.occurs(), new ComplementFromTo()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final TwoNames bothNames = (TwoNames) complement; + final String name1 = bothNames.getName1(); + final String name2 = bothNames.getName2(); + final Task from = project.getExistingTask(name1); + if (from == null) { + return CommandExecutionResult.error("No such " + name1 + " task"); + } + final Task to = project.getExistingTask(name2); + if (to == null) { + return CommandExecutionResult.error("No such " + name2 + " task"); + } + task.setStart(from.getEnd()); + task.setEnd(to.getEnd()); + project.addContraint(new GanttConstraint(new TaskInstant(from, TaskAttribute.START), + new TaskInstant(task, TaskAttribute.START))); + project.addContraint( + new GanttConstraint(new TaskInstant(to, TaskAttribute.END), new TaskInstant(task, TaskAttribute.END))); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java new file mode 100644 index 000000000..49c5468d2 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java @@ -0,0 +1,62 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.Load; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.Day; + +public class SentencePausesDate extends SentenceSimple { + + public SentencePausesDate() { + super(new SubjectTask(), Verbs.pauses(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day pause = (Day) complement; + final Day startingDate = project.getStartingDate(); + if (startingDate == null) { + return CommandExecutionResult.error("No starting date for the project"); + } + task.addPause(pause.asInstantDay(startingDate)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java new file mode 100644 index 000000000..c51b40c44 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * 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.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.DayOfWeek; + +public class SentencePausesDayOfWeek extends SentenceSimple { + + public SentencePausesDayOfWeek() { + super(new SubjectTask(), Verbs.pauses(), new ComplementDayOfWeek()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final DayOfWeek pause = (DayOfWeek) complement; + task.addPause(pause); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsOff.java b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java similarity index 53% rename from src/net/sourceforge/plantuml/project/lang/VerbIsOff.java rename to src/net/sourceforge/plantuml/project/lang/SentenceSimple.java index b7d46c522..2f826dde4 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsOff.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java @@ -35,58 +35,67 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.DaysAsDates; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Resource; -import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.DayOfWeek; -public class VerbIsOff implements VerbPattern { +public abstract class SentenceSimple implements Sentence { - public Collection getComplements() { - return Arrays - . asList(new ComplementDate(), new ComplementDates(), new ComplementDayOfWeek()); + protected final Subject subjectii; + private final IRegex verb; + protected final Something complementii; + + public SentenceSimple(Subject subject, IRegex verb, Something complement) { + this.subjectii = subject; + this.verb = verb; + this.complementii = complement; } - public IRegex toRegex() { - return new RegexConcat(new RegexLeaf("is"), // + public final IRegex toRegex() { + if (complementii instanceof ComplementEmpty) { + return new RegexConcat(// + RegexLeaf.start(), // + subjectii.toRegex(), // + RegexLeaf.spaceOneOrMore(), // + verb, // + RegexLeaf.end()); + + } + return new RegexConcat(// + RegexLeaf.start(), // + subjectii.toRegex(), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("off"), // + verb, // RegexLeaf.spaceOneOrMore(), // - new RegexOr(// - new RegexLeaf("on"),// - new RegexLeaf("for"),// - new RegexLeaf("the"),// - new RegexLeaf("at") // - )); + complementii.toRegex("0"), // + RegexLeaf.end()); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Resource resource = (Resource) subject; - if (complement instanceof DayOfWeek) { - resource.addCloseDay(((DayOfWeek) complement)); - } else if (complement instanceof DaysAsDates) { - for (Day when : (DaysAsDates) complement) { - resource.addCloseDay(project.convert(when)); - } - } else { - final Day when = (Day) complement; - resource.addCloseDay(project.convert(when)); - } - return CommandExecutionResult.ok(); - } + public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { + final Failable subject = subjectii.getMe(project, arg); + if (subject.isFail()) { + return CommandExecutionResult.error(subject.getError()); + } + final Failable complement = complementii.getMe(project, arg, "0"); + if (complement.isFail()) { + return CommandExecutionResult.error(complement.getError()); + } + return execute(project, subject.get(), complement.get()); - }; } + + public abstract CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement); + + public final String getVerbPattern() { + return verb.getPattern(); + } + + public IRegex getVerbRegex() { + return verb; + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsForToday.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java similarity index 65% rename from src/net/sourceforge/plantuml/project/lang/VerbIsForToday.java rename to src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java index abf45bd79..a08dd404b 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsForToday.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java @@ -35,33 +35,27 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class VerbIsForToday implements VerbPattern { +public class SentenceTaskEndsAbsolute extends SentenceSimple { - public Collection getComplements() { - return Arrays. asList(new ComplementInColors(), new ComplementDate()); + public SentenceTaskEndsAbsolute() { + super(new SubjectTask(), Verbs.ends2(), new ComplementDate()); } - public IRegex toRegex() { - return new RegexLeaf("is"); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day end = (Day) complement; + final Day startingDate = project.getStartingDate(); + if (startingDate == null) { + return CommandExecutionResult.error("No starting date for the project"); + } + task.setEnd(end.asInstantDay(startingDate)); + return CommandExecutionResult.ok(); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - // final Today task = (Today) subject; - final Day date = (Day) complement; - return project.setToday(date); - } - }; - } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbEnds.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java similarity index 63% rename from src/net/sourceforge/plantuml/project/lang/VerbEnds.java rename to src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java index 37e67b3cf..4aa962041 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbEnds.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java @@ -35,40 +35,31 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class VerbEnds implements VerbPattern { +public class SentenceTaskStarts extends SentenceSimple { - public Collection getComplements() { - return Arrays. asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); + public SentenceTaskStarts() { + super(new SubjectTask(), Verbs.starts2(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); } - public IRegex toRegex() { - return new RegexLeaf("ends"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final TaskInstant when = (TaskInstant) complement; - task.setEnd(when.getInstantPrecise().decrement()); - project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.END))); - return CommandExecutionResult.ok(); - } - - }; - } + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final TaskInstant when; + HColor color = null; + when = (TaskInstant) complement; + task.setStart(when.getInstantPrecise()); + if (when.isTask()) { + project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.START), color)); + } + return CommandExecutionResult.ok(); + }; } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbLinksTo.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java similarity index 64% rename from src/net/sourceforge/plantuml/project/lang/VerbLinksTo.java rename to src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java index 371d48e2e..1d27dea58 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbLinksTo.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java @@ -35,36 +35,27 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.Day; -public class VerbLinksTo implements VerbPattern { +public class SentenceTaskStartsAbsolute extends SentenceSimple { - public Collection getComplements() { - return Arrays.asList(new ComplementUrl()); + public SentenceTaskStartsAbsolute() { + super(new SubjectTask(), Verbs.starts3(), new ComplementDate()); } - public IRegex toRegex() { - return new RegexLeaf("links to"); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day start = (Day) complement; + final Day startingDate = project.getStartingDate(); + if (startingDate == null) { + return CommandExecutionResult.error("No starting date for the project"); + } + task.setStart(start.asInstantDay(startingDate)); + return CommandExecutionResult.ok(); } - public Verb getVerb(GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final Url url = (Url) complement; - task.setUrl(url); - return CommandExecutionResult.ok(); - } - - }; - } } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbTaskStarts.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java similarity index 62% rename from src/net/sourceforge/plantuml/project/lang/VerbTaskStarts.java rename to src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java index 0418b49d4..e45434bf4 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbTaskStarts.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java @@ -35,41 +35,38 @@ */ package net.sourceforge.plantuml.project.lang; -import java.util.Arrays; -import java.util.Collection; - import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class VerbTaskStarts implements VerbPattern { +public class SentenceTaskStartsWithColor extends SentenceSimple { - public Collection getComplements() { - return Arrays. asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); + public SentenceTaskStartsWithColor() { + super(new SubjectTask(), Verbs.starts2(), + new PairOfSomething(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementWithColorLink())); } - public IRegex toRegex() { - return new RegexLeaf("starts"); - } + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final TaskInstant when; - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final TaskInstant when = (TaskInstant) complement; - task.setStart(when.getInstantPrecise()); - if (when.isTask()) { - project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.START))); - } - return CommandExecutionResult.ok(); - } + final Object[] pairs = (Object[]) complement; + when = (TaskInstant) pairs[0]; + final CenterBorderColor complement22 = (CenterBorderColor) pairs[1]; - }; - } + task.setStart(when.getInstantPrecise()); + if (when.isTask()) { + final HColor color = complement22.getCenter(); + final GanttConstraint link = new GanttConstraint(when, new TaskInstant(task, TaskAttribute.START), color); + link.applyStyle(complement22.getStyle()); + project.addContraint(link); + } + return CommandExecutionResult.ok(); + + }; } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementPattern.java b/src/net/sourceforge/plantuml/project/lang/Something.java similarity index 92% rename from src/net/sourceforge/plantuml/project/lang/ComplementPattern.java rename to src/net/sourceforge/plantuml/project/lang/Something.java index cf5b0057f..4b5a64a51 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementPattern.java +++ b/src/net/sourceforge/plantuml/project/lang/Something.java @@ -40,10 +40,10 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -public interface ComplementPattern { - - public Failable getComplement(GanttDiagram system, RegexResult arg, String suffix); +public interface Something { public IRegex toRegex(String suffix); + public Failable getMe(GanttDiagram project, RegexResult arg, String suffix); + } diff --git a/src/net/sourceforge/plantuml/project/lang/Subject.java b/src/net/sourceforge/plantuml/project/lang/Subject.java index fba6a654e..6196dd951 100644 --- a/src/net/sourceforge/plantuml/project/lang/Subject.java +++ b/src/net/sourceforge/plantuml/project/lang/Subject.java @@ -35,7 +35,19 @@ */ package net.sourceforge.plantuml.project.lang; +import java.util.Collection; + +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.GanttDiagram; public interface Subject { + public Collection getSentences(); + + public IRegex toRegex(); + + public Failable getMe(GanttDiagram project, RegexResult arg); + } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java b/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java index 083c2f07e..f8d043186 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java @@ -38,17 +38,67 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class SubjectDayAsDate implements SubjectPattern { +public class SubjectDayAsDate implements Subject { + + public Failable getMe(GanttDiagram project, RegexResult arg) { + final int day = Integer.parseInt(arg.get("DAY", 0)); + final int month = Integer.parseInt(arg.get("MONTH", 0)); + final int year = Integer.parseInt(arg.get("YEAR", 0)); + return Failable.ok(Day.create(year, month, day)); + } + + public Collection getSentences() { + return Arrays.asList(new Close(), new Open(), new InColor()); + } + + class Close extends SentenceSimple { + + public Close() { + super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementClose()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + project.closeDayAsDate((Day) subject); + return CommandExecutionResult.ok(); + } + } + + class Open extends SentenceSimple { + public Open() { + super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementOpen()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + project.openDayAsDate((Day) subject); + return CommandExecutionResult.ok(); + } + } + + class InColor extends SentenceSimple { + + public InColor() { + super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementInColors2()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final HColor color = ((CenterBorderColor) complement).getCenter(); + project.colorDay((Day) subject, color); + return CommandExecutionResult.ok(); + } - public Collection getVerbs() { - return Arrays. asList(new VerbIsOrAre()); } public IRegex toRegex() { @@ -60,11 +110,4 @@ public class SubjectDayAsDate implements SubjectPattern { new RegexLeaf("DAY", "([\\d]{1,2})")); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { - final int day = Integer.parseInt(arg.get("DAY", 0)); - final int month = Integer.parseInt(arg.get("MONTH", 0)); - final int year = Integer.parseInt(arg.get("YEAR", 0)); - return Day.create(year, month, day); - } - } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java index 5fe23c476..abaf5df36 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java @@ -38,25 +38,42 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.DayOfWeek; -public class SubjectDayOfWeek implements SubjectPattern { - - public Collection getVerbs() { - return Arrays. asList(new VerbAre()); - } +public class SubjectDayOfWeek implements Subject { public IRegex toRegex() { return new RegexLeaf("SUBJECT", "(" + DayOfWeek.getRegexString() + ")"); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { + public Failable getMe(GanttDiagram project, RegexResult arg) { final String s = arg.get("SUBJECT", 0); - return DayOfWeek.fromString(s); + return Failable.ok(DayOfWeek.fromString(s)); + } + + public Collection getSentences() { + return Arrays.asList(new AreClose()); + } + + class AreClose extends SentenceSimple { + + public AreClose() { + super(SubjectDayOfWeek.this, Verbs.are(), new ComplementClose()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final DayOfWeek day = (DayOfWeek) subject; + project.closeDayOfWeek(day); + return CommandExecutionResult.ok(); + } + } } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java b/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java index 6ea25f9a3..6fedb3ce8 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java @@ -38,20 +38,19 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.DaysAsDates; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class SubjectDaysAsDates implements SubjectPattern { - - public Collection getVerbs() { - return Arrays. asList(new VerbIsOrAre(), new VerbIsOrAreNamed()); - } +public class SubjectDaysAsDates implements Subject { public IRegex toRegex() { return new RegexOr(regexTo(), regexAnd(), regexThen()); @@ -104,22 +103,22 @@ public class SubjectDaysAsDates implements SubjectPattern { ); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { + public Failable getMe(GanttDiagram project, RegexResult arg) { final String countAnd = arg.get("COUNT_AND", 0); if (countAnd != null) { final Day date3 = getDate(arg, "3"); final int nb = Integer.parseInt(countAnd); - return new DaysAsDates(project, date3, nb); + return Failable.ok(new DaysAsDates(project, date3, nb)); } final String countThen = arg.get("COUNT_THEN", 0); if (countThen != null) { final Day date3 = project.getThenDate(); final int nb = Integer.parseInt(countThen); - return new DaysAsDates(project, date3, nb); + return Failable.ok(new DaysAsDates(project, date3, nb)); } final Day date1 = getDate(arg, "1"); final Day date2 = getDate(arg, "2"); - return new DaysAsDates(date1, date2); + return Failable.ok(new DaysAsDates(date1, date2)); } private Day getDate(RegexResult arg, String suffix) { @@ -129,4 +128,77 @@ public class SubjectDaysAsDates implements SubjectPattern { return Day.create(year, month, day); } + public Collection getSentences() { + return Arrays.asList(new Close(), new Open(), new InColor(), new Named()); + } + + class Close extends SentenceSimple { + + public Close() { + super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementClose()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + for (Day d : (DaysAsDates) subject) { + project.closeDayAsDate(d); + } + return CommandExecutionResult.ok(); + + } + } + + class Open extends SentenceSimple { + + public Open() { + super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementOpen()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + for (Day d : (DaysAsDates) subject) { + project.openDayAsDate(d); + } + return CommandExecutionResult.ok(); + + } + + } + + class InColor extends SentenceSimple { + + public InColor() { + super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementInColors2()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final HColor color = ((CenterBorderColor) complement).getCenter(); + for (Day d : (DaysAsDates) subject) { + project.colorDay(d, color); + } + return CommandExecutionResult.ok(); + + } + + } + + class Named extends SentenceSimple { + + public Named() { + super(SubjectDaysAsDates.this, Verbs.isOrAreNamed(), new ComplementNamed()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final String name = (String) complement; + final DaysAsDates days = (DaysAsDates) subject; + for (Day d : days) { + project.nameDay(d, name); + } + return CommandExecutionResult.ok(); + } + + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsColoredForToday.java b/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java similarity index 68% rename from src/net/sourceforge/plantuml/project/lang/VerbIsColoredForToday.java rename to src/net/sourceforge/plantuml/project/lang/SubjectLinks.java index db4ba86b4..008d81266 100644 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsColoredForToday.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java @@ -42,28 +42,36 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.Today; -public class VerbIsColoredForToday implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementInColors()); - } +public class SubjectLinks implements Subject { public IRegex toRegex() { - return new RegexLeaf("is[%s]+colou?red"); + return new RegexLeaf("SUBJECT", "links?"); } - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Today task = (Today) subject; - final ComplementColors colors = (ComplementColors) complement; - project.setTodayColors(colors); - return CommandExecutionResult.ok(); - } + public Failable getMe(GanttDiagram project, RegexResult arg) { + return Failable.ok(project); + } + + public Collection getSentences() { + return Arrays.asList(new InColor()); + } + + public class InColor extends SentenceSimple { + + public InColor() { + super(SubjectLinks.this, Verbs.areColored(), new ComplementInColors()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final CenterBorderColor colors = (CenterBorderColor) complement; + project.setLinksColor(colors.getCenter()); + return CommandExecutionResult.ok(); + + } - }; } } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java index 88d36c2e4..71af767aa 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java @@ -38,23 +38,42 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.time.Day; -public class SubjectProject implements SubjectPattern { - - public Collection getVerbs() { - return Arrays. asList(new VerbProjectStarts()); - } +public class SubjectProject implements Subject { public IRegex toRegex() { return new RegexLeaf("SUBJECT", "project"); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { - return project; + public Failable getMe(GanttDiagram project, RegexResult arg) { + return Failable.ok(project); + } + + public Collection getSentences() { + return Arrays.asList(new Starts()); + } + + class Starts extends SentenceSimple { + + public Starts() { + super(SubjectProject.this, Verbs.starts(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Day start = (Day) complement; + assert project == subject; + project.setStartingDate(start); + return CommandExecutionResult.ok(); + } + } } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java index 7723325c1..60ebd5246 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java @@ -38,16 +38,27 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexResult; +import net.sourceforge.plantuml.project.DaysAsDates; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Resource; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.DayOfWeek; -public class SubjectResource implements SubjectPattern { +public class SubjectResource implements Subject { - public Collection getVerbs() { - return Arrays. asList(new VerbIsOff(), new VerbIsOn()); + public Failable getMe(GanttDiagram project, RegexResult arg) { + final String s = arg.get("RESOURCE", 0); + return Failable.ok(project.getResource(s)); + } + + public Collection getSentences() { + return Arrays.asList(new IsOffDate(), new IsOffDates(), new IsOffDayOfWeek(), new IsOnDate(), new IsOnDates()); } public IRegex toRegex() { @@ -56,8 +67,85 @@ public class SubjectResource implements SubjectPattern { ); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { - final String s = arg.get("RESOURCE", 0); - return project.getResource(s); + public class IsOffDate extends SentenceSimple { + + public IsOffDate() { + super(SubjectResource.this, Verbs.isOff(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Resource resource = (Resource) subject; + final Day when = (Day) complement; + resource.addCloseDay(project.convert(when)); + return CommandExecutionResult.ok(); + } + } + + public class IsOffDates extends SentenceSimple { + + public IsOffDates() { + super(SubjectResource.this, Verbs.isOff(), new ComplementDates()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Resource resource = (Resource) subject; + for (Day when : (DaysAsDates) complement) { + resource.addCloseDay(project.convert(when)); + } + return CommandExecutionResult.ok(); + } + + } + + public class IsOffDayOfWeek extends SentenceSimple { + + public IsOffDayOfWeek() { + super(SubjectResource.this, Verbs.isOff(), new ComplementDayOfWeek()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Resource resource = (Resource) subject; + resource.addCloseDay(((DayOfWeek) complement)); + return CommandExecutionResult.ok(); + } + + } + + public class IsOnDate extends SentenceSimple { + + public IsOnDate() { + super(SubjectResource.this, Verbs.isOn(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Resource resource = (Resource) subject; + final Day when = (Day) complement; + resource.addForceOnDay(project.convert(when)); + return CommandExecutionResult.ok(); + } + + } + + public class IsOnDates extends SentenceSimple { + + public IsOnDates() { + super(SubjectResource.this, Verbs.isOn(), new ComplementDates()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Resource resource = (Resource) subject; + for (Day when : (DaysAsDates) complement) { + resource.addForceOnDay(project.convert(when)); + } + return CommandExecutionResult.ok(); + } + + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java index cf664e4ab..9883384ce 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java @@ -44,32 +44,13 @@ 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.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SubjectTask implements SubjectPattern { +public class SubjectTask implements Subject { - public Collection getVerbs() { - return Arrays.asList(new VerbLasts(), new VerbTaskStarts(), new VerbTaskStartsAbsolute(), - new VerbHappens(), new VerbEnds(), new VerbTaskEndsAbsolute(), new VerbIsColored(), new VerbIsDeleted(), - new VerbIsForTask(), new VerbLinksTo()); - } - - public IRegex toRegex() { - return new RegexConcat( // - new RegexLeaf("THEN", "(then[%s]+)?"), // - new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\](?:[%s]+as[%s]+\\[([^\\[\\]]+?)\\])?"), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("on"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("RESOURCE", "((?:\\{[^{}]+\\}[%s]*)+)") // - )) // - ); - } - - public Subject getSubject(GanttDiagram project, RegexResult arg) { + public Failable getMe(GanttDiagram project, RegexResult arg) { final String s = arg.get("SUBJECT", 0); final String shortName = arg.get("SUBJECT", 1); final String then = arg.get("THEN", 0); @@ -87,6 +68,29 @@ public class SubjectTask implements SubjectPattern { } } - return result; + return Failable.ok(result); } + + public Collection getSentences() { + return Arrays.asList(new SentenceLasts(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(), + new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(), + new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsDeleted(), + new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), new SentenceDisplayOnSameRowAs(), + new SentencePausesDate(), new SentencePausesDayOfWeek()); + } + + public IRegex toRegex() { + return new RegexConcat( // + new RegexLeaf("THEN", "(then[%s]+)?"), // + new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\](?:[%s]+as[%s]+\\[([^\\[\\]]+?)\\])?"), // + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("on"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("RESOURCE", "((?:\\{[^{}]+\\}[%s]*)+)") // + )) // + ); + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectToday.java b/src/net/sourceforge/plantuml/project/lang/SubjectToday.java index 1e58b7d78..60ca9fffa 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectToday.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectToday.java @@ -38,18 +38,17 @@ package net.sourceforge.plantuml.project.lang; import java.util.Arrays; import java.util.Collection; +import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexResult; +import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.Today; +import net.sourceforge.plantuml.project.time.Day; -public class SubjectToday implements SubjectPattern { - - public Collection getVerbs() { - return Arrays. asList(new VerbIsColoredForToday(), new VerbIsForToday()); - } +public class SubjectToday implements Subject { public IRegex toRegex() { return new RegexConcat( // @@ -57,7 +56,43 @@ public class SubjectToday implements SubjectPattern { ); } - public Subject getSubject(GanttDiagram project, RegexResult arg) { - return new Today(); + public Failable getMe(GanttDiagram project, RegexResult arg) { + return Failable.ok(new Today()); } + + public Collection getSentences() { + return Arrays.asList(new InColor(), new IsDate()); + } + + class InColor extends SentenceSimple { + + public InColor() { + super(SubjectToday.this, Verbs.isColored(), new ComplementInColors()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Today task = (Today) subject; + final CenterBorderColor colors = (CenterBorderColor) complement; + project.setTodayColors(colors); + return CommandExecutionResult.ok(); + + } + + } + + class IsDate extends SentenceSimple { + + public IsDate() { + super(SubjectToday.this, Verbs.is(), new ComplementDate()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Day date = (Day) complement; + return project.setToday(date); + } + + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementName.java b/src/net/sourceforge/plantuml/project/lang/TwoNames.java similarity index 82% rename from src/net/sourceforge/plantuml/project/lang/ComplementName.java rename to src/net/sourceforge/plantuml/project/lang/TwoNames.java index 75cf8997d..e53b667a0 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementName.java +++ b/src/net/sourceforge/plantuml/project/lang/TwoNames.java @@ -35,16 +35,22 @@ */ package net.sourceforge.plantuml.project.lang; -public class ComplementName implements Complement { +public class TwoNames { - private final String name; + private final String name1; + private final String name2; - public ComplementName(String name) { - this.name = name; + public TwoNames(String name1, String name2) { + this.name1 = name1; + this.name2 = name2; } - public final String getName() { - return name; + public final String getName1() { + return name1; + } + + public final String getName2() { + return name2; } } diff --git a/src/net/sourceforge/plantuml/project/lang/Verb.java b/src/net/sourceforge/plantuml/project/lang/Verb.java index dc46160a2..5f3bb7daf 100644 --- a/src/net/sourceforge/plantuml/project/lang/Verb.java +++ b/src/net/sourceforge/plantuml/project/lang/Verb.java @@ -35,10 +35,10 @@ */ package net.sourceforge.plantuml.project.lang; -import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.regex.IRegex; public interface Verb { - public CommandExecutionResult execute(Subject subject, Complement complement); + public IRegex toRegex(); } diff --git a/src/net/sourceforge/plantuml/project/lang/VerbHappens.java b/src/net/sourceforge/plantuml/project/lang/VerbHappens.java deleted file mode 100644 index 68d15dd8f..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbHappens.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.Load; -import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.core.TaskInstant; -import net.sourceforge.plantuml.project.time.Day; - -public class VerbHappens implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementDate()); - } - - public IRegex toRegex() { - return new RegexLeaf("happens[%s]*(at[%s]*|the[%s]*|on[%s]*)*"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - task.setLoad(Load.inWinks(1)); - if (complement instanceof Day) { - final Day start = (Day) complement; - final Day startingDate = project.getStartingDate(); - if (startingDate == null) { - return CommandExecutionResult.error("No starting date for the project"); - } - task.setStart(start.asInstantDay(startingDate)); - task.setDiamond(true); - } else { - final TaskInstant when = (TaskInstant) complement; - task.setStart(when.getInstantTheorical()); - task.setDiamond(true); - } - return CommandExecutionResult.ok(); - } - - }; - } - -} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsOrAre.java b/src/net/sourceforge/plantuml/project/lang/VerbIsOrAre.java deleted file mode 100644 index efb6f22d1..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsOrAre.java +++ /dev/null @@ -1,121 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.DaysAsDates; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.ugraphic.color.HColor; - -public class VerbIsOrAre implements VerbPattern { - - public Collection getComplements() { - return Arrays - . asList(new ComplementClose(), new ComplementOpen(), new ComplementInColors2()); - } - - public IRegex toRegex() { - return new RegexLeaf("(is|are)"); - } - - public Verb getVerb(final GanttDiagram project, final RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - if (complement instanceof ComplementColors) { - final HColor color = ((ComplementColors) complement).getCenter(); - return manageColor(project, subject, color); - } - if (complement == ComplementClose.CLOSE) { - return manageClose(project, subject); - } - if (complement == ComplementOpen.OPEN) { - return manageOpen(project, subject); - } - return CommandExecutionResult.error("assertion fail"); - } - }; - } - - private CommandExecutionResult manageColor(final GanttDiagram project, Subject subject, HColor color) { - if (subject instanceof Day) { - final Day day = (Day) subject; - project.colorDay(day, color); - } - if (subject instanceof DaysAsDates) { - final DaysAsDates days = (DaysAsDates) subject; - for (Day d : days) { - project.colorDay(d, color); - } - } - return CommandExecutionResult.ok(); - } - - private CommandExecutionResult manageClose(final GanttDiagram project, Subject subject) { - if (subject instanceof Day) { - final Day day = (Day) subject; - project.closeDayAsDate(day); - } - if (subject instanceof DaysAsDates) { - final DaysAsDates days = (DaysAsDates) subject; - for (Day d : days) { - project.closeDayAsDate(d); - } - } - return CommandExecutionResult.ok(); - } - - private CommandExecutionResult manageOpen(final GanttDiagram project, Subject subject) { - if (subject instanceof Day) { - final Day day = (Day) subject; - project.openDayAsDate(day); - } - if (subject instanceof DaysAsDates) { - final DaysAsDates days = (DaysAsDates) subject; - for (Day d : days) { - project.openDayAsDate(d); - } - } - return CommandExecutionResult.ok(); - } - -} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbIsOrAreNamed.java b/src/net/sourceforge/plantuml/project/lang/VerbIsOrAreNamed.java deleted file mode 100644 index 45ddfc761..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbIsOrAreNamed.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.DaysAsDates; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.time.Day; - -public class VerbIsOrAreNamed implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementNamed()); - } - - public IRegex toRegex() { - return new RegexLeaf("(is|are)[%s]+named"); - } - - public Verb getVerb(final GanttDiagram project, final RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final ComplementName named = (ComplementName) complement; - final String name = named.getName(); - final DaysAsDates days = (DaysAsDates) subject; - for (Day d : days) { - project.nameDay(d, name); - } - return CommandExecutionResult.ok(); - } - }; - } - -} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbProjectStarts.java b/src/net/sourceforge/plantuml/project/lang/VerbProjectStarts.java deleted file mode 100644 index bae17615c..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbProjectStarts.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -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.RegexResult; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.time.Day; - -public class VerbProjectStarts implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementDate()); - } - - public IRegex toRegexOld() { - return new RegexLeaf("starts[%s]*(the[%s]*|on[%s]*)*"); - } - - public IRegex toRegex() { - return new RegexConcat(new RegexLeaf("start"), // - new RegexOptional(new RegexLeaf("s")), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional(new RegexOr(// - new RegexLeaf("on"),// - new RegexLeaf("for"),// - new RegexLeaf("the"),// - new RegexLeaf("at") // - )) // - ); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Day start = (Day) complement; - assert project == subject; - project.setStartingDate(start); - return CommandExecutionResult.ok(); - } - - }; - } -} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbTaskEndsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/VerbTaskEndsAbsolute.java deleted file mode 100644 index 11d3276dd..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbTaskEndsAbsolute.java +++ /dev/null @@ -1,74 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.time.Day; - -public class VerbTaskEndsAbsolute implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementDate()); - } - - public IRegex toRegex() { - return new RegexLeaf("ends[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final Day end = (Day) complement; - final Day startingDate = project.getStartingDate(); - if (startingDate == null) { - return CommandExecutionResult.error("No starting date for the project"); - } - task.setEnd(end.asInstantDay(startingDate)); - return CommandExecutionResult.ok(); - } - - }; - } -} diff --git a/src/net/sourceforge/plantuml/project/lang/VerbTaskStartsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/VerbTaskStartsAbsolute.java deleted file mode 100644 index f021a74e4..000000000 --- a/src/net/sourceforge/plantuml/project/lang/VerbTaskStartsAbsolute.java +++ /dev/null @@ -1,74 +0,0 @@ -/* ======================================================================== - * 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.lang; - -import java.util.Arrays; -import java.util.Collection; - -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.time.Day; - -public class VerbTaskStartsAbsolute implements VerbPattern { - - public Collection getComplements() { - return Arrays. asList(new ComplementDate()); - } - - public IRegex toRegex() { - return new RegexLeaf("starts[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); - } - - public Verb getVerb(final GanttDiagram project, RegexResult arg) { - return new Verb() { - public CommandExecutionResult execute(Subject subject, Complement complement) { - final Task task = (Task) subject; - final Day start = (Day) complement; - final Day startingDate = project.getStartingDate(); - if (startingDate == null) { - return CommandExecutionResult.error("No starting date for the project"); - } - task.setStart(start.asInstantDay(startingDate)); - return CommandExecutionResult.ok(); - } - - }; - } -} diff --git a/src/net/sourceforge/plantuml/project/lang/Verbs.java b/src/net/sourceforge/plantuml/project/lang/Verbs.java new file mode 100644 index 000000000..b19f52cb1 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/Verbs.java @@ -0,0 +1,154 @@ +/* ======================================================================== + * 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.lang; + +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; + +public class Verbs { + + public static IRegex are() { + return new RegexLeaf("are"); + } + + public static IRegex areColored() { + return new RegexLeaf("are[%s]+colou?red"); + } + + public static IRegex displayOnSameRowAs() { + return new RegexLeaf("displays?[%s]+on[%s]+same[%s]+row[%s]+as"); + } + + public static IRegex ends() { + return new RegexLeaf("ends"); + } + + public static IRegex ends2() { + return new RegexLeaf("ends[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); + } + + public static IRegex happens() { + return new RegexLeaf("happens?[%s]*(at[%s]*|the[%s]*|on[%s]*)*"); + } + + public static IRegex pauses() { + return new RegexLeaf("pauses?[%s]*(at[%s]*|the[%s]*|on[%s]*)*"); + } + + public static IRegex isDeleted() { + return new RegexLeaf("is[%s]+deleted"); + } + + public static IRegex is() { + return new RegexLeaf("is"); + } + + public static IRegex isColored() { + return new RegexLeaf("is[%s]+colou?red"); + } + + public static IRegex isOff() { + return new RegexConcat(new RegexLeaf("is"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("off"), // + RegexLeaf.spaceOneOrMore(), // + new RegexOr(// + new RegexLeaf("on"), // + new RegexLeaf("for"), // + new RegexLeaf("the"), // + new RegexLeaf("at") // + )); + } + + public static IRegex isOn() { + return new RegexConcat(new RegexLeaf("is"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("on"), // + RegexLeaf.spaceOneOrMore(), // + new RegexOr(// + new RegexLeaf("on"), // + new RegexLeaf("for"), // + new RegexLeaf("the"), // + new RegexLeaf("at") // + ) // + ); + } + + public static IRegex isOrAre() { + return new RegexLeaf("(is|are)"); + } + + public static IRegex isOrAreNamed() { + return new RegexLeaf("(is|are)[%s]+named"); + } + + public static IRegex lasts() { + return new RegexLeaf("lasts"); + } + + public static IRegex linksTo() { + return new RegexLeaf("links to"); + } + + public static IRegex occurs() { + return new RegexLeaf("occurs?"); + } + + public static IRegex starts3() { + return new RegexLeaf("starts[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); + } + + public static IRegex starts2() { + return new RegexLeaf("starts"); + } + + public static IRegex starts() { + return new RegexConcat(new RegexLeaf("start"), // + new RegexOptional(new RegexLeaf("s")), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexOr(// + new RegexLeaf("on"), // + new RegexLeaf("for"), // + new RegexLeaf("the"), // + new RegexLeaf("at") // + )) // + ); + } + +} diff --git a/src/net/sourceforge/plantuml/project/time/Day.java b/src/net/sourceforge/plantuml/project/time/Day.java index 2074e9401..8496e58e8 100644 --- a/src/net/sourceforge/plantuml/project/time/Day.java +++ b/src/net/sourceforge/plantuml/project/time/Day.java @@ -37,10 +37,7 @@ package net.sourceforge.plantuml.project.time; import java.util.Date; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.Subject; - -public class Day implements Complement, Comparable, Subject { +public class Day implements Comparable { private final int dayOfMonth; private final MonthYear monthYear; diff --git a/src/net/sourceforge/plantuml/project/time/DayOfWeek.java b/src/net/sourceforge/plantuml/project/time/DayOfWeek.java index db268f486..26c3818cf 100644 --- a/src/net/sourceforge/plantuml/project/time/DayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/time/DayOfWeek.java @@ -36,10 +36,8 @@ package net.sourceforge.plantuml.project.time; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.project.lang.Complement; -import net.sourceforge.plantuml.project.lang.Subject; -public enum DayOfWeek implements Subject, Complement { +public enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY; diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScale.java b/src/net/sourceforge/plantuml/project/timescale/TimeScale.java index c8ce1e654..4f519b7b8 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScale.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScale.java @@ -45,4 +45,6 @@ public interface TimeScale { public double getWidth(Wink instant); + public boolean isBreaking(Wink instant); + } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java index ba3c335e2..24888ee8e 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.project.timescale; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.Wink; @@ -42,10 +44,12 @@ public class TimeScaleCompressed implements TimeScale { private final int compress; private final TimeScale daily; + private final GCalendar calendar; public TimeScaleCompressed(GCalendar calendar, int compress) { this.daily = new TimeScaleDaily(calendar, null); this.compress = compress; + this.calendar = calendar; } public double getStartingPosition(Wink instant) { @@ -60,4 +64,9 @@ public class TimeScaleCompressed implements TimeScale { return daily.getWidth(instant) / compress; } + public boolean isBreaking(Wink instant) { + final Day day = calendar.toDayAsDate(instant); + return day.getDayOfWeek() == DayOfWeek.SUNDAY; + } + } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java index 30e029702..ade9a8461 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java @@ -66,4 +66,8 @@ public final class TimeScaleDaily implements TimeScale { return basic.getWidth(instant); } + public boolean isBreaking(Wink instant) { + return true; + } + } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java index 1d0280293..ce0af8d66 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java @@ -54,4 +54,8 @@ public class TimeScaleWink implements TimeScale { return scale; } + public boolean isBreaking(Wink instant) { + return true; + } + } diff --git a/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java b/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java index 0d0cd6203..c5d53d7e9 100644 --- a/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java +++ b/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java @@ -75,4 +75,8 @@ public class UnusedTimeScaleWithoutWeekEnd implements TimeScale { throw new UnsupportedOperationException(); } + public boolean isBreaking(Wink instant) { + throw new UnsupportedOperationException(); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java index 5466f1e94..e3d98577d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java @@ -88,7 +88,7 @@ public class CommandArrow extends SingleLineCommand2 { new RegexLeaf("PART1ANCHOR", ANCHOR), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("ARROW_DRESSING1", - "([%s][ox]|(?:[%s][ox])?< { new RegexLeaf("ARROW_STYLE2", getColorOrStylePattern()), // new RegexLeaf("ARROW_BODYB2", "(-+)"))), // new RegexLeaf("ARROW_DRESSING2", - "(>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), // + "(_?>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), // RegexLeaf.spaceZeroOrMore(), // new RegexOr("PART2", // new RegexLeaf("PART2CODE", "([\\p{L}0-9_.@]+)"), // @@ -146,14 +146,21 @@ public class CommandArrow extends SingleLineCommand2 { return false; } + private String getDressing(RegexResult arg, String key) { + String value = arg.get(key, 0); + value = CommandLinkClass.notNull(value); + value = value.replace("_", ""); + return StringUtils.goLowerCase(value); + } + @Override protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { Participant p1; Participant p2; - final String dressing1 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING1", 0))); - final String dressing2 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING2", 0))); + final String dressing1 = getDressing(arg, "ARROW_DRESSING1"); + final String dressing2 = getDressing(arg, "ARROW_DRESSING2"); final boolean circleAtStart; final boolean circleAtEnd; diff --git a/src/net/sourceforge/plantuml/style/CommandStyleImport.java b/src/net/sourceforge/plantuml/style/CommandStyleImport.java index bd00f167f..2f645f05b 100644 --- a/src/net/sourceforge/plantuml/style/CommandStyleImport.java +++ b/src/net/sourceforge/plantuml/style/CommandStyleImport.java @@ -40,7 +40,7 @@ import java.io.InputStream; import net.sourceforge.plantuml.FileSystem; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.security.SFile; -public class CommandStyleImport extends SingleLineCommand2 { +public class CommandStyleImport extends SingleLineCommand2 { public CommandStyleImport() { super(getRegexConcat()); @@ -72,7 +72,7 @@ public class CommandStyleImport extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(TitledDiagram diagram, LineLocation location, RegexResult arg) { final String path = arg.get("PATH", 0); try { final SFile f = FileSystem.getInstance().getFile(path); diff --git a/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java index f7c5ccb8b..89d070296 100644 --- a/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java +++ b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.style; import net.sourceforge.plantuml.SkinParam; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; -public class CommandStyleMultilinesCSS extends CommandMultilines2 { +public class CommandStyleMultilinesCSS extends CommandMultilines2 { public CommandStyleMultilinesCSS() { super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); @@ -60,10 +60,10 @@ public class CommandStyleMultilinesCSS extends CommandMultilines2 { return RegexConcat.build(CommandStyleMultilinesCSS.class.getName(), RegexLeaf.start(), // new RegexLeaf("\\"), // RegexLeaf.end() // - ); + ); } - protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(TitledDiagram diagram, BlocLines lines) { SkinParam.setBetaStyle(true); if (SkinParam.USE_STYLES() == false) { return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index e83370178..ba58f4afc 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -70,6 +70,7 @@ public enum SName { folder, // footer, // frame, // + ganttDiagram, // group, // groupHeader, // header, // @@ -77,6 +78,7 @@ public enum SName { leafNode, // legend, // lifeLine, // + milestone, // mindmapDiagram, // node, // note, // @@ -97,6 +99,7 @@ public enum SName { stereotype, // storage, // swimlane, // + task, // title, // usecase, // wbsDiagram; // diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index a81362285..5cbd155bf 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -678,7 +678,7 @@ public class Line implements Moveable, Hideable, GuideLine { final String comment = link.idCommentForSvg(); final String tmp = uniq(ids, comment); - todraw.setComment(tmp); + todraw.setCommentAndCodeLine(tmp, link.getCodeLine()); drawRainbow(ug.apply(new UTranslate(x, y)), color, todraw, link.getSupplementaryColors(), stroke); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java index 1c0f3bb5c..78e08e97a 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java @@ -154,7 +154,7 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi final double widthTotal = dimTotal.getWidth(); final double heightTotal = dimTotal.getHeight(); final Shadowable rect = new URectangle(widthTotal, heightTotal).rounded(roundCorner) - .withComment(getEntity().getCodeGetName()); + .withCommentAndCodeLine(getEntity().getCodeGetName(), getEntity().getCodeLine()); if (getSkinParam().shadowing(getEntity().getStereotype())) { rect.setDeltaShadow(4); } diff --git a/src/net/sourceforge/plantuml/svg/SvgGraphics.java b/src/net/sourceforge/plantuml/svg/SvgGraphics.java index e309a4827..84b53cee6 100644 --- a/src/net/sourceforge/plantuml/svg/SvgGraphics.java +++ b/src/net/sourceforge/plantuml/svg/SvgGraphics.java @@ -176,8 +176,7 @@ public class SvgGraphics { private Element pendingBackground; public void paintBackcolorGradient(ColorMapper mapper, HColorGradient gr) { - final String id = createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), - gr.getPolicy()); + final String id = createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), gr.getPolicy()); setFillColor("url(#" + id + ")"); setStrokeColor(null); pendingBackground = createRectangleInternal(0, 0, 0, 0); @@ -320,7 +319,7 @@ public class SvgGraphics { } public void svgRectangle(double x, double y, double width, double height, double rx, double ry, double deltaShadow, - String id) { + String id, String codeLine) { if (height <= 0 || width <= 0) { return; // To be restored when Teoz will be finished @@ -337,6 +336,9 @@ public class SvgGraphics { if (id != null) { elt.setAttribute("id", id); } + if (codeLine != null) { + elt.setAttribute("codeLine", codeLine); + } getG().appendChild(elt); } ensureVisible(x + width + 2 * deltaShadow, y + height + 2 * deltaShadow); @@ -622,6 +624,10 @@ public class SvgGraphics { if (id != null) { elt.setAttribute("id", id); } + final String codeLine = path.getCodeLine(); + if (codeLine != null) { + elt.setAttribute("codeLine", codeLine); + } addFilterShadowId(elt, deltaShadow); getG().appendChild(elt); } @@ -801,9 +807,9 @@ public class SvgGraphics { return; } -// if (pendingAction.size() > 0) { -// closeLink(); -// } + if (pendingAction.size() > 0) { + closeLink(); + } pendingAction.add(0, (Element) document.createElement("a")); pendingAction.get(0).setAttribute("target", target); diff --git a/src/net/sourceforge/plantuml/ugraphic/UPath.java b/src/net/sourceforge/plantuml/ugraphic/UPath.java index 79a8d5ad2..13e02bcf4 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UPath.java +++ b/src/net/sourceforge/plantuml/ugraphic/UPath.java @@ -30,6 +30,7 @@ * * * Original Author: Arnaud Roques + * Contribution: Miguel Esteves * * */ @@ -45,6 +46,7 @@ import net.sourceforge.plantuml.ugraphic.comp.CompressionMode; public class UPath extends AbstractShadowable implements Iterable, UShapeIgnorableForCompression { private final String comment; + private final String codeLine; private final List segments = new ArrayList(); private MinMax minmax = MinMax.getEmpty(false); @@ -52,12 +54,13 @@ public class UPath extends AbstractShadowable implements Iterable, USh private boolean ignoreForCompressionOnX; private boolean ignoreForCompressionOnY; - public UPath(String comment) { + public UPath(String comment, String codeLine) { this.comment = comment; + this.codeLine = codeLine; } public UPath() { - this(null); + this(null, null); } public void add(double[] coord, USegmentType pathType) { @@ -83,7 +86,7 @@ public class UPath extends AbstractShadowable implements Iterable, USh } public UPath translate(double dx, double dy) { - final UPath result = new UPath(comment); + final UPath result = new UPath(comment, codeLine); for (USegment seg : segments) { result.addInternal(seg.translate(dx, dy)); } @@ -91,7 +94,7 @@ public class UPath extends AbstractShadowable implements Iterable, USh } public UPath rotate(double theta) { - final UPath result = new UPath(comment); + final UPath result = new UPath(comment, codeLine); for (USegment seg : segments) { result.addInternal(seg.rotate(theta)); } @@ -183,6 +186,10 @@ public class UPath extends AbstractShadowable implements Iterable, USh return comment; } + public final String getCodeLine() { + return codeLine; + } + public void setIgnoreForCompressionOnX() { this.ignoreForCompressionOnX = true; } diff --git a/src/net/sourceforge/plantuml/ugraphic/URectangle.java b/src/net/sourceforge/plantuml/ugraphic/URectangle.java index aaab07f1b..b21462847 100644 --- a/src/net/sourceforge/plantuml/ugraphic/URectangle.java +++ b/src/net/sourceforge/plantuml/ugraphic/URectangle.java @@ -30,6 +30,7 @@ * * * Original Author: Arnaud Roques + * Contribution: Miguel Esteves * */ package net.sourceforge.plantuml.ugraphic; @@ -45,29 +46,32 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi private final double rx; private final double ry; private final String comment; + private final String codeLine; private final boolean ignoreForCompressionOnX; private final boolean ignoreForCompressionOnY; public URectangle withHeight(double newHeight) { final URectangle result = new URectangle(width, newHeight, rx, ry, comment, ignoreForCompressionOnX, - ignoreForCompressionOnY); + ignoreForCompressionOnY, codeLine); result.setDeltaShadow(this.getDeltaShadow()); return result; } public URectangle withWidth(double newWidth) { final URectangle result = new URectangle(newWidth, height, rx, ry, comment, ignoreForCompressionOnX, - ignoreForCompressionOnY); + ignoreForCompressionOnY, codeLine); result.setDeltaShadow(this.getDeltaShadow()); return result; } - public URectangle withComment(String comment) { - return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, ignoreForCompressionOnY); + public URectangle withCommentAndCodeLine(String comment, String codeLine) { + return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, ignoreForCompressionOnY, + codeLine); } public URectangle rounded(double round) { - return new URectangle(width, height, round, round, comment, ignoreForCompressionOnX, ignoreForCompressionOnY); + return new URectangle(width, height, round, round, comment, ignoreForCompressionOnX, ignoreForCompressionOnY, + codeLine); } public Shadowable diagonalCorner(double diagonalCorner) { @@ -91,11 +95,11 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi } public final URectangle ignoreForCompressionOnX() { - return new URectangle(width, height, rx, ry, comment, true, ignoreForCompressionOnY); + return new URectangle(width, height, rx, ry, comment, true, ignoreForCompressionOnY, codeLine); } public final URectangle ignoreForCompressionOnY() { - return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, true); + return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, true, codeLine); } public UShape getScaled(double scale) { @@ -103,13 +107,13 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi return this; } final AbstractShadowable result = new URectangle(width * scale, height * scale, rx * scale, ry * scale, comment, - ignoreForCompressionOnX, ignoreForCompressionOnY); + ignoreForCompressionOnX, ignoreForCompressionOnY, codeLine); result.setDeltaShadow(this.getDeltaShadow()); return result; } public URectangle(double width, double height) { - this(width, height, 0, 0, null, false, false); + this(width, height, 0, 0, null, false, false, null); } public URectangle(Dimension2D dim) { @@ -117,7 +121,7 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi } private URectangle(double width, double height, double rx, double ry, String comment, - boolean ignoreForCompressionOnX, boolean ignoreForCompressionOnY) { + boolean ignoreForCompressionOnX, boolean ignoreForCompressionOnY, String codeLine) { if (height == 0) { throw new IllegalArgumentException("height=" + height); } @@ -127,6 +131,7 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi this.ignoreForCompressionOnX = ignoreForCompressionOnX; this.ignoreForCompressionOnY = ignoreForCompressionOnY; this.comment = comment; + this.codeLine = codeLine; this.width = width; this.height = height; this.rx = rx; @@ -166,6 +171,10 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi return comment; } + public String getCodeLine() { + return codeLine; + } + public void drawWhenCompressed(UGraphic ug, CompressionMode mode) { if (mode == CompressionMode.ON_X) { ug.draw(new UEmpty(2, getHeight())); diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java index b4e5f9b95..d8219e1e3 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java @@ -66,8 +66,8 @@ public class DriverRectangleSvg implements UDriver { final HColor back = param.getBackcolor(); if (back instanceof HColorGradient) { final HColorGradient gr = (HColorGradient) back; - final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), - mapper.toRGB(gr.getColor2()), gr.getPolicy()); + final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), + gr.getPolicy()); svg.setFillColor("url(#" + id + ")"); applyColor(svg, mapper, param); } else { @@ -89,15 +89,16 @@ public class DriverRectangleSvg implements UDriver { return; } } - svg.svgRectangle(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow(), rect.getComment()); + svg.svgRectangle(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow(), rect.getComment(), + rect.getCodeLine()); } public static void applyColor(SvgGraphics svg, ColorMapper mapper, UParam param) { final HColor color = param.getColor(); if (color instanceof HColorGradient) { final HColorGradient gr = (HColorGradient) color; - final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), - mapper.toRGB(gr.getColor2()), gr.getPolicy()); + final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), + gr.getPolicy()); svg.setStrokeColor("url(#" + id + ")"); } else { svg.setStrokeColor(mapper.toSvg(color)); diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java index 17fee68bb..89e59fe05 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java @@ -106,12 +106,12 @@ public class DriverTextSvg implements UDriver { final HColor back = fontConfiguration.getExtendedColor(); if (back instanceof HColorGradient) { final HColorGradient gr = (HColorGradient) back; - final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), - mapper.toRGB(gr.getColor2()), gr.getPolicy()); + final String id = svg.createSvgGradient(mapper.toRGB(gr.getColor1()), mapper.toRGB(gr.getColor2()), + gr.getPolicy()); svg.setFillColor("url(#" + id + ")"); svg.setStrokeColor(null); final double deltaPatch = 2; - svg.svgRectangle(x, y - height + deltaPatch, width, height, 0, 0, 0, null); + svg.svgRectangle(x, y - height + deltaPatch, width, height, 0, 0, 0, null, null); } else { backColor = mapper.toRGB(back); diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index a3c7612ec..ab221217f 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202015; + return 1202016; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1593344385646L; + return 1598214043932L; } public static String compileTimeString() {