1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-24 13:57:33 +00:00

Import version 1.2020.16

This commit is contained in:
Arnaud Roques 2020-08-25 19:24:17 +02:00
parent 345a1eeb7c
commit 55d1d81055
146 changed files with 2932 additions and 1842 deletions

View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2020.15-SNAPSHOT</version>
<version>1.2020.16-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
@ -136,7 +136,7 @@
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>false</debug>
<debug>true</debug>
</configuration>
</plugin>
<plugin>

View File

@ -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
}
}

View File

@ -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();

View File

@ -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) {

View File

@ -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<GeneratedImage> list, ErrorStatus error) throws IOException {
private static void hasErrors(File file, final List<GeneratedImage> 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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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");
}
}
}

View File

@ -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;
}
}

View File

@ -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,6 +59,81 @@ 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()) {
@ -97,10 +179,4 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
return mainFrame;
}
}

View File

@ -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) {
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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<PositionedNote> backwardNotes = new ArrayList<PositionedNote>();
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,8 +165,13 @@ public class InstructionRepeat implements Instruction {
}
public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane 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<Swimlane> getSwimlanes() {
return repeatList.getSwimlanes();

View File

@ -77,8 +77,7 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
}
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<ClassDiagram> {
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<ClassDiagram> {
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<ClassDiagram> {
}
}
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<ClassDiagram> {
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<ClassDiagram> {
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<ClassDiagram> {
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<ClassDiagram> {
// }
// 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);
// }

View File

@ -150,6 +150,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
return CommandExecutionResult.error("No such entity");
}
if (lines.size() > 1) {
entity.setCodeLine(lines.getAt(0).getLocation());
lines = lines.subExtract(1, 1);
// final Url url = null;
// if (lines.size() > 0) {

View File

@ -89,7 +89,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1",
"([%s]+[ox]|[)#\\[<*+^}]|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
"([%s]+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
@ -97,7 +97,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2",
"([ox][%s]+|:\\>\\>?|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|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<AbstractClassOrOb
link.setLinkArrow(labels.getLinkArrow());
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
link.setCodeLine(location);
addLink(diagram, link, arg.get("HEADER", 0));
@ -616,8 +617,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
}
private LinkType getLinkType(RegexResult arg) {
final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
LinkType result = new LinkType(decors2, decors1);
if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains(".")) {
@ -643,8 +644,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
}
private Direction getDirection(RegexResult arg) {
final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
String s = getFullArrow(arg);
s = s.replaceAll("[^-.=\\w]", "");
@ -663,10 +664,21 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return result;
}
private String getArrowHead1(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD1");
}
private String getArrowHead2(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD2");
}
private String getArrowHead(RegexResult arg, final String key) {
return notNull(arg.get(key, 0));
}
private String getFullArrow(RegexResult arg) {
return notNull(arg.get("ARROW_HEAD1", 0)) + notNull(arg.get("ARROW_BODY1", 0))
+ notNull(arg.get("ARROW_DIRECTION", 0)) + notNull(arg.get("ARROW_BODY2", 0))
+ notNull(arg.get("ARROW_HEAD2", 0));
return getArrowHead1(arg) + notNull(arg.get("ARROW_BODY1", 0)) + notNull(arg.get("ARROW_DIRECTION", 0))
+ notNull(arg.get("ARROW_BODY2", 0)) + getArrowHead2(arg);
}
public static String notNull(String s) {

View File

@ -44,6 +44,7 @@ import java.util.Set;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -295,4 +296,12 @@ public class GroupRoot implements IGroup {
public void setThisIsTogether() {
throw new UnsupportedOperationException();
}
public String getCodeLine() {
throw new UnsupportedOperationException();
}
public void setCodeLine(LineLocation codeLine) {
throw new UnsupportedOperationException();
}
}

View File

@ -30,7 +30,7 @@
*
*
* Original Author: Arnaud Roques
*
* Contribution: Miguel Esteves
*
*/
package net.sourceforge.plantuml.cucadiagram;
@ -40,6 +40,7 @@ import java.util.Set;
import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.LineConfigurable;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.Removeable;
import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.Url;
@ -99,5 +100,8 @@ public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, Li
public void setThisIsTogether();
public String getCodeLine();
public void setCodeLine(LineLocation codeLine);
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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<Stereotag> tags = new LinkedHashSet<Stereotag>();
@ -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;
}
}

View File

@ -80,14 +80,14 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
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<DescriptionDiagram> {
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;

View File

@ -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:

View File

@ -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() {
}

View File

@ -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);

View File

@ -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()) {

View File

@ -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<Network, String> conns, Network next) {
final Map<Network, TextBlock> conns2 = new LinkedHashMap<Network, TextBlock>();
for (Entry<Network, String> 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() {

View File

@ -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<DiagGroup> groups;
private final List<Network> networks;
public GridTextBlockDecorated(int lines, int cols, Collection<DiagGroup> groups) {
public GridTextBlockDecorated(int lines, int cols, Collection<DiagGroup> groups, List<Network> 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<Network, Double> pos = drawNetworkTube(ug);
drawLinks(ug, pos);
}
private void drawLinks(UGraphic ug, Map<Network, Double> 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<Network, Double> drawNetworkTube(final UGraphic ug) {
final Map<Network, Double> pos = new HashMap<Network, Double>();
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);
}
}

View File

@ -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) {

View File

@ -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<Network, TextBlock> 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<Network, TextBlock> 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<Network, Double> 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<Double> skip = new TreeSet<Double>(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<Network, TextBlock> 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()

View File

@ -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<String, String> 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<String, DiagElement> 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<Network, String> getLinks(DiagElement element) {
final Map<Network, String> result = new LinkedHashMap<Network, String>();
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<String, DiagElement> ent : elements.entrySet()) {
final DiagElement element = ent.getValue();
if (element.getMainNetwork() == current) {
final Map<Network, String> 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();

View File

@ -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<Double> skip;
public VerticalLine(double y1, double y2, TreeSet<Double> 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);
}
}

View File

@ -30,6 +30,7 @@
*
*
* Original Author: Arnaud Roques
* Contribution: Miguel Esteves
*
*
*/
@ -94,6 +95,7 @@ public class DotPath implements UShape, Moveable {
private final List<CubicCurve2D.Double> beziers = new ArrayList<CubicCurve2D.Double>();
private String comment;
private String codeLine;
public DotPath() {
this(new ArrayList<CubicCurve2D.Double>());
@ -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;
}
}

View File

@ -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;

View File

@ -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<Day> {
public class DaysAsDates implements Iterable<Day> {
private final Day date1;
private final Day date2;

View File

@ -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));
}

View File

@ -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() {
}
}

View File

@ -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<TaskCode, Task> tasks = new LinkedHashMap<TaskCode, Task>();
private final Map<String, Task> byShortName = new HashMap<String, Task>();
@ -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();
}
}

View File

@ -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<SubjectPattern> subjects() {
return Arrays.<SubjectPattern>asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(),
new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday());
static private final List<Subject> subjects() {
return Arrays.<Subject>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<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
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<Command> 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<VerbPattern> 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<VerbPattern> 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)));
}
}
}

View File

@ -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;

View File

@ -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<TaskAttribute, Value> values = new LinkedHashMap<TaskAttribute, Value>();
private final LoadPlanable loadPlanable;
public Solver3(LoadPlanable loadPlanable) {
public Solver(LoadPlanable loadPlanable) {
this.loadPlanable = loadPlanable;
}

View File

@ -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);
}

View File

@ -35,8 +35,6 @@
*/
package net.sourceforge.plantuml.project;
import net.sourceforge.plantuml.project.lang.Subject;
public class Today implements Subject {
public class Today {
}

View File

@ -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<GanttDiagram> {
@ -74,7 +74,7 @@ public class CommandColorTask extends SingleLineCommand2<GanttDiagram> {
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();
}

View File

@ -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<GanttDiagram> {
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<GanttDiagram> {
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();
}

View File

@ -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<GanttDiagram> {
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<GanttDiagram> {
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();
}

View File

@ -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<GanttDiagram> {
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");
}
}

View File

@ -71,8 +71,8 @@ public class CommandPrintBetween extends SingleLineCommand2<GanttDiagram> {
@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();
}

View File

@ -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<GanttDiagram> {
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> 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);
}
}

View File

@ -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<GanttDiagram> {
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<Complement> 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<Complement> 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);
}
}

View File

@ -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<GanttDiagram> {
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);
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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<Resource, Integer> resources2 = new LinkedHashMap<Resource, Integer>();
private final SortedSet<Wink> pausedDay = new TreeSet<Wink>();
private final Set<DayOfWeek> pausedDayOfWeek = new HashSet<DayOfWeek>();
private final Solver solver;
private final Map<Resource, Integer> resources = new LinkedHashMap<Resource, Integer>();
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<Resource, Integer> ent : resources2.entrySet()) {
for (Map.Entry<Resource, Integer> 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<Map.Entry<Resource, Integer>> it = resources2.entrySet().iterator(); it.hasNext();) {
for (Iterator<Map.Entry<Resource, Integer>> it = resources.entrySet().iterator(); it.hasNext();) {
final Map.Entry<Resource, Integer> 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<Wink> getAllPaused() {
final SortedSet<Wink> result = new TreeSet<Wink>(pausedDay);
for (DayOfWeek dayOfWeek : pausedDayOfWeek) {
addAll(result, dayOfWeek);
}
return Collections.unmodifiableCollection(result);
}
private void addAll(SortedSet<Wink> 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;
}
}

View File

@ -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;
}
}

View File

@ -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) {
}
}

View File

@ -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() {
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;
}
}

View File

@ -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);
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 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,
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());
final double start = (timeScale.getStartingPosition(i) + timeScale.getEndingPosition(i)) / 2
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;
}

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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<Wink> 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,19 +157,15 @@ 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;
}
} else {
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);
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);
@ -140,14 +176,35 @@ public class TaskDrawRegular extends AbstractTaskDraw {
}
ug.apply(new HColorNone().bg()).draw(full);
}
}
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;
}
}
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);
}
}

View File

@ -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();
}
}

View File

@ -46,6 +46,7 @@ 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 {
@ -53,7 +54,6 @@ 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());
}

View File

@ -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<Day, HColor> colorDays;
private final Map<Day, String> nameDays;
public TimeHeaderDaily(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan,
Map<Day, HColor> colorDays, Map<Day, String> nameDays, Day printStart, Day printEnd) {
public TimeHeaderDaily(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, Map<Day, HColor> colorDays,
Map<Day, String> 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) {
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), x1, x2);
printCentered(ug.apply(UTranslate.dy(Y_POS_ROW28)), getTextBlock("" + day.getDayOfMonth(), 10, false),
x1, x2);
}
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();

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<TaskInstant> 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.<Complement>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.<Complement>ok(result);
return Failable.ok(result);
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
return Failable.<Complement> ok(CLOSE);
public Failable<Object> getMe(GanttDiagram project, RegexResult arg, String suffix) {
return Failable.ok(new Object());
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Completion> getMe(GanttDiagram system, RegexResult arg, String suffix) {
final String value = arg.get("COMPLEMENT" + suffix, 0);
return Failable.<Complement>ok(new Completion(Integer.parseInt(value)));
return Failable.ok(new Completion(Integer.parseInt(value)));
}
}

View File

@ -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));
@ -90,42 +90,42 @@ public class ComplementDate implements ComplementPattern {
);
}
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Day> getMe(GanttDiagram system, RegexResult arg, String suffix) {
if (arg.get("ADAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultA(arg, suffix));
return Failable.ok(resultA(arg, suffix));
}
if (arg.get("BDAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultB(arg, suffix));
return Failable.ok(resultB(arg, suffix));
}
if (arg.get("CDAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultC(arg, suffix));
return Failable.ok(resultC(arg, suffix));
}
if (arg.get("DCOUNT" + suffix, 0) != null) {
return Failable.<Complement> 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));

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<DaysAsDates> 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.<Complement> ok(new DaysAsDates(date1, date2));
return Failable.ok(new DaysAsDates(date1, date2));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<DayOfWeek> getMe(GanttDiagram project, RegexResult arg, String suffix) {
final String s = arg.get("COMPLEMENT" + suffix, 0);
return Failable.<Complement> ok(DayOfWeek.fromString(s));
return Failable.ok(DayOfWeek.fromString(s));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
return Failable.<Complement> ok(new Complement() {
});
public Failable<Object> getMe(GanttDiagram system, RegexResult arg, String suffix) {
return Failable.ok(new Object());
}
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> 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<TwoNames> 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));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<CenterBorderColor> 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.<Complement> ok(new ComplementColors(col1, col2));
return Failable.ok(new CenterBorderColor(col1, col2));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<CenterBorderColor> 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.<Complement> ok(new ComplementColors(col1, col2));
return Failable.ok(new CenterBorderColor(col1, col2));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<String> getMe(GanttDiagram system, RegexResult arg, String suffix) {
final String name = arg.get("COMPLEMENT" + suffix, 0);
return Failable.<Complement> ok(new ComplementName(name));
return Failable.ok(name);
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
return Failable.<Complement> ok(OPEN);
public Failable<Object> getMe(GanttDiagram project, RegexResult arg, String suffix) {
return Failable.ok(new Object());
}
}

View File

@ -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<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Load> 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.<Complement>ok(Load.inWinks(days1 + days2));
return Failable.ok(Load.inWinks(days1 + days2));
}
}

View File

@ -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<Complement> getComplement(GanttDiagram diagram, RegexResult arg, String suffix) {
public Failable<Url> 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.<Complement>ok(url);
return Failable.ok(url);
}
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> 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<CenterBorderColor> 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));
}
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern>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<? extends Object> getMe(GanttDiagram system, RegexResult arg, String suffix) {
final Failable<? extends Object> r1 = complement1.getMe(system, arg, "A" + suffix);
final Failable<? extends Object> 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);
}
};
}
}

View File

@ -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<VerbPattern> getVerbs();
public Subject getSubject(GanttDiagram project, RegexResult arg);
public interface Sentence {
public IRegex toRegex();
public CommandExecutionResult execute(GanttDiagram project, RegexResult arg);
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> 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));
public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) {
final Failable<? extends Object> subject = sentence1.subjectii.getMe(project, arg);
if (subject.isFail()) {
return CommandExecutionResult.error(subject.getError());
}
} else {
final Day when = (Day) complement;
resource.addForceOnDay(project.convert(when));
final Failable<? extends Object> complement1 = sentence1.complementii.getMe(project, arg, "1");
if (complement1.isFail()) {
return CommandExecutionResult.error(complement1.getError());
}
return CommandExecutionResult.ok();
final CommandExecutionResult result1 = sentence1.execute(project, subject.get(), complement1.get());
if (result1.isOk() == false) {
return result1;
}
final Failable<? extends Object> complement2 = sentence2.complementii.getMe(project, arg, "2");
if (complement2.isFail()) {
return CommandExecutionResult.error(complement2.getError());
}
return sentence2.execute(project, subject.get(), complement2.get());
}
};
}
}

View File

@ -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<? extends Object> subject = sentence1.subjectii.getMe(project, arg);
if (subject.isFail()) {
return CommandExecutionResult.error(subject.getError());
}
final Failable<? extends Object> 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<? extends Object> 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<? extends Object> 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;
}
}

View File

@ -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();
}
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> asList(new ComplementInColors());
public SentenceEnds() {
super(new SubjectTask(), Verbs.ends(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
}
public IRegex toRegex() {
return new RegexLeaf("is[%s]+colou?red");
}
public Verb getVerb(final GanttDiagram project, RegexResult arg) {
return new Verb() {
public CommandExecutionResult execute(Subject subject, Complement complement) {
@Override
public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) {
final Task task = (Task) subject;
final ComplementColors colors = (ComplementColors) complement;
task.setColors(colors);
final TaskInstant when = (TaskInstant) complement;
task.setEnd(when.getInstantPrecise().decrement());
project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.END)));
return CommandExecutionResult.ok();
}
};
}
}

View File

@ -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<ComplementPattern> getComplements() {
return Arrays.<ComplementPattern> asList(new ComplementSeveralDays());
public SentenceHappens() {
super(new SubjectTask(), Verbs.happens(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
}
public IRegex toRegex() {
return new RegexLeaf("lasts");
}
public Verb getVerb(GanttDiagram project, RegexResult arg) {
return new Verb() {
public CommandExecutionResult execute(Subject subject, Complement complement) {
@Override
public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) {
final Task task = (Task) subject;
final Load duration = (Load) complement;
task.setLoad(duration);
task.setLoad(Load.inWinks(1));
final TaskInstant when = (TaskInstant) complement;
task.setStart(when.getInstantTheorical());
task.setDiamond(true);
return CommandExecutionResult.ok();
}
};
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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<ComplementPattern> 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);
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

Some files were not shown because too many files have changed in this diff Show More