1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-23 11:29:06 +00:00

version 1.2019.5

This commit is contained in:
Arnaud Roques 2019-04-21 22:40:01 +02:00
parent 857ec10b8b
commit 73b507c1df
136 changed files with 2755 additions and 860 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2019.5-SNAPSHOT</version>
<version>1.2019.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -104,7 +104,7 @@ public class BlockUml {
throw new IllegalArgumentException();
}
if (mode != null && mode.getPreprocessorMode() == PreprocessorMode.V2_NEW_TIM) {
this.data = new TimLoader(mode.getImportedFiles()).load(strings);
this.data = new TimLoader(mode.getImportedFiles(), defines).load(strings);
} else {
this.data = new ArrayList<StringLocated>(strings);
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleHeight implements Scale {
public class ScaleHeight extends ScaleProtected implements Scale {
private final double maxHeight;
@ -43,7 +43,7 @@ public class ScaleHeight implements Scale {
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
return maxHeight / height;
}
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleMaxHeight implements Scale {
public class ScaleMaxHeight extends ScaleProtected implements Scale {
private final double maxHeight;
@ -43,7 +43,7 @@ public class ScaleMaxHeight implements Scale {
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
final double result = maxHeight / height;
if (result > 1) {
return 1;

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleMaxWidth implements Scale {
public class ScaleMaxWidth extends ScaleProtected implements Scale {
private final double maxWidth;
@ -43,7 +43,7 @@ public class ScaleMaxWidth implements Scale {
this.maxWidth = maxWidth;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
final double result = maxWidth / width;
if (result > 1) {
return 1;

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleMaxWidthAndHeight implements Scale {
public class ScaleMaxWidthAndHeight extends ScaleProtected implements Scale {
private final double maxWidth;
private final double maxHeight;
@ -45,7 +45,7 @@ public class ScaleMaxWidthAndHeight implements Scale {
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
final double scale1 = maxWidth / width;
final double scale2 = maxHeight / height;
final double min = Math.min(scale1, scale2);

View File

@ -0,0 +1,53 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml;
abstract class ScaleProtected implements Scale {
abstract double getScaleInternal(double width, double height);
final public double getScale(double width, double height) {
final double result = getScaleInternal(width, height);
if (result <= 0) {
return 1;
}
if (result > 4) {
return 4;
}
return result;
}
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleSimple implements Scale {
public class ScaleSimple extends ScaleProtected implements Scale {
private final double scale;
@ -43,7 +43,7 @@ public class ScaleSimple implements Scale {
this.scale = scale;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
return scale;
}
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleWidth implements Scale {
public class ScaleWidth extends ScaleProtected implements Scale {
private final double maxWidth;
@ -43,7 +43,7 @@ public class ScaleWidth implements Scale {
this.maxWidth = maxWidth;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
return maxWidth / width;
}
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml;
public class ScaleWidthAndHeight implements Scale {
public class ScaleWidthAndHeight extends ScaleProtected implements Scale {
private final double maxWidth;
private final double maxHeight;
@ -45,7 +45,7 @@ public class ScaleWidthAndHeight implements Scale {
this.maxHeight = maxHeight;
}
public double getScale(double width, double height) {
public double getScaleInternal(double width, double height) {
final double scale1 = maxWidth / width;
final double scale2 = maxHeight / height;
// if (scale1 > 1 && scale2 > 1) {

View File

@ -0,0 +1,106 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated {
private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP);
private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private final DisplaySection header = DisplaySection.none();
private final DisplaySection footer = DisplaySection.none();
private Display mainFrame;
final public void setTitle(DisplayPositionned title) {
if (title.isNull() || title.getDisplay().isWhite()) {
return;
}
this.title = title;
}
@Override
final public DisplayPositionned getTitle() {
return title;
}
final public void setMainFrame(Display mainFrame) {
this.mainFrame = mainFrame;
}
final public void setCaption(DisplayPositionned caption) {
this.caption = caption;
}
final public DisplayPositionned getCaption() {
return caption;
}
final public DisplaySection getHeader() {
return header;
}
final public DisplaySection getFooter() {
return footer;
}
final public DisplayPositionned getLegend() {
return legend;
}
public void setLegend(DisplayPositionned legend) {
this.legend = legend;
}
final public Display getMainFrame() {
return mainFrame;
}
}

View File

@ -46,6 +46,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
@ -64,8 +65,6 @@ import net.sourceforge.plantuml.command.CommandSkinParamMultilines;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
@ -73,11 +72,9 @@ import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.fun.IconLoader;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.pdf.PdfConverter;
import net.sourceforge.plantuml.svek.EmptySvgException;
@ -91,20 +88,13 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
import net.sourceforge.plantuml.version.Version;
public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Annotated, WithSprite {
public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annotated, WithSprite {
private boolean rotation;
private boolean hideUnlinkedData;
private int minwidth = Integer.MAX_VALUE;
private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP);
private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private final DisplaySection header = DisplaySection.none();
private final DisplaySection footer = DisplaySection.none();
private Display mainFrame;
private final Pragma pragma = new Pragma();
private Animation animation;
@ -121,30 +111,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
}
}
final public void setTitle(DisplayPositionned title) {
if (title.isNull() || title.getDisplay().isWhite()) {
return;
}
this.title = title;
}
final public void setMainFrame(Display mainFrame) {
this.mainFrame = mainFrame;
}
final public void setCaption(DisplayPositionned caption) {
this.caption = caption;
}
final public DisplayPositionned getCaption() {
return caption;
}
@Override
final public DisplayPositionned getTitle() {
return title;
}
final public int getMinwidth() {
return minwidth;
}
@ -169,14 +135,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
skinParam.setParam(StringUtils.goLowerCase(key), value);
}
public final DisplaySection getHeader() {
return header;
}
public final DisplaySection getFooter() {
return footer;
}
public final DisplaySection getFooterOrHeaderTeoz(FontParam param) {
if (param == FontParam.FOOTER) {
return getFooter();
@ -214,10 +172,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return getSkinParam().getDpi() * fileFormatOption.getScaleCoef() / 96.0;
}
// public final int getDpi(FileFormatOption fileFormatOption) {
// return getSkinParam().getDpi();
// }
public final boolean isHideUnlinkedData() {
return hideUnlinkedData;
}
@ -438,14 +392,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
skinParam.addSprite(name, sprite);
}
public final DisplayPositionned getLegend() {
return legend;
}
public void setLegend(DisplayPositionned legend) {
this.legend = legend;
}
private boolean useJDot;
public void setUseJDot(boolean useJDot) {
@ -460,20 +406,26 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return useJDot;
}
public final Display getMainFrame() {
return mainFrame;
}
public CommandExecutionResult loadSkin(String filename) throws IOException {
final String res = "/skin/" + filename + ".skin";
final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res);
if (internalIs != null) {
final BlocLines lines2 = BlocLines.load(internalIs, new LineLocationImpl(filename, null));
return loadSkinInternal(lines2);
}
if (OptionFlags.ALLOW_INCLUDE == false) {
return CommandExecutionResult.ok();
}
final File f = new File(filename + ".skin");
System.err.println("f=" + f.getAbsolutePath());
if (f.exists() == false || f.canRead() == false) {
final File f = FileSystem.getInstance().getFile(filename + ".skin");
if (f == null || f.exists() == false || f.canRead() == false) {
return CommandExecutionResult.error("Cannot load skin from " + filename);
}
final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), null));
return loadSkinInternal(lines);
}
private CommandExecutionResult loadSkinInternal(final BlocLines lines) {
final CommandSkinParam cmd1 = new CommandSkinParam();
final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines();
for (int i = 0; i < lines.size(); i++) {

View File

@ -64,7 +64,7 @@ public class ActivityDiagramFactory extends UmlDiagramFactory {
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
cmds.add(new CommandFootboxIgnored());
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandRankDir());
cmds.add(new CommandPartition());

View File

@ -287,6 +287,38 @@ public class ActivityDiagram3 extends UmlDiagram {
return CommandExecutionResult.error("Cannot find split");
}
public void startSwitch(Display test, HtmlColor color) {
manageSwimlaneStrategy();
final InstructionSwitch instructionSwitch = new InstructionSwitch(swinlanes.getCurrentSwimlane(), current(), test,
nextLinkRenderer(), color, getSkinParam());
current().add(instructionSwitch);
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(instructionSwitch);
}
public CommandExecutionResult switchCase(Display labelCase) {
if (current() instanceof InstructionSwitch) {
final boolean ok = ((InstructionSwitch) current()).switchCase(labelCase, nextLinkRenderer());
if (ok == false) {
return CommandExecutionResult.error("You cannot put an elseIf here");
}
setNextLinkRendererInternal(LinkRendering.none());
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find switch");
}
public CommandExecutionResult endSwitch() {
if (current() instanceof InstructionSwitch) {
((InstructionSwitch) current()).endSwitch(nextLinkRenderer());
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(((InstructionSwitch) current()).getParent());
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find switch");
}
public void startIf(Display test, Display whenThen, HtmlColor color) {
manageSwimlaneStrategy();
final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test,

View File

@ -45,12 +45,14 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandArrow3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandBackward3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandBreak;
import net.sourceforge.plantuml.activitydiagram3.command.CommandCase;
import net.sourceforge.plantuml.activitydiagram3.command.CommandCircleSpot3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElse3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElseIf2;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElseLegacy1;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEnd3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEndPartition3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEndSwitch;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEndif3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandFork3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandForkAgain3;
@ -77,6 +79,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandStart3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandStop3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane;
import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane2;
import net.sourceforge.plantuml.activitydiagram3.command.CommandSwitch;
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhile3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhileEnd3;
import net.sourceforge.plantuml.command.Command;
@ -92,7 +95,7 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
final List<Command> cmds = new ArrayList<Command>();
cmds.add(new CommandFootboxIgnored());
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandSwimlane());
cmds.add(new CommandSwimlane2());
cmds.add(new CommandPartition3());
@ -111,15 +114,22 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
cmds.add(new CommandDecoratorMultine(new CommandElse3(), 50));
cmds.add(new CommandElseLegacy1());
cmds.add(new CommandEndif3());
cmds.add(new CommandSwitch());
cmds.add(new CommandCase());
cmds.add(new CommandEndSwitch());
cmds.add(new CommandRepeat3());
cmds.add(new CommandRepeatWhile3());
cmds.add(new CommandRepeatWhile3Multilines());
cmds.add(new CommandBackward3());
cmds.add(new CommandWhile3());
cmds.add(new CommandWhileEnd3());
cmds.add(new CommandFork3());
cmds.add(new CommandForkAgain3());
cmds.add(new CommandForkEnd3());
cmds.add(new CommandSplit3());
cmds.add(new CommandSplitAgain3());
cmds.add(new CommandSplitEnd3());

View File

@ -0,0 +1,158 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class InstructionSwitch extends WithNote implements Instruction, InstructionCollection {
private final List<Branch> branches = new ArrayList<Branch>();
private final ISkinParam skinParam;
private final Instruction parent;
private Branch current;
private final LinkRendering topInlinkRendering;
private LinkRendering afterEndwhile = LinkRendering.none();
private final Display labelTest;
private final Swimlane swimlane;
public boolean containsBreak() {
for (Branch branch : branches) {
if (branch.containsBreak()) {
return true;
}
}
return false;
}
public InstructionSwitch(Swimlane swimlane, Instruction parent, Display labelTest, LinkRendering inlinkRendering,
HtmlColor color, ISkinParam skinParam) {
this.topInlinkRendering = inlinkRendering;
this.parent = parent;
this.skinParam = skinParam;
this.labelTest = labelTest;
if (inlinkRendering == null) {
throw new IllegalArgumentException();
}
this.swimlane = swimlane;
}
public void add(Instruction ins) {
current.add(ins);
}
public Ftile createFtile(FtileFactory factory) {
for (Branch branch : branches) {
branch.updateFtile(factory);
}
Ftile result = factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest);
// if (getPositionedNotes().size() > 0) {
// result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false);
// }
// final List<WeldingPoint> weldingPoints = new ArrayList<WeldingPoint>();
// for (Branch branch : branches) {
// weldingPoints.addAll(branch.getWeldingPoints());
// }
// if (weldingPoints.size() > 0) {
// result = new FtileDecorateWelding(result, weldingPoints);
// }
return result;
}
final public boolean kill() {
throw new UnsupportedOperationException();
}
public LinkRendering getInLinkRendering() {
return topInlinkRendering;
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (swimlane != null) {
result.add(swimlane);
}
for (Branch branch : branches) {
result.addAll(branch.getSwimlanes());
}
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
}
public Instruction getLast() {
return branches.get(branches.size() - 1).getLast();
}
public boolean switchCase(Display labelCase, LinkRendering nextLinkRenderer) {
this.current = new Branch(swimlane, labelCase, labelCase, null, labelCase);
this.branches.add(this.current);
return true;
}
public Instruction getParent() {
return parent;
}
public void endSwitch(LinkRendering nextLinkRenderer) {
// TODO Auto-generated method stub
}
// public void afterEndwhile(LinkRendering linkRenderer) {
// this.afterEndwhile = linkRenderer;
// }
}

View File

@ -0,0 +1,75 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.color.ColorParser;
public class CommandCase extends SingleLineCommand2<ActivityDiagram3> {
public CommandCase() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("case"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("TEST", "\\((.*?)\\)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
String test = arg.get("TEST", 0);
if (test.length() == 0) {
test = null;
}
return diagram.switchCase(Display.getWithNewlines(test));
}
}

View File

@ -0,0 +1,64 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
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 CommandEndSwitch extends SingleLineCommand2<ActivityDiagram3> {
public CommandEndSwitch() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("endswitch"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
return diagram.endSwitch();
}
}

View File

@ -0,0 +1,79 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.color.ColorParser;
public class CommandSwitch extends SingleLineCommand2<ActivityDiagram3> {
public CommandSwitch() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
ColorParser.exp4(), //
new RegexLeaf("switch"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("TEST", "\\((.*?)\\)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
String test = arg.get("TEST", 0);
if (test.length() == 0) {
test = null;
}
diagram.startSwitch(Display.getWithNewlines(test), color);
return CommandExecutionResult.ok();
}
}

View File

@ -87,6 +87,9 @@ public interface FtileFactory {
public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering);
public Ftile createSwitch(Swimlane swimlane, List<Branch> branches, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering, Display labelTest);
public Ftile createParallel(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label);
public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note,

View File

@ -163,6 +163,11 @@ public class FtileFactoryDelegator implements FtileFactory {
return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering);
}
public Ftile createSwitch(Swimlane swimlane, List<Branch> branches, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering, Display labelTest) {
return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest);
}
public Ftile createParallel(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
return factory.createParallel(swimlane, all, style, label);
}

View File

@ -66,6 +66,11 @@ public class Snake implements UShape {
private MergeStrategy mergeable = MergeStrategy.FULL;
private Direction emphasizeDirection;
private final HorizontalAlignment horizontalAlignment;
public final void setIgnoreForCompression(boolean ignoreForCompression) {
this.worm.setIgnoreForCompression(ignoreForCompression);
}
public Snake transformX(CompressionTransform compressionTransform) {
final Snake result = new Snake(startDecoration, horizontalAlignment, color, endDecoration);

View File

@ -1,346 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.Pragma;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.InstructionList;
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.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;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorOneSwimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.VCompactFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UGraphicDelegator;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.UGraphicForSnake;
import net.sourceforge.plantuml.ugraphic.LimitFinder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChange;
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.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.comp.SlotSet;
import net.sourceforge.plantuml.utils.MathUtils;
public class Swimlanes extends AbstractTextBlock implements TextBlock {
private final ISkinParam skinParam;;
private final Pragma pragma;
private final List<Swimlane> swimlanes = new ArrayList<Swimlane>();
private Swimlane currentSwimlane = null;
private final Instruction root = new InstructionList();
private Instruction currentInstruction = root;
private LinkRendering nextLinkRenderer = LinkRendering.none();
public Swimlanes(ISkinParam skinParam, Pragma pragma) {
this.skinParam = skinParam;
this.pragma = pragma;
}
private FontConfiguration getFontConfiguration() {
return new FontConfiguration(skinParam, FontParam.SWIMLANE_TITLE, null);
}
private FtileFactory getFtileFactory(StringBounder stringBounder) {
FtileFactory factory = new VCompactFactory(skinParam, stringBounder);
factory = new FtileFactoryDelegatorAddUrl(factory);
factory = new FtileFactoryDelegatorAssembly(factory);
factory = new FtileFactoryDelegatorIf(factory, pragma);
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;
}
public void swimlane(String name, HtmlColor color, Display label) {
currentSwimlane = getOrCreate(name);
if (color != null) {
currentSwimlane.setSpecificColorTOBEREMOVED(ColorType.BACK, color);
}
if (Display.isNull(label) == false) {
currentSwimlane.setDisplay(label);
}
}
private Swimlane getOrCreate(String name) {
for (Swimlane s : swimlanes) {
if (s.getName().equals(name)) {
return s;
}
}
final Swimlane result = new Swimlane(name);
swimlanes.add(result);
return result;
}
class Cross extends UGraphicDelegator {
private Cross(UGraphic ug) {
super(ug);
}
@Override
public void draw(UShape shape) {
if (shape instanceof Ftile) {
final Ftile tile = (Ftile) shape;
tile.drawU(this);
} else if (shape instanceof Connection) {
final Connection connection = (Connection) shape;
final Ftile tile1 = connection.getFtile1();
final Ftile tile2 = connection.getFtile2();
if (tile1 == null || tile2 == null) {
return;
}
if (tile1.getSwimlaneOut() != tile2.getSwimlaneIn()) {
final ConnectionCross connectionCross = new ConnectionCross(connection);
connectionCross.drawU(getUg());
}
}
}
public UGraphic apply(UChange change) {
return new Cross(getUg().apply(change));
}
}
static private final double separationMargin = 10;
private TextBlock full;
public void drawU(UGraphic ug) {
if (full == null) {
final FtileFactory factory = getFtileFactory(ug.getStringBounder());
full = root.createFtile(factory);
if (swimlanes.size() <= 1) {
// BUG42
full = new TextBlockInterceptorUDrawable(full);
}
}
ug = new UGraphicForSnake(ug);
if (swimlanes.size() <= 1) {
full.drawU(ug);
ug.flushUg();
return;
}
drawWhenSwimlanes(ug, full);
}
static private void printDebug(UGraphic ug, SlotSet slot, HtmlColor col, TextBlock full) {
slot.drawDebugX(ug.apply(new UChangeColor(col)).apply(new UChangeBackColor(col)),
full.calculateDimension(ug.getStringBounder()).getHeight());
}
private void drawWhenSwimlanes(UGraphic ug, TextBlock full) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimensionFull = full.calculateDimension(stringBounder);
final UTranslate titleHeightTranslate = getTitleHeightTranslate(stringBounder);
computeSize(ug, full);
double x2 = 0;
for (Swimlane swimlane : swimlanes) {
final HtmlColor back = swimlane.getColors(skinParam).getColor(ColorType.BACK);
if (back != null) {
final UGraphic background = ug.apply(new UChangeBackColor(back)).apply(new UChangeColor(back))
.apply(new UTranslate(x2, 0));
background.draw(new URectangle(swimlane.getActualWidth(), dimensionFull.getHeight()
+ titleHeightTranslate.getDy()));
}
final TextBlock swTitle = getTitle(swimlane);
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
final double posTitle = x2 + (swimlane.getActualWidth() - titleWidth) / 2;
swTitle.drawU(ug.apply(new UTranslate(posTitle, 0)));
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
full.drawU(new UGraphicInterceptorOneSwimlane(ug, swimlane).apply(swimlane.getTranslate()).apply(
titleHeightTranslate));
x2 += swimlane.getActualWidth();
}
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
final Cross cross = new Cross(ug.apply(titleHeightTranslate));
full.drawU(cross);
cross.flushUg();
}
private void computeDrawingWidths(UGraphic ug, TextBlock full) {
final StringBounder stringBounder = ug.getStringBounder();
for (Swimlane swimlane : swimlanes) {
final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
final UGraphicInterceptorOneSwimlane interceptor = new UGraphicInterceptorOneSwimlane(new UGraphicForSnake(
limitFinder), swimlane);
full.drawU(interceptor);
interceptor.flushUg();
final MinMax minMax = limitFinder.getMinMax();
swimlane.setMinMax(minMax);
}
}
private void computeSize(UGraphic ug, TextBlock full) {
computeDrawingWidths(ug, full);
double x1 = 0;
final StringBounder stringBounder = ug.getStringBounder();
double swimlaneWidth = skinParam.swimlaneWidth();
if (swimlaneWidth == -1) {
for (Swimlane swimlane : swimlanes) {
final MinMax minMax = swimlane.getMinMax();
swimlaneWidth = Math.max(swimlaneWidth, minMax.getWidth());
}
}
for (Swimlane swimlane : swimlanes) {
final MinMax minMax = swimlane.getMinMax();
final double drawingWidth = minMax.getWidth() + 2 * separationMargin;
final TextBlock swTitle = getTitle(swimlane);
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
final double totalWidth = MathUtils.max(swimlaneWidth, drawingWidth, titleWidth + 2 * separationMargin);
final UTranslate translate = new UTranslate(x1 - minMax.getMinX() + separationMargin
+ (totalWidth - drawingWidth) / 2.0, 0);
swimlane.setTranslateAndWidth(translate, totalWidth);
x1 += totalWidth;
}
}
private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) {
double titlesHeight = 0;
for (Swimlane swimlane : swimlanes) {
final TextBlock swTitle = getTitle(swimlane);
titlesHeight = Math.max(titlesHeight, swTitle.calculateDimension(stringBounder).getHeight());
}
final UTranslate titleHeightTranslate = new UTranslate(0, titlesHeight);
return titleHeightTranslate;
}
private TextBlock getTitle(Swimlane swimlane) {
return swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam,
skinParam.wrapWidth());
}
private void drawSeparation(UGraphic ug, double height) {
HtmlColor color = skinParam.getHtmlColor(ColorParam.swimlaneBorder, null, false);
if (color == null) {
color = ColorParam.swimlaneBorder.getDefaultValue();
}
final UStroke thickness = Rose.getStroke(skinParam, LineParam.swimlaneBorder, 2);
ug.apply(thickness).apply(new UChangeColor(color)).draw(new ULine(0, height));
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getMinMax(stringBounder).getDimension();
}
public Instruction getCurrent() {
return currentInstruction;
}
public void setCurrent(Instruction current) {
this.currentInstruction = current;
}
public LinkRendering nextLinkRenderer() {
return nextLinkRenderer;
}
public void setNextLinkRenderer(LinkRendering link) {
if (link == null) {
throw new IllegalArgumentException();
}
this.nextLinkRenderer = link;
}
public Swimlane getCurrentSwimlane() {
return currentSwimlane;
}
private MinMax cachedMinMax;
@Override
public MinMax getMinMax(StringBounder stringBounder) {
if (cachedMinMax == null) {
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder);
}
return cachedMinMax;
}
}

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDele
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.FtileFactoryDelegatorSwitch;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorWhile;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorOneSwimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.VCompactFactory;
@ -98,6 +99,7 @@ public class SwimlanesA extends AbstractTextBlock implements TextBlock {
factory = new FtileFactoryDelegatorAddUrl(factory);
factory = new FtileFactoryDelegatorAssembly(factory);
factory = new FtileFactoryDelegatorIf(factory, pragma);
factory = new FtileFactoryDelegatorSwitch(factory);
factory = new FtileFactoryDelegatorWhile(factory);
factory = new FtileFactoryDelegatorRepeat(factory);
factory = new FtileFactoryDelegatorCreateParallel(factory);

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
public class Worm implements Iterable<Point2D.Double> {
@ -64,6 +65,12 @@ public class Worm implements Iterable<Point2D.Double> {
return points.size() == 2 && points.get(0).getY() == points.get(1).getY();
}
private boolean ignoreForCompression;
public final void setIgnoreForCompression(boolean ignoreForCompression) {
this.ignoreForCompression = ignoreForCompression;
}
public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle color, double stroke,
Direction emphasizeDirection, UPolygon endDecoration) {
final HtmlColor color2 = color.getColor();
@ -96,11 +103,17 @@ public class Worm implements Iterable<Point2D.Double> {
if (startDecoration != null) {
ug = ug.apply(new UStroke(1.5));
final Point2D start = points.get(0);
if (ignoreForCompression) {
startDecoration.setIgnoreForCompression(CompressionMode.ON_X);
}
ug.apply(new UTranslate(start)).apply(new UStroke()).draw(startDecoration);
}
if (endDecoration != null) {
ug = ug.apply(new UStroke(1.5));
final Point2D end = points.get(points.size() - 1);
if (ignoreForCompression) {
endDecoration.setIgnoreForCompression(CompressionMode.ON_X);
}
ug.apply(new UTranslate(end)).apply(new UStroke()).draw(endDecoration);
}
}

View File

@ -0,0 +1,142 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
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.FtileMinWidth;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchNude;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithDiamonds;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
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.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.ConditionStyle;
public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator {
public FtileFactoryDelegatorSwitch(FtileFactory factory) {
super(factory);
}
@Override
public Ftile createSwitch(Swimlane swimlane, List<Branch> branches, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering, Display labelTest) {
// final ConditionStyle conditionStyle = skinParam().getConditionStyle();
//
// final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
// final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground);
// final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
//
// final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);
//
// final FontParam testParam = conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND
// : FontParam.ARROW;
// final FontConfiguration fcTest = new FontConfiguration(skinParam(), testParam, null)
// .changeColor(fontColor(FontParam.ACTIVITY_DIAMOND));
//
// return FtileSwitch.create(swimlane, borderColor, backColor, arrowColor, getFactory(), conditionStyle,
// branches,
// fcArrow, topInlinkRendering, afterEndwhile, fcTest);
// return createNude(swimlane, branches);
return createWithDiamonds(swimlane, branches, labelTest);
}
private Ftile createNude(Swimlane swimlane, List<Branch> branches) {
final List<Ftile> ftiles = new ArrayList<Ftile>();
for (Branch branch : branches) {
ftiles.add(new FtileMinWidth(branch.getFtile(), 30));
}
return new FtileSwitchNude(ftiles, swimlane);
}
private Ftile createWithDiamonds(Swimlane swimlane, List<Branch> branches, Display labelTest) {
final List<Ftile> ftiles = new ArrayList<Ftile>();
for (Branch branch : branches) {
ftiles.add(new FtileMinWidth(branch.getFtile(), 30));
}
final Ftile diamond1 = getDiamond1(swimlane, branches.get(0), labelTest);
final Ftile diamond2 = getDiamond2(swimlane, branches.get(0));
return new FtileSwitchWithDiamonds(ftiles, swimlane, diamond1, diamond2, getStringBounder());
}
private Ftile getDiamond1(Swimlane swimlane, Branch branch0, Display test) {
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(),
ColorParam.activityDiamondBackground) : branch0.getColor();
final FontConfiguration fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null);
final TextBlock tbTest = (Display.isNull(test) || test.isWhite()) ? TextBlockUtils.empty(0, 0) : test.create(
fcDiamond, branch0.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), branch0.skinParam());
return new FtileDiamondInside(branch0.skinParam(), backColor, borderColor, swimlane, tbTest);
}
private Ftile getDiamond2(Swimlane swimlane, Branch branch0) {
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(),
ColorParam.activityDiamondBackground) : branch0.getColor();
return new FtileDiamondInside(branch0.skinParam(), backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0));
}
private HtmlColor fontColor(FontParam param) {
return skinParam().getFontHtmlColor(null, param);
}
}

View File

@ -555,7 +555,7 @@ class FtileIfLongHorizontal extends AbstractFtile {
return trCouple.compose(in);
}
public UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
private UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
final int idx = tiles.indexOf(tile);
if (idx == -1) {
throw new IllegalArgumentException();

View File

@ -80,7 +80,6 @@ class FtileIfLongVertical extends AbstractFtile {
private final Ftile tile2;
private final List<Ftile> diamonds;
private final Ftile lastDiamond;
// private final List<Ftile> couples = new ArrayList<Ftile>();
private final Rainbow arrowColor;
@ -91,9 +90,6 @@ class FtileIfLongVertical extends AbstractFtile {
throw new IllegalArgumentException();
}
this.lastDiamond = lastDiamond;
// for (int i = 0; i < diamonds.size(); i++) {
// couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i)));
// }
this.tile2 = tile2;
this.diamonds = new ArrayList<Ftile>(diamonds);
this.tiles = new ArrayList<Ftile>(tiles);
@ -102,22 +98,6 @@ class FtileIfLongVertical extends AbstractFtile {
}
// private static List<Ftile> alignDiamonds(List<Ftile> diamonds, StringBounder stringBounder) {
// double maxOutY = 0;
// for (Ftile diamond : diamonds) {
// maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
// }
// final List<Ftile> result = new ArrayList<Ftile>();
// for (int i = 0; i < diamonds.size(); i++) {
// Ftile diamond = diamonds.get(i);
// final double missing = maxOutY - diamond.calculateDimension(stringBounder).getOutY();
// assert missing >= 0;
// diamond = FtileUtils.addVerticalMargin(diamond, missing / 2, 20);
// result.add(diamond);
// }
// return result;
// }
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (getSwimlaneIn() != null) {
@ -191,26 +171,13 @@ class FtileIfLongVertical extends AbstractFtile {
}
final Rainbow topInColor = topInlinkRendering.getRainbow(arrowColor);
// for (int i = 0; i < diamonds.size() - 1; i++) {
// final Ftile diam1 = diamonds.get(i);
// final Ftile diam2 = diamonds.get(i + 1);
// conns.add(result.new ConnectionHorizontal(diam1, diam2, topInColor));
// }
conns.add(result.new ConnectionIn(topInColor));
// conns.add(result.new ConnectionLastElseIn(FtileIfWithLinks.getInColor(branch2, arrowColor)));
// conns.add(result.new ConnectionLastElseOut(arrowColor));
// final HtmlColor horizontalOutColor = LinkRendering.getColor(afterEndwhile, arrowColor);
// conns.add(result.new ConnectionHline(horizontalOutColor));
conns.add(result.new ConnectionLastElse(topInColor));
conns.add(result.new ConnectionLastElseOut(arrowColor));
return FtileUtils.addConnection(result, conns);
}
static private double getYdiamontOutToLeft(FtileGeometry dimDiamond1, StringBounder stringBounder) {
return (dimDiamond1.getInY() + dimDiamond1.getOutY()) / 2;
}
class ConnectionIn extends AbstractConnection {
private final Rainbow arrowColor;
@ -489,33 +456,8 @@ class FtileIfLongVertical extends AbstractFtile {
final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder);
final double x = (dimTotal.getWidth() - dim2.getWidth()) / 2;
return new UTranslate(x, y1);
// final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
// final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
//
// final double x2 = dimTotal.getWidth() - dim2.getWidth();
//
// final double h = 0; // getAllDiamondsHeight(stringBounder);
// final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
//
// return new UTranslate(x2, y2);
}
// private UTranslate getTranslateCouple1(Ftile candidat, StringBounder stringBounder) {
// double x1 = 0;
//
// for (Ftile couple : couples) {
// final FtileGeometry dim1 = couple.calculateDimension(stringBounder);
// if (couple == candidat) {
// return new UTranslate(x1, 25);
// }
// x1 += dim1.getWidth() + xSeparation;
// }
// throw new IllegalArgumentException();
//
// }
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
for (Ftile tile1 : tiles) {
@ -530,7 +472,6 @@ class FtileIfLongVertical extends AbstractFtile {
}
private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
// FtileGeometry result = new FtileGeometry(0, marginy1, 0, 0);
double col1 = 0;
double col1overpass = 0;
double col2 = 0;
@ -566,14 +507,6 @@ class FtileIfLongVertical extends AbstractFtile {
return width;
}
private double allTile1Width(StringBounder stringBounder) {
double width = 0;
for (Ftile tile1 : tiles) {
width = Math.max(width, tile1.calculateDimension(stringBounder).getWidth());
}
return width;
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);

View File

@ -0,0 +1,193 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collection;
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.Branch;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
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.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class FtileSwitch extends AbstractFtile {
private final double xSeparation = 20;
private final List<Ftile> tiles;
private final Rainbow arrowColor;
private FtileSwitch(List<Double> inlabelSizes, List<Ftile> tiles, Rainbow arrowColor) {
super(tiles.get(0).skinParam());
this.tiles = new ArrayList<Ftile>(tiles);
this.arrowColor = arrowColor;
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (getSwimlaneIn() != null) {
result.add(getSwimlaneIn());
}
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return tiles.get(0).getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, Rainbow arrowColor,
FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens, FontConfiguration fcArrow,
LinkRendering topInlinkRendering, LinkRendering afterEndwhile, FontConfiguration fcTest) {
if (afterEndwhile == null) {
throw new IllegalArgumentException();
}
final List<Ftile> tiles = new ArrayList<Ftile>();
for (Branch branch : thens) {
tiles.add(new FtileMinWidth(branch.getFtile(), 30));
}
List<Double> inlabelSizes = new ArrayList<Double>();
for (Branch branch : thens) {
final TextBlock tb1 = branch.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
final TextBlock tbTest = branch.getLabelTest().create(fcTest,
ftileFactory.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT),
ftileFactory.skinParam());
final HtmlColor diamondColor = branch.getColor() == null ? backColor : branch.getColor();
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), diamondColor, borderColor,
swimlane, tbTest);
TextBlock tbInlabel = null;
if (Display.isNull(branch.getInlabel())) {
inlabelSizes.add(0.0);
} else {
tbInlabel = branch.getInlabel().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam());
inlabelSizes.add(tbInlabel.calculateDimension(ftileFactory.getStringBounder()).getWidth());
diamond = diamond.withWest(tbInlabel);
}
diamond = diamond.withNorth(tb1);
}
return new FtileSwitch(inlabelSizes, tiles, arrowColor);
}
@Override
public Collection<Ftile> getMyChildren() {
final List<Ftile> result = new ArrayList<Ftile>(tiles);
return Collections.unmodifiableList(result);
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (tiles.contains(child)) {
return getTranslate1(child, stringBounder);
}
throw new UnsupportedOperationException();
}
private UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
double x1 = 0;
for (Ftile candidate : tiles) {
final FtileGeometry dim1 = candidate.calculateDimension(stringBounder);
if (candidate == tile) {
return new UTranslate(x1, 25);
}
x1 += dim1.getWidth() + xSeparation;
}
throw new IllegalArgumentException();
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
for (Ftile tile : tiles) {
ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
}
}
private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
Dimension2D result = new Dimension2DDouble(0, 0);
for (Ftile couple : tiles) {
result = Dimension2DDouble.mergeLR(result, couple.calculateDimension(stringBounder));
}
result = Dimension2DDouble.delta(result, xSeparation * (tiles.size() - 1), 100);
return new FtileGeometry(result, result.getWidth() / 2, 0);
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final List<Ftile> all = new ArrayList<Ftile>(tiles);
for (Ftile tmp : all) {
if (tmp.calculateDimension(stringBounder).hasPointOut()) {
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
}
}
return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
}
}

View File

@ -154,6 +154,7 @@ public class ParallelBuilderFork extends ParallelFtilesBuilder {
snake.addPoint(mp1a.getX(), middle);
snake.addPoint(mp2b.getX(), middle);
snake.addPoint(mp2b);
snake.setIgnoreForCompression(true);
ug.draw(snake);
}
}
@ -213,6 +214,7 @@ public class ParallelBuilderFork extends ParallelFtilesBuilder {
snake.addPoint(mp1a.getX(), middle);
snake.addPoint(mp2b.getX(), middle);
snake.addPoint(mp2b);
snake.setIgnoreForCompression(true);
ug.draw(snake);
}

View File

@ -145,6 +145,15 @@ public class VCompactFactory implements FtileFactory {
return new FtileForkInner(ftiles);
}
public Ftile createSwitch(Swimlane swimlane, List<Branch> branches, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering, Display labelTest) {
final List<Ftile> ftiles = new ArrayList<Ftile>();
for (Branch branch : branches) {
ftiles.add(branch.getFtile());
}
return new FtileForkInner(ftiles);
}
public Ftile createParallel(Swimlane swimlane, List<Ftile> all, ForkStyle style, String label) {
return new FtileForkInner(all);
}

View File

@ -92,8 +92,8 @@ public class FtileIfNude extends FtileDimensionMemoize {
}
protected UTranslate getTranslate1(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
// final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
// final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
final double x1 = 0;
final double y1 = 0;
@ -143,7 +143,7 @@ public class FtileIfNude extends FtileDimensionMemoize {
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
final FtileGeometry dim2 = tile2.calculateDimension(stringBounder);
final double innerMargin = withInner(stringBounder);
final double innerMargin = widthInner(stringBounder);
final double width = dim1.getLeft() + innerMargin + (dim2.getWidth() - dim2.getLeft());
final Dimension2D dim12 = Dimension2DDouble.mergeLR(dim1, dim2);
@ -151,16 +151,10 @@ public class FtileIfNude extends FtileDimensionMemoize {
return new FtileGeometry(width, dim12.getHeight(), dim1.getLeft() + innerMargin / 2, 0);
}
protected double withInner(StringBounder stringBounder) {
protected double widthInner(StringBounder stringBounder) {
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
final FtileGeometry dim2 = tile2.calculateDimension(stringBounder);
return (dim1.getWidth() - dim1.getLeft()) + dim2.getLeft();
}
// protected double getLeft(StringBounder stringBounder) {
// final double left1 = tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
// final double left2 = tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
// return (left1 + left2) / 2;
// }
}

View File

@ -48,7 +48,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public class FtileIfWithDiamonds extends FtileIfNude {
private final double SUPP_WITH = 20;
private static final double SUPP_WIDTH = 20;
protected final Ftile diamond1;
protected final Ftile diamond2;
@ -82,9 +82,9 @@ public class FtileIfWithDiamonds extends FtileIfNude {
}
@Override
protected double withInner(StringBounder stringBounder) {
protected double widthInner(StringBounder stringBounder) {
final FtileGeometry dim1 = diamond1.calculateDimension(stringBounder);
return Math.max(super.withInner(stringBounder), dim1.getWidth() + SUPP_WITH);
return Math.max(super.widthInner(stringBounder), dim1.getWidth() + SUPP_WIDTH);
}
@Override

View File

@ -0,0 +1,139 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond;
import java.awt.geom.Dimension2D;
import java.util.Arrays;
import java.util.Collection;
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.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;
public class FtileSwitchNude extends FtileDimensionMemoize {
protected final double xSeparation = 20;
protected final List<Ftile> tiles;
private final Swimlane in;
public FtileSwitchNude(List<Ftile> tiles, Swimlane in) {
super(tiles.get(0).skinParam());
this.tiles = tiles;
this.in = in;
}
@Override
public Collection<Ftile> getMyChildren() {
return Collections.unmodifiableCollection(tiles);
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (getSwimlaneIn() != null) {
result.add(getSwimlaneIn());
}
for (Ftile tile : tiles) {
result.addAll(tile.getSwimlanes());
}
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return in;
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (tiles.contains(child)) {
return getTranslate1(child, stringBounder);
}
throw new UnsupportedOperationException();
}
private UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
double x1 = 0;
for (Ftile candidate : tiles) {
final FtileGeometry dim1 = candidate.calculateDimension(stringBounder);
if (candidate == tile) {
return new UTranslate(x1, 0);
}
x1 += dim1.getWidth() + xSeparation;
}
throw new IllegalArgumentException();
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
for (Ftile tile : tiles) {
ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
}
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder);
for (Ftile tile : tiles)
if (tile.calculateDimension(stringBounder).hasPointOut()) {
return dimTotal;
}
return dimTotal.withoutPointOut();
}
@Override
protected FtileGeometry calculateDimensionInternalSlow(StringBounder stringBounder) {
Dimension2D result = new Dimension2DDouble(0, 0);
for (Ftile couple : tiles) {
result = Dimension2DDouble.mergeLR(result, couple.calculateDimension(stringBounder));
}
result = Dimension2DDouble.delta(result, xSeparation * (tiles.size() - 1), 100);
return new FtileGeometry(result, result.getWidth() / 2, 0);
}
}

View File

@ -0,0 +1,124 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
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.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class FtileSwitchWithDiamonds extends FtileSwitchNude {
protected final Ftile diamond1;
protected final Ftile diamond2;
public FtileSwitchWithDiamonds(List<Ftile> tiles, Swimlane in, Ftile diamond1, Ftile diamond2,
StringBounder stringBounder) {
super(tiles, in);
this.diamond1 = diamond1;
this.diamond2 = diamond2;
}
@Override
public Collection<Ftile> getMyChildren() {
final Collection<Ftile> result = new ArrayList<Ftile>(super.getMyChildren());
result.add(diamond1);
result.add(diamond2);
return Collections.unmodifiableCollection(result);
}
public int getYdelta1a(StringBounder stringBounder) {
return 20;
}
public int getYdelta1b(StringBounder stringBounder) {
return 10;
}
@Override
protected FtileGeometry calculateDimensionInternalSlow(StringBounder stringBounder) {
final FtileGeometry dim1 = diamond1.calculateDimension(stringBounder);
final FtileGeometry dim2 = diamond2.calculateDimension(stringBounder);
final FtileGeometry dimNude = super.calculateDimensionInternalSlow(stringBounder);
final FtileGeometry all = dim1.appendBottom(dimNude).appendBottom(dim2);
return all.addDim(0, getYdelta1a(stringBounder) + getYdelta1b(stringBounder));
}
@Override
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
super.drawU(ug.apply(getUTranslateMain(stringBounder)));
ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
}
private UChange getUTranslateMain(StringBounder stringBounder) {
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
return new UTranslate(0, dimDiamond1.getHeight() + getYdelta1a(stringBounder));
}
protected UTranslate getTranslateDiamond1(StringBounder stringBounder) {
final double y1 = 0;
final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder);
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
final double x1 = dimTotal.getLeft() - dimDiamond1.getLeft();
return new UTranslate(x1, y1);
}
protected UTranslate getTranslateDiamond2(StringBounder stringBounder) {
final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder);
final FtileGeometry dimDiamond2 = diamond2.calculateDimension(stringBounder);
final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight();
final double x2 = dimTotal.getLeft() - dimDiamond2.getWidth() / 2;
return new UTranslate(x2, y2);
}
}

View File

@ -92,6 +92,7 @@ public class FtileBlackBlock extends AbstractFtile {
public void drawU(UGraphic ug) {
final URectangle rect = new URectangle(width, height, 5, 5);
rect.setIgnoreForCompression(true);
if (skinParam().shadowing(null)) {
rect.setDeltaShadow(3);
}

View File

@ -36,6 +36,8 @@
package net.sourceforge.plantuml.asciiart;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.StringUtils;
@ -43,6 +45,7 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.sequencediagram.MessageNumber;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDirection;
import net.sourceforge.plantuml.skin.ComponentType;
@ -50,7 +53,7 @@ import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class ComponentTextArrow extends AbstractComponentText {
public class ComponentTextArrow extends AbstractComponentText implements ArrowComponent {
private final ComponentType type;
private final Display stringsToDisplay;
@ -132,4 +135,20 @@ public class ComponentTextArrow extends AbstractComponentText {
return width;
}
public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
return new Point2D.Double(0, 0);
}
public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
return new Point2D.Double(0, 0);
}
public double getPaddingY() {
throw new UnsupportedOperationException();
}
public double getYPoint(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
}

View File

@ -36,19 +36,21 @@
package net.sourceforge.plantuml.asciiart;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class ComponentTextSelfArrow extends AbstractComponentText {
public class ComponentTextSelfArrow extends AbstractComponentText implements ArrowComponent {
private final ComponentType type;
private final Display stringsToDisplay;
@ -105,4 +107,20 @@ public class ComponentTextSelfArrow extends AbstractComponentText {
return StringUtils.getWcWidth(stringsToDisplay) + 6;
}
public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
return new Point2D.Double(0, 0);
}
public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
return new Point2D.Double(0, 0);
}
public double getPaddingY() {
throw new UnsupportedOperationException();
}
public double getYPoint(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
}

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.asciiart;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDirection;
import net.sourceforge.plantuml.skin.Component;
@ -53,6 +54,20 @@ public class TextSkin extends Rose {
this.fileFormat = fileFormat;
}
@Override
public ArrowComponent createComponentArrow(ArrowConfiguration config, ISkinParam param, Display stringsToDisplay) {
if (config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL
|| config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE
|| config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION) {
return new ComponentTextArrow(ComponentType.ARROW, config, stringsToDisplay, fileFormat,
param.maxAsciiMessageLength());
}
if (config.isSelfArrow()) {
return new ComponentTextSelfArrow(ComponentType.ARROW, config, stringsToDisplay, fileFormat);
}
throw new UnsupportedOperationException();
}
public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param,
Display stringsToDisplay) {
if (type == ComponentType.ACTOR_HEAD || type == ComponentType.ACTOR_TAIL) {

View File

@ -107,7 +107,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
return createEntityWithNamespace(code, Display.getWithNewlines(getShortName(code)), LeafType.CLASS, symbol);
}
if (getNamespaceSeparator() == null) {
return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
return getOrCreateLeafDefault(code, type, symbol);
}
code = getFullyQualifiedCode(code);
if (super.leafExist(code)) {
@ -122,8 +122,8 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
code = code.withSeparator(getNamespaceSeparator());
}
if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
&& type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP
&& type != LeafType.NOTE) {
&& type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP_FULL
&& type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE) {
return super.createLeaf(code, display, type, symbol);
}
if (getNamespaceSeparator() == null) {
@ -143,7 +143,8 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
if (namespace != null
&& (EntityUtils.groupRoot(group) || group.getCode().getFullName().equals(namespace) == false)) {
final Code namespace2 = Code.of(namespace);
gotoGroupInternal(namespace2, Display.getWithNewlines(namespace), namespace2, GroupType.PACKAGE, getRootGroup());
gotoGroupInternal(namespace2, Display.getWithNewlines(namespace), namespace2, GroupType.PACKAGE,
getRootGroup());
}
final ILeaf result = createLeafInternal(
fullyCode,

View File

@ -93,6 +93,9 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandPage());
cmds.add(new CommandAddMethod());
addCommonHides(cmds);
cmds.add(new CommandHideShow2());
cmds.add(new CommandRemoveRestore());
cmds.add(new CommandCreateClassMultilines());
@ -145,8 +148,8 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandCreateElementMultilines(0));
cmds.add(new CommandCreateElementMultilines(1));
addCommonCommands(cmds);
cmds.add(new CommandHideShow2());
addTitleCommands(cmds);
addCommonCommands2(cmds);
return cmds;
}

View File

@ -70,8 +70,8 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
new RegexLeaf("[%s]*"), //
new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
new RegexLeaf("[%s]*"), //
new RegexOr(new RegexLeaf("LOL_THEN_ENT", "\\(\\)([-=.]+)"), //
new RegexLeaf("ENT_THEN_LOL", "([-=.]+)\\(\\)")), //
new RegexOr(new RegexLeaf("LOL_THEN_ENT", "([()]\\))([-=.]+)"), //
new RegexLeaf("ENT_THEN_LOL", "([-=.]+)(\\([()])")), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
new RegexLeaf("[%s]*"), //
@ -92,8 +92,16 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
throw new IllegalArgumentException();
}
private LeafType getType(String desc) {
if (desc.charAt(0) == desc.charAt(1)) {
return LeafType.LOLLIPOP_HALF;
}
return LeafType.LOLLIPOP_FULL;
}
@Override
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, RegexResult arg) {
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) {
final Code ent1 = Code.of(arg.get("ENT1", 1));
final Code ent2 = Code.of(arg.get("ENT2", 1));
@ -103,16 +111,16 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final IEntity normalEntity;
final String suffix = "lol" + UniqueSequence.getValue();
if (arg.get("LOL_THEN_ENT", 0) == null) {
if (arg.get("LOL_THEN_ENT", 1) == null) {
assert arg.get("ENT_THEN_LOL", 0) != null;
cl1 = diagram.getOrCreateLeaf(ent1, null, null);
cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP,
null);
cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2),
getType(arg.get("ENT_THEN_LOL", 1)), null);
normalEntity = cl1;
} else {
cl2 = diagram.getOrCreateLeaf(ent2, null, null);
cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP,
null);
cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1),
getType(arg.get("LOL_THEN_ENT", 0)), null);
normalEntity = cl2;
}
@ -217,8 +225,8 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
}
private String getQueue(RegexResult arg) {
if (arg.get("LOL_THEN_ENT", 0) != null) {
return StringUtils.trin(arg.get("LOL_THEN_ENT", 0));
if (arg.get("LOL_THEN_ENT", 1) != null) {
return StringUtils.trin(arg.get("LOL_THEN_ENT", 1));
}
if (arg.get("ENT_THEN_LOL", 0) != null) {
return StringUtils.trin(arg.get("ENT_THEN_LOL", 0));

View File

@ -39,6 +39,8 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@ -46,6 +48,7 @@ import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.LineLocationImpl;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -86,8 +89,17 @@ public class BlocLines implements Iterable<StringLocated> {
}
public static BlocLines load(File f, LineLocation location) throws IOException {
final List<StringLocated> result = new ArrayList<StringLocated>();
final BufferedReader br = new BufferedReader(new FileReader(f));
return loadInternal(br, location);
}
public static BlocLines load(InputStream is, LineLocation location) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(is));
return loadInternal(br, location);
}
private static BlocLines loadInternal(final BufferedReader br, LineLocation location) throws IOException {
final List<StringLocated> result = new ArrayList<StringLocated>();
String s;
while ((s = br.readLine()) != null) {
result.add(new StringLocated(s, location));

View File

@ -37,20 +37,20 @@ package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandCaption extends SingleLineCommand<UmlDiagram> {
public class CommandCaption extends SingleLineCommand<TitledDiagram> {
public CommandCaption() {
super("(?i)^caption(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(TitledDiagram diagram, List<String> arg) {
diagram.setCaption(DisplayPositionned.single(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM));
return CommandExecutionResult.ok();

View File

@ -37,18 +37,18 @@ package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandFooter extends SingleLineCommand<UmlDiagram> {
public class CommandFooter extends SingleLineCommand<TitledDiagram> {
public CommandFooter() {
super("(?i)^(?:(left|right|center)?[%s]*)footer(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(TitledDiagram diagram, List<String> arg) {
final String align = arg.get(0);
diagram.getFooter().put(Display.getWithNewlines(arg.get(1)),
HorizontalAlignment.fromString(align, HorizontalAlignment.CENTER));

View File

@ -37,18 +37,18 @@ package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandHeader extends SingleLineCommand<UmlDiagram> {
public class CommandHeader extends SingleLineCommand<TitledDiagram> {
public CommandHeader() {
super("(?i)^(?:(left|right|center)?[%s]*)header(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(TitledDiagram diagram, List<String> arg) {
final String align = arg.get(0);
diagram.getHeader().put(Display.getWithNewlines(arg.get(1)),
HorizontalAlignment.fromString(align, HorizontalAlignment.RIGHT));

View File

@ -37,17 +37,17 @@ package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
public class CommandMainframe extends SingleLineCommand<UmlDiagram> {
public class CommandMainframe extends SingleLineCommand<TitledDiagram> {
public CommandMainframe() {
super("(?i)^mainframe(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(TitledDiagram diagram, List<String> arg) {
final Display label = Display.getWithNewlines(arg.get(0));
diagram.setMainFrame(label);
return CommandExecutionResult.ok();

View File

@ -35,12 +35,12 @@
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
public class CommandMultilinesFooter extends CommandMultilines<TitledDiagram> {
public CommandMultilinesFooter() {
super("(?i)^(?:(left|right|center)?[%s]*)footer$");
@ -51,7 +51,7 @@ public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
return "(?i)^end[%s]?footer$";
}
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) {
lines = lines.trim(false);
final Matcher2 m = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed());
if (m.find() == false) {

View File

@ -35,12 +35,12 @@
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
public class CommandMultilinesHeader extends CommandMultilines<TitledDiagram> {
public CommandMultilinesHeader() {
super("(?i)^(?:(left|right|center)?[%s]*)header$");
@ -51,7 +51,7 @@ public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
return "(?i)^end[%s]?header$";
}
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) {
lines = lines.trim(false);
final Matcher2 m = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed());
if (m.find() == false) {

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
@ -44,7 +44,7 @@ import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
public class CommandMultilinesLegend extends CommandMultilines2<TitledDiagram> {
public CommandMultilinesLegend() {
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
@ -64,7 +64,7 @@ public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
}
@Override
protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) {
protected CommandExecutionResult executeNow(TitledDiagram diagram, BlocLines lines) {
lines = lines.trimSmart(1);
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed());
final String align = line0.get("ALIGN", 0);

View File

@ -35,13 +35,13 @@
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
public class CommandMultilinesTitle extends CommandMultilines<TitledDiagram> {
public CommandMultilinesTitle() {
super("(?i)^title$");
@ -52,7 +52,7 @@ public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
return "(?i)^end[%s]?title$";
}
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) {
lines = lines.subExtract(1, 1);
lines = lines.removeEmptyColumns();
final Display strings = lines.toDisplay();

View File

@ -37,20 +37,20 @@ package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandTitle extends SingleLineCommand<UmlDiagram> {
public class CommandTitle extends SingleLineCommand<TitledDiagram> {
public CommandTitle() {
super("(?i)^title(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
protected CommandExecutionResult executeArg(TitledDiagram diagram, List<String> arg) {
diagram.setTitle(DisplayPositionned.single(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
VerticalAlignment.TOP));
return CommandExecutionResult.ok();

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByVisibility
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
import net.sourceforge.plantuml.utils.StartUtils;
import net.sourceforge.plantuml.version.IteratorCounter2;
@ -202,11 +203,43 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
public abstract AbstractPSystem createEmptyDiagram();
final protected void addCommonCommands(List<Command> cmds) {
final protected void addCommonCommands1(List<Command> cmds) {
addTitleCommands(cmds);
addCommonCommands2(cmds);
addCommonHides(cmds);
}
final protected void addCommonCommands2(List<Command> cmds) {
cmds.add(new CommandNope());
// cmds.add(new CommandComment());
// cmds.add(new CommandMultilinesComment());
cmds.add(new CommandPragma());
cmds.add(new CommandSkinParam());
cmds.add(new CommandSkinParamMultilines());
cmds.add(new CommandSkin());
cmds.add(new CommandMinwidth());
cmds.add(new CommandRotate());
cmds.add(new CommandScale());
cmds.add(new CommandScaleWidthAndHeight());
cmds.add(new CommandScaleWidthOrHeight());
cmds.add(new CommandScaleMaxWidth());
cmds.add(new CommandScaleMaxHeight());
cmds.add(new CommandScaleMaxWidthAndHeight());
cmds.add(new CommandAffineTransform());
cmds.add(new CommandAffineTransformMultiline());
final FactorySpriteCommand factorySpriteCommand = new FactorySpriteCommand();
cmds.add(factorySpriteCommand.createMultiLine(false));
cmds.add(factorySpriteCommand.createSingleLine());
cmds.add(new CommandSpriteFile());
}
final protected void addCommonHides(List<Command> cmds) {
cmds.add(new CommandHideUnlinked());
cmds.add(new CommandHideShowByVisibility());
cmds.add(new CommandHideShowByGender());
}
final protected void addTitleCommands(List<Command> cmds) {
cmds.add(new CommandTitle());
cmds.add(new CommandMainframe());
cmds.add(new CommandCaption());
@ -218,28 +251,6 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
cmds.add(new CommandHeader());
cmds.add(new CommandMultilinesHeader());
cmds.add(new CommandSkinParam());
cmds.add(new CommandSkinParamMultilines());
cmds.add(new CommandMinwidth());
cmds.add(new CommandRotate());
cmds.add(new CommandScale());
cmds.add(new CommandScaleWidthAndHeight());
cmds.add(new CommandScaleWidthOrHeight());
cmds.add(new CommandScaleMaxWidth());
cmds.add(new CommandScaleMaxHeight());
cmds.add(new CommandScaleMaxWidthAndHeight());
cmds.add(new CommandAffineTransform());
cmds.add(new CommandAffineTransformMultiline());
cmds.add(new CommandHideUnlinked());
final FactorySpriteCommand factorySpriteCommand = new FactorySpriteCommand();
cmds.add(factorySpriteCommand.createMultiLine(false));
cmds.add(factorySpriteCommand.createSingleLine());
cmds.add(new CommandSpriteFile());
cmds.add(new CommandHideShowByVisibility());
cmds.add(new CommandHideShowByGender());
}
final public List<String> getDescription() {

View File

@ -54,7 +54,7 @@ public class CompositeDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandLinkBlock());
cmds.add(new CommandCreatePackageBlock());
cmds.add(new CommandEndPackageBlock());
addCommonCommands(cmds);
addCommonCommands1(cmds);
return cmds;
}

View File

@ -97,13 +97,13 @@ public class AtomImg extends AbstractAtom implements Atom {
}
try {
// Check if valid URL
if (src.startsWith("http:") || src.startsWith("https:")) {
// final byte image[] = getFile(src);
return build(src, fc, new URL(src), scale);
}
final File f = FileSystem.getInstance().getFile(src);
if (f.exists() == false) {
// Check if valid URL
if (src.startsWith("http:") || src.startsWith("https:")) {
// final byte image[] = getFile(src);
return build(src, fc, new URL(src), scale);
}
return AtomText.create("(File not found: " + f.getCanonicalPath() + ")", fc);
}
if (f.getName().endsWith(".svg")) {

View File

@ -84,32 +84,32 @@ public class Display implements Iterable<CharSequence> {
public final static Display NULL = new Display(null, null, true, CreoleMode.FULL);
private void check() {
// if (displayData != null)
// for (CharSequence s : displayData) {
// if (s == null) {
// continue;
// }
// if (s instanceof String) {
// continue;
// }
// if (s instanceof Stereotype) {
// continue;
// }
// // if (s instanceof CharSequence2) {
// // continue;
// // }
// if (s instanceof MessageNumber) {
// continue;
// }
// if (s instanceof EmbeddedDiagram) {
// continue;
// }
// System.err.println("PB=" + s);
// System.err.println("PB=" + s.getClass());
// for (int i = 0; i < 100; i++)
// Thread.dumpStack();
// System.exit(0);
// }
// if (displayData != null)
// for (CharSequence s : displayData) {
// if (s == null) {
// continue;
// }
// if (s instanceof String) {
// continue;
// }
// if (s instanceof Stereotype) {
// continue;
// }
// // if (s instanceof CharSequence2) {
// // continue;
// // }
// if (s instanceof MessageNumber) {
// continue;
// }
// if (s instanceof EmbeddedDiagram) {
// continue;
// }
// System.err.println("PB=" + s);
// System.err.println("PB=" + s.getClass());
// for (int i = 0; i < 100; i++)
// Thread.dumpStack();
// System.exit(0);
// }
}
public Display replaceBackslashT() {
@ -267,12 +267,16 @@ public class Display implements Iterable<CharSequence> {
final List<CharSequence> result = new ArrayList<CharSequence>();
boolean first = true;
for (CharSequence line : displayData) {
String lineString = line.toString();
if (first && VisibilityModifier.isVisibilityCharacter(line)) {
lineString = lineString.substring(1).trim();
if (line instanceof EmbeddedDiagram) {
result.add(line);
} else {
String lineString = line.toString();
if (first && VisibilityModifier.isVisibilityCharacter(line)) {
lineString = lineString.substring(1).trim();
}
final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString);
result.add(withGuillement);
}
final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString);
result.add(withGuillement);
first = false;
}
return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode);

View File

@ -41,7 +41,7 @@ public enum LeafType {
EMPTY_PACKAGE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP, NOTE, TIPS, OBJECT, ASSOCIATION, ENUM, CIRCLE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, ASSOCIATION, ENUM, CIRCLE,
USECASE,

View File

@ -76,7 +76,7 @@ public class DescriptionDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandNamespaceSeparator());
cmds.add(new CommandRankDir());
cmds.add(new CommandNewpage(this));
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandPage());
cmds.add(new CommandLinkElement());

View File

@ -71,7 +71,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntity
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("SYMBOL",
"(package|rectangle|node|artifact|folder|file|frame|cloud|database|storage|component|card|together)"), //
"(package|rectangle|node|artifact|folder|file|frame|cloud|database|storage|component|card|together|queue)"), //
new RegexLeaf("[%s]+"), //
new RegexOr(//
new RegexConcat( //

View File

@ -514,7 +514,7 @@ public class EpsGraphics {
if (xRadius != yRadius) {
scale = yRadius / xRadius;
append("gsave", true);
append("1 " + format(scale) + " scale", true);
append("1 " + formatSimple4(scale) + " scale", true);
}
if (fillcolor != null) {
appendColor(fillcolor);

View File

@ -49,9 +49,9 @@ public class EpsGraphicsMacroAndText extends EpsGraphicsMacro {
final UFont font = fontConfiguration.getFont();
final int size = font.getSize();
append("/" + getPSName(fontConfiguration) + " findfont " + size + " scalefont setfont", true);
append("1 -1 scale", true);
append("100 -100 scale", true);
append("(" + getTextAsEps(text) + ") show", false);
append("1 -1 scale", true);
append(".01 -.01 scale", true);
}
private String getPSName(FontConfiguration fontConfiguration) {

View File

@ -44,12 +44,12 @@ import javax.imageio.ImageIO;
public class IconLoader {
private static final int NUMBER_OF_ICONS = 25;
private static final int NUMBER_OF_ICONS = 27;
private final static Map<String, BufferedImage> all = new ConcurrentHashMap<String, BufferedImage>();
public static BufferedImage getRandom() {
// return addTransparent(getIcon("sprite013.png"));
// return addTransparent(getIcon("sprite026.png"));
return addTransparent(getIcon(getSomeQuote()));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

View File

@ -154,26 +154,25 @@ class USymbolQueue extends USymbol {
@Override
public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype,
final double width, final double height, final SymbolContext symbolContext) {
throw new UnsupportedOperationException();
// return new TextBlock() {
//
// public void drawU(UGraphic ug) {
// final Dimension2D dim = calculateDimension(ug.getStringBounder());
// ug = symbolContext.apply(ug);
// drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
// final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
// final double posStereo = (width - dimStereo.getWidth()) / 2;
// stereotype.drawU(ug.apply(new UTranslate(posStereo, 0)));
//
// final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
// final double posTitle = (width - dimTitle.getWidth()) / 2;
// title.drawU(ug.apply(new UTranslate(posTitle, 21)));
// }
//
// public Dimension2D calculateDimension(StringBounder stringBounder) {
// return new Dimension2DDouble(width, height);
// }
// };
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {
final Dimension2D dim = calculateDimension(ug.getStringBounder());
ug = symbolContext.apply(ug);
drawQueue(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
final double posStereo = (width - dimStereo.getWidth()) / 2;
stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
final double posTitle = (width - dimTitle.getWidth()) / 2;
title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(width, height);
}
};
}
public boolean manageHorizontalLine() {

View File

@ -87,7 +87,7 @@ public class MindMapDiagram extends UmlDiagram {
throws IOException {
final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam();
final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor,
skinParam.getBackgroundColor(), "", "", 10, 10, null, skinParam.handwritten());

View File

@ -52,7 +52,7 @@ public class MindMapDiagramFactory extends UmlDiagramFactory {
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandMindMapTabulation());
cmds.add(new CommandMindMapOrgmode());
cmds.add(new CommandMindMapRoot());

View File

@ -52,7 +52,7 @@ public class NwDiagramFactory extends UmlDiagramFactory {
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandNwDiagInit());
cmds.add(new CommandComment());
cmds.add(new CommandElement());

View File

@ -82,12 +82,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
}
public int getNbOfHozizontalLollipop(IEntity entity) {
if (entity.getLeafType() == LeafType.LOLLIPOP) {
if (entity.getLeafType() == LeafType.LOLLIPOP_FULL || entity.getLeafType() == LeafType.LOLLIPOP_HALF) {
throw new IllegalArgumentException();
}
int result = 0;
for (Link link : getLinks()) {
if (link.getLength() == 1 && link.contains(entity) && link.containsType(LeafType.LOLLIPOP)) {
if (link.getLength() == 1 && link.contains(entity)
&& (link.containsType(LeafType.LOLLIPOP_FULL) || link.containsType(LeafType.LOLLIPOP_HALF))) {
result++;
}

View File

@ -64,7 +64,7 @@ public class ObjectDiagramFactory extends UmlDiagramFactory {
final List<Command> cmds = new ArrayList<Command>();
cmds.add(new CommandFootboxIgnored());
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandRankDir());
cmds.add(new CommandPage());
cmds.add(new CommandAddData());

View File

@ -64,7 +64,7 @@ public class PSystemListOpenIconic extends AbstractPSystem {
throws IOException {
final UDrawable result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false);
fileFormat.isWithMetadata() ? getMetadata() : null, null, 0, 0, null, false);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}

View File

@ -46,7 +46,7 @@ public class PostIdDiagramFactory extends UmlDiagramFactory {
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandCreatePostIt());
cmds.add(new CommandWidth());
return cmds;

View File

@ -106,6 +106,10 @@ public class Defines implements Truth {
result.environment.put("dirpath", file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/'));
return result;
}
public String getEnvironmentValue(String key) {
return this.environment.get(key);
}
private static String nameNoExtension(String name) {
final int x = name.lastIndexOf('.');

View File

@ -73,6 +73,7 @@ public class Preprocessor implements ReadLineNumbered {
}
final ReadFilterAnd filtersV2 = new ReadFilterAnd();
filtersV2.add(new ReadLineQuoteComment());
filtersV2.add(new SubPreprocessor(charset, definitionsContainer));
this.sourceV2 = filtersV2.applyFilter(reader);
final ReadFilterAnd filters = new ReadFilterAnd();

View File

@ -115,7 +115,7 @@ public class SubPreprocessor implements ReadFilter {
return s.withErrorPreprocessor("Cannot include " + FileWithSuffix.getFileName(f));
}
final SubPreprocessor data = new SubPreprocessor(charset, definitionsContainer);
InnerReadLine tmp = (InnerReadLine) data.applyFilter(getReaderInclude(s, f));
InnerReadLine tmp = (InnerReadLine) data.applyFilter(getReaderIncludeWithoutComment(s, f));
while (tmp.readLine() != null) {
// Read file
}
@ -177,7 +177,11 @@ public class SubPreprocessor implements ReadFilter {
}
private ReadLine getReaderInclude(StringLocated s, final File f) {
private ReadLine getReaderIncludeWithoutComment(StringLocated s, final File f) {
return new ReadLineQuoteComment().applyFilter(getReaderIncludeRaw(s, f));
}
private ReadLine getReaderIncludeRaw(StringLocated s, final File f) {
try {
if (charset == null) {
Log.info("Using default charset");

View File

@ -35,6 +35,8 @@
*/
package net.sourceforge.plantuml.project3;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@ -48,10 +50,14 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
@ -62,10 +68,13 @@ 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.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
@ -74,7 +83,7 @@ import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GanttDiagram extends AbstractPSystem implements Subject {
public class GanttDiagram extends TitledDiagram implements Subject {
private final Map<TaskCode, Task> tasks = new LinkedHashMap<TaskCode, Task>();
private final Map<String, Task> byShortName = new HashMap<String, Task>();
@ -125,41 +134,49 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
throws IOException {
final double margin = 10;
// OsortTasks();
final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), dpiFactor, null, "", "", 0, 0,
null, false);
final UDrawable result = getUDrawable();
final SkinParam skinParam = SkinParam.create(UmlDiagramType.TIMING);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
}
// private void sortTasks() {
// 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 TextBlockBackcolored getTextBlock() {
initMinMax();
final TimeScale timeScale = getTimeScale();
initTaskAndResourceDraws(timeScale);
return new TextBlockBackcolored() {
private UDrawable getUDrawable() {
return new UDrawable() {
public void drawU(UGraphic ug) {
initMinMax();
final TimeScale timeScale = getTimeScale();
drawTimeHeader(ug, timeScale);
drawTasks(ug, timeScale);
drawConstraints(ug, timeScale);
}
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return null;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final double xmin = timeScale.getStartingPosition(min);
final double xmax = timeScale.getEndingPosition(max);
return new Dimension2DDouble(xmax - xmin, totalHeight);
}
public MinMax getMinMax(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
public HtmlColor getBackcolor() {
return null;
}
};
}
@ -217,16 +234,16 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
}
private void drawTimeHeader(final UGraphic ug, TimeScale timeScale) {
private double totalHeight;
final double yTotal = initTaskAndResourceDraws(timeScale);
private void drawTimeHeader(final UGraphic ug, TimeScale timeScale) {
final double xmin = timeScale.getStartingPosition(min);
final double xmax = timeScale.getEndingPosition(max);
if (calendar == null) {
drawSimpleDayCounter(ug, timeScale, yTotal);
drawSimpleDayCounter(ug, timeScale);
} else {
drawCalendar(ug, timeScale, yTotal);
drawCalendar(ug, timeScale);
}
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).draw(new ULine(xmax - xmin, 0));
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, getHeaderHeight() - 3))
@ -257,9 +274,9 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
private static final int Y_WEEKDAY = 16;
private static final int Y_NUMDAY = 28;
private void drawCalendar(final UGraphic ug, TimeScale timeScale, final double yTotal) {
private void drawCalendar(final UGraphic ug, TimeScale timeScale) {
timeScale = new TimeScaleBasic();
final ULine vbar = new ULine(0, yTotal - Y_WEEKDAY);
final ULine vbar = new ULine(0, totalHeight - Y_WEEKDAY);
Month lastMonth = null;
final GCalendarSimple calendarAll = getCalendarSimple();
final Instant max2 = calendarAll.fromDayAsDate(calendar.toDayAsDate((InstantDay) max));
@ -274,7 +291,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
if (i.compareTo(max2.increment()) < 0) {
final TextBlock weekDay = getTextBlock(dayOfWeek.shortName(), 10, false);
final URectangle rect = new URectangle(x2 - x1 - 1, yTotal - Y_WEEKDAY);
final URectangle rect = new URectangle(x2 - x1 - 1, totalHeight - Y_WEEKDAY);
if (isWorkingDay) {
final HtmlColor back = colorDays.get(day);
if (back != null) {
@ -338,8 +355,8 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
text.drawU(ug.apply(new UTranslate(x1 + delta / 2, 0)));
}
private void drawSimpleDayCounter(final UGraphic ug, TimeScale timeScale, final double yTotal) {
final ULine vbar = new ULine(0, yTotal);
private void drawSimpleDayCounter(final UGraphic ug, TimeScale timeScale) {
final ULine vbar = new ULine(0, totalHeight);
for (Instant i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) {
final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(10, false),
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
@ -354,7 +371,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
}
}
private double initTaskAndResourceDraws(TimeScale timeScale) {
private void initTaskAndResourceDraws(TimeScale timeScale) {
double y = getHeaderHeight();
for (Task task : tasks.values()) {
final TaskDraw draw;
@ -373,7 +390,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
y += draw.getHeight();
}
return y;
this.totalHeight = y;
}
private void initMinMax() {
@ -429,12 +446,14 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
private void drawTasks(final UGraphic ug, TimeScale timeScale) {
for (Task task : tasks.values()) {
final TaskDraw draw = task.getTaskDraw();
draw.drawU(ug.apply(new UTranslate(0, draw.getY())));
draw.drawTitle(ug.apply(new UTranslate(0, draw.getY())));
final UTranslate move = new UTranslate(0, draw.getY());
draw.drawU(ug.apply(move));
draw.drawTitle(ug.apply(move));
}
for (Resource res : resources.values()) {
final ResourceDraw draw = res.getResourceDraw();
draw.drawU(ug.apply(new UTranslate(0, draw.getY())));
final UTranslate move = new UTranslate(0, draw.getY());
draw.drawU(ug.apply(move));
}
}

View File

@ -63,6 +63,7 @@ public class GanttDiagramFactory extends UmlDiagramFactory {
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
addTitleCommands(cmds);
// addCommonCommands(cmds);
cmds.add(new CommandNope());
// cmds.add(new CommandComment());

View File

@ -73,7 +73,10 @@ public class TaskDrawRegular implements TaskDraw {
public void drawTitle(UGraphic ug) {
final TextBlock title = Display.getWithNewlines(task.getPrettyDisplay()).create(getFontConfiguration(),
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
title.drawU(ug.apply(new UTranslate(timeScale.getEndingPosition(task.getStart()), 0)));
final double shapeHeight = getShapeHeight(100);
final double titleHeight = title.calculateDimension(ug.getStringBounder()).getHeight();
final double h = (margin + shapeHeight - titleHeight) / 2;
title.drawU(ug.apply(new UTranslate(timeScale.getEndingPosition(task.getStart()), h)));
}
private FontConfiguration getFontConfiguration() {
@ -85,12 +88,10 @@ public class TaskDrawRegular implements TaskDraw {
final double start = timeScale.getStartingPosition(task.getStart());
ug1 = applyColors(ug1);
UGraphic ug2 = ug1.apply(new UTranslate(start + margin, margin));
// final int load = 42; // task.getLoad();
final UShape shapeFull = getShape(100);
if (shapeFull instanceof UPolygon) {
ug2.draw(shapeFull);
} else {
// final double fullHeight = ((URectangle) shapeFull).getHeight();
ug2.draw(shapeFull);
}
}
@ -105,13 +106,6 @@ public class TaskDrawRegular implements TaskDraw {
return ug.apply(new UChangeColor(HtmlColorUtils.BLUE)).apply(new UChangeBackColor(defaultColor));
}
// private URectangle getShapeInside(Instant instant) {
// final double start = timeScale.getStartingPosition(instant);
// final double end = timeScale.getEndingPosition(instant);
// final double height = getHeight() - 2 * margin;
// return new URectangle(end - start, height);
// }
private UShape getShape(int load) {
if (isDiamond()) {
return getDiamond();
@ -120,8 +114,11 @@ public class TaskDrawRegular implements TaskDraw {
final Instant instantEnd = task.getEnd();
final double start = timeScale.getStartingPosition(instantStart);
final double end = timeScale.getEndingPosition(instantEnd);
final double height = (getHeight() - 2 * margin) * load / 100.0;
return new URectangle(end - start - 2 * margin, height, 8, 8);
return new URectangle(end - start - 2 * margin, getShapeHeight(load), 8, 8);
}
private double getShapeHeight(int load) {
return (getHeight() - 2 * margin) * load / 100.0;
}
private boolean isDiamond() {

View File

@ -95,7 +95,7 @@ public class SequenceDiagramFactory extends UmlDiagramFactory {
final List<Command> cmds = new ArrayList<Command>();
addCommonCommands(cmds);
addCommonCommands1(cmds);
cmds.add(new CommandActivate());
cmds.add(new CommandDeactivateShort());
@ -136,7 +136,6 @@ public class SequenceDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandHSpace());
cmds.add(new CommandReferenceOverSeveral());
cmds.add(new CommandReferenceMultilinesOverSeveral());
cmds.add(new CommandSkin());
cmds.add(new CommandAutonumber());
cmds.add(new CommandAutonumberStop());
cmds.add(new CommandAutonumberResume());

View File

@ -39,7 +39,7 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.sequencediagram.InGroupable;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -47,7 +47,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
abstract class Arrow extends GraphicalElement implements InGroupable {
private final Rose skin;
private final AbstractComponentRoseArrow arrowComponent;
private final ArrowComponent arrowComponent;
private double paddingArrowHead;
private double maxX;
private final Url url;
@ -68,7 +68,7 @@ abstract class Arrow extends GraphicalElement implements InGroupable {
public abstract double getActualWidth(StringBounder stringBounder);
Arrow(double startingY, Rose skin, AbstractComponentRoseArrow arrowComponent, Url url) {
Arrow(double startingY, Rose skin, ArrowComponent arrowComponent, Url url) {
super(startingY);
this.skin = skin;
this.arrowComponent = arrowComponent;
@ -97,7 +97,7 @@ abstract class Arrow extends GraphicalElement implements InGroupable {
return skin;
}
protected final AbstractComponentRoseArrow getArrowComponent() {
protected final ArrowComponent getArrowComponent() {
return arrowComponent;
}

View File

@ -306,7 +306,7 @@ class DrawableSetInitializer {
private void prepareNewpage(StringBounder stringBounder, Newpage newpage, ParticipantRange range) {
final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
.createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
.createComponentNewPage(drawableSet.getSkinParam()));
this.lastFreeY2 = freeY2;
freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
drawableSet.addEvent(newpage, graphicalNewpage);
@ -315,7 +315,7 @@ class DrawableSetInitializer {
private void prepareNewpageSpecial(StringBounder stringBounder, Newpage newpage, Event justBefore,
ParticipantRange range) {
final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
.createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
.createComponentNewPage(drawableSet.getSkinParam()));
this.lastFreeY2 = freeY2;
freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
drawableSet.addEvent(newpage, graphicalNewpage, justBefore);

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -56,7 +55,7 @@ class MessageArrow extends Arrow {
private final LivingParticipantBox p2;
private final Component compAliveBox;
public MessageArrow(double startingY, Rose skin, AbstractComponentRoseArrow arrow, LivingParticipantBox p1, LivingParticipantBox p2,
public MessageArrow(double startingY, Rose skin, ArrowComponent arrow, LivingParticipantBox p1, LivingParticipantBox p2,
Url url, Component compAliveBox) {
super(startingY, skin, arrow, url);
@ -152,7 +151,7 @@ class MessageArrow extends Arrow {
@Override
public double getArrowYStartLevel(StringBounder stringBounder) {
if (getArrowComponent() instanceof ArrowComponent) {
final AbstractComponentRoseArrow arrowComponent = (AbstractComponentRoseArrow) getArrowComponent();
final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
arrowComponent.getPreferredHeight(stringBounder));
return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
@ -163,7 +162,7 @@ class MessageArrow extends Arrow {
@Override
public double getArrowYEndLevel(StringBounder stringBounder) {
if (getArrowComponent() instanceof ArrowComponent) {
final AbstractComponentRoseArrow arrowComponent = (AbstractComponentRoseArrow) getArrowComponent();
final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
arrowComponent.getPreferredHeight(stringBounder));
return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();

View File

@ -60,7 +60,7 @@ public class MessageExoArrow extends Arrow {
private final boolean shortArrow;
private final ArrowConfiguration arrowConfiguration;
public MessageExoArrow(double startingY, Rose skin, AbstractComponentRoseArrow arrow, LivingParticipantBox p, MessageExoType type,
public MessageExoArrow(double startingY, Rose skin, ArrowComponent arrow, LivingParticipantBox p, MessageExoType type,
Url url, boolean shortArrow, ArrowConfiguration arrowConfiguration) {
super(startingY, skin, arrow, url);
this.p = p;

View File

@ -44,7 +44,6 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -55,7 +54,7 @@ class MessageSelfArrow extends Arrow {
private final double deltaX;
private final double deltaY;
public MessageSelfArrow(double startingY, Rose skin, AbstractComponentRoseArrow arrow, LivingParticipantBox p1, double deltaY,
public MessageSelfArrow(double startingY, Rose skin, ArrowComponent arrow, LivingParticipantBox p1, double deltaY,
Url url, double deltaX) {
super(startingY, skin, arrow, url);
this.p1 = p1;
@ -105,7 +104,7 @@ class MessageSelfArrow extends Arrow {
@Override
public double getArrowYStartLevel(StringBounder stringBounder) {
if (getArrowComponent() instanceof ArrowComponent) {
final AbstractComponentRoseArrow arrowComponent = (AbstractComponentRoseArrow) getArrowComponent();
final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
arrowComponent.getPreferredHeight(stringBounder));
return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
@ -116,7 +115,7 @@ class MessageSelfArrow extends Arrow {
@Override
public double getArrowYEndLevel(StringBounder stringBounder) {
if (getArrowComponent() instanceof ArrowComponent) {
final AbstractComponentRoseArrow arrowComponent = (AbstractComponentRoseArrow) getArrowComponent();
final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
arrowComponent.getPreferredHeight(stringBounder));
return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();

View File

@ -133,8 +133,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final double headerHeight = drawableSet.getHeadHeight(stringBounder);
final double tailHeight = drawableSet.getTailHeight(stringBounder, showFootbox);
final double signatureHeight = 0;
final double newpageHeight = drawableSet.getSkin()
.createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), Display.create(""))
final double newpageHeight = drawableSet.getSkin().createComponentNewPage(drawableSet.getSkinParam())
.getPreferredHeight(stringBounder);
return new PageSplitter(fullDimension.getHeight(), headerHeight, positions, tailHeight, signatureHeight,

View File

@ -48,11 +48,11 @@ import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.sequencediagram.Note;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.skin.ArrowBody;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowHead;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
class Step1Message extends Step1Abstract {
@ -70,7 +70,7 @@ class Step1Message extends Step1Abstract {
if (isSelfMessage()) {
this.messageArrow = null;
} else {
final AbstractComponentRoseArrow comp = drawingSet.getSkin().createComponentArrow(getConfig(),
final ArrowComponent comp = drawingSet.getSkin().createComponentArrow(getConfig(),
drawingSet.getSkinParam(), message.getLabelNumbered());
final Component compAliveBox = drawingSet.getSkin().createComponent(ComponentType.ALIVE_BOX_OPEN_OPEN,
null, drawingSet.getSkinParam(), null);

View File

@ -44,11 +44,11 @@ import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.MessageExo;
import net.sourceforge.plantuml.sequencediagram.MessageExoType;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDecoration;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.ComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -81,12 +81,12 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
}
private AbstractComponentRoseArrow getComponent(StringBounder stringBounder) {
private ArrowComponent getComponent(StringBounder stringBounder) {
ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
if (message.getType().getDirection() == -1) {
arrowConfiguration = arrowConfiguration.reverse();
}
final AbstractComponentRoseArrow comp = skin
final ArrowComponent comp = skin
.createComponentArrow(arrowConfiguration, skinParam, message.getLabelNumbered());
return comp;
}
@ -167,7 +167,7 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
}
public void updateStairs(StringBounder stringBounder, double y) {
final AbstractComponentRoseArrow comp = getComponent(stringBounder);
final ArrowComponent comp = getComponent(stringBounder);
final Dimension2D dim = comp.getPreferredDimension(stringBounder);
final double arrowY = comp.getStartPoint(stringBounder, dim).getY();

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.Context2D;
@ -104,7 +105,7 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
return message.isCreate();
}
private AbstractComponentRoseArrow getComponent(StringBounder stringBounder) {
private ArrowComponent getComponent(StringBounder stringBounder) {
ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
/*
* if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else
@ -113,7 +114,7 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
arrowConfiguration = arrowConfiguration.reverse();
}
final AbstractComponentRoseArrow comp = skin.createComponentArrow(arrowConfiguration, skinParam,
final ArrowComponent comp = skin.createComponentArrow(arrowConfiguration, skinParam,
message.getLabelNumbered());
return comp;
}
@ -145,7 +146,7 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
return;
}
final StringBounder stringBounder = ug.getStringBounder();
final AbstractComponentRoseArrow comp = getComponent(stringBounder);
final ArrowComponent comp = getComponent(stringBounder);
final Dimension2D dim = comp.getPreferredDimension(stringBounder);
double x1 = getPoint1(stringBounder).getCurrentValue();
double x2 = getPoint2(stringBounder).getCurrentValue();

View File

@ -46,10 +46,10 @@ import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.rose.AbstractComponentRoseArrow;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -90,16 +90,16 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat
//
// }
private AbstractComponentRoseArrow getComponent(StringBounder stringBounder) {
private ArrowComponent getComponent(StringBounder stringBounder) {
ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
arrowConfiguration = arrowConfiguration.self();
final AbstractComponentRoseArrow comp = skin
final ArrowComponent comp = skin
.createComponentArrow(arrowConfiguration, skinParam, message.getLabelNumbered());
return comp;
}
public void updateStairs(StringBounder stringBounder, double y) {
final AbstractComponentRoseArrow comp = getComponent(stringBounder);
final ArrowComponent comp = getComponent(stringBounder);
final Dimension2D dim = comp.getPreferredDimension(stringBounder);
final Point2D p1 = comp.getStartPoint(stringBounder, dim);
final Point2D p2 = comp.getEndPoint(stringBounder, dim);

View File

@ -185,8 +185,9 @@ public class EventsHistory {
if (position != null) {
assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight;
value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
final SymbolContext activateColor = getActivateColor(event);
result.addStep(new StairsPosition(Math.max(createY, position), isNextEventADestroy(event)), value,
getActivateColor(event));
activateColor);
}
}
// System.err.println("EventsHistory::getStairs finishing totalHeight=" + totalHeight);

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.sequencediagram.teoz;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@ -226,7 +227,7 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
positionedTiles.add(new YPositionedTile(tile, y));
if (tile instanceof GroupingTile) {
final GroupingTile groupingTile = (GroupingTile) tile;
final double headerHeight = groupingTile.getPreferredDimensionIfEmpty(stringBounder).getHeight();
final double headerHeight = groupingTile.getHeaderHeight(stringBounder);
fillPositionelTiles(stringBounder, y + headerHeight, groupingTile.tiles,
new ArrayList<YPositionedTile>());
}
@ -236,6 +237,10 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
}
private double getHeaderHeight(StringBounder stringBounder) {
return getPreferredDimensionIfEmpty(stringBounder).getHeight() + 10;
}
private static List<Tile> mergeParallel(List<Tile> tiles) {
TileParallel pending = null;
tiles = removeEmptyCloseToParallel(tiles);
@ -248,7 +253,7 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
if (tmp instanceof LifeEventTile) {
pending.add(result.get(result.size() - 2));
pending.add(tmp);
// result.set(result.size() - 1, pending);
// result.set(result.size() - 1, pending);
result.set(result.size() - 2, pending);
result.remove(result.size() - 1);
} else {
@ -287,6 +292,18 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
return tile instanceof TileParallel == false && tile.getEvent().isParallel();
}
void addYNewPages(Collection<Double> yNewPages) {
for (Tile tile : tiles) {
if (tile instanceof GroupingTile) {
((GroupingTile) tile).addYNewPages(yNewPages);
}
if (tile instanceof NewpageTile) {
final double y = ((NewpageTile) tile).getCallbackY();
yNewPages.add(y);
}
}
}
// public double getStartY() {
// return y + MARGINY;
// }

View File

@ -233,7 +233,6 @@ public class LivingSpace {
}
public void goCreate(double y) {
System.err.println("LivingSpace::goCreate y=" + y);
this.createY = y;
this.create = true;
}

View File

@ -0,0 +1,91 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Newpage;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class NewpageTile extends AbstractTile implements TileWithCallbackY {
private final Newpage newpage;
private final TileArguments tileArguments;
@Override
public double getYPoint(StringBounder stringBounder) {
return 0;
}
public NewpageTile(Newpage newpage, TileArguments tileArguments) {
this.newpage = newpage;
this.tileArguments = tileArguments;
}
public void drawU(UGraphic ug) {
}
public double getPreferredHeight(StringBounder stringBounder) {
return 0;
}
public void addConstraints(StringBounder stringBounder) {
}
public Real getMinX(StringBounder stringBounder) {
return tileArguments.getOrigin();
}
public Real getMaxX(StringBounder stringBounder) {
return tileArguments.getOrigin();
}
private double y;
public void callbackY(double y) {
this.y = y;
}
public double getCallbackY() {
return y;
}
public Event getEvent() {
return newpage;
}
}

View File

@ -42,13 +42,12 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.real.RealUtils;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.LinkAnchor;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.ugraphic.LimitFinder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class MainTile extends AbstractTile implements Tile, Bordered {
public class PlayingSpace implements Bordered {
private final double startingY = 8;
private final Real min;
@ -60,7 +59,7 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
private final List<LinkAnchor> linkAnchors;
private final ISkinParam skinParam;
public MainTile(SequenceDiagram diagram, Englobers englobers, TileArguments tileArguments) {
public PlayingSpace(SequenceDiagram diagram, Englobers englobers, TileArguments tileArguments) {
this.livingSpaces = tileArguments.getLivingSpaces();
this.linkAnchors = diagram.getLinkAnchors();
@ -77,8 +76,6 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
max2.add(englobers.getMaxX(tileArguments.getStringBounder()));
}
// tiles.add(new EmptyTile(8, tileArguments));
tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null));
for (Tile tile : tiles) {
@ -97,7 +94,7 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
this.isShowFootbox = diagram.isShowFootbox();
}
public void drawU(UGraphic ug) {
public void drawBackground(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final LiveBoxFinder liveBoxFinder = new LiveBoxFinder(stringBounder);
@ -116,7 +113,7 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
final List<YPositionedTile> positionedTiles = new ArrayList<YPositionedTile>();
final double y = GroupingTile.fillPositionelTiles(stringBounder, startingY, tiles, positionedTiles);
for (YPositionedTile tile : positionedTiles) {
tile.drawU(ug);
tile.drawInArea(ug);
}
for (LinkAnchor linkAnchor : linkAnchors) {
final YPositionedTile tile1 = getFromAnchor(positionedTiles, linkAnchor.getAnchor1());
@ -159,10 +156,6 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
return max;
}
public Event getEvent() {
return null;
}
public boolean isShowFootbox() {
return isShowFootbox;
}
@ -179,4 +172,24 @@ public class MainTile extends AbstractTile implements Tile, Bordered {
return max.getCurrentValue();
}
public List<Double> yNewPages() {
final List<Double> yNewPages = new ArrayList<Double>();
yNewPages.add((double) 0);
for (Tile tile : tiles) {
if (tile instanceof GroupingTile) {
((GroupingTile) tile).addYNewPages(yNewPages);
}
if (tile instanceof NewpageTile) {
final double y = ((NewpageTile) tile).getCallbackY();
yNewPages.add(y);
}
}
yNewPages.add(Double.MAX_VALUE);
return yNewPages;
}
public int getNbPages() {
return yNewPages().size() - 1;
}
}

View File

@ -36,38 +36,45 @@
package net.sourceforge.plantuml.sequencediagram.teoz;
import java.awt.geom.Dimension2D;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class MainTileAdapter extends AbstractTextBlock implements TextBlock {
public class PlayingSpaceWithParticipants extends AbstractTextBlock implements TextBlock {
private final MainTile mainTile;
private final PlayingSpace playingSpace;
private Dimension2D cacheDimension;
private double ymin;
private double ymax;
public MainTileAdapter(MainTile mainTile) {
if (mainTile == null) {
public PlayingSpaceWithParticipants(PlayingSpace playingSpace) {
if (playingSpace == null) {
throw new IllegalArgumentException();
}
this.mainTile = mainTile;
this.playingSpace = playingSpace;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
if (cacheDimension == null) {
final double width = mainTile.getMaxX(stringBounder).getCurrentValue()
- mainTile.getMinX(stringBounder).getCurrentValue();
final double width = playingSpace.getMaxX(stringBounder).getCurrentValue()
- playingSpace.getMinX(stringBounder).getCurrentValue();
final int factor = mainTile.isShowFootbox() ? 2 : 1;
final double height = mainTile.getPreferredHeight(stringBounder) + factor
* mainTile.getLivingSpaces().getHeadHeight(stringBounder);
final int factor = playingSpace.isShowFootbox() ? 2 : 1;
final double height = playingSpace.getPreferredHeight(stringBounder) + factor
* playingSpace.getLivingSpaces().getHeadHeight(stringBounder);
cacheDimension = new Dimension2DDouble(width, height);
}
@ -78,22 +85,60 @@ public class MainTileAdapter extends AbstractTextBlock implements TextBlock {
final StringBounder stringBounder = ug.getStringBounder();
final Context2D context = new SimpleContext2D(false);
final double height = mainTile.getPreferredHeight(stringBounder);
final LivingSpaces livingSpaces = mainTile.getLivingSpaces();
final double height = playingSpace.getPreferredHeight(stringBounder);
final LivingSpaces livingSpaces = playingSpace.getLivingSpaces();
final double headHeight = livingSpaces.getHeadHeight(stringBounder);
mainTile.drawU(ug.apply(new UTranslate(0, headHeight)));
if (ymax == 0) {
playingSpace.drawBackground(ug.apply(new UTranslate(0, headHeight)));
} else {
final UClip clip = new UClip(-1000, ymin, Double.MAX_VALUE, ymax - ymin + 1);
playingSpace.drawBackground(ug.apply(new UTranslate(0, headHeight)).apply(clip));
}
livingSpaces.drawLifeLines(ug.apply(new UTranslate(0, headHeight)), height, context);
livingSpaces.drawHeads(ug, context, VerticalAlignment.BOTTOM);
if (mainTile.isShowFootbox()) {
if (playingSpace.isShowFootbox()) {
livingSpaces.drawHeads(ug.apply(new UTranslate(0, height + headHeight)), context, VerticalAlignment.TOP);
}
mainTile.drawForeground(ug.apply(new UTranslate(0, headHeight)));
if (ymax == 0) {
playingSpace.drawForeground(ug.apply(new UTranslate(0, headHeight)));
} else {
final UClip clip = new UClip(-1000, ymin, Double.MAX_VALUE, ymax - ymin + 1);
// playingSpace.drawForeground(new UGraphicNewpages(ug.apply(new UTranslate(0, headHeight)), ymin, ymax));
playingSpace.drawForeground(ug.apply(new UTranslate(0, headHeight)).apply(clip));
}
// drawNewPages(ug.apply(new UTranslate(0, headHeight)));
}
public Real getMinX(StringBounder stringBounder) {
return mainTile.getMinX(stringBounder);
return playingSpace.getMinX(stringBounder);
}
public int getNbPages() {
return playingSpace.getNbPages();
}
public void setIndex(int index) {
final List<Double> yNewPages = playingSpace.yNewPages();
this.ymin = yNewPages.get(index);
this.ymax = yNewPages.get(index + 1);
}
private List<Double> yNewPages() {
return playingSpace.yNewPages();
}
private void drawNewPages(UGraphic ug) {
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLUE));
for (Double change : yNewPages()) {
if (change == 0 || change == Double.MAX_VALUE) {
continue;
}
ug.apply(new UTranslate(0, change)).draw(new ULine(100, 0));
}
}
}

View File

@ -86,8 +86,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
this.header = getFooterOrHeader(FontParam.HEADER);
this.annotatedWorker = new AnnotatedWorker(sequenceDiagram, sequenceDiagram.getSkinParam(), stringBounder);
this.main = new MainTileAdapter(createMainTile());
this.min1 = ((MainTileAdapter) main).getMinX(stringBounder);
this.body = new PlayingSpaceWithParticipants(createMainTile());
this.min1 = body.getMinX(stringBounder);
this.title = getTitle();
this.legend = getLegend();
@ -96,17 +96,16 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
this.heightEnglober1 = englobers.getOffsetForEnglobers(stringBounder);
this.heightEnglober2 = heightEnglober1 == 0 ? 0 : 10;
final double totalWidth = MathUtils.max(main.calculateDimension(stringBounder).getWidth(), title
final double totalWidth = MathUtils.max(body.calculateDimension(stringBounder).getWidth(), title
.calculateDimension(stringBounder).getWidth(), footer.calculateDimension(stringBounder).getWidth(),
header.calculateDimension(stringBounder).getWidth(), legend.calculateDimension(stringBounder)
.getWidth());
final double totalHeight = main.calculateDimension(stringBounder).getHeight() + heightEnglober1
final double totalHeight = body.calculateDimension(stringBounder).getHeight() + heightEnglober1
+ heightEnglober2 + title.calculateDimension(stringBounder).getHeight()
+ header.calculateDimension(stringBounder).getHeight()
+ legend.calculateDimension(stringBounder).getHeight()
+ footer.calculateDimension(stringBounder).getHeight();
this.dimTotal = new Dimension2DDouble(totalWidth, totalHeight);
}
private Englobers englobers;
@ -115,7 +114,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
private final TextBlock footer;
private final TextBlock header;
private final TextBlock main;
private final PlayingSpaceWithParticipants body;
private final TextBlock title;
private final TextBlock legend;
@ -134,8 +133,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
return a;
}
public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
final UTranslate min1translate = new UTranslate(-min1.getCurrentValue(), 0);
public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException {
final double dpiFactor = diagram.getDpiFactor(fileFormatOption, dimTotal);
final double scale = 1;
@ -145,38 +143,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
null, 3, 10, diagram.getAnimation());
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {
ug = ug.apply(min1translate);
englobers.drawEnglobers(goDownAndCenterForEnglobers(ug), main.calculateDimension(stringBounder)
.getHeight() + heightEnglober1 + heightEnglober2 / 2, new SimpleContext2D(true));
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header);
ug = goDown(ug, header);
printAligned(ug, HorizontalAlignment.CENTER, title);
ug = goDown(ug, title);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
ug = ug.apply(new UTranslate(0, heightEnglober1));
printAligned(ug, HorizontalAlignment.CENTER, main);
ug = goDown(ug, main);
ug = ug.apply(new UTranslate(0, heightEnglober2));
printAligned(ug, HorizontalAlignment.CENTER, caption);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer);
drawInternal(ug, index);
}
});
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
@ -189,7 +157,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) {
ug = goDown(ug, legend);
}
final double dx = (dimTotal.getWidth() - main.calculateDimension(stringBounder).getWidth()) / 2;
final double dx = (dimTotal.getWidth() - body.calculateDimension(stringBounder).getWidth()) / 2;
return ug.apply(new UTranslate(dx, 0));
}
@ -207,7 +175,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
layer.drawU(ug.apply(new UTranslate(dx, 0)));
}
private MainTile createMainTile() {
private PlayingSpace createMainTile() {
final RealOrigin origin = RealUtils.createOrigin();
Real currentPos = origin.addAtLeast(0);
for (Participant p : diagram.participants()) {
@ -221,7 +189,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
diagram.getSkinParam(), origin);
this.englobers = new Englobers(tileArguments);
final MainTile mainTile = new MainTile(diagram, englobers, tileArguments);
final PlayingSpace mainTile = new PlayingSpace(diagram, englobers, tileArguments);
this.livingSpaces.addConstraints(stringBounder);
mainTile.addConstraints(stringBounder);
this.englobers.addConstraints(stringBounder);
@ -266,7 +234,41 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
}
public int getNbPages() {
return 1;
return body.getNbPages();
}
private void drawInternal(UGraphic ug, int index) {
body.setIndex(index);
final UTranslate min1translate = new UTranslate(-min1.getCurrentValue(), 0);
ug = ug.apply(min1translate);
englobers.drawEnglobers(goDownAndCenterForEnglobers(ug), body.calculateDimension(stringBounder).getHeight()
+ heightEnglober1 + heightEnglober2 / 2, new SimpleContext2D(true));
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header);
ug = goDown(ug, header);
printAligned(ug, HorizontalAlignment.CENTER, title);
ug = goDown(ug, title);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
ug = ug.apply(new UTranslate(0, heightEnglober1));
printAligned(ug, HorizontalAlignment.CENTER, body);
ug = goDown(ug, body);
ug = ug.apply(new UTranslate(0, heightEnglober2));
printAligned(ug, HorizontalAlignment.CENTER, caption);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer);
}
}

View File

@ -62,7 +62,7 @@ public class Stairs2 {
assert ys.size() == values.size();
if (ys.size() > 0) {
final double lastY = ys.get(ys.size() - 1).getValue();
if (position.getValue() < lastY) {
if (position.getValue() <= lastY) {
// throw new IllegalArgumentException();
return;
}

View File

@ -35,7 +35,6 @@
*/
package net.sourceforge.plantuml.sequencediagram.teoz;
public class StairsPosition implements Comparable<StairsPosition> {
private final double value;
@ -51,6 +50,17 @@ public class StairsPosition implements Comparable<StairsPosition> {
return "" + value + "-(" + destroy + ")";
}
@Override
public int hashCode() {
return new Double(value).hashCode() + (destroy ? 17 : 37);
}
@Override
public boolean equals(Object obj) {
final StairsPosition other = (StairsPosition) obj;
return this.value == other.value && this.destroy == other.destroy;
}
public double getValue() {
return value;
}

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.sequencediagram.HSpace;
import net.sourceforge.plantuml.sequencediagram.LifeEvent;
import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.sequencediagram.MessageExo;
import net.sourceforge.plantuml.sequencediagram.Newpage;
import net.sourceforge.plantuml.sequencediagram.Note;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.Notes;
@ -161,6 +162,9 @@ public class TileBuilder {
final LifeEvent lifeEvent = (LifeEvent) ev;
final LivingSpace livingSpace = livingSpaces.get(lifeEvent.getParticipant());
tiles.add(new LifeEventTile(lifeEvent, tileArguments, livingSpace, skin, skinParam));
} else if (ev instanceof Newpage) {
final Newpage newpage = (Newpage) ev;
tiles.add(new NewpageTile(newpage, tileArguments));
} else {
System.err.println("TileBuilder::Ignoring " + ev.getClass());
}

View File

@ -47,9 +47,18 @@ import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TileParallel implements Tile, TileWithUpdateStairs {
public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbackY {
private final List<Tile> tiles = new ArrayList<Tile>();
public void callbackY(double y) {
for (Tile tile : tiles) {
if (tile instanceof TileWithCallbackY) {
((TileWithCallbackY) tile).callbackY(y);
}
}
}
public void updateStairs(StringBounder stringBounder, double y) {
for (Tile tile : tiles) {
@ -156,4 +165,5 @@ public class TileParallel implements Tile, TileWithUpdateStairs {
return null;
}
}

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