mirror of
https://github.com/octoleo/plantuml.git
synced 2024-06-06 02:10:53 +00:00
version 8055
This commit is contained in:
parent
69c25ec749
commit
a2cbfb5712
3
pom.xml
3
pom.xml
|
@ -30,7 +30,8 @@
|
|||
Script Author: Julien Eluard
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
|
|
|
@ -75,7 +75,7 @@ public enum ColorParam {
|
|||
componentBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
|
||||
interfaceBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
interfaceBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
|
||||
componentArrow(HtmlColorUtils.MY_RED, ColorType.ARROW),
|
||||
arrow(HtmlColorUtils.MY_RED, ColorType.ARROW),
|
||||
|
||||
stateBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
stateBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
|
||||
|
|
|
@ -68,12 +68,13 @@ import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
|
|||
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
|
||||
import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
|
||||
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
|
||||
import net.sourceforge.plantuml.project2.PSystemProjectFactory2;
|
||||
import net.sourceforge.plantuml.project3.GanttDiagramFactory;
|
||||
import net.sourceforge.plantuml.salt.PSystemSaltFactory;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
|
||||
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
|
||||
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
|
||||
import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingDiagramFactory;
|
||||
import net.sourceforge.plantuml.ugraphic.sprite.PSystemListInternalSpritesFactory;
|
||||
import net.sourceforge.plantuml.version.License;
|
||||
import net.sourceforge.plantuml.version.PSystemLicenseFactory;
|
||||
|
@ -163,11 +164,12 @@ public class PSystemBuilder {
|
|||
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
|
||||
factories.add(new PSystemXearthFactory());
|
||||
}
|
||||
factories.add(new PSystemProjectFactory2());
|
||||
factories.add(new GanttDiagramFactory());
|
||||
factories.add(new FlowDiagramFactory());
|
||||
factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
|
||||
factories.add(new PSystemCuteFactory(DiagramType.CUTE));
|
||||
factories.add(new PSystemDedicationFactory());
|
||||
factories.add(new TimingDiagramFactory());
|
||||
return factories;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,5 +31,5 @@
|
|||
package net.sourceforge.plantuml;
|
||||
|
||||
public enum UmlDiagramType {
|
||||
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW
|
||||
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING
|
||||
}
|
||||
|
|
|
@ -81,6 +81,12 @@ public class Arrows {
|
|||
if (direction == Direction.DOWN) {
|
||||
return asToDown();
|
||||
}
|
||||
if (direction == Direction.LEFT) {
|
||||
return asToLeft();
|
||||
}
|
||||
if (direction == Direction.RIGHT) {
|
||||
return asToRight();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
|
|||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddNote;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddUrl;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAssembly;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateParallel;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateGroup;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateParallel;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorIf;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorRepeat;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorWhile;
|
||||
|
@ -108,6 +108,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||
factory = new FtileFactoryDelegatorWhile(factory);
|
||||
factory = new FtileFactoryDelegatorRepeat(factory);
|
||||
factory = new FtileFactoryDelegatorCreateParallel(factory);
|
||||
// factory = new FtileFactoryDelegatorCreateParallelAddingMargin(new FtileFactoryDelegatorCreateParallel1(factory));
|
||||
factory = new FtileFactoryDelegatorAddNote(factory);
|
||||
factory = new FtileFactoryDelegatorCreateGroup(factory);
|
||||
return factory;
|
||||
|
|
|
@ -51,11 +51,14 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator {
|
|||
super(factory);
|
||||
}
|
||||
|
||||
private Ftile allOverlapped(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
|
||||
return new FtileForkInnerOverlapped(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ftile createParallel(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
|
||||
|
||||
final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension(
|
||||
getStringBounder());
|
||||
final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension(getStringBounder());
|
||||
final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
|
||||
|
||||
final List<Ftile> list = new ArrayList<Ftile>();
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.activitydiagram3.ftile.vcompact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.activitydiagram3.ForkStyle;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
|
||||
public class FtileFactoryDelegatorCreateParallel1 extends FtileFactoryDelegator {
|
||||
|
||||
public FtileFactoryDelegatorCreateParallel1(FtileFactory factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
private Ftile allOverlapped(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
|
||||
return new FtileForkInnerOverlapped(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ftile createParallel(Swimlane swimlane, List<Ftile> list, ForkStyle style, String label) {
|
||||
|
||||
final Ftile inner = super.createParallel(swimlane, list, style, label);
|
||||
|
||||
ParallelFtilesBuilder builder;
|
||||
|
||||
if (style == ForkStyle.SPLIT) {
|
||||
builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), list, inner, swimlane);
|
||||
} else if (style == ForkStyle.MERGE) {
|
||||
builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner, swimlane);
|
||||
} else if (style == ForkStyle.FORK) {
|
||||
builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, swimlane, label);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.activitydiagram3.ftile.vcompact;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.activitydiagram3.ForkStyle;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
|
||||
public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactoryDelegator {
|
||||
|
||||
private final double spaceArroundBlackBar = 20;
|
||||
private final double xMargin = 14;
|
||||
|
||||
public FtileFactoryDelegatorCreateParallelAddingMargin(FtileFactory factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ftile createParallel(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
|
||||
|
||||
final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension(
|
||||
getStringBounder());
|
||||
final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
|
||||
|
||||
final List<Ftile> list = new ArrayList<Ftile>();
|
||||
for (Ftile tmp : all) {
|
||||
list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1));
|
||||
}
|
||||
return super.createParallel(swimlane, list, style, label);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.activitydiagram3.ftile.vcompact;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
class FtileForkInnerOverlapped extends AbstractFtile {
|
||||
|
||||
private final List<Ftile> forks = new ArrayList<Ftile>();
|
||||
|
||||
public FtileForkInnerOverlapped(List<Ftile> forks) {
|
||||
super(forks.get(0).skinParam());
|
||||
for (Ftile ftile : forks) {
|
||||
this.forks.add(ftile);
|
||||
}
|
||||
}
|
||||
|
||||
public Swimlane getSwimlaneIn() {
|
||||
return forks.get(0).getSwimlaneIn();
|
||||
}
|
||||
|
||||
public Swimlane getSwimlaneOut() {
|
||||
return getSwimlaneIn();
|
||||
}
|
||||
|
||||
public Set<Swimlane> getSwimlanes() {
|
||||
return mergeSwimlanes(forks);
|
||||
}
|
||||
|
||||
public static Set<Swimlane> mergeSwimlanes(List<Ftile> tiles) {
|
||||
final Set<Swimlane> result = new HashSet<Swimlane>();
|
||||
for (Ftile tile : tiles) {
|
||||
result.addAll(tile.getSwimlanes());
|
||||
}
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
// final StringBounder stringBounder = ug.getStringBounder();
|
||||
|
||||
final double xpos = 0;
|
||||
for (Ftile ftile : forks) {
|
||||
ug.apply(new UTranslate(xpos, 0)).draw(ftile);
|
||||
// final Dimension2D dim = ftile.calculateDimension(stringBounder);
|
||||
// xpos += dim.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||
double height = 0;
|
||||
double width = 0;
|
||||
for (Ftile ftile : forks) {
|
||||
final Dimension2D dim = ftile.calculateDimension(stringBounder);
|
||||
// width += dim.getWidth();
|
||||
width = Math.max(width, dim.getWidth());
|
||||
if (dim.getHeight() > height) {
|
||||
height = dim.getHeight();
|
||||
}
|
||||
}
|
||||
final Dimension2D dimTotal = new Dimension2DDouble(width, height);
|
||||
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
|
||||
}
|
||||
|
||||
public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) {
|
||||
final double xpos = 0;
|
||||
for (Ftile ftile : forks) {
|
||||
if (ftile == searched) {
|
||||
return new UTranslate(xpos, 0);
|
||||
}
|
||||
// final Dimension2D dim = ftile.calculateDimension(stringBounder);
|
||||
// xpos += dim.getWidth();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
|
@ -50,7 +50,7 @@ public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
|
|||
final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
|
||||
|
||||
final String field = arg.get(1);
|
||||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
|
||||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {
|
||||
system.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(field, entity);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
|||
|
||||
private static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacter() + ")?"), //
|
||||
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), //
|
||||
new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class|entity)[%s]+"), //
|
||||
new RegexOr(//
|
||||
new RegexConcat(//
|
||||
|
@ -132,7 +132,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
|||
lines = lines.subExtract(1, 0);
|
||||
}
|
||||
for (CharSequence s : lines) {
|
||||
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s)) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s.toString(), entity);
|
||||
|
@ -179,7 +179,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
|||
final String visibilityString = arg.get("VISIBILITY", 0);
|
||||
VisibilityModifier visibilityModifier = null;
|
||||
if (visibilityString != null) {
|
||||
visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString.charAt(0), false);
|
||||
visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString + "FOO", false);
|
||||
}
|
||||
|
||||
final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
|
||||
|
|
|
@ -76,7 +76,12 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
|
|||
new RegexLeaf("SYMBOL", regex), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexOr(//
|
||||
new RegexLeaf("CODE1", CODE_WITH_QUOTE) //
|
||||
new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), //
|
||||
new RegexConcat(//
|
||||
new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), //
|
||||
new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
|
||||
new RegexLeaf("[%s]*as[%s]+"), //
|
||||
new RegexLeaf("CODE2", CommandCreateElementFull.CODE)) //
|
||||
), //
|
||||
new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
|
@ -86,13 +91,7 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
|
|||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||
private static final String CODE = "(" + CODE_CORE + ")";
|
||||
private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
|
||||
|
||||
private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||
private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
|
||||
private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
|
||||
|
||||
@Override
|
||||
final protected boolean isForbidden(CharSequence line) {
|
||||
|
|
|
@ -96,9 +96,9 @@ public class MemberImpl implements Member {
|
|||
displayClean = " ";
|
||||
}
|
||||
|
||||
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
|
||||
if (VisibilityModifier.isVisibilityCharacter(displayClean)) {
|
||||
visibilityModifier = VisibilityModifier
|
||||
.getVisibilityModifier(displayClean.charAt(0), isMethod == false);
|
||||
.getVisibilityModifier(displayClean, isMethod == false);
|
||||
this.display = StringUtils.trin(StringUtils.manageGuillemet(displayClean.substring(1)));
|
||||
} else {
|
||||
this.display = StringUtils.manageGuillemet(displayClean);
|
||||
|
|
|
@ -96,11 +96,11 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
|
|||
}
|
||||
|
||||
private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||
private static final String CODE = "(" + CODE_CORE + ")";
|
||||
private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
|
||||
public static final String CODE = "(" + CODE_CORE + ")";
|
||||
public static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
|
||||
|
||||
private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
|
||||
private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
|
||||
public static final String DISPLAY = "(" + DISPLAY_CORE + ")";
|
||||
private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
|
||||
|
||||
@Override
|
||||
|
|
|
@ -290,7 +290,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
|||
colors = CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link, colors);
|
||||
if (arg.get("STEREOTYPE", 0) != null) {
|
||||
final Stereotype stereotype = new Stereotype(arg.get("STEREOTYPE", 0));
|
||||
colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.componentArrow);
|
||||
colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.arrow);
|
||||
}
|
||||
|
||||
link.setColors(colors);
|
||||
|
|
|
@ -60,7 +60,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
|||
|
||||
public class PSystemDonors extends AbstractPSystem {
|
||||
|
||||
public static final String DONORS = "UDfTL4josp0CtUCKN6lIGoXsxDI_PEmqdSaEbc29CKMufEHKFaUlaaLdkki5VAH2JcLIuKeO0k1x3mzAJVB_a8D7gicfrDPiDMRmH4auNC62G-Wyf7qfRc7gmXMriA4j-bgZLIikBQGsPwUcJFM9ki_TJZBwTBImmEWXMyDOzu4sa8RMV8HD4o2qCDN9y5Y6MO-oyR2fwL2ILIFcW_0Rz--GXtdrgPGTZDXegzRSU89Py-a-UMKXqWS73Si8DLPnA4-bXdwYpKNEKQcbQu6k5QRhAsrRm2f6Nv_WmUYZ58nrjXVarnjjuSvVMzi8H49769ygNRjMBR3a767MYVvIehIFyX8oOLnozgt8PB6MFC4dk6OVu6a_O6Lp2Lqccanmwzezl_czbaP6oXvShKzm7x9pXgNEIZBg5hLfOmRc58Fn7cQ4ziiCinyDUJLkjWvbbYRmVURNch9IpHrw390A4ej64tlhd2KfQiv77HlbOfLlWR16M4VcxPw8UIQlKds8RCNxJfbRTcZH76xK2zN81mzh8OWkLtFTZHOcXbsdz_Bl7sCkGm-6C94vnKwBgvqSzcftKo-7Z3myOc-FjHu0JerM6yHSLiSLfBwJBSZTg6Nwz7MJ1cidR65AWvM9cTjCB5AfPq4z5jFEGwQZRhAoB0iYk3l6pZyYh48JgdgGIKHZscZnHLEHcd13TT0typ299tFX4jnWJx5i0dUb2_7GHbTX1GMGRFAkKnfbgoFGYJ5m_dL-ZzgVty-_OLGELhkLnMksbn-1ix8Bzpo0CoNUxHorQgKh6Tm_1JvLlG00";
|
||||
public static final String DONORS = "UDfbL4josp0CtUCKN6lIGoXsx5J-96EdwKnsi0HRZ2d29IMdyZbwbImwqrqlu2CLSYkJIhaIXW3utiE3KfFyE-JWaMfoAhKrMuqvF54I3bSmvn0w3sbVYXkOkd15BQnfWxxMQDMIImkfBTYfALDzekvpkvMCFXqjp35woDOmrdsW3QIXDHzXtGG8BKnrCZoM8UjHDXxMDHrAich4V11-u_uTyZ2hFfIoWn4RRTMA6q-GDH_karSM8drmqB28K6CLX_9KQkWxsaBa79LQkkxGjS9qTQLjTx2CqTSdU33wA0LZdUy5-VL6MxZprzOs0f7G4SQdIjUkLNCikK38Ej5VIfJsKLv29enBphuLcIpMaYVu15Vs5ppj1wni8Q7BHPC9RboxvpU_rzB8IDc3g_K9xaDsmR3GUKb6tQ8sRSp0d68mtaD6Q3zbc7zhoAjnit4eipI1xpE_rfINQkRGOu2q8x5eDB6tpbcIecPyrB5HBbRv4WXhX5Latkw9c6VoAjM7o5QyxvIvPOSMpU56lL2DVF2m4eBe2ZNJtMXXOjXrUYz-_pBcClHW21EPK-mqlzh9OQzsD_LooCZ38_RsMEa1uDHejKOiP7NSZjHNiZjoDsgHFdrUfy7Q2LkOqc1bOkOs5ujKwbbGZyMqiv3fg9kiBCkS2EwEiVEF2ClGXAeUP1BHc3PQVD5Kf2RSK1tqpJrCuibSk0Gts5Cicy1TwfruQAshi882I3PvsocDijKHwCGOEFyulqVjp-_ddp0g1wlTok8rcykFm5dPXNiUm9aIRxUEMhNKbGmkm___Ady0ufjPnG00";
|
||||
|
||||
@Override
|
||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CommandAddData extends SingleLineCommand<AbstractClassOrObjectDiagr
|
|||
final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
|
||||
|
||||
final String field = arg.get(1);
|
||||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
|
||||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(field, entity);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
|||
lines = lines.subExtract(1, 1);
|
||||
for (CharSequence s : lines) {
|
||||
assert s.length() > 0;
|
||||
if (VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
if (VisibilityModifier.isVisibilityCharacter(s)) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s.toString(), entity);
|
||||
|
|
|
@ -47,7 +47,7 @@ import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
|||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.eps.EpsStrategy;
|
||||
import net.sourceforge.plantuml.png.PngIO;
|
||||
import net.sourceforge.plantuml.project.graphic.GanttDiagram;
|
||||
import net.sourceforge.plantuml.project.graphic.GanttDiagramUnused;
|
||||
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
|
||||
|
@ -71,7 +71,7 @@ public class PSystemProject extends AbstractPSystem {
|
|||
@Override
|
||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
final GanttDiagram diagram = new GanttDiagram(project);
|
||||
final GanttDiagramUnused diagram = new GanttDiagramUnused(project);
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
if (fileFormat == FileFormat.PNG) {
|
||||
final BufferedImage im = createImage(diagram);
|
||||
|
@ -95,7 +95,7 @@ public class PSystemProject extends AbstractPSystem {
|
|||
return new ImageDataSimple();
|
||||
}
|
||||
|
||||
private BufferedImage createImage(GanttDiagram diagram) {
|
||||
private BufferedImage createImage(GanttDiagramUnused diagram) {
|
||||
EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, background);
|
||||
Graphics2D g2d = builder.getGraphics2D();
|
||||
UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
|
||||
|
|
|
@ -51,13 +51,13 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
|
|||
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class GanttDiagram {
|
||||
public class GanttDiagramUnused {
|
||||
|
||||
private final Project project;
|
||||
private final TimeScale timeScale;
|
||||
private final ItemHeader itemHeader;
|
||||
|
||||
public GanttDiagram(Project project) {
|
||||
public GanttDiagramUnused(Project project) {
|
||||
this.project = project;
|
||||
this.timeScale = new TimeScale(project);
|
||||
this.itemHeader = new ItemHeader(project);
|
92
src/net/sourceforge/plantuml/project3/Arrows.java
Normal file
92
src/net/sourceforge/plantuml/project3/Arrows.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
|
||||
public class Arrows {
|
||||
|
||||
final static private double delta2 = 4;
|
||||
|
||||
private static UPolygon asToUp() {
|
||||
final UPolygon polygon = new UPolygon("asToUp");
|
||||
polygon.addPoint(-delta2, 0);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.addPoint(delta2, 0);
|
||||
polygon.addPoint(0, -4);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
private static UPolygon asToDown() {
|
||||
final UPolygon polygon = new UPolygon("asToDown");
|
||||
polygon.addPoint(-delta2, 0);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.addPoint(delta2, 0);
|
||||
polygon.addPoint(0, 4);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
private static UPolygon asToRight() {
|
||||
final UPolygon polygon = new UPolygon("asToRight");
|
||||
polygon.addPoint(0, -delta2);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.addPoint(0, delta2);
|
||||
polygon.addPoint(4, 0);
|
||||
return polygon.translate(-4, 0);
|
||||
}
|
||||
|
||||
private static UPolygon asToLeft() {
|
||||
final UPolygon polygon = new UPolygon("asToLeft");
|
||||
polygon.addPoint(0, -delta2);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.addPoint(0, delta2);
|
||||
polygon.addPoint(-4, 0);
|
||||
return polygon.translate(4, 0);
|
||||
}
|
||||
|
||||
public static UPolygon asTo(Direction direction) {
|
||||
if (direction == Direction.UP) {
|
||||
return asToUp();
|
||||
}
|
||||
if (direction == Direction.DOWN) {
|
||||
return asToDown();
|
||||
}
|
||||
if (direction == Direction.LEFT) {
|
||||
return asToLeft();
|
||||
}
|
||||
if (direction == Direction.RIGHT) {
|
||||
return asToRight();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
36
src/net/sourceforge/plantuml/project3/Complement.java
Normal file
36
src/net/sourceforge/plantuml/project3/Complement.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
|
||||
public interface Complement {
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPattern {
|
||||
|
||||
public IRegex toRegex(String suffix) {
|
||||
return new RegexLeaf("COMPLEMENT" + suffix,
|
||||
"(?:at|(\\d+)[%s]+days?[%s]+(before|after))[%s]+\\[([^\\[\\]]+?)\\].?s[%s]+(start|end)");
|
||||
}
|
||||
|
||||
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
final String code = arg.get("COMPLEMENT" + suffix, 2);
|
||||
final String position = arg.get("COMPLEMENT" + suffix, 3);
|
||||
final Task task = system.getTask(new TaskCode(code));
|
||||
final String days = arg.get("COMPLEMENT" + suffix, 0);
|
||||
TaskInstant result = new TaskInstant(task, TaskAttribute.fromString(position));
|
||||
if (days != null) {
|
||||
int delta = Integer.parseInt(days);
|
||||
if ("before".equalsIgnoreCase(arg.get("COMPLEMENT" + suffix, 1))) {
|
||||
delta = -delta;
|
||||
}
|
||||
result = result.withDelta(delta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
64
src/net/sourceforge/plantuml/project3/ComplementColors.java
Normal file
64
src/net/sourceforge/plantuml/project3/ComplementColors.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
|
||||
public class ComplementColors implements Complement {
|
||||
|
||||
private final HtmlColor center;
|
||||
private final HtmlColor border;
|
||||
|
||||
public ComplementColors(HtmlColor center, HtmlColor border) {
|
||||
this.center = center;
|
||||
this.border = border;
|
||||
}
|
||||
|
||||
public UGraphic apply(UGraphic ug) {
|
||||
if (isOk() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
ug = ug.apply(new UChangeBackColor(center));
|
||||
if (border == null) {
|
||||
ug = ug.apply(new UChangeColor(center));
|
||||
} else {
|
||||
ug = ug.apply(new UChangeColor(border));
|
||||
}
|
||||
return ug;
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
return center != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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.graphic.HtmlColor;
|
||||
|
||||
public class ComplementInColors implements ComplementPattern {
|
||||
|
||||
public IRegex toRegex(String suffix) {
|
||||
return new RegexLeaf("COMPLEMENT" + suffix, "in[%s+](#?\\w+)(?:/(#?\\w+))?");
|
||||
}
|
||||
|
||||
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
final String color1 = arg.get("COMPLEMENT" + suffix, 0);
|
||||
final String color2 = arg.get("COMPLEMENT" + suffix, 1);
|
||||
final HtmlColor col1 = system.getIHtmlColorSet().getColorIfValid(color1);
|
||||
final HtmlColor col2 = system.getIHtmlColorSet().getColorIfValid(color2);
|
||||
return new ComplementColors(col1, col2);
|
||||
}
|
||||
}
|
42
src/net/sourceforge/plantuml/project3/ComplementPattern.java
Normal file
42
src/net/sourceforge/plantuml/project3/ComplementPattern.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public interface ComplementPattern {
|
||||
|
||||
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix);
|
||||
|
||||
public IRegex toRegex(String suffix);
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public class ComplementSeveralDays implements ComplementPattern {
|
||||
|
||||
public IRegex toRegex(String suffix) {
|
||||
return new RegexLeaf("COMPLEMENT" + suffix, "(\\d+)[%s]+days?");
|
||||
}
|
||||
|
||||
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
|
||||
final String days = arg.get("COMPLEMENT" + suffix, 0);
|
||||
return new DurationDay(Integer.parseInt(days));
|
||||
}
|
||||
}
|
35
src/net/sourceforge/plantuml/project3/Duration.java
Normal file
35
src/net/sourceforge/plantuml/project3/Duration.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public interface Duration extends Value, Complement {
|
||||
|
||||
}
|
50
src/net/sourceforge/plantuml/project3/DurationDay.java
Normal file
50
src/net/sourceforge/plantuml/project3/DurationDay.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public class DurationDay implements Duration {
|
||||
|
||||
private final int days;
|
||||
|
||||
public DurationDay(int days) {
|
||||
this.days = days;
|
||||
}
|
||||
|
||||
public int getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + days + " days}";
|
||||
}
|
||||
|
||||
}
|
132
src/net/sourceforge/plantuml/project3/GanttArrow.java
Normal file
132
src/net/sourceforge/plantuml/project3/GanttArrow.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class GanttArrow implements UDrawable {
|
||||
|
||||
private final TimeScale timeScale;
|
||||
private final Direction atStart;
|
||||
private final TaskInstant source;
|
||||
private final Direction atEnd;
|
||||
private final TaskInstant dest;
|
||||
|
||||
public GanttArrow(TimeScale timeScale, TaskInstant source, TaskInstant dest) {
|
||||
this.timeScale = timeScale;
|
||||
this.source = source;
|
||||
this.dest = dest;
|
||||
if (source.getAttribute() == TaskAttribute.END && dest.getAttribute() == TaskAttribute.START) {
|
||||
this.atStart = Direction.DOWN;
|
||||
this.atEnd = Direction.RIGHT;
|
||||
} else if (source.getAttribute() == TaskAttribute.END && dest.getAttribute() == TaskAttribute.END) {
|
||||
this.atStart = Direction.RIGHT;
|
||||
this.atEnd = Direction.LEFT;
|
||||
} else if (source.getAttribute() == TaskAttribute.START && dest.getAttribute() == TaskAttribute.START) {
|
||||
this.atStart = Direction.LEFT;
|
||||
this.atEnd = Direction.RIGHT;
|
||||
} else if (source.getAttribute() == TaskAttribute.START && dest.getAttribute() == TaskAttribute.END) {
|
||||
this.atStart = Direction.DOWN;
|
||||
this.atEnd = Direction.LEFT;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.RED_DARK)).apply(new UChangeColor(HtmlColorUtils.RED_DARK))
|
||||
.apply(new UStroke(1.5));
|
||||
|
||||
final TaskDraw draw1 = source.getTask().getTaskDraw();
|
||||
final TaskDraw draw2 = dest.getTask().getTaskDraw();
|
||||
|
||||
double x1 = getX(source.withDelta(0), atStart);
|
||||
double y1 = draw1.getY(atStart);
|
||||
|
||||
final double x2 = getX(dest, atEnd.getInv());
|
||||
final double y2 = draw2.getY(atEnd);
|
||||
|
||||
if (this.atStart == Direction.DOWN && this.atEnd == Direction.RIGHT) {
|
||||
if (x2 > x1) {
|
||||
drawLine(ug, x1, y1, x1, y2, x2, y2);
|
||||
} else {
|
||||
x1 = getX(source.withDelta(0), Direction.RIGHT);
|
||||
y1 = draw1.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) {
|
||||
final double xmax = Math.max(x1, x2) + 8;
|
||||
drawLine(ug, x1, y1, xmax, y1, xmax, y2, x2, y2);
|
||||
} else if (this.atStart == Direction.LEFT && this.atEnd == Direction.RIGHT) {
|
||||
final double xmin = Math.min(x1, x2) - 8;
|
||||
drawLine(ug, x1, y1, xmin, y1, xmin, y2, x2, y2);
|
||||
} else if (this.atStart == Direction.DOWN && this.atEnd == Direction.LEFT) {
|
||||
drawLine(ug, x1, y1, x1, y2, x2, y2);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
ug.apply(new UTranslate(x2, y2)).draw(Arrows.asTo(atEnd));
|
||||
|
||||
}
|
||||
|
||||
private void drawLine(UGraphic ug, double... coord) {
|
||||
for (int i = 0; i < coord.length - 2; i += 2) {
|
||||
final double x1 = coord[i];
|
||||
final double y1 = coord[i + 1];
|
||||
final double x2 = coord[i + 2];
|
||||
final double y2 = coord[i + 3];
|
||||
ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private double getX(TaskInstant when, Direction direction) {
|
||||
final double x1 = timeScale.getPixel(when.getInstantTheorical());
|
||||
final double x2 = timeScale.getPixel(when.getInstantTheorical().increment());
|
||||
if (direction == Direction.LEFT) {
|
||||
return x1;
|
||||
}
|
||||
if (direction == Direction.RIGHT) {
|
||||
return x2;
|
||||
}
|
||||
return (x1 + x2) / 2;
|
||||
}
|
||||
}
|
54
src/net/sourceforge/plantuml/project3/GanttConstraint.java
Normal file
54
src/net/sourceforge/plantuml/project3/GanttConstraint.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
|
||||
public class GanttConstraint implements Complement {
|
||||
|
||||
private final TaskInstant source;
|
||||
private final TaskInstant dest;
|
||||
|
||||
public GanttConstraint(TaskInstant source, TaskInstant dest) {
|
||||
this.source = source;
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return source.toString() + " --> " + dest.toString();
|
||||
}
|
||||
|
||||
public UDrawable getUDrawable(final TimeScale timeScale) {
|
||||
return new GanttArrow(timeScale, source, dest);
|
||||
}
|
||||
}
|
225
src/net/sourceforge/plantuml/project3/GanttDiagram.java
Normal file
225
src/net/sourceforge/plantuml/project3/GanttDiagram.java
Normal file
|
@ -0,0 +1,225 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class GanttDiagram extends AbstractPSystem {
|
||||
|
||||
private final Map<TaskCode, Task> tasks = new LinkedHashMap<TaskCode, Task>();
|
||||
private final List<GanttConstraint> constraints = new ArrayList<GanttConstraint>();
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
return new DiagramDescriptionImpl("(Project)", getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
final double dpiFactor = 1;
|
||||
final double margin = 10;
|
||||
|
||||
// public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata,
|
||||
// String warningOrError, double margin1, double margin2, Animation animation, boolean useHandwritten) {
|
||||
|
||||
sortTasks();
|
||||
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, "", "", 0, 0, null,
|
||||
false);
|
||||
imageBuilder.setUDrawable(getUDrawable());
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
}
|
||||
|
||||
private void sortTasks() {
|
||||
System.err.println("SORTING TASKS!");
|
||||
final TaskCodeSimpleOrder order = getCanonicalOrder(1);
|
||||
final List<Task> list = new ArrayList<Task>(tasks.values());
|
||||
Collections.sort(list, new Comparator<Task>() {
|
||||
public int compare(Task task1, Task task2) {
|
||||
return order.compare(task1.getCode(), task2.getCode());
|
||||
}
|
||||
});
|
||||
tasks.clear();
|
||||
for (Task task : list) {
|
||||
tasks.put(task.getCode(), task);
|
||||
}
|
||||
}
|
||||
|
||||
private UDrawable getUDrawable() {
|
||||
return new UDrawable() {
|
||||
public void drawU(UGraphic ug) {
|
||||
final TimeScale timeScale = new TimeScale();
|
||||
drawInternal(ug, timeScale);
|
||||
drawConstraints(ug, timeScale);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void drawConstraints(final UGraphic ug, TimeScale timeScale) {
|
||||
for (GanttConstraint constraint : constraints) {
|
||||
constraint.getUDrawable(timeScale).drawU(ug);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawInternal(final UGraphic ug, TimeScale timeScale) {
|
||||
|
||||
// System.err.println("==============");
|
||||
// for (Task task : tasks.values()) {
|
||||
// System.err.println("task=" + task + " " + ((TaskImpl) task).debug());
|
||||
// }
|
||||
// System.err.println("==============");
|
||||
|
||||
Instant min = tasks.values().iterator().next().getStart();
|
||||
Instant max = tasks.values().iterator().next().getEnd();
|
||||
for (Task task : tasks.values()) {
|
||||
final Instant start = task.getStart();
|
||||
final Instant end = task.getEnd();
|
||||
if (min.compareTo(start) > 0) {
|
||||
min = start;
|
||||
}
|
||||
if (max.compareTo(end) < 0) {
|
||||
max = end;
|
||||
}
|
||||
}
|
||||
|
||||
final double header = 16;
|
||||
double y = header;
|
||||
for (Task task : tasks.values()) {
|
||||
final TaskDraw draw = new TaskDraw(task, timeScale, y);
|
||||
task.setTaskDraw(draw);
|
||||
y += draw.getHeight();
|
||||
}
|
||||
|
||||
ULine vbar = new ULine(0, y);
|
||||
final double xmin = timeScale.getPixel(min);
|
||||
final double xmax = timeScale.getPixel(max.increment());
|
||||
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).draw(new ULine(xmax - xmin, 0));
|
||||
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, header - 3))
|
||||
.draw(new ULine(xmax - xmin, 0));
|
||||
|
||||
for (Instant i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) {
|
||||
final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(),
|
||||
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
|
||||
final double x1 = timeScale.getPixel(i);
|
||||
final double x2 = timeScale.getPixel(i.increment());
|
||||
final double width = num.calculateDimension(ug.getStringBounder()).getWidth();
|
||||
final double delta = (x2 - x1) - width;
|
||||
if (i.compareTo(max.increment()) < 0) {
|
||||
num.drawU(ug.apply(new UTranslate(x1 + delta / 2, 0)));
|
||||
}
|
||||
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(x1, 0)).draw(vbar);
|
||||
}
|
||||
|
||||
for (Task task : tasks.values()) {
|
||||
final TaskDraw draw = task.getTaskDraw();
|
||||
draw.drawU(ug.apply(new UTranslate(0, draw.getY())));
|
||||
draw.getTitle().drawU(
|
||||
ug.apply(new UTranslate(timeScale.getPixel(task.getStart().increment()), draw.getY())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
final UFont font = new UFont("Serif", Font.PLAIN, 10);
|
||||
return new FontConfiguration(font, HtmlColorUtils.LIGHT_GRAY, HtmlColorUtils.LIGHT_GRAY, false);
|
||||
}
|
||||
|
||||
public Task getTask(TaskCode code) {
|
||||
Task result = tasks.get(code);
|
||||
if (result == null) {
|
||||
result = new TaskImpl(code);
|
||||
tasks.put(code, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private TaskCodeSimpleOrder getCanonicalOrder(int hierarchyHeader) {
|
||||
final List<TaskCode> codes = new ArrayList<TaskCode>();
|
||||
for (TaskCode code : tasks.keySet()) {
|
||||
if (code.getHierarchySize() >= hierarchyHeader) {
|
||||
codes.add(code.truncateHierarchy(hierarchyHeader));
|
||||
}
|
||||
}
|
||||
return new TaskCodeSimpleOrder(codes, hierarchyHeader);
|
||||
}
|
||||
|
||||
private int getMaxHierarchySize() {
|
||||
int max = Integer.MIN_VALUE;
|
||||
for (TaskCode code : tasks.keySet()) {
|
||||
max = Math.max(max, code.getHierarchySize());
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public void addContraint(GanttConstraint constraint) {
|
||||
constraints.add(constraint);
|
||||
}
|
||||
|
||||
private final IHtmlColorSet colorSet = new HtmlColorSetSimple();
|
||||
|
||||
public IHtmlColorSet getIHtmlColorSet() {
|
||||
return colorSet;
|
||||
}
|
||||
|
||||
}
|
121
src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java
Normal file
121
src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandComment;
|
||||
import net.sourceforge.plantuml.command.CommandMultilinesComment;
|
||||
import net.sourceforge.plantuml.command.CommandNope;
|
||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
|
||||
public class GanttDiagramFactory extends UmlDiagramFactory {
|
||||
|
||||
private List<SubjectPattern> subjects() {
|
||||
return Arrays.<SubjectPattern> asList(new SubjectTask());
|
||||
}
|
||||
|
||||
public GanttDiagramFactory() {
|
||||
super(DiagramType.UML);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Command> createCommands() {
|
||||
final List<Command> cmds = new ArrayList<Command>();
|
||||
cmds.add(new CommandNope());
|
||||
cmds.add(new CommandComment());
|
||||
cmds.add(new CommandMultilinesComment());
|
||||
|
||||
for (Command cmd : getLanguageCommands()) {
|
||||
cmds.add(cmd);
|
||||
}
|
||||
return cmds;
|
||||
}
|
||||
|
||||
private Collection<Command> getLanguageCommands() {
|
||||
final Collection<Command> result = new ArrayList<Command>();
|
||||
for (SubjectPattern subject : subjects()) {
|
||||
for (VerbPattern verb : subject.getVerbs()) {
|
||||
for (ComplementPattern complement : verb.getComplements()) {
|
||||
result.add(NaturalCommand.create(subject, verb, complement));
|
||||
}
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
result.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()) {
|
||||
result.add(NaturalCommandAndAnd.create(subject, verb1, complement1, verb2,
|
||||
complement2, verb3, complement3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableCollection(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GanttDiagram createEmptyDiagram() {
|
||||
return new GanttDiagram();
|
||||
}
|
||||
|
||||
}
|
45
src/net/sourceforge/plantuml/project3/Instant.java
Normal file
45
src/net/sourceforge/plantuml/project3/Instant.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public interface Instant extends Value, Comparable<Instant> {
|
||||
|
||||
public Instant add(Duration duration);
|
||||
|
||||
public Instant sub(Duration duration);
|
||||
|
||||
public Instant increment();
|
||||
|
||||
public Instant decrement();
|
||||
|
||||
public String toShortString();
|
||||
|
||||
}
|
76
src/net/sourceforge/plantuml/project3/InstantDay.java
Normal file
76
src/net/sourceforge/plantuml/project3/InstantDay.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public class InstantDay implements Instant {
|
||||
|
||||
private final int numDay;
|
||||
|
||||
public InstantDay(int numDay) {
|
||||
this.numDay = numDay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(day +" + numDay + ")";
|
||||
}
|
||||
|
||||
public Instant add(Duration duration) {
|
||||
final int nbdays = ((DurationDay) duration).getDays();
|
||||
return new InstantDay(numDay + nbdays);
|
||||
}
|
||||
|
||||
public Instant sub(Duration duration) {
|
||||
final int nbdays = ((DurationDay) duration).getDays();
|
||||
return new InstantDay(numDay - nbdays);
|
||||
}
|
||||
|
||||
public Instant increment() {
|
||||
return new InstantDay(numDay + 1);
|
||||
}
|
||||
|
||||
public Instant decrement() {
|
||||
return new InstantDay(numDay - 1);
|
||||
}
|
||||
|
||||
final int getNumDay() {
|
||||
return numDay;
|
||||
}
|
||||
|
||||
public int compareTo(Instant other) {
|
||||
return this.numDay - ((InstantDay) other).numDay;
|
||||
}
|
||||
|
||||
public String toShortString() {
|
||||
return "" + (numDay + 1);
|
||||
}
|
||||
|
||||
}
|
76
src/net/sourceforge/plantuml/project3/NaturalCommand.java
Normal file
76
src/net/sourceforge/plantuml/project3/NaturalCommand.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class NaturalCommand extends SingleLineCommand2<GanttDiagram> {
|
||||
|
||||
private final SubjectPattern subjectPattern;
|
||||
private final VerbPattern verbPattern;
|
||||
private final ComplementPattern complementPattern;
|
||||
|
||||
private NaturalCommand(RegexConcat pattern, SubjectPattern subject, VerbPattern verb, ComplementPattern complement) {
|
||||
super(pattern);
|
||||
this.subjectPattern = subject;
|
||||
this.verbPattern = verb;
|
||||
this.complementPattern = complement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return subjectPattern.toString() + " " + verbPattern.toString() + " " + complementPattern.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(GanttDiagram system, RegexResult arg) {
|
||||
final Subject subject = subjectPattern.getSubject(system, arg);
|
||||
final Verb verb = verbPattern.getVerb(system, arg);
|
||||
final Complement complement = complementPattern.getComplement(system, arg, "0");
|
||||
return verb.execute(subject, complement);
|
||||
}
|
||||
|
||||
public static Command create(SubjectPattern subject, VerbPattern verb, ComplementPattern complement) {
|
||||
return new NaturalCommand(new RegexConcat(//
|
||||
new RegexLeaf("^"), //
|
||||
subject.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement.toRegex("0"), //
|
||||
new RegexLeaf("$")), subject, verb, complement);
|
||||
}
|
||||
}
|
96
src/net/sourceforge/plantuml/project3/NaturalCommandAnd.java
Normal file
96
src/net/sourceforge/plantuml/project3/NaturalCommandAnd.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
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, RegexResult arg) {
|
||||
final Subject subject = subjectPattern.getSubject(system, arg);
|
||||
final Verb verb1 = verbPattern1.getVerb(system, arg);
|
||||
final Complement complement1 = complementPattern1.getComplement(system, arg, "1");
|
||||
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");
|
||||
return verb2.execute(subject, complement2);
|
||||
}
|
||||
|
||||
public static Command create(SubjectPattern subject, VerbPattern verb1, ComplementPattern complement1,
|
||||
VerbPattern verb2, ComplementPattern complement2) {
|
||||
final RegexConcat pattern = new RegexConcat(//
|
||||
new RegexLeaf("^"), //
|
||||
subject.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb1.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement1.toRegex("1"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
new RegexLeaf("and"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb2.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement2.toRegex("2"), //
|
||||
new RegexLeaf("$"));
|
||||
return new NaturalCommandAnd(pattern, subject, verb1, complement1, verb2, complement2);
|
||||
}
|
||||
}
|
114
src/net/sourceforge/plantuml/project3/NaturalCommandAndAnd.java
Normal file
114
src/net/sourceforge/plantuml/project3/NaturalCommandAndAnd.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
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, RegexResult arg) {
|
||||
final Subject subject = subjectPattern.getSubject(system, arg);
|
||||
final Verb verb1 = verbPattern1.getVerb(system, arg);
|
||||
final Complement complement1 = complementPattern1.getComplement(system, arg, "1");
|
||||
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");
|
||||
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");
|
||||
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(//
|
||||
new RegexLeaf("^"), //
|
||||
subject.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb1.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement1.toRegex("1"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
new RegexLeaf("and"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb2.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement2.toRegex("2"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
new RegexLeaf("and"), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
verb3.toRegex(), //
|
||||
new RegexLeaf("[%s]+"), //
|
||||
complement3.toRegex("3"), //
|
||||
new RegexLeaf("$"));
|
||||
return new NaturalCommandAndAnd(pattern, subject, verb1, complement1, verb2, complement2, verb3, complement3);
|
||||
}
|
||||
}
|
86
src/net/sourceforge/plantuml/project3/Solver.java
Normal file
86
src/net/sourceforge/plantuml/project3/Solver.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class Solver {
|
||||
|
||||
private final Map<TaskAttribute, Value> values = new LinkedHashMap<TaskAttribute, Value>();
|
||||
|
||||
public void setData(TaskAttribute attribute, Value value) {
|
||||
values.remove(attribute);
|
||||
values.put(attribute, value);
|
||||
if (values.size() > 2) {
|
||||
removeFirstElement();
|
||||
}
|
||||
assert values.size() <= 2;
|
||||
|
||||
}
|
||||
|
||||
private void removeFirstElement() {
|
||||
final Iterator<Entry<TaskAttribute, Value>> it = values.entrySet().iterator();
|
||||
it.next();
|
||||
it.remove();
|
||||
}
|
||||
|
||||
public Value getData(TaskAttribute attribute) {
|
||||
Value result = values.get(attribute);
|
||||
if (result == null) {
|
||||
if (attribute == TaskAttribute.END) {
|
||||
return computeEnd();
|
||||
}
|
||||
if (attribute == TaskAttribute.START) {
|
||||
return computeStart();
|
||||
}
|
||||
throw new UnsupportedOperationException(attribute.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Instant computeStart() {
|
||||
final Instant end = (Instant) values.get(TaskAttribute.END);
|
||||
final Duration duration = (Duration) values.get(TaskAttribute.DURATION);
|
||||
assert end != null && duration != null;
|
||||
return end.sub(duration).increment();
|
||||
}
|
||||
|
||||
private Instant computeEnd() {
|
||||
final Instant start = (Instant) values.get(TaskAttribute.START);
|
||||
final Duration duration = (Duration) values.get(TaskAttribute.DURATION);
|
||||
assert start != null && duration != null;
|
||||
return start.add(duration).decrement();
|
||||
}
|
||||
|
||||
}
|
36
src/net/sourceforge/plantuml/project3/Subject.java
Normal file
36
src/net/sourceforge/plantuml/project3/Subject.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
|
||||
public interface Subject {
|
||||
|
||||
}
|
46
src/net/sourceforge/plantuml/project3/SubjectPattern.java
Normal file
46
src/net/sourceforge/plantuml/project3/SubjectPattern.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public interface SubjectPattern {
|
||||
|
||||
public Collection<VerbPattern> getVerbs();
|
||||
|
||||
public Subject getSubject(GanttDiagram project, RegexResult arg);
|
||||
|
||||
public IRegex toRegex();
|
||||
|
||||
}
|
56
src/net/sourceforge/plantuml/project3/SubjectTask.java
Normal file
56
src/net/sourceforge/plantuml/project3/SubjectTask.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public class SubjectTask implements SubjectPattern {
|
||||
|
||||
public Collection<VerbPattern> getVerbs() {
|
||||
return Arrays.<VerbPattern> asList(new VerbLasts(), new VerbStarts(), new VerbHappens(), new VerbEnds(),
|
||||
new VerbIsColored());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\]");
|
||||
}
|
||||
|
||||
public Subject getSubject(GanttDiagram project, RegexResult arg) {
|
||||
final String s = arg.get("SUBJECT", 0);
|
||||
return project.getTask(new TaskCode(s));
|
||||
}
|
||||
|
||||
}
|
55
src/net/sourceforge/plantuml/project3/Task.java
Normal file
55
src/net/sourceforge/plantuml/project3/Task.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public interface Task extends Subject {
|
||||
|
||||
public TaskCode getCode();
|
||||
|
||||
public Instant getStart();
|
||||
|
||||
public Instant getEnd();
|
||||
|
||||
public Duration getDuration();
|
||||
|
||||
public void setStart(Instant start);
|
||||
|
||||
public void setEnd(Instant end);
|
||||
|
||||
public void setDuration(Duration duration);
|
||||
|
||||
public void setTaskDraw(TaskDraw taskDraw);
|
||||
|
||||
public TaskDraw getTaskDraw();
|
||||
|
||||
public void setColors(ComplementColors colors);
|
||||
|
||||
}
|
40
src/net/sourceforge/plantuml/project3/TaskAttribute.java
Normal file
40
src/net/sourceforge/plantuml/project3/TaskAttribute.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public enum TaskAttribute {
|
||||
START, END, DURATION;
|
||||
|
||||
public static TaskAttribute fromString(String value) {
|
||||
return valueOf(value.toUpperCase());
|
||||
}
|
||||
|
||||
}
|
88
src/net/sourceforge/plantuml/project3/TaskCode.java
Normal file
88
src/net/sourceforge/plantuml/project3/TaskCode.java
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
|
||||
public class TaskCode {
|
||||
|
||||
private final List<String> hierarchy;
|
||||
|
||||
public TaskCode(String code) {
|
||||
this.hierarchy = Arrays.asList(code.split("/"));
|
||||
}
|
||||
|
||||
public boolean startsWith(TaskCode other) {
|
||||
if (other.hierarchy.size() > this.hierarchy.size()) {
|
||||
return false;
|
||||
}
|
||||
assert other.hierarchy.size() <= this.hierarchy.size();
|
||||
final List<String> sub = this.hierarchy.subList(0, other.hierarchy.size());
|
||||
return sub.equals(other.hierarchy);
|
||||
}
|
||||
|
||||
private TaskCode(List<String> hierarchy) {
|
||||
this.hierarchy = hierarchy;
|
||||
}
|
||||
|
||||
public TaskCode truncateHierarchy(int size) {
|
||||
return new TaskCode(this.hierarchy.subList(0, size));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hierarchy.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object arg) {
|
||||
final TaskCode other = (TaskCode) arg;
|
||||
return this.hierarchy.equals(other.hierarchy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return hierarchy.toString();
|
||||
}
|
||||
|
||||
public Display getSimpleDisplay() {
|
||||
final String last = hierarchy.get(hierarchy.size() - 1);
|
||||
return Display.getWithNewlines(last);
|
||||
}
|
||||
|
||||
public int getHierarchySize() {
|
||||
return hierarchy.size();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class TaskCodeSimpleOrder implements Comparator<TaskCode> {
|
||||
|
||||
private final List<TaskCode> order;
|
||||
private final int hierarchySize;
|
||||
|
||||
public TaskCodeSimpleOrder(Collection<TaskCode> order, int hierarchySize) {
|
||||
this.order = new ArrayList<TaskCode>(order);
|
||||
this.hierarchySize = hierarchySize;
|
||||
for (TaskCode code : order) {
|
||||
if (code.getHierarchySize() != hierarchySize) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int compare(TaskCode code1, TaskCode code2) {
|
||||
if (code1.getHierarchySize() < hierarchySize) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (code2.getHierarchySize() < hierarchySize) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
code1 = code1.truncateHierarchy(hierarchySize);
|
||||
code2 = code2.truncateHierarchy(hierarchySize);
|
||||
final int idx1 = order.indexOf(code1);
|
||||
final int idx2 = order.indexOf(code2);
|
||||
return idx1 - idx2;
|
||||
}
|
||||
}
|
144
src/net/sourceforge/plantuml/project3/TaskDraw.java
Normal file
144
src/net/sourceforge/plantuml/project3/TaskDraw.java
Normal file
|
@ -0,0 +1,144 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class TaskDraw implements UDrawable {
|
||||
|
||||
private final Task task;
|
||||
private final TimeScale timeScale;
|
||||
private final double y;
|
||||
private ComplementColors colors;
|
||||
|
||||
private final double margin = 2;
|
||||
|
||||
public TaskDraw(Task task, TimeScale timeScale, double y) {
|
||||
this.y = y;
|
||||
this.task = task;
|
||||
this.timeScale = timeScale;
|
||||
}
|
||||
|
||||
public TextBlock getTitle() {
|
||||
return task.getCode().getSimpleDisplay()
|
||||
.create(getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
final UFont font = new UFont("Serif", Font.PLAIN, 11);
|
||||
return new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLACK, false);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final double start = timeScale.getPixel(task.getStart());
|
||||
final UShape rect = getShape();
|
||||
|
||||
ug = applyColors(ug);
|
||||
ug.apply(new UTranslate(start + margin, margin)).draw(rect);
|
||||
}
|
||||
|
||||
private UGraphic applyColors(UGraphic ug) {
|
||||
if (colors != null && colors.isOk()) {
|
||||
return colors.apply(ug);
|
||||
}
|
||||
if (isDiamond()) {
|
||||
return ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK));
|
||||
}
|
||||
return ug.apply(new UChangeColor(HtmlColorUtils.BLUE)).apply(new UChangeBackColor(HtmlColorUtils.COL_84BE84));
|
||||
}
|
||||
|
||||
private UShape getShape() {
|
||||
if (isDiamond()) {
|
||||
return getDiamond();
|
||||
}
|
||||
final Instant instantStart = task.getStart();
|
||||
final Instant instantEnd = task.getEnd();
|
||||
final double start = timeScale.getPixel(instantStart);
|
||||
final double end = timeScale.getPixel(instantEnd.increment());
|
||||
return new URectangle(end - start - 2 * margin, getHeight() - 2 * margin, 8, 8);
|
||||
}
|
||||
|
||||
private boolean isDiamond() {
|
||||
final Instant instantStart = task.getStart();
|
||||
final Instant instantEnd = task.getEnd();
|
||||
return instantStart.compareTo(instantEnd) == 0;
|
||||
}
|
||||
|
||||
private UShape getDiamond() {
|
||||
final double h = getHeight() - 2 * margin;
|
||||
final UPolygon result = new UPolygon();
|
||||
result.addPoint(h / 2, 0);
|
||||
result.addPoint(h, h / 2);
|
||||
result.addPoint(h / 2, h);
|
||||
result.addPoint(0, h / 2);
|
||||
return result;
|
||||
// return result.translate(2, 2);
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getY(Direction direction) {
|
||||
if (direction == Direction.UP) {
|
||||
return y;
|
||||
}
|
||||
if (direction == Direction.DOWN) {
|
||||
return y + getHeight();
|
||||
}
|
||||
return y + getHeight() / 2;
|
||||
}
|
||||
|
||||
public void setColors(ComplementColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
}
|
97
src/net/sourceforge/plantuml/project3/TaskImpl.java
Normal file
97
src/net/sourceforge/plantuml/project3/TaskImpl.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public class TaskImpl implements Task {
|
||||
|
||||
private final TaskCode code;
|
||||
private final Solver solver = new Solver();
|
||||
|
||||
public TaskImpl(TaskCode code) {
|
||||
this.code = code;
|
||||
setStart(new InstantDay(0));
|
||||
setDuration(new DurationDay(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return code.toString();
|
||||
}
|
||||
|
||||
public String debug() {
|
||||
return "" + getStart() + " ---> " + getEnd() + " [" + getDuration() + "]";
|
||||
}
|
||||
|
||||
public TaskCode getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Instant getStart() {
|
||||
return (Instant) solver.getData(TaskAttribute.START);
|
||||
}
|
||||
|
||||
public Instant getEnd() {
|
||||
return (Instant) solver.getData(TaskAttribute.END);
|
||||
}
|
||||
|
||||
public Duration getDuration() {
|
||||
return (Duration) solver.getData(TaskAttribute.DURATION);
|
||||
}
|
||||
|
||||
public void setStart(Instant start) {
|
||||
solver.setData(TaskAttribute.START, start);
|
||||
}
|
||||
|
||||
public void setEnd(Instant end) {
|
||||
solver.setData(TaskAttribute.END, end);
|
||||
}
|
||||
|
||||
public void setDuration(Duration duration) {
|
||||
solver.setData(TaskAttribute.DURATION, duration);
|
||||
}
|
||||
|
||||
private TaskDraw taskDraw;
|
||||
private ComplementColors colors;
|
||||
|
||||
public void setTaskDraw(TaskDraw taskDraw) {
|
||||
taskDraw.setColors(colors);
|
||||
this.taskDraw = taskDraw;
|
||||
}
|
||||
|
||||
public TaskDraw getTaskDraw() {
|
||||
return taskDraw;
|
||||
}
|
||||
|
||||
public void setColors(ComplementColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
}
|
103
src/net/sourceforge/plantuml/project3/TaskInstant.java
Normal file
103
src/net/sourceforge/plantuml/project3/TaskInstant.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public class TaskInstant implements Complement {
|
||||
|
||||
private final Task task;
|
||||
private final TaskAttribute attribute;
|
||||
private final int delta;
|
||||
|
||||
public TaskInstant(Task task, TaskAttribute attribute) {
|
||||
this(task, attribute, 0);
|
||||
}
|
||||
|
||||
private TaskInstant(Task task, TaskAttribute attribute, int delta) {
|
||||
this.task = task;
|
||||
this.attribute = attribute;
|
||||
this.delta = delta;
|
||||
if (attribute != TaskAttribute.START && attribute != TaskAttribute.END) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public TaskInstant withDelta(int newDelta) {
|
||||
return new TaskInstant(task, attribute, newDelta);
|
||||
}
|
||||
|
||||
private Instant manageDelta(Instant value) {
|
||||
if (delta > 0) {
|
||||
for (int i = 0; i < delta; i++) {
|
||||
value = value.increment();
|
||||
}
|
||||
}
|
||||
if (delta < 0) {
|
||||
for (int i = 0; i < -delta; i++) {
|
||||
value = value.decrement();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public Instant getInstantPrecise() {
|
||||
if (attribute == TaskAttribute.START) {
|
||||
return manageDelta(task.getStart());
|
||||
}
|
||||
if (attribute == TaskAttribute.END) {
|
||||
return manageDelta(task.getEnd().increment());
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public Instant getInstantTheorical() {
|
||||
if (attribute == TaskAttribute.START) {
|
||||
return manageDelta(task.getStart());
|
||||
}
|
||||
if (attribute == TaskAttribute.END) {
|
||||
return manageDelta(task.getEnd());
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return attribute.toString() + " of " + task;
|
||||
}
|
||||
|
||||
public final Task getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public final TaskAttribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
}
|
42
src/net/sourceforge/plantuml/project3/TimeScale.java
Normal file
42
src/net/sourceforge/plantuml/project3/TimeScale.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public class TimeScale {
|
||||
|
||||
private final double scale = 16.0;
|
||||
|
||||
public double getPixel(Instant instant) {
|
||||
final int day = ((InstantDay) instant).getNumDay();
|
||||
return day * scale;
|
||||
}
|
||||
|
||||
}
|
35
src/net/sourceforge/plantuml/project3/Value.java
Normal file
35
src/net/sourceforge/plantuml/project3/Value.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
public interface Value {
|
||||
|
||||
}
|
39
src/net/sourceforge/plantuml/project3/Verb.java
Normal file
39
src/net/sourceforge/plantuml/project3/Verb.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
|
||||
public interface Verb {
|
||||
|
||||
public CommandExecutionResult execute(Subject subject, Complement complement);
|
||||
|
||||
}
|
64
src/net/sourceforge/plantuml/project3/VerbEnds.java
Normal file
64
src/net/sourceforge/plantuml/project3/VerbEnds.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class VerbEnds implements VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements() {
|
||||
return Arrays.<ComplementPattern> asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexLeaf("ends");
|
||||
}
|
||||
|
||||
public Verb getVerb(final GanttDiagram project, RegexResult arg) {
|
||||
return new Verb() {
|
||||
public CommandExecutionResult execute(Subject subject, Complement complement) {
|
||||
final Task task = (Task) subject;
|
||||
final TaskInstant when = (TaskInstant) complement;
|
||||
task.setEnd(when.getInstantPrecise().decrement());
|
||||
project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.END)));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
64
src/net/sourceforge/plantuml/project3/VerbHappens.java
Normal file
64
src/net/sourceforge/plantuml/project3/VerbHappens.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class VerbHappens implements VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements() {
|
||||
return Arrays.<ComplementPattern> asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexLeaf("happens");
|
||||
}
|
||||
|
||||
public Verb getVerb(GanttDiagram project, RegexResult arg) {
|
||||
return new Verb() {
|
||||
public CommandExecutionResult execute(Subject subject, Complement complement) {
|
||||
final Task task = (Task) subject;
|
||||
final TaskInstant when = (TaskInstant) complement;
|
||||
task.setDuration(new DurationDay(1));
|
||||
task.setStart(when.getInstantTheorical());
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
62
src/net/sourceforge/plantuml/project3/VerbIsColored.java
Normal file
62
src/net/sourceforge/plantuml/project3/VerbIsColored.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class VerbIsColored implements VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements() {
|
||||
return Arrays.<ComplementPattern> asList(new ComplementInColors());
|
||||
}
|
||||
|
||||
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) {
|
||||
final Task task = (Task) subject;
|
||||
final ComplementColors colors = (ComplementColors) complement;
|
||||
task.setColors(colors);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
62
src/net/sourceforge/plantuml/project3/VerbLasts.java
Normal file
62
src/net/sourceforge/plantuml/project3/VerbLasts.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class VerbLasts implements VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements() {
|
||||
return Arrays.<ComplementPattern> asList(new ComplementSeveralDays());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexLeaf("lasts");
|
||||
}
|
||||
|
||||
public Verb getVerb(GanttDiagram project, RegexResult arg) {
|
||||
return new Verb() {
|
||||
public CommandExecutionResult execute(Subject subject, Complement complement) {
|
||||
final Task task = (Task) subject;
|
||||
final Duration duration = (Duration) complement;
|
||||
task.setDuration(duration);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
46
src/net/sourceforge/plantuml/project3/VerbPattern.java
Normal file
46
src/net/sourceforge/plantuml/project3/VerbPattern.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public interface VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements();
|
||||
|
||||
public Verb getVerb(GanttDiagram project, RegexResult arg);
|
||||
|
||||
public IRegex toRegex();
|
||||
|
||||
}
|
63
src/net/sourceforge/plantuml/project3/VerbStarts.java
Normal file
63
src/net/sourceforge/plantuml/project3/VerbStarts.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.project3;
|
||||
|
||||
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;
|
||||
|
||||
public class VerbStarts implements VerbPattern {
|
||||
|
||||
public Collection<ComplementPattern> getComplements() {
|
||||
return Arrays.<ComplementPattern> asList(new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
|
||||
}
|
||||
|
||||
public IRegex toRegex() {
|
||||
return new RegexLeaf("starts");
|
||||
}
|
||||
|
||||
public Verb getVerb(final GanttDiagram project, RegexResult arg) {
|
||||
return new Verb() {
|
||||
public CommandExecutionResult execute(Subject subject, Complement complement) {
|
||||
final Task task = (Task) subject;
|
||||
final TaskInstant when = (TaskInstant) complement;
|
||||
task.setStart(when.getInstantPrecise());
|
||||
project.addContraint(new GanttConstraint(when, new TaskInstant(task, TaskAttribute.START)));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
|
@ -62,8 +62,8 @@ public enum VisibilityModifier {
|
|||
private final ColorParam foregroundParam;
|
||||
private final ColorParam backgroundParam;
|
||||
|
||||
public static String regexForVisibilityCharacter() {
|
||||
return "[-#+~*]";
|
||||
public static String regexForVisibilityCharacterInClassName() {
|
||||
return "[-#+~]";
|
||||
}
|
||||
|
||||
private VisibilityModifier(ColorParam foreground, ColorParam background) {
|
||||
|
@ -141,8 +141,8 @@ public enum VisibilityModifier {
|
|||
|
||||
case IE_MANDATORY:
|
||||
drawCircle(ug, true, size, x, y);
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -182,7 +182,14 @@ public enum VisibilityModifier {
|
|||
ug.apply(new UTranslate(x + 1, y)).draw(poly);
|
||||
}
|
||||
|
||||
public static boolean isVisibilityCharacter(char c) {
|
||||
public static boolean isVisibilityCharacter(CharSequence s) {
|
||||
if (s.length() <= 2) {
|
||||
return false;
|
||||
}
|
||||
final char c = s.charAt(0);
|
||||
if (s.charAt(1) == c) {
|
||||
return false;
|
||||
}
|
||||
if (c == '-') {
|
||||
return true;
|
||||
}
|
||||
|
@ -201,7 +208,14 @@ public enum VisibilityModifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static VisibilityModifier getVisibilityModifier(char c, boolean isField) {
|
||||
public static VisibilityModifier getVisibilityModifier(CharSequence s, boolean isField) {
|
||||
if (s.length() <= 2) {
|
||||
return null;
|
||||
}
|
||||
final char c = s.charAt(0);
|
||||
if (s.charAt(1) == c) {
|
||||
return null;
|
||||
}
|
||||
if (isField) {
|
||||
return getVisibilityModifierForField(c);
|
||||
}
|
||||
|
@ -223,7 +237,7 @@ public enum VisibilityModifier {
|
|||
}
|
||||
if (c == '*') {
|
||||
return VisibilityModifier.IE_MANDATORY;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -242,7 +256,7 @@ public enum VisibilityModifier {
|
|||
}
|
||||
if (c == '*') {
|
||||
return VisibilityModifier.IE_MANDATORY;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,12 +69,12 @@ public class Control extends AbstractTextBlock implements TextBlock {
|
|||
ug = ug.apply(new UChangeBackColor(symbolContext.getForeColor()));
|
||||
final UPolygon polygon = new UPolygon();
|
||||
polygon.addPoint(0, 0);
|
||||
final int xAile = 6;
|
||||
final int yOuverture = 5;
|
||||
polygon.addPoint(xAile, -yOuverture);
|
||||
final int xWing = 6;
|
||||
final int yAperture = 5;
|
||||
polygon.addPoint(xWing, -yAperture);
|
||||
final int xContact = 4;
|
||||
polygon.addPoint(xContact, 0);
|
||||
polygon.addPoint(xAile, yOuverture);
|
||||
polygon.addPoint(xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
|
||||
ug.apply(new UTranslate(x + radius - xContact, y)).draw(polygon);
|
||||
|
|
|
@ -75,6 +75,7 @@ import net.sourceforge.plantuml.posimo.PositionableUtils;
|
|||
import net.sourceforge.plantuml.svek.SvekUtils.PointListIterator;
|
||||
import net.sourceforge.plantuml.svek.extremity.Extremity;
|
||||
import net.sourceforge.plantuml.svek.extremity.ExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryExtends;
|
||||
import net.sourceforge.plantuml.svek.image.EntityImageNoteLink;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
|
@ -448,6 +449,9 @@ public class Line implements Moveable, Hideable {
|
|||
// System.err.println("angle=" + angle * 180 / Math.PI);
|
||||
return extremityFactory.createUDrawable(center, angle, null);
|
||||
}
|
||||
if (decor == LinkDecor.EXTENDS) {
|
||||
return new ExtremityFactoryExtends(backgroundColor).createUDrawable(center, angle, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,12 +71,12 @@ class ExtremityArrow extends Extremity {
|
|||
|
||||
private int buildPolygon() {
|
||||
polygon.addPoint(0, 0);
|
||||
final int xAile = 9;
|
||||
final int yOuverture = 4;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
final int xWing = 9;
|
||||
final int yAperture = 4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
final int xContact = 5;
|
||||
polygon.addPoint(-xContact, 0);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
return xContact;
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@ class ExtremityArrowAndCircle extends Extremity {
|
|||
angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
this.dest = new Point2D.Double(p1.getX(), p1.getY());
|
||||
final int xAile = 9;
|
||||
final int yOuverture = 4;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
final int xWing = 9;
|
||||
final int yAperture = 4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
final int xContact = 5;
|
||||
polygon.addPoint(-xContact, 0);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(angle + Math.PI / 2);
|
||||
polygon = polygon.translate(p1.getX() + radius * Math.sin(angle), p1.getY() - radius * Math.cos(angle));
|
||||
|
|
|
@ -56,14 +56,14 @@ class ExtremityCircleCrowfoot extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final int xAile = 8;
|
||||
final int yOuverture = 6;
|
||||
final int xWing = 8;
|
||||
final int yAperture = 6;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
Point2D middle = new Point2D.Double(0, 0);
|
||||
Point2D left = new Point2D.Double(0, -yOuverture);
|
||||
Point2D base = new Point2D.Double(-xAile, 0);
|
||||
Point2D right = new Point2D.Double(0, yOuverture);
|
||||
Point2D circleBase = new Point2D.Double(-xAile-radius-2, 0);
|
||||
Point2D left = new Point2D.Double(0, -yAperture);
|
||||
Point2D base = new Point2D.Double(-xWing, 0);
|
||||
Point2D right = new Point2D.Double(0, yAperture);
|
||||
Point2D circleBase = new Point2D.Double(-xWing-radius-2, 0);
|
||||
rotate.transform(left, left);
|
||||
rotate.transform(base, base);
|
||||
rotate.transform(right, right);
|
||||
|
|
|
@ -56,14 +56,14 @@ class ExtremityCircleLine extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final int xAile = 4;
|
||||
final int xWing = 4;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
Point2D middle = new Point2D.Double(0, 0);
|
||||
Point2D base = new Point2D.Double(-xAile-radius-3, 0);
|
||||
Point2D circleBase = new Point2D.Double(-xAile-radius-3, 0);
|
||||
Point2D base = new Point2D.Double(-xWing-radius-3, 0);
|
||||
Point2D circleBase = new Point2D.Double(-xWing-radius-3, 0);
|
||||
|
||||
Point2D lineTop = new Point2D.Double(-xAile, -lineHeight);
|
||||
Point2D lineBottom = new Point2D.Double(-xAile, lineHeight);
|
||||
Point2D lineTop = new Point2D.Double(-xWing, -lineHeight);
|
||||
Point2D lineBottom = new Point2D.Double(-xWing, lineHeight);
|
||||
|
||||
rotate.transform(lineTop, lineTop);
|
||||
rotate.transform(lineBottom, lineBottom);
|
||||
|
|
|
@ -56,13 +56,13 @@ class ExtremityCrowfoot extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final int xAile = 8;
|
||||
final int yOuverture = 8;
|
||||
final int xWing = 8;
|
||||
final int yAperture = 8;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
Point2D middle = new Point2D.Double(0, 0);
|
||||
Point2D left = new Point2D.Double(0, -yOuverture);
|
||||
Point2D base = new Point2D.Double(-xAile, 0);
|
||||
Point2D right = new Point2D.Double(0, yOuverture);
|
||||
Point2D left = new Point2D.Double(0, -yAperture);
|
||||
Point2D base = new Point2D.Double(-xWing, 0);
|
||||
Point2D right = new Point2D.Double(0, yAperture);
|
||||
rotate.transform(left, left);
|
||||
rotate.transform(base, base);
|
||||
rotate.transform(right, right);
|
||||
|
|
|
@ -55,11 +55,11 @@ class ExtremityDiamond extends Extremity {
|
|||
this.contact = new Point2D.Double(p1.getX(), p1.getY());
|
||||
angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
final int xAile = 6;
|
||||
final int yOuverture = 4;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
polygon.addPoint(-xAile * 2, 0);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
final int xWing = 6;
|
||||
final int yAperture = 4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
polygon.addPoint(-xWing * 2, 0);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(angle + Math.PI / 2);
|
||||
polygon = polygon.translate(p1.getX(), p1.getY());
|
||||
|
|
|
@ -54,15 +54,15 @@ class ExtremityDoubleLine extends Extremity {
|
|||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final int xAile = 4;
|
||||
final int xWing = 4;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
Point2D firstLineTop = new Point2D.Double(-xAile, -lineHeight);
|
||||
Point2D firstLineBottom = new Point2D.Double(-xAile, lineHeight);
|
||||
Point2D secondLineTop = new Point2D.Double(-xAile - 3, -lineHeight);
|
||||
Point2D secondLineBottom = new Point2D.Double(-xAile - 3, lineHeight);
|
||||
Point2D firstLineTop = new Point2D.Double(-xWing, -lineHeight);
|
||||
Point2D firstLineBottom = new Point2D.Double(-xWing, lineHeight);
|
||||
Point2D secondLineTop = new Point2D.Double(-xWing - 3, -lineHeight);
|
||||
Point2D secondLineBottom = new Point2D.Double(-xWing - 3, lineHeight);
|
||||
|
||||
Point2D middle = new Point2D.Double(0, 0);
|
||||
Point2D base = new Point2D.Double(-xAile - 4, 0);
|
||||
Point2D base = new Point2D.Double(-xWing - 4, 0);
|
||||
|
||||
rotate.transform(middle, middle);
|
||||
rotate.transform(base, base);
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.svek.extremity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
|
||||
class ExtremityExtends extends Extremity {
|
||||
|
||||
private UPolygon polygon = new UPolygon();
|
||||
private final HtmlColor fill;
|
||||
private final Point2D contact;
|
||||
|
||||
@Override
|
||||
public Point2D somePoint() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public ExtremityExtends(Point2D p1, double angle, HtmlColor backgroundColor) {
|
||||
this.fill = backgroundColor;
|
||||
this.contact = new Point2D.Double(p1.getX(), p1.getY());
|
||||
angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
final double xWing = 19;// 8 * 2.4;
|
||||
final double yAperture = 7;// 3 * 2.4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(angle + Math.PI / 2);
|
||||
polygon = polygon.translate(p1.getX(), p1.getY());
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = ug.apply(new UChangeBackColor(fill));
|
||||
ug.draw(polygon);
|
||||
}
|
||||
|
||||
}
|
|
@ -38,6 +38,7 @@ import net.sourceforge.plantuml.svek.Side;
|
|||
|
||||
public class ExtremityFactoryArrow extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
@Override
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
return new ExtremityArrow(p0, angle);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@ import net.sourceforge.plantuml.svek.Side;
|
|||
|
||||
public class ExtremityFactoryCircleConnect extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
@Override
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
angle -= Math.PI / 2;
|
||||
return new ExtremityCircleConnect(p0, angle);
|
||||
}
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
return new ExtremityCircleConnect(p1, ortho);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.svek.extremity;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryExtends extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
private final HtmlColor backgroundColor;
|
||||
|
||||
public ExtremityFactoryExtends(HtmlColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
return new ExtremityExtends(p0, angle - Math.PI / 2, backgroundColor);
|
||||
}
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
throw new UnsupportedOperationException();
|
||||
// final double ortho = atan2(p0, p2);
|
||||
// return new ExtremityExtends(p1, ortho, true);
|
||||
}
|
||||
|
||||
}
|
|
@ -38,6 +38,7 @@ import net.sourceforge.plantuml.svek.Side;
|
|||
|
||||
public class ExtremityFactorySquarre extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
@Override
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
return new ExtremitySquarre(p0);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ import net.sourceforge.plantuml.svek.Side;
|
|||
|
||||
public class ExtremityFactoryTriangle extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
@Override
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
return new ExtremityTriangle(p0, angle - Math.PI / 2, false);
|
||||
}
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
|
|
|
@ -56,15 +56,15 @@ class ExtremityLineCrowfoot extends Extremity {
|
|||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
||||
final int xAile = 8;
|
||||
final int yOuverture = 6;
|
||||
final int xWing = 8;
|
||||
final int yAperture = 6;
|
||||
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
|
||||
Point2D middle = new Point2D.Double(0, 0);
|
||||
Point2D left = new Point2D.Double(0, -yOuverture);
|
||||
Point2D base = new Point2D.Double(-xAile, 0);
|
||||
Point2D lineTop = new Point2D.Double(-xAile-2, -lineHeight);
|
||||
Point2D lineBottom = new Point2D.Double(-xAile-2, lineHeight);
|
||||
Point2D right = new Point2D.Double(0, yOuverture);
|
||||
Point2D left = new Point2D.Double(0, -yAperture);
|
||||
Point2D base = new Point2D.Double(-xWing, 0);
|
||||
Point2D lineTop = new Point2D.Double(-xWing-2, -lineHeight);
|
||||
Point2D lineBottom = new Point2D.Double(-xWing-2, lineHeight);
|
||||
Point2D right = new Point2D.Double(0, yAperture);
|
||||
rotate.transform(left, left);
|
||||
rotate.transform(base, base);
|
||||
rotate.transform(right, right);
|
||||
|
|
|
@ -58,12 +58,12 @@ class ExtremityStateLine1 extends Extremity {
|
|||
this.angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
this.dest = new Point2D.Double(center.getX(), center.getY());
|
||||
final int xAile = 9;
|
||||
final int yOuverture = 4;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
final int xWing = 9;
|
||||
final int yAperture = 4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
final int xContact = 5;
|
||||
polygon.addPoint(-xContact, 0);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(this.angle);
|
||||
polygon = polygon.translate(center.getX(), center.getY());
|
||||
|
|
|
@ -57,12 +57,12 @@ class ExtremityStateLine2 extends Extremity {
|
|||
this.angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
this.dest = new Point2D.Double(center.getX(), center.getY());
|
||||
final int xAile = 9;
|
||||
final int yOuverture = 4;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
final int xWing = 9;
|
||||
final int yAperture = 4;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
final int xContact = 5;
|
||||
polygon.addPoint(-xContact, 0);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(this.angle);
|
||||
polygon = polygon.translate(center.getX(), center.getY());
|
||||
|
|
|
@ -53,10 +53,10 @@ class ExtremityTriangle extends Extremity {
|
|||
this.contact = new Point2D.Double(p1.getX(), p1.getY());
|
||||
angle = manageround(angle);
|
||||
polygon.addPoint(0, 0);
|
||||
final int xAile = 8;
|
||||
final int yOuverture = 3;
|
||||
polygon.addPoint(-xAile, -yOuverture);
|
||||
polygon.addPoint(-xAile, yOuverture);
|
||||
final int xWing = 8;
|
||||
final int yAperture = 3;
|
||||
polygon.addPoint(-xWing, -yAperture);
|
||||
polygon.addPoint(-xWing, yAperture);
|
||||
polygon.addPoint(0, 0);
|
||||
polygon.rotate(angle + Math.PI / 2);
|
||||
polygon = polygon.translate(p1.getX(), p1.getY());
|
||||
|
|
|
@ -430,6 +430,10 @@ public class SvgGraphics {
|
|||
elt.setAttribute("text-decoration", textDecoration);
|
||||
}
|
||||
if (fontFamily != null) {
|
||||
// http://plantuml.sourceforge.net/qa/?qa=5432/svg-monospace-output-has-wrong-font-family
|
||||
if ("monospaced".equalsIgnoreCase(fontFamily)) {
|
||||
fontFamily = "monospace";
|
||||
}
|
||||
elt.setAttribute("font-family", fontFamily);
|
||||
}
|
||||
if (textBackColor != null) {
|
||||
|
|
55
src/net/sourceforge/plantuml/timingdiagram/ChangeState.java
Normal file
55
src/net/sourceforge/plantuml/timingdiagram/ChangeState.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
public class ChangeState implements Comparable<ChangeState> {
|
||||
|
||||
private final TimeTick when;
|
||||
private final String state;
|
||||
|
||||
public ChangeState(TimeTick when, String state) {
|
||||
this.when = when;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int compareTo(ChangeState other) {
|
||||
return this.when.compareTo(other.when);
|
||||
}
|
||||
|
||||
public final TimeTick getWhen() {
|
||||
return when;
|
||||
}
|
||||
|
||||
public final String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
36
src/net/sourceforge/plantuml/timingdiagram/Clock.java
Normal file
36
src/net/sourceforge/plantuml/timingdiagram/Clock.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
public interface Clock {
|
||||
|
||||
public TimeTick getNow();
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandAtTime extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
public CommandAtTime() {
|
||||
super(getRegexConcat());
|
||||
}
|
||||
|
||||
private static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
TimeTickBuilder.expressionAt("TIME"), //
|
||||
new RegexLeaf("[%s]*$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
|
||||
final TimeTick timeTick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram);
|
||||
diagram.addTime(timeTick);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandChangeState extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
public CommandChangeState() {
|
||||
super(getRegexConcat());
|
||||
}
|
||||
|
||||
private static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
|
||||
new RegexLeaf("[%s]*is[%s]*"), //
|
||||
new RegexLeaf("STATE", "(.*?)"), //
|
||||
new RegexLeaf("[%s]*$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
|
||||
final String code = arg.get("CODE", 0);
|
||||
final Player player = diagram.getPlayer(code);
|
||||
if (player == null) {
|
||||
return CommandExecutionResult.error("Unkown \"" + code + "\"");
|
||||
}
|
||||
final TimeTick now = diagram.getNow();
|
||||
player.setState(now, arg.get("STATE", 0));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandLifeLine extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
public CommandLifeLine() {
|
||||
super(getRegexConcat());
|
||||
}
|
||||
|
||||
private static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexLeaf("TYPE", //
|
||||
"(robust|concise)[%s]+"), //
|
||||
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
|
||||
new RegexLeaf("[%s]+as[%s]+"), //
|
||||
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
|
||||
final String code = arg.get("CODE", 0);
|
||||
final String full = arg.get("FULL", 0);
|
||||
final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase());
|
||||
diagram.createLifeLine(code, full, type);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandTimeMessage extends SingleLineCommand2<TimingDiagram> {
|
||||
|
||||
public CommandTimeMessage() {
|
||||
super(getRegexConcat());
|
||||
}
|
||||
|
||||
private static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexLeaf("PART1", "([\\p{L}0-9_.]+)"), //
|
||||
TimeTickBuilder.optionalExpressionAt("TIME1"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("ARROW", "(-+)\\>"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("PART2", "([\\p{L}0-9_.]+)"), //
|
||||
TimeTickBuilder.optionalExpressionAt("TIME2"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), new RegexLeaf("[%s]*$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
|
||||
final Player player1 = diagram.getPlayer(arg.get("PART1", 0));
|
||||
final Player player2 = diagram.getPlayer(arg.get("PART2", 0));
|
||||
final TimeTick tick1 = TimeTickBuilder.parseTimeTick("TIME1", arg, diagram);
|
||||
final TimeTick tick2 = TimeTickBuilder.parseTimeTick("TIME2", arg, diagram);
|
||||
diagram.createTimeMessage(player1, tick1, player2, tick2, arg.get("MESSAGE", 0));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
165
src/net/sourceforge/plantuml/timingdiagram/Histogram.java
Normal file
165
src/net/sourceforge/plantuml/timingdiagram/Histogram.java
Normal file
|
@ -0,0 +1,165 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class Histogram implements TimeDrawing {
|
||||
|
||||
private final List<ChangeState> changes = new ArrayList<ChangeState>();
|
||||
|
||||
private List<String> allStates = new ArrayList<String>();
|
||||
private final double stepHeight = 20;
|
||||
|
||||
private final ISkinParam skinParam;
|
||||
private final TimingRuler ruler;
|
||||
|
||||
public Histogram(TimingRuler ruler, ISkinParam skinParam) {
|
||||
this.ruler = ruler;
|
||||
this.skinParam = skinParam;
|
||||
}
|
||||
|
||||
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
|
||||
final double x = ruler.getPosInPixel(tick);
|
||||
final List<String> states = getStatesAt(tick);
|
||||
if (states.size() == 1) {
|
||||
final int num = getStateNumFor(states.get(0));
|
||||
return new IntricatedPoint(new Point2D.Double(x, num * stepHeight), new Point2D.Double(x, num * stepHeight));
|
||||
}
|
||||
assert states.size() == 2;
|
||||
final int num1 = getStateNumFor(states.get(0));
|
||||
final int num2 = getStateNumFor(states.get(1));
|
||||
assert num1 != num2;
|
||||
return new IntricatedPoint(new Point2D.Double(x, num1 * stepHeight), new Point2D.Double(x, num2 * stepHeight));
|
||||
// if (isTransition(tick)) {
|
||||
// return new IntricatedPoint(new Point2D.Double(x, state * stepHeight), new Point2D.Double(x, state
|
||||
// * stepHeight + stepHeight));
|
||||
// }
|
||||
// return new IntricatedPoint(new Point2D.Double(x, state * stepHeight), new Point2D.Double(x, state *
|
||||
// stepHeight));
|
||||
}
|
||||
|
||||
private int getStateNumFor(String state) {
|
||||
// final String state = getStateAt(tick);
|
||||
return allStates.size() - 1 - allStates.indexOf(state);
|
||||
}
|
||||
|
||||
private List<String> getStatesAt(TimeTick tick) {
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
if (changes.get(i).getWhen().compareTo(tick) == 0) {
|
||||
return Arrays.asList(changes.get(i - 1).getState(), changes.get(i).getState());
|
||||
}
|
||||
if (changes.get(i).getWhen().compareTo(tick) > 0) {
|
||||
return Collections.singletonList(changes.get(i - 1).getState());
|
||||
}
|
||||
}
|
||||
return Collections.singletonList(changes.get(changes.size() - 1).getState());
|
||||
}
|
||||
|
||||
public void addChange(ChangeState change) {
|
||||
final String state = change.getState();
|
||||
if (allStates.contains(state) == false) {
|
||||
allStates.add(state);
|
||||
}
|
||||
changes.add(change);
|
||||
}
|
||||
|
||||
private Point2D getPoint(int i) {
|
||||
final ChangeState change = changes.get(i);
|
||||
final double x = ruler.getPosInPixel(change.getWhen());
|
||||
return new Point2D.Double(x, yOfState(change.getState()));
|
||||
}
|
||||
|
||||
private double yOfState(String state) {
|
||||
return -stepHeight * allStates.indexOf(state);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = ug.apply(new UChangeColor(HtmlColorUtils.COL_038048)).apply(new UStroke(1.5));
|
||||
final UTranslate deltaY = new UTranslate(0, stepHeight * (allStates.size() - 1));
|
||||
// System.err.println("changes=" + changes);
|
||||
for (int i = 0; i < changes.size() - 1; i++) {
|
||||
final Point2D pt = getPoint(i);
|
||||
final Point2D pt2 = getPoint(i + 1);
|
||||
final double len = pt2.getX() - pt.getX();
|
||||
ug.apply(new UTranslate(pt).compose(deltaY)).draw(new ULine(len, 0));
|
||||
}
|
||||
final Point2D pt = getPoint(changes.size() - 1);
|
||||
final double len = ruler.getWidth() - pt.getX();
|
||||
ug.apply(new UTranslate(pt).compose(deltaY)).draw(new ULine(len, 0));
|
||||
|
||||
for (int i = 1; i < changes.size(); i++) {
|
||||
final Point2D before = getPoint(i - 1);
|
||||
final Point2D current = getPoint(i);
|
||||
ug.apply(new UTranslate(current).compose(deltaY)).draw(new ULine(0, before.getY() - current.getY()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
final Point2D ptLabel = getPoint(i);
|
||||
final TextBlock label = getStateTextBlock(changes.get(i).getState());
|
||||
final Dimension2D dim = label.calculateDimension(ug.getStringBounder());
|
||||
label.drawU(ug.apply(new UTranslate(ptLabel).compose(deltaY).compose(new UTranslate(2, -dim.getHeight()))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
return new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
|
||||
}
|
||||
|
||||
private TextBlock getStateTextBlock(String state) {
|
||||
final Display display = Display.getWithNewlines(state);
|
||||
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return stepHeight * allStates.size() + 10;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class IntricatedPoint {
|
||||
|
||||
private final Point2D pta;
|
||||
private final Point2D ptb;
|
||||
|
||||
public IntricatedPoint(Point2D pta, Point2D ptb) {
|
||||
this.pta = pta;
|
||||
this.ptb = ptb;
|
||||
}
|
||||
|
||||
public final Point2D getPointA() {
|
||||
return pta;
|
||||
}
|
||||
|
||||
public final Point2D getPointB() {
|
||||
return ptb;
|
||||
}
|
||||
|
||||
public IntricatedPoint translated(UTranslate translate) {
|
||||
return new IntricatedPoint(translate.getTranslated(pta), translate.getTranslated(ptb));
|
||||
}
|
||||
|
||||
}
|
146
src/net/sourceforge/plantuml/timingdiagram/Player.java
Normal file
146
src/net/sourceforge/plantuml/timingdiagram/Player.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class Player implements TextBlock, TimeProjected {
|
||||
|
||||
private final String code;
|
||||
private final Display full;
|
||||
private final TimingStyle type;
|
||||
private final ISkinParam skinParam;
|
||||
private final TimingRuler ruler;
|
||||
|
||||
private final Set<ChangeState> changes = new TreeSet<ChangeState>();
|
||||
|
||||
public Player(String code, String full, TimingStyle type, ISkinParam skinParam, TimingRuler ruler) {
|
||||
this.code = code;
|
||||
this.full = Display.getWithNewlines(full);
|
||||
this.type = type;
|
||||
this.skinParam = skinParam;
|
||||
this.ruler = ruler;
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
return new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final TextBlock title = getTitle();
|
||||
title.drawU(ug);
|
||||
final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
|
||||
drawLine(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(1.0)), -TimingDiagram.marginX1,
|
||||
dimTitle.getHeight() + 1, dimTitle.getWidth() + 1, dimTitle.getHeight() + 1,
|
||||
dimTitle.getWidth() + 1 + 10, 0);
|
||||
|
||||
getTimeDrawing().drawU(ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())));
|
||||
}
|
||||
|
||||
private void drawLine(UGraphic ug, double... coord) {
|
||||
for (int i = 0; i < coord.length - 2; i += 2) {
|
||||
final double x1 = coord[i];
|
||||
final double y1 = coord[i + 1];
|
||||
final double x2 = coord[i + 2];
|
||||
final double y2 = coord[i + 3];
|
||||
ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private UTranslate getTranslateForTimeDrawing(StringBounder stringBounder) {
|
||||
final TextBlock title = getTitle();
|
||||
return new UTranslate(0, title.calculateDimension(stringBounder).getHeight() * 2);
|
||||
}
|
||||
|
||||
private TextBlock getTitle() {
|
||||
return full.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
private TimeDrawing getTimeDrawing() {
|
||||
final TimeDrawing result;
|
||||
if (type == TimingStyle.ROBUST) {
|
||||
result = new Ribbon(ruler, skinParam);
|
||||
} else if (type == TimingStyle.CONCISE) {
|
||||
result = new Histogram(ruler, skinParam);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
for (ChangeState change : changes) {
|
||||
result.addChange(change);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
final TextBlock title = getTitle();
|
||||
final double width = ruler.getWidth();
|
||||
final double zoneHeight = getZoneHeight();
|
||||
return new Dimension2DDouble(width, title.calculateDimension(stringBounder).getHeight() * 2 + zoneHeight);
|
||||
}
|
||||
|
||||
private double getZoneHeight() {
|
||||
return getTimeDrawing().getHeight();
|
||||
}
|
||||
|
||||
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setState(TimeTick now, String state) {
|
||||
this.changes.add(new ChangeState(now, state));
|
||||
|
||||
}
|
||||
|
||||
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
|
||||
final IntricatedPoint point = getTimeDrawing().getTimeProjection(stringBounder, tick);
|
||||
final UTranslate translation = getTranslateForTimeDrawing(stringBounder);
|
||||
return point.translated(translation);
|
||||
}
|
||||
|
||||
}
|
142
src/net/sourceforge/plantuml/timingdiagram/Ribbon.java
Normal file
142
src/net/sourceforge/plantuml/timingdiagram/Ribbon.java
Normal file
|
@ -0,0 +1,142 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class Ribbon implements TimeDrawing {
|
||||
|
||||
private final List<ChangeState> changes = new ArrayList<ChangeState>();
|
||||
|
||||
private final double delta = 12;
|
||||
private final ISkinParam skinParam;
|
||||
private final TimingRuler ruler;
|
||||
|
||||
public Ribbon(TimingRuler ruler, ISkinParam skinParam) {
|
||||
this.ruler = ruler;
|
||||
this.skinParam = skinParam;
|
||||
}
|
||||
|
||||
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
|
||||
final double x = ruler.getPosInPixel(tick);
|
||||
final double y = delta * 0.5;
|
||||
for (ChangeState change : changes) {
|
||||
if (change.getWhen().compareTo(tick) == 0) {
|
||||
return new IntricatedPoint(new Point2D.Double(x, y), new Point2D.Double(x, y));
|
||||
}
|
||||
}
|
||||
return new IntricatedPoint(new Point2D.Double(x, y - delta), new Point2D.Double(x, y + delta));
|
||||
}
|
||||
|
||||
public void addChange(ChangeState change) {
|
||||
this.changes.add(change);
|
||||
}
|
||||
|
||||
private double getPosInPixel(ChangeState change) {
|
||||
return ruler.getPosInPixel(change.getWhen());
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
return new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
|
||||
}
|
||||
|
||||
private TextBlock getStateTextBlock(ChangeState state) {
|
||||
final Display display = Display.getWithNewlines(state.getState());
|
||||
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = ug.apply(new UTranslate(0, 0.5 * delta));
|
||||
|
||||
// System.err.println("changes=" + changes);
|
||||
for (int i = 0; i < changes.size() - 1; i++) {
|
||||
final double a = getPosInPixel(changes.get(i));
|
||||
final double b = getPosInPixel(changes.get(i + 1));
|
||||
assert b > a;
|
||||
draw1(ug.apply(new UTranslate(a, 0)), b - a, true);
|
||||
draw2(ug.apply(new UTranslate(a, 0)), b - a, true);
|
||||
}
|
||||
final double a = getPosInPixel(changes.get(changes.size() - 1));
|
||||
draw1(ug.apply(new UTranslate(a, 0)), ruler.getWidth() - a, false);
|
||||
draw2(ug.apply(new UTranslate(a, 0)), ruler.getWidth() - a, false);
|
||||
|
||||
for (ChangeState change : changes) {
|
||||
final TextBlock state = getStateTextBlock(change);
|
||||
final Dimension2D dim = state.calculateDimension(ug.getStringBounder());
|
||||
final double x = ruler.getPosInPixel(change.getWhen());
|
||||
state.drawU(ug.apply(new UTranslate(x + getDelta(), -dim.getHeight() / 2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void draw1(UGraphic ug, double len, boolean withEnd) {
|
||||
ug = ug.apply(new UChangeColor(HtmlColorUtils.COL_038048)).apply(new UStroke(1.5));
|
||||
ug.draw(new ULine(delta, delta));
|
||||
ug.apply(new UTranslate(delta, delta)).draw(new ULine(len - 2 * delta, 0));
|
||||
if (withEnd) {
|
||||
ug.apply(new UTranslate(len - delta, delta)).draw(new ULine(delta, -delta));
|
||||
}
|
||||
}
|
||||
|
||||
private void draw2(UGraphic ug, double len, boolean withEnd) {
|
||||
ug = ug.apply(new UChangeColor(HtmlColorUtils.COL_038048)).apply(new UStroke(1.5));
|
||||
ug.draw(new ULine(delta, -delta));
|
||||
ug.apply(new UTranslate(delta, -delta)).draw(new ULine(len - 2 * delta, 0));
|
||||
if (withEnd) {
|
||||
ug.apply(new UTranslate(len - delta, -delta)).draw(new ULine(delta, delta));
|
||||
}
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return 3 * delta;
|
||||
}
|
||||
|
||||
public double getDelta() {
|
||||
return delta;
|
||||
}
|
||||
|
||||
}
|
50
src/net/sourceforge/plantuml/timingdiagram/TickInPlayer.java
Normal file
50
src/net/sourceforge/plantuml/timingdiagram/TickInPlayer.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
public class TickInPlayer {
|
||||
|
||||
private final Player player;
|
||||
private final TimeTick tick;
|
||||
|
||||
public TickInPlayer(Player player, TimeTick tick) {
|
||||
this.player = player;
|
||||
this.tick = tick;
|
||||
}
|
||||
|
||||
public final Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public final TimeTick getTick() {
|
||||
return tick;
|
||||
}
|
||||
|
||||
}
|
140
src/net/sourceforge/plantuml/timingdiagram/TimeArrow.java
Normal file
140
src/net/sourceforge/plantuml/timingdiagram/TimeArrow.java
Normal file
|
@ -0,0 +1,140 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class TimeArrow implements UDrawable {
|
||||
|
||||
private final Point2D start;
|
||||
private final Point2D end;
|
||||
private final Display label;
|
||||
private final ISkinSimple spriteContainer;
|
||||
|
||||
public static TimeArrow create(IntricatedPoint pt1, IntricatedPoint pt2, Display label, ISkinSimple spriteContainer) {
|
||||
final TimeArrow arrow1 = new TimeArrow(pt1.getPointA(), pt2.getPointA(), label, spriteContainer);
|
||||
final TimeArrow arrow2 = new TimeArrow(pt1.getPointA(), pt2.getPointB(), label, spriteContainer);
|
||||
final TimeArrow arrow3 = new TimeArrow(pt1.getPointB(), pt2.getPointA(), label, spriteContainer);
|
||||
final TimeArrow arrow4 = new TimeArrow(pt1.getPointB(), pt2.getPointB(), label, spriteContainer);
|
||||
return shorter(arrow1, arrow2, arrow3, arrow4);
|
||||
}
|
||||
|
||||
private TimeArrow(Point2D start, Point2D end, Display label, ISkinSimple spriteContainer) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.label = label;
|
||||
this.spriteContainer = spriteContainer;
|
||||
}
|
||||
|
||||
private double getAngle() {
|
||||
return Math.atan2(end.getX() - start.getX(), end.getY() - start.getY());
|
||||
}
|
||||
|
||||
private static TimeArrow shorter(TimeArrow arrow1, TimeArrow arrow2) {
|
||||
if (arrow1.len() < arrow2.len()) {
|
||||
return arrow1;
|
||||
}
|
||||
return arrow2;
|
||||
}
|
||||
|
||||
private static TimeArrow shorter(TimeArrow arrow1, TimeArrow arrow2, TimeArrow arrow3, TimeArrow arrow4) {
|
||||
return shorter(shorter(arrow1, arrow2), shorter(arrow3, arrow4));
|
||||
}
|
||||
|
||||
private double len() {
|
||||
return start.distance(end);
|
||||
}
|
||||
|
||||
public TimeArrow translate(UTranslate translate) {
|
||||
return new TimeArrow(translate.getTranslated(start), translate.getTranslated(end), label, spriteContainer);
|
||||
}
|
||||
|
||||
private Point2D onCircle(double alpha, double radius) {
|
||||
final double x = end.getX() - Math.sin(alpha) * radius;
|
||||
final double y = end.getY() - Math.cos(alpha) * radius;
|
||||
return new Point2D.Double(x, y);
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
final UFont font = new UFont("Serif", Font.PLAIN, 14);
|
||||
return new FontConfiguration(font, HtmlColorUtils.BLUE, HtmlColorUtils.BLUE, false);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final double angle = getAngle();
|
||||
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLUE)).apply(new UStroke(1.5));
|
||||
final ULine line = new ULine(end.getX() - start.getX(), end.getY() - start.getY());
|
||||
ug.apply(new UTranslate(start)).draw(line);
|
||||
|
||||
final double delta = 20.0 * Math.PI / 180.0;
|
||||
final Point2D pt1 = onCircle(angle + delta, 8);
|
||||
final Point2D pt2 = onCircle(angle - delta, 8);
|
||||
|
||||
final UPolygon polygon = new UPolygon();
|
||||
polygon.addPoint(pt1.getX(), pt1.getY());
|
||||
polygon.addPoint(pt2.getX(), pt2.getY());
|
||||
polygon.addPoint(end.getX(), end.getY());
|
||||
|
||||
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLUE));
|
||||
ug.draw(polygon);
|
||||
|
||||
final TextBlock textLabel = label.create(getFontConfiguration(), HorizontalAlignment.LEFT, spriteContainer);
|
||||
double xText = (pt1.getX() + pt2.getX()) / 2;
|
||||
double yText = (pt1.getY() + pt2.getY()) / 2;
|
||||
if (start.getY() < end.getY()) {
|
||||
final Dimension2D dimLabel = textLabel.calculateDimension(ug.getStringBounder());
|
||||
yText -= dimLabel.getHeight();
|
||||
}
|
||||
textLabel.drawU(ug.apply(new UTranslate(xText, yText)));
|
||||
|
||||
// final double radius = 4;
|
||||
// final UTranslate forCirle = new UTranslate(end.getX() - radius, end.getY() - radius);
|
||||
// ug.apply(forCirle).draw(new UEllipse(2 * radius, 2 * radius));
|
||||
}
|
||||
|
||||
}
|
40
src/net/sourceforge/plantuml/timingdiagram/TimeDrawing.java
Normal file
40
src/net/sourceforge/plantuml/timingdiagram/TimeDrawing.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
|
||||
public interface TimeDrawing extends TimeProjected, UDrawable {
|
||||
|
||||
public double getHeight();
|
||||
|
||||
public void addChange(ChangeState change);
|
||||
|
||||
}
|
66
src/net/sourceforge/plantuml/timingdiagram/TimeMessage.java
Normal file
66
src/net/sourceforge/plantuml/timingdiagram/TimeMessage.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
|
||||
public class TimeMessage {
|
||||
|
||||
private final TickInPlayer tickInPlayer1;
|
||||
private final TickInPlayer tickInPlayer2;
|
||||
private final Display label;
|
||||
|
||||
public TimeMessage(TickInPlayer tickInPlayer1, TickInPlayer tickInPlayer2, String label) {
|
||||
this.tickInPlayer1 = tickInPlayer1;
|
||||
this.tickInPlayer2 = tickInPlayer2;
|
||||
this.label = Display.getWithNewlines(label);
|
||||
}
|
||||
|
||||
public final Player getPlayer1() {
|
||||
return tickInPlayer1.getPlayer();
|
||||
}
|
||||
|
||||
public final Player getPlayer2() {
|
||||
return tickInPlayer2.getPlayer();
|
||||
}
|
||||
|
||||
public final TimeTick getTick1() {
|
||||
return tickInPlayer1.getTick();
|
||||
}
|
||||
|
||||
public final TimeTick getTick2() {
|
||||
return tickInPlayer2.getTick();
|
||||
}
|
||||
|
||||
public final Display getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
|
||||
public interface TimeProjected {
|
||||
|
||||
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick);
|
||||
|
||||
}
|
48
src/net/sourceforge/plantuml/timingdiagram/TimeTick.java
Normal file
48
src/net/sourceforge/plantuml/timingdiagram/TimeTick.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
public class TimeTick implements Comparable<TimeTick> {
|
||||
|
||||
private final int time;
|
||||
|
||||
public TimeTick(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public final int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public int compareTo(TimeTick other) {
|
||||
return this.time - other.time;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
public class TimeTickBuilder {
|
||||
|
||||
private static final String REGEX = "@(\\+?)(\\d+)";
|
||||
|
||||
public static RegexLeaf expressionAt(String name) {
|
||||
return new RegexLeaf(name, REGEX);
|
||||
}
|
||||
|
||||
public static RegexLeaf optionalExpressionAt(String name) {
|
||||
return new RegexLeaf(name, "(?:" + REGEX + ")?");
|
||||
}
|
||||
|
||||
public static TimeTick parseTimeTick(String name, RegexResult arg, Clock clock) {
|
||||
final String number = arg.get(name, 1);
|
||||
if (number == null) {
|
||||
return clock.getNow();
|
||||
}
|
||||
final boolean isRelative = "+".equals(arg.get(name, 0));
|
||||
int value = Integer.parseInt(number);
|
||||
if (isRelative) {
|
||||
value += clock.getNow().getTime();
|
||||
}
|
||||
return new TimeTick(value);
|
||||
}
|
||||
|
||||
}
|
177
src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java
Normal file
177
src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class TimingDiagram extends UmlDiagram implements Clock {
|
||||
|
||||
private final Map<String, Player> players = new LinkedHashMap<String, Player>();
|
||||
private final List<TimeMessage> messages = new ArrayList<TimeMessage>();
|
||||
private final TimingRuler ruler = new TimingRuler(getSkinParam());
|
||||
private TimeTick now;
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
return new DiagramDescriptionImpl("(Timing Diagram)", getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UmlDiagramType getUmlDiagramType() {
|
||||
return UmlDiagramType.TIMING;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
final double dpiFactor = 1;
|
||||
final double margin = 10;
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), dpiFactor,
|
||||
fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), margin, margin,
|
||||
getAnimation());
|
||||
imageBuilder.setUDrawable(getUDrawable());
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
}
|
||||
|
||||
private UDrawable getUDrawable() {
|
||||
return new UDrawable() {
|
||||
public void drawU(UGraphic ug) {
|
||||
drawInternal(ug);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final double marginX1 = 5;
|
||||
private final double marginX2 = 5;
|
||||
|
||||
private void drawInternal(UGraphic ug) {
|
||||
final UTranslate lastTranslate = getUTranslateForPlayer(null, ug.getStringBounder());
|
||||
final double totalWith = ruler.getWidth() + marginX1 + marginX2;
|
||||
final ULine border = new ULine(0, lastTranslate.getDy());
|
||||
final UStroke borderStroke = new UStroke(1.7);
|
||||
ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(borderStroke).draw(border);
|
||||
ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(borderStroke).apply(new UTranslate(totalWith, 0))
|
||||
.draw(border);
|
||||
// ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(2.0)).draw(border);
|
||||
|
||||
ug = ug.apply(new UTranslate(marginX1, 0));
|
||||
|
||||
for (Player player : players.values()) {
|
||||
final UGraphic playerUg = ug.apply(getUTranslateForPlayer(player, ug.getStringBounder()));
|
||||
player.drawU(playerUg);
|
||||
playerUg.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(borderStroke)
|
||||
.apply(new UTranslate(-marginX1, 0)).draw(new ULine(totalWith, 0));
|
||||
}
|
||||
ruler.draw(ug.apply(lastTranslate));
|
||||
for (TimeMessage timeMessage : messages) {
|
||||
drawMessages(ug, timeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMessages(UGraphic ug, TimeMessage message) {
|
||||
final Player player1 = message.getPlayer1();
|
||||
final Player player2 = message.getPlayer2();
|
||||
|
||||
final UTranslate translate1 = getUTranslateForPlayer(player1, ug.getStringBounder());
|
||||
final UTranslate translate2 = getUTranslateForPlayer(player2, ug.getStringBounder());
|
||||
|
||||
final IntricatedPoint pt1 = player1.getTimeProjection(ug.getStringBounder(), message.getTick1());
|
||||
final IntricatedPoint pt2 = player2.getTimeProjection(ug.getStringBounder(), message.getTick2());
|
||||
|
||||
final TimeArrow timeArrow = TimeArrow.create(pt1.translated(translate1), pt2.translated(translate2),
|
||||
message.getLabel(), getSkinParam());
|
||||
timeArrow.drawU(ug);
|
||||
|
||||
}
|
||||
|
||||
public UTranslate getUTranslateForPlayer(Player candidat, StringBounder stringBounder) {
|
||||
double y = 0;
|
||||
for (Player player : players.values()) {
|
||||
final Dimension2D dim = player.calculateDimension(stringBounder);
|
||||
if (candidat == player) {
|
||||
return new UTranslate(0, y);
|
||||
}
|
||||
y += dim.getHeight();
|
||||
}
|
||||
if (candidat == null) {
|
||||
return new UTranslate(0, y);
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public void createLifeLine(String code, String full, TimingStyle type) {
|
||||
players.put(code, new Player(code, full, type, getSkinParam(), ruler));
|
||||
}
|
||||
|
||||
public void createTimeMessage(Player player1, TimeTick time1, Player player2, TimeTick time2, String label) {
|
||||
final TimeMessage message = new TimeMessage(new TickInPlayer(player1, time1), new TickInPlayer(player2, time2),
|
||||
label);
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
public void addTime(TimeTick time) {
|
||||
this.now = time;
|
||||
ruler.addTime(time);
|
||||
}
|
||||
|
||||
public Player getPlayer(String code) {
|
||||
return players.get(code);
|
||||
}
|
||||
|
||||
public TimeTick getNow() {
|
||||
// if (now == null) {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
return now;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
|
||||
public class TimingDiagramFactory extends UmlDiagramFactory {
|
||||
|
||||
@Override
|
||||
public TimingDiagram createEmptyDiagram() {
|
||||
return new TimingDiagram();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Command> createCommands() {
|
||||
|
||||
final List<Command> cmds = new ArrayList<Command>();
|
||||
|
||||
addCommonCommands(cmds);
|
||||
|
||||
cmds.add(new CommandLifeLine());
|
||||
cmds.add(new CommandChangeState());
|
||||
cmds.add(new CommandAtTime());
|
||||
cmds.add(new CommandTimeMessage());
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
||||
}
|
130
src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java
Normal file
130
src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
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.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class TimingRuler {
|
||||
|
||||
private final List<TimeTick> times = new ArrayList<TimeTick>();
|
||||
private int highestCommonFactor = -1;
|
||||
private final ISkinParam skinParam;
|
||||
|
||||
private final double tickIntervalInPixels = 50;
|
||||
|
||||
public TimingRuler(ISkinParam skinParam) {
|
||||
this.skinParam = skinParam;
|
||||
}
|
||||
|
||||
public void addTime(TimeTick time) {
|
||||
times.add(time);
|
||||
int tick = time.getTime();
|
||||
if (tick > 0) {
|
||||
if (highestCommonFactor == -1) {
|
||||
highestCommonFactor = time.getTime();
|
||||
} else {
|
||||
highestCommonFactor = computeHighestCommonFactor(highestCommonFactor, time.getTime());
|
||||
}
|
||||
}
|
||||
// System.err.println("highestCommonFactor=" + highestCommonFactor);
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
return new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
|
||||
}
|
||||
|
||||
private TextBlock getTimeTextBlock(TimeTick time) {
|
||||
final Display display = Display.getWithNewlines("" + time.getTime());
|
||||
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
public void draw(UGraphic ug) {
|
||||
ug = ug.apply(new UStroke(2.0));
|
||||
final int nb = getNbTick();
|
||||
// System.err.println("nb=" + nb);
|
||||
final double tickHeight = 5;
|
||||
final ULine line = new ULine(0, tickHeight);
|
||||
for (int i = 0; i <= nb; i++) {
|
||||
ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line);
|
||||
}
|
||||
ug.draw(new ULine(nb * tickIntervalInPixels, 0));
|
||||
|
||||
for (TimeTick tick : times) {
|
||||
final TextBlock text = getTimeTextBlock(tick);
|
||||
final Dimension2D dim = text.calculateDimension(ug.getStringBounder());
|
||||
text.drawU(ug.apply(new UTranslate(getPosInPixel(tick) - dim.getWidth() / 2, tickHeight + 1)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int getNbTick() {
|
||||
return 1 + getMax().getTime() / highestCommonFactor;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return getPosInPixel((getNbTick()) * highestCommonFactor);
|
||||
}
|
||||
|
||||
private TimeTick getMax() {
|
||||
return times.get(times.size() - 1);
|
||||
}
|
||||
|
||||
private static int computeHighestCommonFactor(int a, int b) {
|
||||
int r = a;
|
||||
while (r != 0) {
|
||||
r = a % b;
|
||||
a = b;
|
||||
b = r;
|
||||
}
|
||||
return (Math.abs(a));
|
||||
}
|
||||
|
||||
public final double getPosInPixel(int time) {
|
||||
return 1.0 * time / highestCommonFactor * tickIntervalInPixels;
|
||||
}
|
||||
|
||||
public double getPosInPixel(TimeTick when) {
|
||||
return getPosInPixel(when.getTime());
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user