diff --git a/README.md b/README.md index bdf14e46b..a4604a4a1 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,14 @@ Generate UML diagram from textual description PlantUML is a component that allows to quickly write : - * [Sequence diagram](http://plantuml.com/sequence.html), - * [Use case diagram](http://plantuml.com/usecase.html), - * [Class diagram](http://plantuml.com/classes.html), - * [Activity diagram](http://plantuml.com/activity2.html), - * [Component diagram](http://plantuml.com/component.html), - * [State diagram](http://plantuml.com/state.html), - * [Object diagram](http://plantuml.com/objects.html) + * [Sequence diagram](http://plantuml.com/sequence-diagram), + * [Use case diagram](http://plantuml.com/use-case-diagram), + * [Class diagram](http://plantuml.com/class-diagram), + * [Activity diagram](http://plantuml.com/activity-diagram-beta), + * [Component diagram](http://plantuml.com/component-diagram), + * [State diagram](http://plantuml.com/state-diagram), + * [Object diagram](http://plantuml.com/object-diagram), + * [Deployment diagram](http://plantuml.com/deployment-diagram), + * [Timing diagram](http://plantuml.com/timing-diagram) To know more about PlantUML, please visit http://plantuml.com/ diff --git a/build.xml b/build.xml index cd52688e0..fa13a26d7 100644 --- a/build.xml +++ b/build.xml @@ -64,7 +64,6 @@ - diff --git a/pom.xml b/pom.xml index 526fc4dd5..0bfdd87fc 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 8057-SNAPSHOT + 8058-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index cafab7e71..0f23a024c 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -96,7 +96,7 @@ public interface ISkinParam extends ISkinSimple { public double getRoundCorner(String param, Stereotype stereotype); - public double maxMessageSize(); + public LineBreakStrategy maxMessageSize(); public boolean strictUmlStyle(); @@ -129,10 +129,11 @@ public interface ISkinParam extends ISkinSimple { public SplitParam getSplitParam(); public int swimlaneWidth(); - + public UmlDiagramType getUmlDiagramType(); - + public HtmlColor getHoverPathColor(); + public double getPadding(PaddingParam param); } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/LineBreakStrategy.java b/src/net/sourceforge/plantuml/LineBreakStrategy.java new file mode 100644 index 000000000..31f134df5 --- /dev/null +++ b/src/net/sourceforge/plantuml/LineBreakStrategy.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml; + +public class LineBreakStrategy { + + public static final LineBreakStrategy NONE = new LineBreakStrategy(null); + + private final String value; + + public LineBreakStrategy(String value) { + this.value = value; + } + + public double getMathWidth() { + if (value != null && value.matches("-?\\d+")) { + return Double.parseDouble(value); + } + return 0; + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/PaddingParam.java b/src/net/sourceforge/plantuml/PaddingParam.java new file mode 100644 index 000000000..a21e5a304 --- /dev/null +++ b/src/net/sourceforge/plantuml/PaddingParam.java @@ -0,0 +1,41 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml; + + +public enum PaddingParam { + PARTICIPANT, BOX; + + public String getSkinName() { + return StringUtils.goLowerCase(name()) + "Padding"; + } + +} diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 064253834..93fc64174 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -130,7 +130,7 @@ public class Run { } new MainWindow2(option, dir); } else if (option.isPipe() || option.isPipeMap() || option.isSyntax()) { - managePipe(option); + error = managePipe(option); forceQuit = true; } else if (option.isFailfast2()) { final long start2 = System.currentTimeMillis(); @@ -256,7 +256,7 @@ public class Run { } } - private static void managePipe(Option option) throws IOException { + private static boolean managePipe(Option option) throws IOException { final String charset = option.getCharset(); final BufferedReader br; if (charset == null) { @@ -264,10 +264,11 @@ public class Run { } else { br = new BufferedReader(new InputStreamReader(System.in, charset)); } - managePipe(option, br, System.out); + return managePipe(option, br, System.out); } - public static void managePipe(Option option, final BufferedReader br, final PrintStream ps) throws IOException { + static public boolean managePipe(Option option, final BufferedReader br, final PrintStream ps) throws IOException { + boolean error = false; final StringBuilder sb = new StringBuilder(); String s = null; while ((s = br.readLine()) != null) { @@ -286,6 +287,7 @@ public class Run { ps.println(((UmlDiagram) system).getUmlDiagramType().name()); ps.println(system.getDescription()); } else if (system instanceof PSystemError) { + error = true; ps.println("ERROR"); final PSystemError sys = (PSystemError) system; ps.println(sys.getHigherErrorPosition()); @@ -302,6 +304,7 @@ public class Run { } else if (option.isPipe()) { final String result = sourceStringReader.generateImage(ps, 0, option.getFileFormatOption()); if ("(error)".equalsIgnoreCase(result)) { + error = true; System.err.println("ERROR"); final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram(); final PSystemError sys = (PSystemError) system; @@ -311,6 +314,7 @@ public class Run { } } } + return error; } private static boolean manageAllFiles(Option option) throws IOException, InterruptedException { diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 4769a9e2f..f9c75967c 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -641,12 +641,8 @@ public class SkinParam implements ISkinParam { return null; } - public double maxMessageSize() { - final String value = getValue("maxmessagesize"); - if (value != null && value.matches("-?\\d+")) { - return Double.parseDouble(value); - } - return 0; + public LineBreakStrategy maxMessageSize() { + return new LineBreakStrategy(getValue("maxmessagesize")); } public boolean strictUmlStyle() { @@ -726,14 +722,6 @@ public class SkinParam implements ISkinParam { return true; } - public double getPadding() { - final String value = getValue("padding"); - if (value != null && value.matches("\\d+(\\.\\d+)?")) { - return Double.parseDouble(value); - } - return 0; - } - public int groupInheritance() { final String value = getValue("groupinheritance"); int result = Integer.MAX_VALUE; @@ -839,4 +827,20 @@ public class SkinParam implements ISkinParam { return getIHtmlColorSet().getColorIfValid(value, false); } + public double getPadding() { + final String value = getValue("padding"); + if (value != null && value.matches("\\d+(\\.\\d+)?")) { + return Double.parseDouble(value); + } + return 0; + } + + public double getPadding(PaddingParam param) { + final String value = getValue(param.getSkinName()); + if (value != null && value.matches("\\d+(\\.\\d+)?")) { + return Double.parseDouble(value); + } + return 0; + } + } diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 59085ba03..d8e5b5037 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -150,7 +150,7 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getThickness(param, stereotype); } - public double maxMessageSize() { + public LineBreakStrategy maxMessageSize() { return skinParam.maxMessageSize(); } @@ -254,4 +254,8 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getHoverPathColor(); } + public double getPadding(PaddingParam param) { + return skinParam.getPadding(param); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java index 72a16f667..845484e71 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java @@ -35,6 +35,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; @@ -68,7 +69,7 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note); - final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, + final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1)); this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(), false); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java index 265879550..6c2b8e11f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java @@ -40,6 +40,7 @@ import java.util.Set; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; @@ -125,7 +126,7 @@ class FtileIfAndStop extends AbstractFtile { final Sheet sheet = new CreoleParser(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(labelTest); - final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tileNonStop.getThickness()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java index 78e8197ac..3764740ca 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java @@ -38,6 +38,7 @@ import java.util.Set; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -98,7 +99,7 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil { final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note); - final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1)); + final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1)); opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(), false); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 9386c488e..7896c675f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -121,7 +122,7 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil { final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); - final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1)); + final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1)); opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(), withLink); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java index 4101f42c7..b836255ea 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java @@ -38,6 +38,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -98,7 +99,7 @@ public class FtileWithNotes extends AbstractFtile { for (PositionedNote note : notes) { final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); - final SheetBlock1 sheet1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); + final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); final SheetBlock2 sheet2 = new SheetBlock2(sheet1, new Stencil() { // -6 and 15 value comes from Opale: this is very ugly! public double getStartingX(StringBounder stringBounder, double y) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java index 1b3c46548..9f6f15c86 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -193,7 +194,7 @@ public class ConditionalBuilder { final Sheet sheet = new CreoleParser(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(labelTest); - final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness()); final Ftile diamond1; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index 5fa73f01a..bfc4c29b6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; @@ -119,7 +120,7 @@ public class FtileBox extends AbstractFtile { final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(label); - this.tb = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), new MyStencil(), new UStroke(1)); + this.tb = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), new MyStencil(), new UStroke(1)); this.print = label.toString(); } diff --git a/src/net/sourceforge/plantuml/creole/AtomText.java b/src/net/sourceforge/plantuml/creole/AtomText.java index 6ac2cb13a..0dda16670 100644 --- a/src/net/sourceforge/plantuml/creole/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/AtomText.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.StringTokenizer; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; @@ -227,7 +228,8 @@ public class AtomText implements Atom { return x; } - public List getSplitted(StringBounder stringBounder, double maxWidth) { + public List getSplitted(StringBounder stringBounder, LineBreakStrategy maxWidthAsString) { + final double maxWidth = maxWidthAsString.getMathWidth(); final List result = new ArrayList(); final StringTokenizer st = new StringTokenizer(text, " ", true); final StringBuilder currentLine = new StringBuilder(); diff --git a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java index 849fd4c55..004a3f476 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java +++ b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java @@ -34,6 +34,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -77,7 +78,7 @@ public class CreoleHorizontalLine implements Atom { } final CreoleParser parser = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL); final Sheet sheet = parser.createSheet(Display.getWithNewlines(line)); - final TextBlock tb = new SheetBlock1(sheet, 0, skinParam.getPadding()); + final TextBlock tb = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); return tb; } diff --git a/src/net/sourceforge/plantuml/creole/Fission.java b/src/net/sourceforge/plantuml/creole/Fission.java index f1121614d..1a3769cc2 100644 --- a/src/net/sourceforge/plantuml/creole/Fission.java +++ b/src/net/sourceforge/plantuml/creole/Fission.java @@ -36,32 +36,37 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.graphic.StringBounder; public class Fission { private final Stripe stripe; - private final double maxWidth; + private final LineBreakStrategy maxWidth; - public Fission(Stripe stripe, double maxWidth) { + public Fission(Stripe stripe, LineBreakStrategy maxWidth) { this.stripe = stripe; this.maxWidth = maxWidth; + if (maxWidth == null) { + throw new IllegalArgumentException(); + } } public List getSplitted(StringBounder stringBounder) { - if (maxWidth == 0) { + final double valueMaxWidth = maxWidth.getMathWidth(); + if (valueMaxWidth == 0) { return Arrays.asList(stripe); } final List result = new ArrayList(); StripeSimple current = new StripeSimple(); - for (Atom a1 : stripe.getAtoms()) { - for (Atom atom : getSplitted(stringBounder, a1)) { - final double width = atom.calculateDimension(stringBounder).getWidth(); - if (current.totalWidth + width > maxWidth) { + for (Atom atom : stripe.getAtoms()) { + for (Atom atomSplitted : getSplitted(stringBounder, atom)) { + final double width = atomSplitted.calculateDimension(stringBounder).getWidth(); + if (current.totalWidth + width > valueMaxWidth) { result.add(current); current = new StripeSimple(); } - current.addAtom(atom, width); + current.addAtom(atomSplitted, width); } } if (current.totalWidth > 0) { diff --git a/src/net/sourceforge/plantuml/creole/PSystemCreole.java b/src/net/sourceforge/plantuml/creole/PSystemCreole.java index 37e95e3c7..52ec19d15 100644 --- a/src/net/sourceforge/plantuml/creole/PSystemCreole.java +++ b/src/net/sourceforge/plantuml/creole/PSystemCreole.java @@ -38,6 +38,7 @@ import java.util.List; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescriptionImpl; import net.sourceforge.plantuml.core.ImageData; @@ -71,7 +72,7 @@ public class PSystemCreole extends AbstractPSystem { final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.FULL) .createSheet(display); - final SheetBlock1 sheetBlock = new SheetBlock1(sheet, 0, 0); + final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, false); diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java index ee9166b81..7382091e8 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock1.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -54,13 +55,16 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S private Map widths; private Map positions; private MinMax minMax; - private final double maxWidth; + private final LineBreakStrategy maxWidth; private final double padding; - public SheetBlock1(Sheet sheet, double maxWidth, double padding) { + public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, double padding) { this.sheet = sheet; this.maxWidth = maxWidth; this.padding = padding; + if (maxWidth == null) { + throw new IllegalArgumentException(); + } } @Override diff --git a/src/net/sourceforge/plantuml/creole/StripeTable.java b/src/net/sourceforge/plantuml/creole/StripeTable.java index a69d693a5..42309b6db 100644 --- a/src/net/sourceforge/plantuml/creole/StripeTable.java +++ b/src/net/sourceforge/plantuml/creole/StripeTable.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.StringTokenizer; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -69,7 +70,7 @@ public class StripeTable implements Stripe { for (StripeSimple cell : cells) { sheet.add(cell); } - return new SheetBlock1(sheet, 0, padding); + return new SheetBlock1(sheet, LineBreakStrategy.NONE, padding); } private HtmlColor getBackColor(String line) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index 8cba93daf..0bce60b1c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.CharSequence2; import net.sourceforge.plantuml.CharSequence2Impl; import net.sourceforge.plantuml.EmbededDiagram; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineLocationImpl; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.StringUtils; @@ -371,12 +372,21 @@ public class Display implements Iterable { public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, CreoleMode modeSimpleLine) { - return create(fontConfiguration, horizontalAlignment, spriteContainer, 0, modeSimpleLine, null, null); + return create(fontConfiguration, horizontalAlignment, spriteContainer, LineBreakStrategy.NONE, modeSimpleLine, null, null); } public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple spriteContainer, double maxMessageSize, CreoleMode modeSimpleLine, UFont fontForStereotype, - HtmlColor htmlColorForStereotype) { + ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize) { + return create(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, defaultCreoleMode, null, + null); + } + + public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode modeSimpleLine, + UFont fontForStereotype, HtmlColor htmlColorForStereotype) { + if (maxMessageSize == null) { + throw new IllegalArgumentException(); + } if (getNaturalHorizontalAlignment() != null) { horizontalAlignment = getNaturalHorizontalAlignment(); } @@ -398,7 +408,7 @@ public class Display implements Iterable { } private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple spriteContainer, double maxMessageSize, CreoleMode modeSimpleLine) { + ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode modeSimpleLine) { final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, modeSimpleLine) .createSheet(this); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0 @@ -407,7 +417,7 @@ public class Display implements Iterable { } private TextBlock createMessageNumber(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple spriteContainer, double maxMessageSize) { + ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize) { TextBlock tb1 = subList(0, 1).getCreole(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL); tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0); diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index be0ebd6d4..1e8f13460 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -60,7 +60,7 @@ import net.sourceforge.plantuml.version.PSystemVersion; public class PSystemDonors extends AbstractPSystem { - public static final String DONORS = "UDfbL4josp0CtUCKN6lIGoXsx5J-96EdwKnsi0HRZ2d29IMdyZbwbImwqrqlu2CLSYkJIhaIXW3utiE3KfFyE-JWaMfoAhKrMuqvF54I3bSmvn0w3sbVYXkOkd15BQnfWxxMQDMIImkfBTYfALDzekvpkvMCFXqjp35woDOmrdsW3QIXDHzXtGG8BKnrCZoM8UjHDXxMDHrAich4V11-u_uTyZ2hFfIoWn4RRTMA6q-GDH_karSM8drmqB28K6CLX_9KQkWxsaBa79LQkkxGjS9qTQLjTx2CqTSdU33wA0LZdUy5-VL6MxZprzOs0f7G4SQdIjUkLNCikK38Ej5VIfJsKLv29enBphuLcIpMaYVu15Vs5ppj1wni8Q7BHPC9RboxvpU_rzB8IDc3g_K9xaDsmR3GUKb6tQ8sRSp0d68mtaD6Q3zbc7zhoAjnit4eipI1xpE_rfINQkRGOu2q8x5eDB6tpbcIecPyrB5HBbRv4WXhX5Latkw9c6VoAjM7o5QyxvIvPOSMpU56lL2DVF2m4eBe2ZNJtMXXOjXrUYz-_pBcClHW21EPK-mqlzh9OQzsD_LooCZ38_RsMEa1uDHejKOiP7NSZjHNiZjoDsgHFdrUfy7Q2LkOqc1bOkOs5ujKwbbGZyMqiv3fg9kiBCkS2EwEiVEF2ClGXAeUP1BHc3PQVD5Kf2RSK1tqpJrCuibSk0Gts5Cicy1TwfruQAshi882I3PvsocDijKHwCGOEFyulqVjp-_ddp0g1wlTok8rcykFm5dPXNiUm9aIRxUEMhNKbGmkm___Ady0ufjPnG00"; + public static final String DONORS = "UDfbL4josp0CtUCKN6lIGoXsx5J-96EdwKnsi0HRZ2d29IMdyZbwbImwqrqlu2CLSYkJIhaoJ01y3tXFgKd-7NBmI3KvbTgQhSOSdYW9XokOSmYTXxGlnGrCNRYY5jQqGLzhj6h9fONK5kpKbAa-KVTpkvMCFXqjp35woDOmrdsW3QIXDHzXtGG8BKnrCZoM8UjHDXxMDHrAich4V11-u_uTyZ2hFfIoWn4RRTMA6q-GDH_karSM8drmqB28K6CLX_9KQkWxsaB6EIgrTDsXQuNfwahRxc0PewzFy63qKGh6EjyBykkDjd3dhwrj12AX8unFbQvTg-POSe6GTKD_AL7QHta9cR0kEVjMncInbZp19xYol-1fFs1b2mbTBZEPuCQrUtxpUosDZ9Gzk5gVu3va5mmBdPTar2rgqyOCp2a6upraXFPJXlctXhmQDnk7iaiJ-3xpQqrvgMOEFGP8EnA9HXjxwvGbAMh6HnqBvIALBu6mHbX5uksUY7achr9zY6J5-suoj-pGeZdSg1UgaGyULa8GNQ5ckbijJ0oxRjwBtx-CkImz2C94uXGvpQzoSjXFkzjwEMJauH5xUQpq071gj5eZ5c8TjoFrbUoEt8rQf4-VrscGTi8MfZImJCpSvYAHIZqBwh68TXOo7NMR5RFCYU3k62l_YB0CJQZgGIOHZMcZHHTDHMh23TLXlhc7IRoP2vUW1dkAnoPmbted6bhhAbXG08cJjzsaKLmTWKwCWVEFytlK_ln-_WcZSc3jLepNR2uV0cV52_SyW3CbtcuTjMgfArbSXlz_LLRN_yGZVm26X5oY"; @Override final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java index cd5cd6414..8cd6d28b7 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java @@ -30,7 +30,6 @@ */ package net.sourceforge.plantuml.graphic; - public class HtmlColorUtils { public static final HtmlColor BLACK; @@ -66,7 +65,6 @@ public class HtmlColorUtils { public static final HtmlColor COL_D7E0F2; public static final HtmlColor COL_989898; public static final HtmlColor COL_BBBBBB; - static { @@ -108,4 +106,11 @@ public class HtmlColorUtils { } + public static HtmlColor noGradient(HtmlColor color) { + if (color instanceof HtmlColorGradient) { + return ((HtmlColorGradient) color).getColor1(); + } + return color; + } + } diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 1fff3834a..3aba5b3cf 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -203,7 +203,8 @@ public class QuoteUtils { "Ab WninFpevcg senzrjbexf jrer perngrq qhevat gur jevgvat bs guvf zrffntr.", "P'rfg cerffr-cherr dhv g'nf vagreebtr ?", "Ybbx, nygreangvir snpgf ner abg snpgf. Gurl'er snyfrubbqf", - "Guvf vf abg n penfu, guvf vf zber bs na nygreangvir erfhyg."); + "Guvf vf abg n penfu, guvf vf zber bs na nygreangvir erfhyg.", + "Lbh yrnearq gb cebtenz va SBEGENA qvqa'g lbh?"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockTitle.java b/src/net/sourceforge/plantuml/graphic/TextBlockTitle.java index 13143eaa8..64daadd85 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockTitle.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockTitle.java @@ -35,6 +35,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -50,8 +51,8 @@ public class TextBlockTitle implements TextBlock { if (stringsToDisplay.size() == 1 && stringsToDisplay.get(0).length() == 0) { throw new IllegalArgumentException(); } - textBlock = stringsToDisplay.create(font, HorizontalAlignment.CENTER, spriteContainer, 0, CreoleMode.FULL, - null, null); + textBlock = stringsToDisplay.create(font, HorizontalAlignment.CENTER, spriteContainer, LineBreakStrategy.NONE, + CreoleMode.FULL, null, null); } public final void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/jungle/GTileNode.java b/src/net/sourceforge/plantuml/jungle/GTileNode.java index 47c0ae342..f4caad6e9 100644 --- a/src/net/sourceforge/plantuml/jungle/GTileNode.java +++ b/src/net/sourceforge/plantuml/jungle/GTileNode.java @@ -34,6 +34,7 @@ import java.awt.geom.Dimension2D; import java.util.Arrays; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; @@ -76,7 +77,7 @@ public class GTileNode extends AbstractTextBlock implements GTile { final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL) .createSheet(display); - final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, 0, 0); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, LineBreakStrategy.NONE, 0); return sheetBlock1; } diff --git a/src/net/sourceforge/plantuml/project3/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java b/src/net/sourceforge/plantuml/project3/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java index ae6fdfae0..999c26c65 100644 --- a/src/net/sourceforge/plantuml/project3/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java +++ b/src/net/sourceforge/plantuml/project3/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java @@ -44,7 +44,10 @@ public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPatt public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) { final String code = arg.get("COMPLEMENT" + suffix, 2); final String position = arg.get("COMPLEMENT" + suffix, 3); - final Task task = system.getTask(new TaskCode(code)); + final Task task = system.getExistingTask(code); + if (task == null) { + throw new IllegalStateException(); + } final String days = arg.get("COMPLEMENT" + suffix, 0); TaskInstant result = new TaskInstant(task, TaskAttribute.fromString(position)); if (days != null) { diff --git a/src/net/sourceforge/plantuml/project3/ComplementDate.java b/src/net/sourceforge/plantuml/project3/ComplementDate.java new file mode 100644 index 000000000..481d953fb --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/ComplementDate.java @@ -0,0 +1,86 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class ComplementDate implements ComplementPattern { + + public IRegex toRegex(String suffix) { + return new RegexOr(toRegexA(suffix), toRegexB(suffix)); + } + + private IRegex toRegexA(String suffix) { + return new RegexConcat( // + new RegexLeaf("ADAY" + suffix, "([\\d]+)"), // + new RegexLeaf("[\\w ]*?"), // + new RegexLeaf("AMONTH" + suffix, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w ]*?"), // + new RegexLeaf("AYEAR" + suffix, "([\\d]+)")); + } + + private IRegex toRegexB(String suffix) { + return new RegexConcat( // + new RegexLeaf("BYEAR" + suffix, "([\\d]{4})"), // + new RegexLeaf("\\D"), // + new RegexLeaf("BMONTH" + suffix, "([\\d]{1,2})"), // + new RegexLeaf("\\D"), // + new RegexLeaf("BDAY" + suffix, "([\\d]{1,2})")); + } + + public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) { + if (arg.get("ADAY" + suffix, 0) != null) { + return resultA(arg, suffix); + } + if (arg.get("BDAY" + suffix, 0) != null) { + return resultB(arg, suffix); + } + throw new IllegalStateException(); + } + + private Complement resultA(RegexResult arg, String suffix) { + final int day = Integer.parseInt(arg.get("ADAY" + suffix, 0)); + final String month = arg.get("AMONTH" + suffix, 0); + final int year = Integer.parseInt(arg.get("AYEAR" + suffix, 0)); + return DayAsDate.create(year, month, day); + } + + private Complement resultB(RegexResult arg, String suffix) { + final int day = Integer.parseInt(arg.get("BDAY" + suffix, 0)); + final int month = Integer.parseInt(arg.get("BMONTH" + suffix, 0)); + final int year = Integer.parseInt(arg.get("BYEAR" + suffix, 0)); + return DayAsDate.create(year, month, day); + } +} diff --git a/src/net/sourceforge/plantuml/project3/DayAsDate.java b/src/net/sourceforge/plantuml/project3/DayAsDate.java new file mode 100644 index 000000000..516afb7a8 --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/DayAsDate.java @@ -0,0 +1,92 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +public class DayAsDate implements Complement { + + private final int year; + private final int dayOfMonth; + private final Month month; + + public static DayAsDate create(int year, String month, int dayOfMonth) { + return new DayAsDate(year, Month.fromString(month), dayOfMonth); + } + + public static DayAsDate create(int year, int month, int dayOfMonth) { + return new DayAsDate(year, Month.values()[month - 1], dayOfMonth); + } + + private DayAsDate(int year, Month month, int dayOfMonth) { + this.year = year; + this.dayOfMonth = dayOfMonth; + this.month = month; + } + + @Override + public String toString() { + return "" + year + "/" + month + "/" + dayOfMonth; + } + + public final int getDayOfMonth() { + return dayOfMonth; + } + + private int daysPerMonth() { + return month.getDaysPerMonth(year); + } + + public DayAsDate next() { + int newDayOfMonth = dayOfMonth + 1; + if (newDayOfMonth <= daysPerMonth()) { + return new DayAsDate(year, month, newDayOfMonth); + } + assert newDayOfMonth > daysPerMonth(); + newDayOfMonth = 1; + final Month newMonth = month.next(); + final int newYear = newMonth == Month.JANUARY ? year + 1 : year; + return new DayAsDate(newYear, newMonth, newDayOfMonth); + } + + public Month getMonth() { + return month; + } + + // https://en.wikipedia.org/wiki/Zeller%27s_congruence + public DayOfWeek getDayOfWeek() { + final int q = dayOfMonth; + final int m = month.m(); + final int y = m >= 13 ? year - 1 : year; + final int k = y % 100; + final int j = y / 100; + final int h = ((q + 13 * (m + 1) / 5) + k + k / 4 + j / 4 + 5 * j) % 7; + return DayOfWeek.fromH(h); + } +} diff --git a/src/net/sourceforge/plantuml/project3/DayOfWeek.java b/src/net/sourceforge/plantuml/project3/DayOfWeek.java new file mode 100644 index 000000000..add3a8f19 --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/DayOfWeek.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +import net.sourceforge.plantuml.StringUtils; + +public enum DayOfWeek { + + MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY; + + public DayOfWeek next() { + return DayOfWeek.values()[(ordinal() + 1) % 7]; + } + + public static DayOfWeek fromH(int h) { + return DayOfWeek.values()[(h + 5) % 7]; + } + + public String shortName() { + return StringUtils.capitalize(name().substring(0, 2)); + } +} diff --git a/src/net/sourceforge/plantuml/project3/GCalendar.java b/src/net/sourceforge/plantuml/project3/GCalendar.java new file mode 100644 index 000000000..f226c4abc --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/GCalendar.java @@ -0,0 +1,39 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +public interface GCalendar { + + // public DayAsDate next(DayAsDate day); + + public DayAsDate toDayAsDate(InstantDay day); + +} diff --git a/src/net/sourceforge/plantuml/project3/GCalendarSimple.java b/src/net/sourceforge/plantuml/project3/GCalendarSimple.java new file mode 100644 index 000000000..351766a06 --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/GCalendarSimple.java @@ -0,0 +1,49 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +public class GCalendarSimple implements GCalendar { + + private final DayAsDate start; + + public GCalendarSimple(DayAsDate start) { + this.start = start; + } + + public DayAsDate toDayAsDate(InstantDay day) { + DayAsDate result = start; + for (int i = 0; i < day.getNumDay(); i++) { + result = result.next(); + } + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/project3/GanttDiagram.java b/src/net/sourceforge/plantuml/project3/GanttDiagram.java index 55203f94c..37482b475 100644 --- a/src/net/sourceforge/plantuml/project3/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project3/GanttDiagram.java @@ -36,6 +36,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -49,7 +50,6 @@ import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.IHtmlColorSet; @@ -63,10 +63,16 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class GanttDiagram extends AbstractPSystem { +public class GanttDiagram extends AbstractPSystem implements Subject { private final Map tasks = new LinkedHashMap(); + private final Map byShortName = new HashMap(); private final List constraints = new ArrayList(); + private final IHtmlColorSet colorSet = new HtmlColorSetSimple(); + private GCalendar calendar; + + private Instant min; + private Instant max; public DiagramDescription getDescription() { return new DiagramDescriptionImpl("(Project)", getClass()); @@ -91,7 +97,6 @@ public class GanttDiagram extends AbstractPSystem { } private void sortTasks() { - System.err.println("SORTING TASKS!"); final TaskCodeSimpleOrder order = getCanonicalOrder(1); final List list = new ArrayList(tasks.values()); Collections.sort(list, new Comparator() { @@ -108,8 +113,10 @@ public class GanttDiagram extends AbstractPSystem { private UDrawable getUDrawable() { return new UDrawable() { public void drawU(UGraphic ug) { + initMinMax(); final TimeScale timeScale = new TimeScale(); - drawInternal(ug, timeScale); + drawTimeHeader(ug, timeScale); + drawTasks(ug, timeScale); drawConstraints(ug, timeScale); } }; @@ -122,42 +129,66 @@ public class GanttDiagram extends AbstractPSystem { } - private void drawInternal(final UGraphic ug, TimeScale timeScale) { + private void drawTimeHeader(final UGraphic ug, TimeScale timeScale) { - // System.err.println("=============="); - // for (Task task : tasks.values()) { - // System.err.println("task=" + task + " " + ((TaskImpl) task).debug()); - // } - // System.err.println("=============="); + final double yTotal = initTaskDraws(timeScale); - Instant min = tasks.values().iterator().next().getStart(); - Instant max = tasks.values().iterator().next().getEnd(); - for (Task task : tasks.values()) { - final Instant start = task.getStart(); - final Instant end = task.getEnd(); - if (min.compareTo(start) > 0) { - min = start; - } - if (max.compareTo(end) < 0) { - max = end; - } - } - - final double header = 16; - double y = header; - for (Task task : tasks.values()) { - final TaskDraw draw = new TaskDraw(task, timeScale, y); - task.setTaskDraw(draw); - y += draw.getHeight(); - } - - ULine vbar = new ULine(0, y); final double xmin = timeScale.getPixel(min); final double xmax = timeScale.getPixel(max.increment()); ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).draw(new ULine(xmax - xmin, 0)); - ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, header - 3)) + ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, getHeaderHeight() - 3)) .draw(new ULine(xmax - xmin, 0)); + if (calendar == null) { + drawSimpleDayCounter(ug, timeScale, yTotal); + } else { + drawCalendar(ug, timeScale, yTotal); + } + } + + private void drawCalendar(final UGraphic ug, TimeScale timeScale, final double yTotal) { + final int magic = 12; + final ULine vbar = new ULine(0, yTotal - magic); + Month lastMonth = null; + for (Instant i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) { + final DayAsDate day = calendar.toDayAsDate((InstantDay) i); + final String d1 = "" + day.getDayOfMonth(); + final TextBlock num = Display.getWithNewlines(d1).create(getFontConfiguration(), HorizontalAlignment.LEFT, + new SpriteContainerEmpty()); + final double x1 = timeScale.getPixel(i); + final double x2 = timeScale.getPixel(i.increment()); + if (i.compareTo(max.increment()) < 0) { + final TextBlock weekDay = Display.getWithNewlines(day.getDayOfWeek().shortName()).create( + getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + + drawCenter(ug.apply(new UTranslate(0, magic * 2)), num, x1, x2); + drawCenter(ug.apply(new UTranslate(0, magic)), weekDay, x1, x2); + if (lastMonth != day.getMonth()) { + final TextBlock month = Display.getWithNewlines(day.getMonth().name()).create( + getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + month.drawU(ug.apply(new UTranslate(x1, 0))); + } + lastMonth = day.getMonth(); + } + ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(x1, magic)).draw(vbar); + } + } + + private double getHeaderHeight() { + if (calendar != null) { + return 40; + } + return 16; + } + + private void drawCenter(final UGraphic ug, final TextBlock text, final double x1, final double x2) { + final double width = text.calculateDimension(ug.getStringBounder()).getWidth(); + final double delta = (x2 - x1) - width; + 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); for (Instant i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) { final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); @@ -170,14 +201,40 @@ public class GanttDiagram extends AbstractPSystem { } ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(x1, 0)).draw(vbar); } + } + private double initTaskDraws(TimeScale timeScale) { + double y = getHeaderHeight(); + for (Task task : tasks.values()) { + final TaskDraw draw = new TaskDraw(task, timeScale, y); + task.setTaskDraw(draw); + y += draw.getHeight(); + } + return y; + } + + private void initMinMax() { + min = tasks.values().iterator().next().getStart(); + max = tasks.values().iterator().next().getEnd(); + for (Task task : tasks.values()) { + final Instant start = task.getStart(); + final Instant end = task.getEnd(); + if (min.compareTo(start) > 0) { + min = start; + } + if (max.compareTo(end) < 0) { + max = end; + } + } + } + + 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.getTitle().drawU( ug.apply(new UTranslate(timeScale.getPixel(task.getStart().increment()), draw.getY()))); } - } private FontConfiguration getFontConfiguration() { @@ -185,11 +242,38 @@ public class GanttDiagram extends AbstractPSystem { return new FontConfiguration(font, HtmlColorUtils.LIGHT_GRAY, HtmlColorUtils.LIGHT_GRAY, false); } - public Task getTask(TaskCode code) { - Task result = tasks.get(code); + public Task getExistingTask(String id) { + if (id == null) { + throw new IllegalArgumentException(); + } + Task result = byShortName.get(id); + if (result != null) { + return result; + } + final TaskCode code = new TaskCode(id); + return tasks.get(code); + } + + public Task getOrCreateTask(String codeOrShortName, String shortName) { + if (codeOrShortName == null) { + throw new IllegalArgumentException(); + } + Task result = shortName == null ? null : byShortName.get(shortName); + if (result != null) { + return result; + } + result = byShortName.get(codeOrShortName); + if (result != null) { + return result; + } + final TaskCode code = new TaskCode(codeOrShortName); + result = tasks.get(code); if (result == null) { result = new TaskImpl(code); tasks.put(code, result); + if (byShortName != null) { + byShortName.put(shortName, result); + } } return result; } @@ -216,10 +300,12 @@ public class GanttDiagram extends AbstractPSystem { constraints.add(constraint); } - private final IHtmlColorSet colorSet = new HtmlColorSetSimple(); - public IHtmlColorSet getIHtmlColorSet() { return colorSet; } + public void setStartingDate(DayAsDate start) { + this.calendar = new GCalendarSimple(start); + } + } diff --git a/src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java b/src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java index 612e5f548..2525c894a 100644 --- a/src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java +++ b/src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.core.DiagramType; public class GanttDiagramFactory extends UmlDiagramFactory { private List subjects() { - return Arrays. asList(new SubjectTask()); + return Arrays. asList(new SubjectTask(), new SubjectProject()); } public GanttDiagramFactory() { diff --git a/src/net/sourceforge/plantuml/project3/Month.java b/src/net/sourceforge/plantuml/project3/Month.java new file mode 100644 index 000000000..d6a8cc43e --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/Month.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +import net.sourceforge.plantuml.StringUtils; + +public enum Month { + + JANUARY(31), FEBRUARY(28), MARCH(31), APRIL(30), MAY(31), JUNE(30), // + JULY(31), AUGUST(31), SEPTEMBER(30), OCTOBER(31), NOVEMBER(30), DECEMBER(31); + + private final int daysPerMonth; + + private Month(int daysPerMonth) { + this.daysPerMonth = daysPerMonth; + } + + static public String getRegexString() { + final StringBuilder sb = new StringBuilder(); + for (Month month : Month.values()) { + if (sb.length() > 0) { + sb.append("|"); + } + sb.append(month.name().substring(0, 3) + "[a-z]*"); + } + return sb.toString(); + } + + public static Month fromString(String value) { + value = StringUtils.goUpperCase(value).substring(0, 3); + for (Month m : Month.values()) { + if (m.name().startsWith(value)) { + return m; + } + } + throw new IllegalArgumentException(); + } + + public final int getDaysPerMonth(int year) { + if (this == FEBRUARY && year % 4 == 0) { + return 29; + } + return daysPerMonth; + } + + public Month next() { + return Month.values()[(this.ordinal() + 1) % 12]; + } + + public int m() { + return 3 + (ordinal() + 10) % 12; + } +} diff --git a/src/net/sourceforge/plantuml/project3/NaturalCommand.java b/src/net/sourceforge/plantuml/project3/NaturalCommand.java index 44c604184..365caecc0 100644 --- a/src/net/sourceforge/plantuml/project3/NaturalCommand.java +++ b/src/net/sourceforge/plantuml/project3/NaturalCommand.java @@ -60,6 +60,9 @@ public class NaturalCommand extends SingleLineCommand2 { final Subject subject = subjectPattern.getSubject(system, arg); final Verb verb = verbPattern.getVerb(system, arg); final Complement complement = complementPattern.getComplement(system, arg, "0"); + if (complement == null) { + throw new IllegalStateException(); + } return verb.execute(subject, complement); } diff --git a/src/net/sourceforge/plantuml/project3/SubjectProject.java b/src/net/sourceforge/plantuml/project3/SubjectProject.java new file mode 100644 index 000000000..9eca0fc38 --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/SubjectProject.java @@ -0,0 +1,54 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +import java.util.Arrays; +import java.util.Collection; + +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class SubjectProject implements SubjectPattern { + + public Collection getVerbs() { + return Arrays. asList(new VerbProjectStarts()); + } + + public IRegex toRegex() { + return new RegexLeaf("SUBJECT", "project"); + } + + public Subject getSubject(GanttDiagram project, RegexResult arg) { + return project; + } + +} diff --git a/src/net/sourceforge/plantuml/project3/SubjectTask.java b/src/net/sourceforge/plantuml/project3/SubjectTask.java index d33926619..fca2168e7 100644 --- a/src/net/sourceforge/plantuml/project3/SubjectTask.java +++ b/src/net/sourceforge/plantuml/project3/SubjectTask.java @@ -45,12 +45,17 @@ public class SubjectTask implements SubjectPattern { } public IRegex toRegex() { - return new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\]"); + return new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\](?:[%s]+as[%s]+\\[([^\\[\\]]+?)\\])?"); } public Subject getSubject(GanttDiagram project, RegexResult arg) { final String s = arg.get("SUBJECT", 0); - return project.getTask(new TaskCode(s)); + final String shortName = arg.get("SUBJECT", 1); + final Task result = project.getOrCreateTask(s, shortName); + if (result == null) { + throw new IllegalStateException(); + } + return result; } } diff --git a/src/net/sourceforge/plantuml/project3/TaskDraw.java b/src/net/sourceforge/plantuml/project3/TaskDraw.java index 0f8669827..c03d901f0 100644 --- a/src/net/sourceforge/plantuml/project3/TaskDraw.java +++ b/src/net/sourceforge/plantuml/project3/TaskDraw.java @@ -36,7 +36,6 @@ import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; diff --git a/src/net/sourceforge/plantuml/project3/VerbProjectStarts.java b/src/net/sourceforge/plantuml/project3/VerbProjectStarts.java new file mode 100644 index 000000000..94fcfa586 --- /dev/null +++ b/src/net/sourceforge/plantuml/project3/VerbProjectStarts.java @@ -0,0 +1,62 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project3; + +import java.util.Arrays; +import java.util.Collection; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class VerbProjectStarts implements VerbPattern { + + public Collection getComplements() { + return Arrays. asList(new ComplementDate()); + } + + public IRegex toRegex() { + return new RegexLeaf("starts[%s]*(the[%s]*|on[%s]*)*"); + } + + public Verb getVerb(final GanttDiagram project, RegexResult arg) { + return new Verb() { + public CommandExecutionResult execute(Subject subject, Complement complement) { + final DayAsDate start = (DayAsDate) complement; + assert project == subject; + project.setStartingDate(start); + return CommandExecutionResult.ok(); + } + + }; + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index 34e11bfc2..d0967260e 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -36,6 +36,7 @@ import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.OptionFlags; +import net.sourceforge.plantuml.PaddingParam; import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.SkinParamBackcoloredReference; import net.sourceforge.plantuml.cucadiagram.Display; @@ -191,8 +192,9 @@ class DrawableSetInitializer { } } + takeParticipantEngloberPadding(stringBounder); constraintSet.takeConstraintIntoAccount(stringBounder); - takeParticipantEngloberTitleWidth3(stringBounder); + takeParticipantEngloberTitleWidth(stringBounder); prepareMissingSpace(stringBounder); @@ -201,7 +203,22 @@ class DrawableSetInitializer { return drawableSet; } - private void takeParticipantEngloberTitleWidth3(StringBounder stringBounder) { + private void takeParticipantEngloberPadding(StringBounder stringBounder) { + final double padding = drawableSet.getSkinParam().getPadding(PaddingParam.BOX); + if (padding == 0) { + return; + } + for (Englober pe : drawableSet.getExistingParticipantEnglober(stringBounder)) { + final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2TOBEPRIVATE()) + .getParticipantBox(); + final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2TOBEPRIVATE()) + .getParticipantBox(); + constraintSet.pushToLeftParticipantBox(padding, first, true); + constraintSet.pushToLeftParticipantBox(padding, last, false); + } + } + + private void takeParticipantEngloberTitleWidth(StringBounder stringBounder) { for (Englober pe : drawableSet.getExistingParticipantEnglober(stringBounder)) { final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder, pe.getParticipantEnglober()); diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index 9a62212e7..933fca3d7 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -34,6 +34,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; import net.sourceforge.plantuml.cucadiagram.Display; @@ -58,16 +59,16 @@ public abstract class AbstractTextualComponent extends AbstractComponent { private final UFont font; private final HtmlColor fontColor; - public AbstractTextualComponent(CharSequence label, FontConfiguration font, - HorizontalAlignment horizontalAlignment, int marginX1, int marginX2, int marginY, - ISkinSimple spriteContainer, double maxMessageSize, UFont fontForStereotype, + public AbstractTextualComponent(LineBreakStrategy maxMessageSize, CharSequence label, + FontConfiguration font, HorizontalAlignment horizontalAlignment, int marginX1, int marginX2, + int marginY, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - this(Display.getWithNewlines(label == null ? "" : label.toString()), font, horizontalAlignment, marginX1, - marginX2, marginY, spriteContainer, maxMessageSize, false, fontForStereotype, htmlColorForStereotype); + this(maxMessageSize, Display.getWithNewlines(label == null ? "" : label.toString()), font, horizontalAlignment, + marginX1, marginX2, marginY, spriteContainer, false, fontForStereotype, htmlColorForStereotype); } - public AbstractTextualComponent(Display strings, FontConfiguration font, HorizontalAlignment horizontalAlignment, - int marginX1, int marginX2, int marginY, ISkinSimple spriteContainer, double maxMessageSize, + public AbstractTextualComponent(LineBreakStrategy maxMessageSize, Display strings, FontConfiguration font, + HorizontalAlignment horizontalAlignment, int marginX1, int marginX2, int marginY, ISkinSimple spriteContainer, boolean enhanced, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { this.font = font.getFont(); this.fontColor = font.getColor(); diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java index 34011d2cd..bbf10b446 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -50,8 +51,8 @@ public abstract class AbstractComponentBlueModernArrow extends AbstractTextualCo private final HtmlColor foregroundColor; public AbstractComponentBlueModernArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.LEFT, 17, 17, 2, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.LEFT, 17, 17, + 2, spriteContainer, false, null, null); this.arrowConfiguration = arrowConfiguration; this.foregroundColor = foregroundColor; } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java index a14f5bcc2..a7f7e67f7 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -51,8 +52,8 @@ public class ComponentBlueModernActor extends AbstractTextualComponent { public ComponentBlueModernActor(HtmlColor backgroundColor, HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, + 0, spriteContainer, false, null, null); this.head = head; stickman = new StickMan(backgroundColor, foregroundColor); } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java index 1f8093550..8517de820 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -47,8 +48,8 @@ public class ComponentBlueModernDelayText extends AbstractTextualComponent { public ComponentBlueModernDelayText(FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, + 4, spriteContainer, false, null, null); } @Override diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java index 24dc26552..b107a4b22 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -58,8 +59,8 @@ public class ComponentBlueModernDivider extends AbstractTextualComponent { public ComponentBlueModernDivider(FontConfiguration font, HtmlColor background1, HtmlColor background2, HtmlColor borderColor, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, + 4, spriteContainer, false, null, null); this.background1 = background1; this.background2 = background2; this.borderColor = borderColor; diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java index 432406d6b..77f4c8660 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ public class ComponentBlueModernEnglober extends AbstractTextualComponent { public ComponentBlueModernEnglober(HtmlColor borderColor, HtmlColor backColor, Display strings, FontConfiguration font, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.CENTER, 4, 4, 1, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.CENTER, 4, 4, 1, spriteContainer, false, null, null); this.borderColor = borderColor; this.backColor = backColor; diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java index a86ab5ea8..d11aa756e 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -65,7 +66,7 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent public ComponentBlueModernGroupingHeader(HtmlColor headerBackgroundColor, HtmlColor generalBackgroundColor, HtmlColor borderColor, HtmlColor fontColor2, FontConfiguration bigFont, UFont smallFont, Display strings, ISkinSimple spriteContainer) { - super(strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, 0, null, null); + super(LineBreakStrategy.NONE, strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, null, null); this.headerBackgroundColor = headerBackgroundColor; this.generalBackgroundColor = generalBackgroundColor; this.borderColor = borderColor; diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java index b981a8d05..6349a260b 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ final public class ComponentBlueModernNote extends AbstractTextualComponent { public ComponentBlueModernNote(HtmlColor back, HtmlColor foregroundColor, FontConfiguration font, Display strings, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, false, null, null); this.back = back; this.foregroundColor = foregroundColor; diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java index 3092b97e3..18357ded2 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.bluemodern; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -50,8 +51,8 @@ public class ComponentBlueModernParticipant extends AbstractTextualComponent { public ComponentBlueModernParticipant(HtmlColor blue1, HtmlColor blue2, FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, + 7, spriteContainer, false, null, null); this.blue1 = blue1; this.blue2 = blue2; } diff --git a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java index 2387e9217..debedc72a 100644 --- a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -48,9 +49,9 @@ public abstract class AbstractComponentRoseArrow extends AbstractTextualComponen public AbstractComponentRoseArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, HorizontalAlignment textHorizontalAlignment, - double maxMessageSize) { - super(stringsToDisplay, font, textHorizontalAlignment, 7, 7, 1, spriteContainer, - maxMessageSize, false, null, null); + LineBreakStrategy maxMessageSize) { + super(maxMessageSize, stringsToDisplay, font, textHorizontalAlignment, 7, 7, 1, + spriteContainer, false, null, null); this.arrowConfiguration = arrowConfiguration; this.foregroundColor = foregroundColor; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java index 96e0bfe90..c41cdd786 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ public class ComponentRoseActor extends AbstractTextualComponent { public ComponentRoseActor(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, false, fontForStereotype, htmlColorForStereotype); this.head = head; this.stickman = new StickMan(biColor); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index b65265d07..743993477 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -34,6 +34,7 @@ import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -62,7 +63,7 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { public ComponentRoseArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, HorizontalAlignment messagePosition, ISkinSimple spriteContainer, - HorizontalAlignment textHorizontalAlignment, double maxMessageSize, boolean niceArrow) { + HorizontalAlignment textHorizontalAlignment, LineBreakStrategy maxMessageSize, boolean niceArrow) { super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, textHorizontalAlignment, maxMessageSize); this.messagePosition = messagePosition; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java index 307458a54..4f17a8013 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ public class ComponentRoseBoundary extends AbstractTextualComponent { public ComponentRoseBoundary(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, false, fontForStereotype, htmlColorForStereotype); this.head = head; this.stickman = new Boundary(biColor); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java index eb46fe956..2bcf41f0a 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ public class ComponentRoseControl extends AbstractTextualComponent { public ComponentRoseControl(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, false, fontForStereotype, htmlColorForStereotype); this.head = head; this.stickman = new Control(biColor); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java index 82611fa7d..934e01908 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -56,7 +57,7 @@ public class ComponentRoseDatabase extends AbstractTextualComponent { public ComponentRoseDatabase(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, false, fontForStereotype, htmlColorForStereotype); this.head = head; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java index ba9c95b1d..5d81b4b97 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -46,8 +47,8 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class ComponentRoseDelayText extends AbstractTextualComponent { public ComponentRoseDelayText(FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 0, 0, 4, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 0, 0, + 4, spriteContainer, false, null, null); } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java index f5e59a74d..791e90f16 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -60,7 +61,7 @@ public class ComponentRoseDivider extends AbstractTextualComponent { public ComponentRoseDivider(FontConfiguration font, HtmlColor background, Display stringsToDisplay, ISkinSimple spriteContainer, boolean withShadow, UStroke stroke, HtmlColor borderColor) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4, spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4, spriteContainer, false, null, null); this.background = background; this.borderColor = borderColor; this.empty = stringsToDisplay.get(0).length() == 0; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java index 283538ad8..953e6ecec 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -49,7 +50,7 @@ public class ComponentRoseEnglober extends AbstractTextualComponent { private final SymbolContext symbolContext; public ComponentRoseEnglober(SymbolContext symbolContext, Display strings, FontConfiguration font, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.CENTER, 3, 3, 1, spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.CENTER, 3, 3, 1, spriteContainer, false, null, null); this.symbolContext = symbolContext; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java index 15b66e602..36fd4dc1f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -54,7 +55,7 @@ public class ComponentRoseEntity extends AbstractTextualComponent { public ComponentRoseEntity(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head, ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false, + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, false, fontForStereotype, htmlColorForStereotype); this.head = head; this.stickman = new EntityDomain(biColor); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index d82bdc8f6..7b24af76a 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -57,8 +58,8 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { public ComponentRoseGroupingElse(HtmlColor groupBorder, FontConfiguration smallFont, CharSequence comment, ISkinSimple spriteContainer, HtmlColor backgroundColor) { - super(comment == null ? null : "[" + comment + "]", smallFont, HorizontalAlignment.LEFT, 5, 5, 1, - spriteContainer, 0, null, null); + super(LineBreakStrategy.NONE, comment == null ? null : "[" + comment + "]", smallFont, HorizontalAlignment.LEFT, 5, 5, + 1, spriteContainer, null, null); this.groupBorder = groupBorder; this.backgroundColor = backgroundColor; // this.stroke = stroke; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java index 2a1540065..b7a4eb203 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -62,7 +63,7 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { public ComponentRoseGroupingHeader(HtmlColor background, SymbolContext symbolContext, FontConfiguration bigFont, FontConfiguration smallFont2, Display strings, ISkinSimple spriteContainer) { - super(strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, 0, null, null); + super(LineBreakStrategy.NONE, strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, null, null); this.symbolContext = symbolContext; this.background = background; if (strings.size() == 1 || strings.get(1) == null) { diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java index 608371e3e..6f5e4951f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -55,7 +56,7 @@ final public class ComponentRoseNote extends AbstractTextualComponent implements public ComponentRoseNote(SymbolContext symbolContext, FontConfiguration font, Display strings, double paddingX, double paddingY, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, 0, true, null, null); + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, true, null, null); this.paddingX = paddingX; this.paddingY = paddingY; this.symbolContext = symbolContext; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java index 48f5c65b6..eb3e49b61 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -49,7 +50,7 @@ final public class ComponentRoseNoteBox extends AbstractTextualComponent { public ComponentRoseNoteBox(SymbolContext symbolContext, FontConfiguration font, Display strings, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.LEFT, 4, 4, 4, spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 4, 4, 4, spriteContainer, false, null, null); this.symbolContext = symbolContext; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java index 73d5aa1ee..06ce40749 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -51,7 +52,7 @@ final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent { public ComponentRoseNoteHexagonal(SymbolContext symbolContext, FontConfiguration font, Display strings, ISkinSimple spriteContainer) { - super(strings, font, HorizontalAlignment.LEFT, 12, 12, 4, spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 12, 12, 4, spriteContainer, false, null, null); this.symbolContext = symbolContext; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java index a6836159c..5f15e33d7 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -57,12 +58,14 @@ public class ComponentRoseParticipant extends AbstractTextualComponent { private final UStroke stroke; private final double minWidth; private final boolean collections; + private final double padding; public ComponentRoseParticipant(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer, double roundCorner, UFont fontForStereotype, HtmlColor htmlColorForStereotype, - double minWidth, boolean collections) { - super(stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7, spriteContainer, 0, false, + double minWidth, boolean collections, double padding) { + super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7, spriteContainer, false, fontForStereotype, htmlColorForStereotype); + this.padding = padding; this.minWidth = minWidth; this.collections = collections; this.back = biColor.getBackColor(); @@ -75,6 +78,7 @@ public class ComponentRoseParticipant extends AbstractTextualComponent { @Override protected void drawInternalU(UGraphic ug, Area area) { final StringBounder stringBounder = ug.getStringBounder(); + ug = ug.apply(new UTranslate(padding, 0)); ug = ug.apply(new UChangeBackColor(back)).apply(new UChangeColor(foregroundColor)); ug = ug.apply(stroke); final URectangle rect = new URectangle(getTextWidth(stringBounder), getTextHeight(stringBounder), roundCorner, @@ -104,7 +108,7 @@ public class ComponentRoseParticipant extends AbstractTextualComponent { @Override public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + deltaShadow + getDeltaCollection(); + return getTextWidth(stringBounder) + deltaShadow + getDeltaCollection() + 2 * padding; } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java index 168186887..dccc4039b 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.skin.rose; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -60,8 +61,8 @@ public class ComponentRoseReference extends AbstractTextualComponent { public ComponentRoseReference(FontConfiguration font, SymbolContext symbolContext, FontConfiguration header, Display stringsToDisplay, HorizontalAlignment position, ISkinSimple spriteContainer, HtmlColor background) { - super(stringsToDisplay.subList(1, stringsToDisplay.size()), font, HorizontalAlignment.LEFT, 4, 4, 4, - spriteContainer, 0, false, null, null); + super(LineBreakStrategy.NONE, stringsToDisplay.subList(1, stringsToDisplay.size()), font, HorizontalAlignment.LEFT, 4, 4, + 4, spriteContainer, false, null, null); this.position = position; this.symbolContext = symbolContext; this.background = background; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java index bc4e18653..a950a76eb 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java @@ -34,6 +34,7 @@ import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -59,7 +60,7 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { private final boolean niceArrow; public ComponentRoseSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, - ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, double maxMessageSize, boolean niceArrow) { + ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, boolean niceArrow) { super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, HorizontalAlignment.LEFT, maxMessageSize); this.niceArrow = niceArrow; diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index ee840b9d9..8dc2826a3 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -35,6 +35,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.PaddingParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -100,25 +101,26 @@ public class Rose implements Skin { config, messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(), param.strictUmlStyle() == false); } + final double padding = param.getPadding(PaddingParam.PARTICIPANT); if (type == ComponentType.PARTICIPANT_HEAD) { return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, - getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false); + getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding); } if (type == ComponentType.PARTICIPANT_TAIL) { return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, - getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false); + getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding); } if (type == ComponentType.COLLECTIONS_HEAD) { return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, - getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true); + getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding); } if (type == ComponentType.COLLECTIONS_TAIL) { return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, - getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true); + getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding); } if (type == ComponentType.PARTICIPANT_LINE) { final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder); diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index 1f275226f..dc56abc88 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -249,7 +249,7 @@ public class Line implements Moveable, Hideable { final double marginLabel = startUid.equalsId(endUid) ? 6 : 1; final TextBlock label = TextBlockUtils.withMargin( link.getLabel().create(labelFont, skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER), - skinParam), marginLabel, marginLabel); + skinParam, skinParam.maxMessageSize()), marginLabel, marginLabel); if (getLinkArrow() == LinkArrow.NONE) { labelOnly = label; } else { diff --git a/src/net/sourceforge/plantuml/svek/SvekResult.java b/src/net/sourceforge/plantuml/svek/SvekResult.java index a22291b3d..e8fc56c97 100644 --- a/src/net/sourceforge/plantuml/svek/SvekResult.java +++ b/src/net/sourceforge/plantuml/svek/SvekResult.java @@ -37,6 +37,7 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.cucadiagram.dot.DotData; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.Moveable; import net.sourceforge.plantuml.skin.rose.Rose; @@ -66,8 +67,9 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage, cluster.drawU(ug, new UStroke(1.5), dotData.getUmlDiagramType(), dotData.getSkinParam()); } - final HtmlColor color = rose.getHtmlColor(dotData.getSkinParam(), getArrowColorParam(), null); - + final HtmlColor color = HtmlColorUtils.noGradient(rose.getHtmlColor(dotData.getSkinParam(), + getArrowColorParam(), null)); + for (Shape shape : dotStringFactory.getBibliotekon().allShapes()) { final double minX = shape.getMinX(); final double minY = shape.getMinY(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index e977f37a7..3878f3697 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -37,6 +37,7 @@ import java.util.Map; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.command.Position; @@ -122,6 +123,7 @@ public class EntityImageTips extends AbstractEntityImage { final Point2D positionOther = shapeOther.getPosition(); bibliotekon.getShape(getEntity()); final Position position = getPosition(); + Direction direction = position.reverseDirection(); double height = 0; for (Map.Entry ent : getEntity().getTips().entrySet()) { final Display display = ent.getValue(); @@ -133,14 +135,17 @@ public class EntityImageTips extends AbstractEntityImage { final Dimension2D dim = opale.calculateDimension(stringBounder); final Point2D pp1 = new Point2D.Double(0, dim.getHeight() / 2); double x = positionOther.getX() - positionMe.getX(); - if (position == Position.RIGHT) { + if (direction == Direction.RIGHT && x < 0) { + direction = direction.getInv(); + } + if (direction == Direction.LEFT) { x += memberPosition.getMaxX(); } else { x += 4; } final double y = positionOther.getY() - positionMe.getY() - height + memberPosition.getCenterY(); final Point2D pp2 = new Point2D.Double(x, y); - opale.setOpale(position.reverseDirection(), pp1, pp2); + opale.setOpale(direction, pp1, pp2); opale.drawU(ug); ug = ug.apply(new UTranslate(0, dim.getHeight() + ySpacing)); height += dim.getHeight(); diff --git a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java index 6472de79e..b3a2f34f7 100644 --- a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java +++ b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java @@ -288,6 +288,62 @@ public class TikzGraphics { cmd.add(sb.toString()); } + private void round(double r, double[] points) { + final StringBuilder sb = new StringBuilder("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + } + sb.append("line width=" + thickness + "pt]"); + sb.append(" "); + int i = 0; + sb.append(couple(points[i++], points[i++])); + sb.append(" arc (180:270:" + format(r) + "pt) -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" arc (270:360:" + format(r) + "pt) -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" arc (0:90:" + format(r) + "pt) -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" arc (90:180:" + format(r) + "pt) -- "); + sb.append(couple(points[i++], points[i++])); + sb.append(" -- "); + sb.append("cycle;"); + cmd.add(sb.toString()); + } + + public void rectangleRound(double x, double y, double width, double height, double r) { + double[] points = new double[8 * 2]; + points[0] = x; + points[1] = y + r; + points[2] = x + r; + points[3] = y; + + points[4] = x + width - r; + points[5] = y; + points[6] = x + width; + points[7] = y + r; + + points[8] = x + width; + points[9] = y + height - r; + points[10] = x + width - r; + points[11] = y + height; + + points[12] = x + r; + points[13] = y + height; + points[14] = x; + points[15] = y + height - r; + + round(r, points); + } + public void upath(double x, double y, UPath path) { final StringBuilder sb = new StringBuilder("\\draw[color=" + getColorName(color) + ",line width=" + thickness + "pt] "); diff --git a/src/net/sourceforge/plantuml/timingdiagram/Histogram.java b/src/net/sourceforge/plantuml/timingdiagram/Histogram.java index 4140843b5..956a0284e 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Histogram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Histogram.java @@ -189,11 +189,11 @@ public class Histogram implements TimeDrawing { final UTranslate deltaY = new UTranslate(0, getFullDeltaY()); final UTranslate pos = new UTranslate(pt).compose(deltaY); ug = ug.apply(pos); - final SymbolContext context = getContext(); - final double height = -pt.getY(); - if (height > 0) { - context.withForeColor(context.getBackColor()).apply(ug).draw(new URectangle(len, height)); - } + // final SymbolContext context = getContext(); + // final double height = -pt.getY(); + // if (height > 0) { + // context.withForeColor(context.getBackColor()).apply(ug).draw(new URectangle(len, height)); + // } ug.draw(new ULine(len, 0)); } diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java index 867e9a746..66c29e50f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java @@ -35,6 +35,7 @@ import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UShape; +import net.sourceforge.plantuml.utils.MathUtils; public class DriverRectangleTikz implements UDriver { @@ -43,11 +44,16 @@ public class DriverRectangleTikz implements UDriver { final double width = rect.getWidth(); final double height = rect.getHeight(); + final double r = MathUtils.min(rect.getRx(), rect.getRy(), width / 2, height / 2); + tikz.setFillColor(mapper.getMappedColor(param.getBackcolor())); tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz()); - tikz.rectangle(x, y, width, height); - + if (r == 0) { + tikz.rectangle(x, y, width, height); + } else { + tikz.rectangleRound(x, y, width, height, r); + } } } diff --git a/src/net/sourceforge/plantuml/utils/MathUtils.java b/src/net/sourceforge/plantuml/utils/MathUtils.java index f52ffd80b..69cc550f9 100644 --- a/src/net/sourceforge/plantuml/utils/MathUtils.java +++ b/src/net/sourceforge/plantuml/utils/MathUtils.java @@ -48,6 +48,22 @@ public class MathUtils { return max(max(a, b, c), max(d, e)); } + public static double min(double a, double b) { + return Math.min(a, b); + } + + public static double min(double a, double b, double c) { + return min(min(a, b), c); + } + + public static double min(double a, double b, double c, double d) { + return min(min(a, b), min(c, d)); + } + + public static double min(double a, double b, double c, double d, double e) { + return min(min(a, b, c), min(d, e)); + } + public static double limitation(double v, double min, double max) { if (min >= max) { // assert false : "min="+min+" max="+max+" v="+v; diff --git a/src/net/sourceforge/plantuml/version/PSystemVersion.java b/src/net/sourceforge/plantuml/version/PSystemVersion.java index 2788d621b..6f82d027e 100644 --- a/src/net/sourceforge/plantuml/version/PSystemVersion.java +++ b/src/net/sourceforge/plantuml/version/PSystemVersion.java @@ -80,7 +80,7 @@ public class PSystemVersion extends AbstractPSystem { } catch (IOException e) { e.printStackTrace(); } - return null; + return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); } public static BufferedImage getCharlieImage() { @@ -92,7 +92,7 @@ public class PSystemVersion extends AbstractPSystem { } catch (IOException e) { e.printStackTrace(); } - return null; + return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); } public static BufferedImage getPlantumlSmallIcon() { @@ -104,7 +104,7 @@ public class PSystemVersion extends AbstractPSystem { } catch (IOException e) { e.printStackTrace(); } - return null; + return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); } private static BufferedImage transparentIcon; @@ -115,7 +115,7 @@ public class PSystemVersion extends AbstractPSystem { } final BufferedImage ico = getPlantumlSmallIcon(); if (ico == null) { - return null; + return new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); } transparentIcon = new BufferedImage(ico.getWidth(), ico.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); for (int i = 0; i < ico.getWidth(); i++) { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 464a634b0..46d5d0873 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -36,7 +36,7 @@ import java.util.Date; public class Version { public static int version() { - return 8056; + return 8057; } public static String versionString() { @@ -68,7 +68,7 @@ public class Version { } public static long compileTime() { - return 1487187608733L; + return 1488106743921L; } public static String compileTimeString() {