From e7251d394d702022486501397b2ef3b7e667df79 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Sat, 11 Jul 2015 11:32:49 +0200 Subject: [PATCH] version 8028 --- .../plantuml/AnimatedGifEncoder.java | 2 - src/net/sourceforge/plantuml/OptionFlags.java | 3 +- src/net/sourceforge/plantuml/StringUtils.java | 4 - src/net/sourceforge/plantuml/UmlDiagram.java | 10 +- src/net/sourceforge/plantuml/Url.java | 9 + .../activitydiagram3/ActivityDiagram3.java | 24 +- .../ActivityDiagramFactory3.java | 4 +- .../plantuml/activitydiagram3/Branch.java | 8 +- .../activitydiagram3/InstructionGroup.java | 2 +- .../activitydiagram3/InstructionIf.java | 6 +- .../activitydiagram3/InstructionRepeat.java | 18 +- .../activitydiagram3/InstructionWhile.java | 11 +- .../activitydiagram3/LinkRendering.java | 4 +- .../CommandRepeatWhile3Multilines.java | 6 +- .../ftile/EntityImageLegend.java | 4 +- .../ftile/FtileFactoryDelegator.java | 2 +- .../ftile/FtileMargedRight.java | 87 ++++ .../activitydiagram3/ftile/FtileUtils.java | 4 + .../activitydiagram3/ftile/Snake.java | 13 +- .../activitydiagram3/ftile/Swimlanes.java | 11 +- .../ftile/vcompact/FloatingNote.java | 3 +- .../FtileFactoryDelegatorAssembly.java | 18 +- .../FtileFactoryDelegatorCreateSplit.java | 5 +- .../vcompact/FtileFactoryDelegatorIf.java | 17 +- .../ftile/vcompact/FtileGroup.java | 4 +- .../ftile/vcompact/FtileIfAndStop.java | 7 +- .../ftile/vcompact/FtileIfLong2.java | 11 +- ...tileIfLong.java => FtileIfLongUnused.java} | 17 +- .../{FtileIf.java => FtileIfOrigin.java} | 21 +- .../ftile/vcompact/FtileRepeat.java | 28 +- .../ftile/vcompact/FtileWhile.java | 10 +- .../ftile/vcompact/FtileWithNoteOpale.java | 3 +- .../vcompact/cond/ConditionalBuilder.java | 200 +++++++++ .../vcompact/cond/FtileDimensionMemoize.java | 57 +++ .../ftile/vcompact/cond/FtileIfNude.java | 155 +++++++ .../vcompact/cond/FtileIfWithDiamonds.java | 134 ++++++ .../ftile/vcompact/cond/FtileIfWithLinks.java | 381 ++++++++++++++++++ .../ftile/vertical/FtileBox.java | 3 +- .../plantuml/classdiagram/ClassDiagram.java | 10 +- .../command/CommandCreateClass.java | 4 +- .../command/CommandCreateClassMultilines.java | 6 +- .../command/CommandDiamondAssociation.java | 3 +- .../classdiagram/command/CommandImport.java | 5 +- .../plantuml/command/ProtectedCommand.java | 1 + .../note/FactoryNoteActivityCommand.java | 8 +- .../note/FactoryNoteOnEntityCommand.java | 9 +- .../note/FactoryTipOnEntityCommand.java | 5 +- .../plantuml/creole/AtomTable.java | 18 +- .../plantuml/creole/CreoleHorizontalLine.java | 2 +- .../plantuml/creole/CreoleMode.java | 39 ++ .../plantuml/creole/CreoleParser.java | 6 +- .../creole/CreoleStripeSimpleParser.java | 26 +- .../plantuml/creole/PSystemCreole.java | 2 +- .../plantuml/creole/StripeSimple.java | 4 +- .../plantuml/creole/StripeTable.java | 2 +- .../plantuml/creole/StripeTree.java | 2 +- .../plantuml/cucadiagram/Bodier.java | 4 +- .../plantuml/cucadiagram/BodyEnhanced.java | 10 +- .../plantuml/cucadiagram/BodyEnhanced2.java | 5 +- .../plantuml/cucadiagram/CucaDiagram.java | 4 +- .../plantuml/cucadiagram/Display.java | 171 +++++++- .../plantuml/cucadiagram/Link.java | 19 +- .../plantuml/cucadiagram/Magma.java | 8 +- .../plantuml/cucadiagram/MemberImpl.java | 16 +- .../cucadiagram/MethodsOrFieldsArea.java | 3 +- .../cucadiagram/entity/EntityFactory.java | 2 +- .../cucadiagram/entity/EntityImpl.java | 2 +- .../DescriptionDiagramFactory.java | 10 +- .../CommandCreateElementMultilines.java | 59 ++- .../command/CommandLinkElement.java | 4 +- .../plantuml/flowdiagram/ActivityBox.java | 2 +- src/net/sourceforge/plantuml/golem/Tile.java | 3 +- .../sourceforge/plantuml/graph/Elastane.java | 6 +- .../plantuml/graph/EntityImageActivity.java | 8 +- .../graph/EntityImageCircleInterface.java | 8 +- .../plantuml/graph/EntityImageComponent.java | 96 ----- .../plantuml/graph/EntityImageDefault.java | 8 +- .../plantuml/graph/EntityImageNote.java | 8 +- .../plantuml/graph/EntityImageUsecase.java | 8 +- .../plantuml/graph/MethodsOrFieldsArea.java | 5 +- .../plantuml/graphic/DateEventUtils.java | 4 +- .../plantuml/graphic/GraphicStrings.java | 9 +- .../plantuml/graphic/QuoteUtils.java | 3 +- .../plantuml/graphic/TextBlockSimple.java | 6 +- .../plantuml/graphic/TextBlockSpotted.java | 4 +- .../plantuml/graphic/TextBlockUtils.java | 89 +--- .../sourceforge/plantuml/graphic/USymbol.java | 2 +- .../plantuml/graphic/USymbolArtifact.java | 21 +- .../plantuml/graphic/USymbolCard.java | 2 +- .../plantuml/graphic/USymbolCloud.java | 2 +- .../plantuml/graphic/USymbolComponent1.java | 2 +- .../plantuml/graphic/USymbolComponent2.java | 2 +- .../plantuml/graphic/USymbolDatabase.java | 2 +- .../plantuml/graphic/USymbolFolder.java | 16 +- .../plantuml/graphic/USymbolFrame.java | 2 +- .../plantuml/graphic/USymbolNode.java | 2 +- .../plantuml/graphic/USymbolQueue.java | 2 +- .../plantuml/graphic/USymbolRect.java | 2 +- .../graphic/USymbolSimpleAbstract.java | 2 +- .../plantuml/graphic/USymbolStorage.java | 2 +- .../plantuml/jungle/GTileNode.java | 5 +- .../plantuml/logo/TurtleGraphicsPane.java | 3 +- .../AbstractClassOrObjectDiagram.java | 10 +- .../sourceforge/plantuml/png/PngTitler.java | 8 +- .../sourceforge/plantuml/posimo/Frame.java | 3 +- .../plantuml/posimo/LabelImage.java | 5 +- .../plantuml/printskin/PrintSkin.java | 6 +- .../plantuml/project/graphic/ItemHeader.java | 3 +- .../plantuml/project/graphic/TimeScale.java | 6 +- .../plantuml/project2/GanttDiagram2.java | 3 +- .../plantuml/project2/TimeHeaderDay.java | 3 +- .../plantuml/project2/TimeHeaderMonth.java | 3 +- .../plantuml/real/AbstractReal.java | 1 + src/net/sourceforge/plantuml/real/Real.java | 8 +- .../sourceforge/plantuml/real/RealLine.java | 27 +- .../salt/element/AbstractElementText.java | 4 +- .../salt/element/ElementDroplist.java | 3 +- .../salt/element/ElementMenuEntry.java | 2 +- .../salt/element/ElementRadioCheckbox.java | 2 +- .../plantuml/salt/element/ElementText.java | 2 +- .../plantuml/sequencediagram/Englober.java | 24 +- .../plantuml/sequencediagram/Participant.java | 4 +- .../sequencediagram/SequenceDiagram.java | 33 +- .../SequenceDiagramFactory.java | 4 + .../command/CommandAutonumber.java | 4 +- .../command/CommandAutonumberResume.java | 70 ++++ .../command/CommandAutonumberStop.java | 53 +++ .../command/CommandNewpage.java | 4 +- .../command/CommandParticipant.java | 2 +- .../graphic/DrawableSetInitializer.java | 18 +- .../SequenceDiagramFileMakerPuma2.java | 12 +- .../sequencediagram/teoz/Bordered.java | 43 ++ .../teoz/CommunicationExoTile.java | 54 ++- .../sequencediagram/teoz/DelayTile.java | 29 +- .../sequencediagram/teoz/DividerTile.java | 21 +- .../sequencediagram/teoz/Englobers.java | 29 +- .../sequencediagram/teoz/EventsHistory.java | 25 +- .../sequencediagram/teoz/GroupingTile.java | 3 +- .../sequencediagram/teoz/LifeEventTile.java | 25 +- .../sequencediagram/teoz/LiveBoxes.java | 8 + .../sequencediagram/teoz/LivingSpace.java | 6 + .../sequencediagram/teoz/MainTile.java | 25 +- .../sequencediagram/teoz/ReferenceTile.java | 9 +- .../teoz/SequenceDiagramFileMakerTeoz.java | 11 +- .../sequencediagram/teoz/Stairs2.java | 3 +- .../sequencediagram/teoz/TileArguments.java | 46 ++- .../sequencediagram/teoz/TileBuilder.java | 4 +- .../skin/AbstractTextualComponent.java | 7 +- .../plantuml/skin/GrayComponent.java | 6 +- .../ComponentBlueModernGroupingHeader.java | 6 +- .../skin/rose/ComponentRoseDatabase.java | 4 +- .../rose/ComponentRoseGroupingHeader.java | 7 +- .../plantuml/skin/rose/ComponentRoseNote.java | 5 +- .../skin/rose/ComponentRoseReference.java | 3 +- .../plantuml/sudoku/GraphicsSudoku.java | 11 +- .../svek/CucaDiagramFileMakerSvek.java | 17 +- .../svek/CucaDiagramFileMakerSvek2.java | 22 +- .../plantuml/svek/GroupPngMakerActivity.java | 2 +- .../plantuml/svek/GroupPngMakerState.java | 5 +- src/net/sourceforge/plantuml/svek/Line.java | 10 +- .../plantuml/svek/SingleStrategy.java | 5 +- .../svek/image/EntityImageActivity.java | 8 +- .../svek/image/EntityImageArcCircle.java | 16 +- .../svek/image/EntityImageClassHeader2.java | 34 +- ...onent.java => EntityImageDescription.java} | 19 +- .../svek/image/EntityImageEmptyPackage2.java | 9 +- .../plantuml/svek/image/EntityImageGroup.java | 2 +- .../image/EntityImageLollipopInterface.java | 10 +- .../EntityImageLollipopInterfaceEye1.java | 10 +- .../EntityImageLollipopInterfaceEye2.java | 8 +- .../svek/image/EntityImageObject.java | 18 +- .../svek/image/EntityImagePseudoState.java | 8 +- .../plantuml/svek/image/EntityImageState.java | 16 +- .../svek/image/EntityImageState2.java | 2 +- .../svek/image/EntityImageStateBorder.java | 8 +- .../EntityImageStateEmptyDescription.java | 8 +- .../svek/image/EntityImageUseCase.java | 8 +- .../plantuml/tikz/TikzGraphics.java | 149 ++++++- .../AbstractUGraphicHorizontalLine.java | 3 - .../plantuml/ugraphic/tikz/UGraphicTikz.java | 2 + .../sourceforge/plantuml/version/Version.java | 6 +- 181 files changed, 2415 insertions(+), 818 deletions(-) create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedRight.java rename src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/{FtileIfLong.java => FtileIfLongUnused.java} (96%) rename src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/{FtileIf.java => FtileIfOrigin.java} (96%) create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileDimensionMemoize.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java create mode 100644 src/net/sourceforge/plantuml/creole/CreoleMode.java delete mode 100644 src/net/sourceforge/plantuml/graph/EntityImageComponent.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/teoz/Bordered.java rename src/net/sourceforge/plantuml/svek/image/{EntityImageComponent.java => EntityImageDescription.java} (82%) diff --git a/src/net/sourceforge/plantuml/AnimatedGifEncoder.java b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java index b81860e9f..7d4e89f17 100644 --- a/src/net/sourceforge/plantuml/AnimatedGifEncoder.java +++ b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java @@ -141,7 +141,6 @@ public class AnimatedGifEncoder { * * @param iter * int number of iterations. - * @return */ public void setRepeat(int iter) { if (iter >= 0) { @@ -263,7 +262,6 @@ public class AnimatedGifEncoder { * * @param quality * int greater than 0. - * @return */ public void setQuality(int quality) { if (quality < 1) diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 50b47e33f..a58e6b10d 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16158 $ + * Revision $Revision: 16562 $ * */ package net.sourceforge.plantuml; @@ -53,6 +53,7 @@ public class OptionFlags { static public final boolean USE_HECTOR = false; static public boolean ADD_NICE_FOR_DOT = false; static public final boolean STRICT_SELFMESSAGE_POSITION = true; + static public final boolean USE_NEW_IF = true; static public final boolean FORCE_TEOZ = false; static public final boolean USE_INTERFACE_EYE1 = false; static public final boolean USE_INTERFACE_EYE2 = false; diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index 0ff4db178..45fa81332 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -390,10 +390,6 @@ public class StringUtils { return uid1 + String.format("%04d", uid2); } - public static boolean isMethod(String s) { - return s.contains("(") || s.contains(")"); - } - public static List merge(List l1, List l2) { final List result = new ArrayList(l1); result.addAll(l2); diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 42de67ee8..882b3ce70 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16441 $ + * Revision $Revision: 16549 $ * */ package net.sourceforge.plantuml; @@ -92,10 +92,10 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram { private int minwidth = Integer.MAX_VALUE; - private Display title; - private Display header; - private Display footer; - private Display legend = null; + private Display title = Display.NULL; + private Display header = Display.NULL; + private Display footer = Display.NULL; + private Display legend = Display.NULL; private HorizontalAlignment legendAlignment = HorizontalAlignment.CENTER; private VerticalAlignment legendVerticalAlignment = VerticalAlignment.BOTTOM; diff --git a/src/net/sourceforge/plantuml/Url.java b/src/net/sourceforge/plantuml/Url.java index 31b97d344..0bb3853ce 100644 --- a/src/net/sourceforge/plantuml/Url.java +++ b/src/net/sourceforge/plantuml/Url.java @@ -64,6 +64,15 @@ public class Url implements EnsureVisible { this.label = label; } } + + public static boolean isLatex(String pendingUrl) { + return pendingUrl.startsWith("latex://"); + } + + public boolean isLatex() { + return isLatex(url); + } + public final String getUrl() { return url; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 31acc5ab6..9dc08b22e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -161,7 +161,7 @@ public class ActivityDiagram3 extends UmlDiagram { private TextBlock addLegend(TextBlock original) { final Display legend = getLegend(); - if (legend == null) { + if (Display.isNull(legend)) { return original; } final TextBlock text = EntityImageLegend.create(legend, getSkinParam()); @@ -207,12 +207,12 @@ public class ActivityDiagram3 extends UmlDiagram { private TextBlock addTitle(TextBlock original) { final Display title = getTitle(); - if (title == null) { + if (Display.isNull(title)) { return original; } - final TextBlock text = TextBlockUtils.create(title, new FontConfiguration(getFont(FontParam.TITLE), - getFontColor(FontParam.TITLE, null), getSkinParam().getHyperlinkColor(), getSkinParam() - .useUnderlineForHyperlink()), HorizontalAlignment.CENTER, getSkinParam()); + final TextBlock text = title.create(new FontConfiguration(getFont(FontParam.TITLE), + getFontColor(FontParam.TITLE, null), getSkinParam().getHyperlinkColor(), getSkinParam() + .useUnderlineForHyperlink()), HorizontalAlignment.CENTER, getSkinParam()); return new DecorateTextBlock(original, text, HorizontalAlignment.CENTER); } @@ -220,15 +220,15 @@ public class ActivityDiagram3 extends UmlDiagram { private TextBlock addHeaderAndFooter(TextBlock original) { final Display footer = getFooter(); final Display header = getHeader(); - if (footer == null && header == null) { + if (Display.isNull(footer) && Display.isNull(header)) { return original; } - final TextBlock textFooter = footer == null ? null : TextBlockUtils.create(footer, new FontConfiguration( - getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), getSkinParam().getHyperlinkColor(), - getSkinParam().useUnderlineForHyperlink()), getFooterAlignment(), getSkinParam()); - final TextBlock textHeader = header == null ? null : TextBlockUtils.create(header, new FontConfiguration( - getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), getSkinParam().getHyperlinkColor(), - getSkinParam().useUnderlineForHyperlink()), getHeaderAlignment(), getSkinParam()); + final TextBlock textFooter = Display.isNull(footer) ? null : footer.create(new FontConfiguration( + getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), getSkinParam().getHyperlinkColor(), + getSkinParam().useUnderlineForHyperlink()), getFooterAlignment(), getSkinParam()); + final TextBlock textHeader = Display.isNull(header) ? null : header.create(new FontConfiguration( + getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), getSkinParam().getHyperlinkColor(), + getSkinParam().useUnderlineForHyperlink()), getHeaderAlignment(), getSkinParam()); return new DecorateTextBlock(original, textHeader, getHeaderAlignment(), textFooter, getFooterAlignment()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java index 226574d5b..000b9f19c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3; import net.sourceforge.plantuml.activitydiagram3.command.CommandElse3; import net.sourceforge.plantuml.activitydiagram3.command.CommandElseIf2; import net.sourceforge.plantuml.activitydiagram3.command.CommandElseLegacy1; +import net.sourceforge.plantuml.activitydiagram3.command.CommandEnd3; import net.sourceforge.plantuml.activitydiagram3.command.CommandEndPartition3; import net.sourceforge.plantuml.activitydiagram3.command.CommandEndif3; import net.sourceforge.plantuml.activitydiagram3.command.CommandFork3; @@ -69,7 +70,6 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitAgain3; import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitEnd3; import net.sourceforge.plantuml.activitydiagram3.command.CommandStart3; import net.sourceforge.plantuml.activitydiagram3.command.CommandStop3; -import net.sourceforge.plantuml.activitydiagram3.command.CommandEnd3; import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane; import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane2; import net.sourceforge.plantuml.activitydiagram3.command.CommandWhile3; @@ -102,7 +102,6 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory { cmds.add(new CommandDecoratorMultine(new CommandIf2())); cmds.add(new CommandIfLegacy1()); cmds.add(new CommandElseIf2()); - // cmds.add(new CommandDecoratorMultine(new CommandElseIf2())); cmds.add(new CommandElse3()); cmds.add(new CommandDecoratorMultine(new CommandElse3())); cmds.add(new CommandElseLegacy1()); @@ -133,6 +132,7 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory { cmds.add(new CommandLabel()); cmds.add(new CommandGoto()); + cmds.add(new CommandDecoratorMultine(new CommandElseIf2())); return cmds; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index dedebe7dc..d795e8622 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -58,6 +58,12 @@ public class Branch { } public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color) { + if (labelPositive == null) { + throw new IllegalArgumentException(); + } + if (labelTest == null) { + throw new IllegalArgumentException(); + } this.list = new InstructionList(swimlane); this.labelTest = labelTest; this.labelPositive = labelPositive; @@ -90,7 +96,7 @@ public class Branch { public final Display getLabelPositive() { final LinkRendering in = ftile.getInLinkRendering(); - if (in != null && in.getDisplay() != null) { + if (in != null && Display.isNull(in.getDisplay()) == false) { return in.getDisplay(); } return labelPositive; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java index 28739ccd6..021ba5b8e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java @@ -50,7 +50,7 @@ public class InstructionGroup implements Instruction { private final HtmlColor titleColor; private final Display test; - private Display headerNote; + private Display headerNote = Display.NULL; public InstructionGroup(Instruction parent, Display test, HtmlColor backColor, HtmlColor titleColor, Swimlane swimlane) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index 10aab4510..0a4fb2848 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -84,7 +84,7 @@ public class InstructionIf implements Instruction { branch.updateFtile(factory); } if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, null, null, null); + this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null); } elseBranch.updateFtile(factory); Ftile result = factory.createIf(swimlane, thens, elseBranch); @@ -103,7 +103,7 @@ public class InstructionIf implements Instruction { return false; } this.current.setInlinkRendering(nextLinkRenderer); - this.elseBranch = new Branch(swimlane, whenElse, null, null); + this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null); this.current = elseBranch; return true; } @@ -120,7 +120,7 @@ public class InstructionIf implements Instruction { public void endif(LinkRendering nextLinkRenderer) { if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, null, null, null); + this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null); } this.current.setInlinkRendering(nextLinkRenderer); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index c53f1070b..d10ff028d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -50,9 +50,9 @@ public class InstructionRepeat implements Instruction { private final Swimlane swimlane; private final HtmlColor color; - private Display test; - private Display yes; - private Display out; + private Display test = Display.NULL; + private Display yes = Display.NULL; + private Display out = Display.NULL; private LinkRendering endRepeatLinkRendering; private LinkRendering backRepeatLinkRendering; @@ -76,10 +76,20 @@ public class InstructionRepeat implements Instruction { return parent; } - public void setTest(Display test, Display yes, Display out, LinkRendering endRepeatLinkRendering, LinkRendering backRepeatLinkRendering) { + public void setTest(Display test, Display yes, Display out, LinkRendering endRepeatLinkRendering, + LinkRendering backRepeatLinkRendering) { this.test = test; this.yes = yes; this.out = out; + if (test == null) { + throw new IllegalArgumentException(); + } + if (yes == null) { + throw new IllegalArgumentException(); + } + if (out == null) { + throw new IllegalArgumentException(); + } this.endRepeatLinkRendering = endRepeatLinkRendering; this.backRepeatLinkRendering = backRepeatLinkRendering; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java index 3392bc2a0..4f11812e7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java @@ -53,7 +53,7 @@ public class InstructionWhile implements Instruction { private final Display test; private final Display yes; - private Display out; + private Display out = Display.NULL; private LinkRendering endInlinkRendering; private LinkRendering afterEndwhile; private final Swimlane swimlane; @@ -61,6 +61,12 @@ public class InstructionWhile implements Instruction { public InstructionWhile(Swimlane swimlane, Instruction parent, Display test, LinkRendering nextLinkRenderer, Display yes, HtmlColor color, ISkinParam skinParam) { + if (test == null) { + throw new IllegalArgumentException(); + } + if (yes == null) { + throw new IllegalArgumentException(); + } this.parent = parent; this.test = test; this.nextLinkRenderer = nextLinkRenderer; @@ -102,6 +108,9 @@ public class InstructionWhile implements Instruction { public void endwhile(LinkRendering nextLinkRenderer, Display out) { this.endInlinkRendering = nextLinkRenderer; this.out = out; + if (out == null) { + throw new IllegalArgumentException(); + } } public void afterEndwhile(LinkRendering linkRenderer) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java b/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java index 8627bc80f..542f09027 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; public class LinkRendering { private final HtmlColor color; - private Display display; + private Display display = Display.NULL; public LinkRendering(HtmlColor color) { this.color = color; @@ -78,7 +78,7 @@ public class LinkRendering { public static Display getDisplay(LinkRendering linkRendering) { if (linkRendering == null) { - return null; + return Display.NULL; } return linkRendering.getDisplay(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java index 002e406af..3253d5b13 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java @@ -93,11 +93,11 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3 splitted = testDisplay.splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\(", Pattern.CASE_INSENSITIVE)); if (splitted.size() == 2) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index 4d06c71fb..215039c50 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -76,8 +76,8 @@ public class EntityImageLegend extends AbstractTextBlock implements TextBlock { final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.LEGEND); final UFont fontNote = skinParam.getFont(FontParam.LEGEND, null, false); - this.textBlock = TextBlockUtils.create(note, new FontConfiguration(fontNote, fontColor, - skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam); + this.textBlock = note.create(new FontConfiguration(fontNote, fontColor, + skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam); } public static TextBlock create(Display legend, ISkinParam skinParam) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 9639f85d9..7ae59ae89 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -67,7 +67,7 @@ public class FtileFactoryDelegator implements FtileFactory { protected Display getInLinkRenderingDisplay(Ftile tile) { final LinkRendering linkRendering = tile.getInLinkRendering(); if (linkRendering == null) { - return null; + return Display.NULL; } return linkRendering.getDisplay(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedRight.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedRight.java new file mode 100644 index 000000000..eced7e7ca --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedRight.java @@ -0,0 +1,87 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile; + +import java.util.Set; + +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class FtileMargedRight extends AbstractFtile { + + private final Ftile tile; + private final double maxX; + + public FtileMargedRight(Ftile tile, double maxX) { + super(tile.shadowing()); + this.tile = tile; + this.maxX = maxX; + } + + @Override + public LinkRendering getInLinkRendering() { + return tile.getInLinkRendering(); + } + + @Override + public LinkRendering getOutLinkRendering() { + return tile.getOutLinkRendering(); + } + + public Set getSwimlanes() { + return tile.getSwimlanes(); + } + + public Swimlane getSwimlaneIn() { + return tile.getSwimlaneIn(); + } + + public Swimlane getSwimlaneOut() { + return tile.getSwimlaneOut(); + } + + public FtileGeometry calculateDimension(StringBounder stringBounder) { + final FtileGeometry orig = tile.calculateDimension(stringBounder); + if (orig.getWidth() > maxX) { + throw new IllegalStateException(); + } + return new FtileGeometry(maxX, orig.getHeight(), orig.getLeft(), orig.getInY(), orig.getOutY()); + } + + public void drawU(UGraphic ug) { + ug.draw(tile); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java index 117b44eb3..fd0c7b966 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java @@ -60,6 +60,10 @@ public class FtileUtils { return new FtileMargedVertically(ftile, marginTop, marginBottom); } + public static Ftile addHorizontalMargin(Ftile ftile, double margin) { + return new FtileMarged(ftile, margin); + } + private static Ftile neverNull(Ftile ftile) { if (ftile == null) { return new FtileEmpty(false); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java index 3c60cde98..e538930f7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java @@ -42,6 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.CompressionTransform; @@ -50,6 +51,7 @@ import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -150,9 +152,12 @@ public class Snake implements UShape { } if (textBlock != null) { final Point2D position = getTextBlockPosition(ug.getStringBounder()); - // double max = getMaxX(ug.getStringBounder()); - // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, - // position.getY())).draw(new URectangle(max, 10)); + // final double max = getMaxX(ug.getStringBounder()); + // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)) + // .apply(new UTranslate(position.getX(), position.getY())) + // .draw(new URectangle(textBlock.calculateDimension(ug.getStringBounder()))); + // ug.apply(new UChangeBackColor(HtmlColorUtils.RED)).apply(new UTranslate(0, position.getY() + 10)) + // .draw(new URectangle(max, 10)); textBlock.drawU(ug.apply(new UTranslate(position))); } } @@ -355,7 +360,7 @@ public class Snake implements UShape { if (Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.LEFT).equals(patternAt)) { final Point2D.Double p1 = points.get(i + 1); final Point2D.Double p4 = points.get(i + 4); - if (p4.x < p1.x) { + if (p4.x + 4 < p1.x) { final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y); points.remove(i + 3); points.remove(i + 2); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java index ba77b6ce3..b7f706f89 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java @@ -122,7 +122,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { if (color != null) { currentSwimlane.setSpecificBackcolor(color); } - if (label != null) { + if (Display.isNull(label) == false) { currentSwimlane.setDisplay(label); } } @@ -250,8 +250,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { } if (OptionFlags.SWI2 == false) { - final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(), - HorizontalAlignment.LEFT, skinParam); + final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth(); final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2; swTitle.drawU(ug.apply(new UTranslate(posTitle, 0))); @@ -283,8 +282,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { final MinMax minMax = limitFinder.getMinMax(); final double drawingWidth = minMax.getWidth() + 2 * separationMargin; - final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(), - HorizontalAlignment.LEFT, skinParam); + final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth(); final double totalWidth = Math.max(drawingWidth, titleWidth + 2 * separationMargin); @@ -299,8 +297,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) { double titlesHeight = 0; for (Swimlane swimlane : swimlanes) { - final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(), - HorizontalAlignment.LEFT, skinParam); + final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); titlesHeight = Math.max(titlesHeight, swTitle.calculateDimension(stringBounder).getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java index e523b417f..7bec4b350 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java @@ -38,6 +38,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.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -71,7 +72,7 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note); + final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(note); final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, 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/FtileFactoryDelegatorAssembly.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java index 4b54ab037..2a74094ba 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java @@ -41,9 +41,9 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedVertically; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedRight; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -86,14 +86,20 @@ public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator { final ConnectionVerticalDown connection = new ConnectionVerticalDown(tile1, tile2, p1, p2, color, textBlock); result = FtileUtils.addConnection(result, connection); if (textBlock != null) { - final double width = result.calculateDimension(stringBounder).getWidth(); + final FtileGeometry dim = result.calculateDimension(stringBounder); + final double width = dim.getWidth(); // System.err.println("width=" + width); // System.err.println("p1=" + p1); // System.err.println("p2=" + p2); final double maxX = connection.getMaxX(stringBounder); + // System.err.println("FtileFactoryDelegatorAssembly dim=" + dim); // System.err.println("maxX=" + maxX); final double needed = (maxX - width) * 2; - result = new FtileMinWidth(result, needed); + // result = new FtileMinWidth(result, needed); + if (width < maxX) { + result = new FtileMargedRight(result, maxX); + } + // System.err.println("FtileFactoryDelegatorAssembly result=" + result.calculateDimension(stringBounder)); } return result; } @@ -102,7 +108,7 @@ public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator { private TextBlock getTextBlock(Display display) { // DUP1433 - if (display == null) { + if (Display.isNull(display)) { return null; } final ISkinParam skinParam = getSkinParam(); @@ -110,6 +116,6 @@ public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator { final HtmlColor color = rose.getFontColor(skinParam, FontParam.ACTIVITY_ARROW); final FontConfiguration fontConfiguration = new FontConfiguration(font, color, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - return TextBlockUtils.create(display, fontConfiguration, HorizontalAlignment.LEFT, null, true); + return display.create(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.SIMPLE_LINE); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java index ae1a5f90b..2c575b4f3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMarged; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -209,7 +210,7 @@ public class FtileFactoryDelegatorCreateSplit extends FtileFactoryDelegator { private TextBlock getTextBlock(LinkRendering linkRendering) { // DUP1433 final Display display = LinkRendering.getDisplay(linkRendering); - if (display == null) { + if (Display.isNull(display)) { return null; } final ISkinParam skinParam = getSkinParam(); @@ -217,7 +218,7 @@ public class FtileFactoryDelegatorCreateSplit extends FtileFactoryDelegator { final HtmlColor color = rose.getFontColor(skinParam, FontParam.ACTIVITY_ARROW); final FontConfiguration fontConfiguration = new FontConfiguration(font, color, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - return TextBlockUtils.create(display, fontConfiguration, HorizontalAlignment.LEFT, null, true); + return display.create(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.SIMPLE_LINE); } private Ftile simpleSwimlanes(List all) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java index 1927b60ab..1450e1ae7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java @@ -38,11 +38,13 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.ConditionalBuilder; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UFont; @@ -59,7 +61,8 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { final ConditionStyle conditionStyle = getSkinParam().getConditionStyle(); final UFont fontArrow = getSkinParam().getFont(FontParam.ACTIVITY_ARROW, null, false); final UFont fontTest = getSkinParam().getFont( - conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ACTIVITY_ARROW, null, false); + conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ACTIVITY_ARROW, null, + false); final Branch branch0 = thens.get(0); final HtmlColor borderColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityBorder); @@ -69,10 +72,16 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { if (thens.size() > 1) { return FtileIfLong2.create(swimlane, borderColor, backColor, fontArrow, arrowColor, getFactory(), - conditionStyle, thens, elseBranch, getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()); + conditionStyle, thens, elseBranch, getSkinParam().getHyperlinkColor(), getSkinParam() + .useUnderlineForHyperlink()); + } + if (OptionFlags.USE_NEW_IF) { + return ConditionalBuilder.create(swimlane, borderColor, backColor, fontArrow, fontTest, arrowColor, + getFactory(), conditionStyle, thens.get(0), elseBranch, getSkinParam(), getStringBounder()); + } else { + return FtileIfOrigin.create(swimlane, borderColor, backColor, fontArrow, fontTest, arrowColor, + getFactory(), conditionStyle, thens.get(0), elseBranch, getSkinParam(), getStringBounder()); } - return FtileIf.create(swimlane, borderColor, backColor, fontArrow, fontTest, arrowColor, getFactory(), - conditionStyle, thens.get(0), elseBranch, getSkinParam(), getStringBounder()); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java index dbb11731f..fb462d136 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java @@ -87,9 +87,9 @@ public class FtileGroup extends AbstractFtile { if (title == null) { this.name = TextBlockUtils.empty(0, 0); } else { - this.name = TextBlockUtils.create(title, fc, HorizontalAlignment.LEFT, skinParam); + this.name = title.create(fc, HorizontalAlignment.LEFT, skinParam); } - if (displayNote == null) { + if (Display.isNull(displayNote)) { this.headerNote = TextBlockUtils.empty(0, 0); } else { this.headerNote = new FloatingNote(displayNote, skinParam); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java index 9d478c0b5..fcd911bc4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -127,12 +128,12 @@ class FtileIfAndStop extends AbstractFtile { final Ftile stopFtile = ftileFactory.stop(swimlane); - // final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, + // final TextBlock tb1 = Display.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, // ftileFactory); - // final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, + // final TextBlock tb2 = Display.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, // ftileFactory); - final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest); + final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(labelTest); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java index 2543a445c..5380765a9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java @@ -56,13 +56,13 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -149,18 +149,15 @@ class FtileIfLong2 extends AbstractFtile { List diamonds = new ArrayList(); final List conns = new ArrayList(); for (Branch branch : thens) { - final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT, - ftileFactory); - final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT, - ftileFactory); + final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory); + final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT, ftileFactory); FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.shadowing(), backColor, borderColor, swimlane, tbTest); diamond = diamond.withNorth(tb1); diamonds.add(diamond); } - final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT, - ftileFactory); + final TextBlock tb2 = branch2.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory); final int last = diamonds.size() - 1; diamonds.set(last, ((FtileDiamondInside2) diamonds.get(last)).withEast(tb2)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongUnused.java similarity index 96% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongUnused.java index a86acd8f9..70c4c1812 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongUnused.java @@ -55,19 +55,19 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; +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.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -class FtileIfLong extends AbstractFtile { +class FtileIfLongUnused extends AbstractFtile { private final double xSeparation = 20; @@ -77,7 +77,7 @@ class FtileIfLong extends AbstractFtile { private final HtmlColor arrowColor; - private FtileIfLong(List diamonds, List tiles, Ftile tile2, HtmlColor arrowColor) { + private FtileIfLongUnused(List diamonds, List tiles, Ftile tile2, HtmlColor arrowColor) { super(tiles.get(0).shadowing() || tile2.shadowing()); this.diamonds = diamonds; this.tiles = tiles; @@ -125,22 +125,19 @@ class FtileIfLong extends AbstractFtile { final List diamonds = new ArrayList(); final List conns = new ArrayList(); for (Branch branch : thens) { - final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT, - ftileFactory); - final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT, - ftileFactory); + final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory); + final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT, ftileFactory); FtileDiamondInside diamond = new FtileDiamondInside(branch.shadowing(), backColor, borderColor, swimlane, tbTest); diamond = diamond.withNorth(tb1); diamonds.add(diamond); } - final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT, - ftileFactory); + final TextBlock tb2 = branch2.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory); final int last = diamonds.size() - 1; diamonds.set(last, ((FtileDiamondInside) diamonds.get(last)).withEast(tb2)); - final FtileIfLong result = new FtileIfLong(diamonds, tiles, tile2, arrowColor); + final FtileIfLongUnused result = new FtileIfLongUnused(diamonds, tiles, tile2, arrowColor); for (int i = 0; i < thens.size(); i++) { final Ftile ftile = tiles.get(i); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfOrigin.java similarity index 96% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfOrigin.java index 201686652..309e98df2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfOrigin.java @@ -63,6 +63,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -81,7 +82,7 @@ import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -class FtileIf extends AbstractFtile { +class FtileIfOrigin extends AbstractFtile { private final Ftile tile1; private final Ftile tile2; @@ -90,7 +91,7 @@ class FtileIf extends AbstractFtile { private final HtmlColor arrowColor; - private FtileIf(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, HtmlColor arrowColor) { + private FtileIfOrigin(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, HtmlColor arrowColor) { super(tile1.shadowing() || tile2.shadowing()); this.diamond1 = diamond1; this.diamond2 = diamond2; @@ -140,12 +141,10 @@ class FtileIf extends AbstractFtile { final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, - ftileFactory, true); - final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT, - ftileFactory, true); + final TextBlock tb1 = branch1.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, CreoleMode.SIMPLE_LINE); + final TextBlock tb2 = branch2.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, CreoleMode.SIMPLE_LINE); - final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest); + final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(labelTest); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5)); @@ -164,18 +163,16 @@ class FtileIf extends AbstractFtile { if (tile1.calculateDimension(stringBounder).hasPointOut() && tile2.calculateDimension(stringBounder).hasPointOut()) { final Display out1 = LinkRendering.getDisplay(branch1.getFtile().getOutLinkRendering()); - final TextBlock tbout1 = out1 == null ? null : TextBlockUtils.create(out1, fcArrow, - HorizontalAlignment.LEFT, ftileFactory, true); + final TextBlock tbout1 = out1 == null ? null : out1.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, CreoleMode.SIMPLE_LINE); final Display out2 = LinkRendering.getDisplay(branch2.getFtile().getOutLinkRendering()); - final TextBlock tbout2 = out2 == null ? null : TextBlockUtils.create(out2, fcArrow, - HorizontalAlignment.LEFT, ftileFactory, true); + final TextBlock tbout2 = out2 == null ? null : out2.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, CreoleMode.SIMPLE_LINE); diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane).withWest(tbout1).withEast( tbout2); } else { diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2, swimlane, swimlane); } - final FtileIf result = new FtileIf(diamond1, tile1, tile2, diamond2, arrowColor); + final FtileIfOrigin result = new FtileIfOrigin(diamond1, tile1, tile2, diamond2, arrowColor); final List conns = new ArrayList(); conns.add(result.new ConnectionHorizontalThenVertical(tile1, branch1)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index 30b0224de..11f8b5f4f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondFoo1; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -104,10 +105,10 @@ class FtileRepeat extends AbstractFtile { final FontConfiguration fc = new FontConfiguration(fontTest, HtmlColorUtils.BLACK, hyperlinkColor, useUnderlineForHyperlink); - final TextBlock tbTest = (test == null || test.isWhite()) ? TextBlockUtils.empty(0, 0) : TextBlockUtils.create( - test, fc, HorizontalAlignment.LEFT, spriteContainer); - final TextBlock yesTb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer); - final TextBlock outTb = TextBlockUtils.create(out, fc, HorizontalAlignment.LEFT, spriteContainer); + final TextBlock tbTest = (Display.isNull(test) || test.isWhite()) ? TextBlockUtils.empty(0, 0) : test.create( + fc, HorizontalAlignment.LEFT, spriteContainer); + final TextBlock yesTb = yes.create(fc, HorizontalAlignment.LEFT, spriteContainer); + final TextBlock outTb = out.create(fc, HorizontalAlignment.LEFT, spriteContainer); final Ftile diamond1 = new FtileDiamond(repeat.shadowing(), backColor, borderColor, swimlane); final FtileRepeat result; @@ -128,18 +129,19 @@ class FtileRepeat extends AbstractFtile { final List conns = new ArrayList(); final Display in1 = LinkRendering.getDisplay(repeat.getInLinkRendering()); - final TextBlock tbin1 = in1 == null ? null : TextBlockUtils.create(in1, fc, HorizontalAlignment.LEFT, - spriteContainer, true); + final TextBlock tbin1 = in1 == null ? null : in1.create(fc, HorizontalAlignment.LEFT, spriteContainer, + CreoleMode.SIMPLE_LINE); conns.add(result.new ConnectionIn(LinkRendering.getColor(repeat.getInLinkRendering(), arrowColor), tbin1)); final Display backLink1 = LinkRendering.getDisplay(backRepeatLinkRendering); - final TextBlock tbbackLink1 = backLink1 == null ? null : TextBlockUtils.create(backLink1, fc, - HorizontalAlignment.LEFT, spriteContainer, true); + final TextBlock tbbackLink1 = backLink1 == null ? null : backLink1.create(fc, HorizontalAlignment.LEFT, + spriteContainer, CreoleMode.SIMPLE_LINE); conns.add(result.new ConnectionBack(LinkRendering.getColor(backRepeatLinkRendering, arrowColor), tbbackLink1)); final Display out1 = LinkRendering.getDisplay(repeat.getOutLinkRendering()); - final TextBlock tbout1 = out1 == null ? null : TextBlockUtils.create(out1, fc, HorizontalAlignment.LEFT, - spriteContainer, true); + final TextBlock tbout1 = out1 == null ? null : out1.create(fc, HorizontalAlignment.LEFT, spriteContainer, + CreoleMode.SIMPLE_LINE); + conns.add(result.new ConnectionOut(LinkRendering.getColor(endRepeatLinkColor, arrowColor), tbout1)); return FtileUtils.addConnection(result, conns); } @@ -198,6 +200,9 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); + if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) { + return; + } final Snake snake = new Snake(arrowColor, Arrows.asToDown()); snake.setLabel(tbout); @@ -209,6 +214,9 @@ class FtileRepeat extends AbstractFtile { public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); + if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) { + return; + } final Snake snake = new Snake(arrowColor); snake.setLabel(tbout); final Point2D mp1a = translate1.getTranslated(getP1(stringBounder)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java index c3ebce6a7..14006c458 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java @@ -106,11 +106,11 @@ class FtileWhile extends AbstractFtile { HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) { final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor, useUnderlineForHyperlink); - final TextBlock tmpb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer); + final TextBlock tmpb = yes.create(fc, HorizontalAlignment.LEFT, spriteContainer); if (test == null) { return tmpb; } - return TextBlockUtils.mergeTB(TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer), tmpb, + return TextBlockUtils.mergeTB(test.create(fc, HorizontalAlignment.LEFT, spriteContainer), tmpb, HorizontalAlignment.CENTER); } @@ -123,9 +123,9 @@ class FtileWhile extends AbstractFtile { useUnderlineForHyperlink); final FontConfiguration fcTest = new FontConfiguration(fontTest, HtmlColorUtils.BLACK, hyperlinkColor, useUnderlineForHyperlink); - final TextBlock yesTb = TextBlockUtils.create(yes, fcArrow, HorizontalAlignment.LEFT, ftileFactory); - final TextBlock testTb = TextBlockUtils.create(test, fcTest, HorizontalAlignment.LEFT, ftileFactory); - final TextBlock out = TextBlockUtils.create(out2, fcArrow, HorizontalAlignment.LEFT, ftileFactory); + final TextBlock yesTb = yes.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory); + final TextBlock testTb = test.create(fcTest, HorizontalAlignment.LEFT, ftileFactory); + final TextBlock out = out2.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory); final Ftile diamond1; final TextBlock supplementarySouthText; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 8c73a6e00..ea7be8a4b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -102,7 +103,7 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil { final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note); + final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(note); final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, 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/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java new file mode 100644 index 000000000..2f77d63a9 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -0,0 +1,200 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.CreoleParser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.svek.ConditionStyle; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UStroke; + +public class ConditionalBuilder { + + private final Swimlane swimlane; + private final HtmlColor borderColor; + private final HtmlColor backColor; + private final UFont fontArrow; + private final UFont fontTest; + private final HtmlColor arrowColor; + private final FtileFactory ftileFactory; + private final ConditionStyle conditionStyle; + private final Branch branch1; + private final Branch branch2; + private final ISkinParam skinParam; + private final StringBounder stringBounder; + + private final Ftile tile1; + private final Ftile tile2; + + public ConditionalBuilder(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, + UFont fontTest, HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, + Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder) { + this.swimlane = swimlane; + this.borderColor = borderColor; + this.backColor = backColor; + this.fontArrow = fontArrow; + this.fontTest = fontTest; + this.arrowColor = arrowColor; + this.ftileFactory = ftileFactory; + this.conditionStyle = conditionStyle; + this.branch1 = branch1; + this.branch2 = branch2; + this.skinParam = skinParam; + this.stringBounder = stringBounder; + + this.tile1 = new FtileMinWidth(branch1.getFtile(), 30); + this.tile2 = new FtileMinWidth(branch2.getFtile(), 30); + + } + + static public Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, + UFont fontTest, HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, + Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder) { + final ConditionalBuilder builder = new ConditionalBuilder(swimlane, borderColor, backColor, fontArrow, + fontTest, arrowColor, ftileFactory, conditionStyle, branch1, branch2, skinParam, stringBounder); + return builder.createWithLinks(); + // return builder.createWithDiamonds(); + // return builder.createNude(); + + } + + private Ftile createNude() { + return new FtileIfNude(tile1, tile2, swimlane); + + } + + private Ftile createWithDiamonds() { + final Ftile diamond1 = getDiamond1(); + final Ftile diamond2 = getDiamond2(); + return new FtileIfWithDiamonds(diamond1, tile1, tile2, diamond2, swimlane, stringBounder); + } + + private Ftile createWithLinks() { + final Ftile diamond1 = getDiamond1(); + final Ftile diamond2 = getDiamond2(); + final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10); + final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10); + return new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor, stringBounder).addLinks( + branch1, branch2, stringBounder); + } + + private Ftile getDiamond1() { + final Display labelTest = branch1.getLabelTest(); + + final FontConfiguration fcArrow = fcArrow(); + + final TextBlock tb1 = branch1.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, + CreoleMode.SIMPLE_LINE); + final TextBlock tb2 = branch2.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, + CreoleMode.SIMPLE_LINE); + + final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor(), skinParam.getHyperlinkColor(), + skinParam.useUnderlineForHyperlink()); + final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL) + .createSheet(labelTest); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding()); + final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5)); + + final Ftile diamond1; + if (conditionStyle == ConditionStyle.INSIDE) { + diamond1 = new FtileDiamondInside(tile1.shadowing(), backColor, borderColor, swimlane, tbTest) + .withWest(tb1).withEast(tb2); + } else if (conditionStyle == ConditionStyle.DIAMOND) { + diamond1 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane).withWest(tb1) + .withEast(tb2).withNorth(tbTest); + } else { + throw new IllegalStateException(); + } + + return diamond1; + } + + private Ftile getDiamond2() { + final FontConfiguration fcArrow = fcArrow(); + + final Ftile diamond2; + if (hasTwoBranches()) { + final Display out1 = LinkRendering.getDisplay(branch1.getFtile().getOutLinkRendering()); + final TextBlock tbout1 = out1 == null ? null : out1.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, + CreoleMode.SIMPLE_LINE); + final Display out2 = LinkRendering.getDisplay(branch2.getFtile().getOutLinkRendering()); + final TextBlock tbout2 = out2 == null ? null : out2.create(fcArrow, HorizontalAlignment.LEFT, ftileFactory, + CreoleMode.SIMPLE_LINE); + diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane).withWest(tbout1).withEast( + tbout2); + } else { + // diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2, + // swimlane, swimlane); + diamond2 = new FtileEmpty(tile1.shadowing(), 0, Diamond.diamondHalfSize / 2, swimlane, swimlane); + } + return diamond2; + } + + public boolean hasTwoBranches() { + return tile1.calculateDimension(stringBounder).hasPointOut() + && tile2.calculateDimension(stringBounder).hasPointOut(); + } + + private FontConfiguration fcArrow() { + return new FontConfiguration(fontArrow, fontColor(), skinParam.getHyperlinkColor(), + skinParam.useUnderlineForHyperlink()); + } + + private HtmlColor fontColor() { + return skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileDimensionMemoize.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileDimensionMemoize.java new file mode 100644 index 000000000..c00c1f8d4 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileDimensionMemoize.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; +import net.sourceforge.plantuml.graphic.StringBounder; + +public abstract class FtileDimensionMemoize extends AbstractFtile { + + public FtileDimensionMemoize(boolean shadowing) { + super(shadowing); + } + + private Dimension2D calculateDimensionInternal; + + protected final Dimension2D calculateDimensionInternal(StringBounder stringBounder) { + if (calculateDimensionInternal == null) { + calculateDimensionInternal = calculateDimensionInternalSlow(stringBounder); + } + return calculateDimensionInternal; + } + + abstract protected Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder); +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java new file mode 100644 index 000000000..1f540b582 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java @@ -0,0 +1,155 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; + +import java.awt.geom.Dimension2D; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class FtileIfNude extends FtileDimensionMemoize { + + protected final Ftile tile1; + protected final Ftile tile2; + private final Swimlane in; + + FtileIfNude(Ftile tile1, Ftile tile2, Swimlane in) { + super(tile1.shadowing() || tile2.shadowing()); + this.tile1 = tile1; + this.tile2 = tile2; + this.in = in; + } + + public boolean hasTwoBranches(StringBounder stringBounder) { + return tile1.calculateDimension(stringBounder).hasPointOut() + && tile2.calculateDimension(stringBounder).hasPointOut(); + } + + public Set getSwimlanes() { + final Set result = new HashSet(); + if (getSwimlaneIn() != null) { + result.add(getSwimlaneIn()); + } + result.addAll(tile1.getSwimlanes()); + result.addAll(tile2.getSwimlanes()); + return Collections.unmodifiableSet(result); + } + + public Swimlane getSwimlaneIn() { + return in; + } + + public Swimlane getSwimlaneOut() { + return getSwimlaneIn(); + } + + protected UTranslate getTranslate1(StringBounder stringBounder) { + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + final Dimension2D dim1 = tile1.calculateDimension(stringBounder); + + final double x1 = 0; + final double y1 = 0; + return new UTranslate(x1, y1); + } + + protected UTranslate getTranslate2(StringBounder stringBounder) { + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + final Dimension2D dim2 = tile2.calculateDimension(stringBounder); + + final double x2 = dimTotal.getWidth() - dim2.getWidth(); + final double y2 = 0; + return new UTranslate(x2, y2); + + } + + @Override + public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) { + if (child == tile1) { + return getTranslate1(stringBounder); + } + if (child == tile2) { + return getTranslate2(stringBounder); + } + throw new UnsupportedOperationException(); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + ug.apply(getTranslate1(stringBounder)).draw(tile1); + ug.apply(getTranslate2(stringBounder)).draw(tile2); + } + + public FtileGeometry calculateDimension(StringBounder stringBounder) { + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + if (tile1.calculateDimension(stringBounder).hasPointOut() + || tile2.calculateDimension(stringBounder).hasPointOut()) { + return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight()); + } + return new FtileGeometry(dimTotal, getLeft(stringBounder), 0); + } + + @Override + protected Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) { + final FtileGeometry dim1 = tile1.calculateDimension(stringBounder); + final FtileGeometry dim2 = tile2.calculateDimension(stringBounder); + + final double width = dim1.getLeft() + withInner(stringBounder) + (dim2.getWidth() - dim2.getLeft()); + + final Dimension2D dim12 = Dimension2DDouble.mergeLR(dim1, dim2); + + return new Dimension2DDouble(width, dim12.getHeight()); + } + + protected double withInner(StringBounder stringBounder) { + final FtileGeometry dim1 = tile1.calculateDimension(stringBounder); + final FtileGeometry dim2 = tile2.calculateDimension(stringBounder); + return (dim1.getWidth() - dim1.getLeft()) + dim2.getLeft(); + } + + protected double getLeft(StringBounder stringBounder) { + final double left1 = tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft(); + final double left2 = tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft(); + return (left1 + left2) / 2; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java new file mode 100644 index 000000000..7eef115bd --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java @@ -0,0 +1,134 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.utils.MathUtils; + +public class FtileIfWithDiamonds extends FtileIfNude { + + private final double SUPP_WITH = 20; + protected final Ftile diamond1; + protected final Ftile diamond2; + + public FtileIfWithDiamonds(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, Swimlane in, + StringBounder stringBounder) { + super(tile1, tile2, in); + this.diamond1 = diamond1; + this.diamond2 = diamond2; + } + + public int getYdelta1a(StringBounder stringBounder) { + // if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) { + if (getSwimlanes().size() > 1) { + return 20; + } + return 10; + // return hasTwoBranches(stringBounder) ? 6 : 6; + } + + public int getYdelta1b(StringBounder stringBounder) { + // if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) { + if (getSwimlanes().size() > 1) { + return 10; + } + return hasTwoBranches(stringBounder) ? 6 : 0; + } + + @Override + protected double withInner(StringBounder stringBounder) { + final FtileGeometry dim1 = diamond1.calculateDimension(stringBounder); + return Math.max(super.withInner(stringBounder), dim1.getWidth() + SUPP_WITH); + } + + @Override + protected Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) { + final FtileGeometry dim1 = diamond1.calculateDimension(stringBounder); + final FtileGeometry dim2 = diamond2.calculateDimension(stringBounder); + + final Dimension2D dimNude = super.calculateDimensionInternalSlow(stringBounder); + + final double width = MathUtils.max(dim1.getWidth(), dim2.getWidth(), dimNude.getWidth()); + final double height = dimNude.getHeight() + dim1.getHeight() + dim2.getHeight() + getYdelta1a(stringBounder) + + getYdelta1b(stringBounder); + return new Dimension2DDouble(width, height); + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1); + super.drawU(ug); + ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2); + } + + @Override + protected UTranslate getTranslate1(StringBounder stringBounder) { + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + return super.getTranslate1(stringBounder).compose( + new UTranslate(0, dimDiamond1.getHeight() + getYdelta1a(stringBounder))); + } + + @Override + protected UTranslate getTranslate2(StringBounder stringBounder) { + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + return super.getTranslate2(stringBounder).compose( + new UTranslate(0, dimDiamond1.getHeight() + getYdelta1a(stringBounder))); + } + + protected UTranslate getTranslateDiamond1(StringBounder stringBounder) { + final double y1 = 0; + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2; + return new UTranslate(x1, y1); + } + + protected UTranslate getTranslateDiamond2(StringBounder stringBounder) { + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight(); + final double x2 = getLeft(stringBounder) - dimDiamond2.getWidth() / 2; + return new UTranslate(x2, y2); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java new file mode 100644 index 000000000..6bce86f69 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java @@ -0,0 +1,381 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 8475 $ + * + */ +package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; +import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; +import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class FtileIfWithLinks extends FtileIfWithDiamonds { + + private final HtmlColor arrowColor; + + public FtileIfWithLinks(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, Swimlane in, + HtmlColor arrowColor, StringBounder stringBounder) { + super(diamond1, tile1, tile2, diamond2, in, stringBounder); + this.arrowColor = arrowColor; + } + + private HtmlColor getInColor(Branch branch) { + if (branch.isEmpty()) { + return LinkRendering.getColor(branch.getFtile().getOutLinkRendering(), arrowColor); + } + final LinkRendering linkIn = branch.getFtile().getInLinkRendering(); + final HtmlColor color = linkIn == null ? arrowColor : linkIn.getColor(); + return color; + + } + + class ConnectionHorizontalThenVertical extends AbstractConnection implements ConnectionTranslatable { + + private final HtmlColor color; + private final UPolygon usingArrow; + + public ConnectionHorizontalThenVertical(Ftile tile, Branch branch) { + super(diamond1, tile); + color = getInColor(branch); + usingArrow = branch.isEmpty() ? null : Arrows.asToDown(); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Point2D p1 = getP1(stringBounder); + final Point2D p2 = getP2(stringBounder); + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + final Snake snake = new Snake(color, usingArrow); + snake.addPoint(x1, y1); + snake.addPoint(x2, y1); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + + private Point2D getP1(StringBounder stringBounder) { + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final double diamondWidth = dimDiamond1.getWidth(); + final double x; + if (getFtile2() == tile1) { + x = 0; + } else if (getFtile2() == tile2) { + x = diamondWidth; + } else { + throw new IllegalStateException(); + } + return getTranslateDiamond1(stringBounder) + .getTranslated(new Point2D.Double(x, dimDiamond1.getHeight() / 2)); + } + + private Point2D getP2(final StringBounder stringBounder) { + return translate(stringBounder).getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); + } + + private UTranslate translate(StringBounder stringBounder) { + if (getFtile2() == tile1) { + return getTranslate1(stringBounder); + } + if (getFtile2() == tile2) { + return getTranslate2(stringBounder); + } + throw new IllegalStateException(); + } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + Point2D p1 = getP1(stringBounder); + Point2D p2 = getP2(stringBounder); + final Direction originalDirection = Direction.leftOrRight(p1, p2); + p1 = translate1.getTranslated(p1); + p2 = translate2.getTranslated(p2); + final Direction newDirection = Direction.leftOrRight(p1, p2); + if (originalDirection != newDirection) { + final double delta = (originalDirection == Direction.RIGHT ? -1 : 1) * Diamond.diamondHalfSize; + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final Snake small = new Snake(color); + small.addPoint(p1); + small.addPoint(p1.getX() + delta, p1.getY()); + small.addPoint(p1.getX() + delta, p1.getY() + dimDiamond1.getHeight() * .75); + ug.draw(small); + p1 = small.getLast(); + } + final Snake snake = new Snake(color, usingArrow); + snake.addPoint(p1); + snake.addPoint(p2.getX(), p1.getY()); + snake.addPoint(p2); + ug.draw(snake); + + } + + } + + class ConnectionVerticalThenHorizontal extends AbstractConnection implements ConnectionTranslatable { + private final HtmlColor myArrowColor; + private final boolean branchEmpty; + + public ConnectionVerticalThenHorizontal(Ftile tile, HtmlColor myArrowColor, boolean branchEmpty) { + super(tile, diamond2); + this.myArrowColor = myArrowColor == null ? arrowColor : myArrowColor; + this.branchEmpty = branchEmpty; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); + if (geo.hasPointOut() == false) { + return; + } + final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut(); + final Point2D p2 = getP2(stringBounder); + + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft(); + final Snake snake = new Snake(myArrowColor, arrow); + if (branchEmpty) { + snake.emphasizeDirection(Direction.DOWN); + } + snake.addPoint(x1, y1); + snake.addPoint(x1, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + + private Point2D getP2(StringBounder stringBounder) { + final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double diamondWidth = dimDiamond2.getWidth(); + final double x; + if (getFtile1() == tile1) { + x = 0; + } else if (getFtile1() == tile2) { + x = diamondWidth; + } else { + throw new IllegalStateException(); + } + return getTranslateDiamond2(stringBounder) + .getTranslated(new Point2D.Double(x, dimDiamond2.getHeight() / 2)); + } + + private UTranslate translate(StringBounder stringBounder) { + if (getFtile1() == tile1) { + return getTranslate1(stringBounder); + } + if (getFtile1() == tile2) { + return getTranslate2(stringBounder); + } + throw new IllegalStateException(); + } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); + if (geo.hasPointOut() == false) { + return; + } + final Point2D p2 = getP2(stringBounder); + final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut(); + final Direction originalDirection = Direction.leftOrRight(p1, p2); + + final double x1 = p1.getX(); + final double x2 = p2.getX(); + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + final Direction newDirection = Direction.leftOrRight(mp1a, mp2b); + final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft(); + if (originalDirection == newDirection) { + final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize; + final Point2D mp2bc = new Point2D.Double(mp2b.getX() + delta, mp2b.getY()); + final Snake snake = new Snake(myArrowColor); + final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), middle); + snake.addPoint(mp2bc.getX(), middle); + snake.addPoint(mp2bc); + ug.draw(snake); + final Snake small = new Snake(myArrowColor, arrow); + small.addPoint(mp2bc); + small.addPoint(mp2bc.getX(), mp2b.getY()); + small.addPoint(mp2b); + ug.draw(small); + } else { + final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize; + final Point2D mp2bb = new Point2D.Double(mp2b.getX() + delta, mp2b.getY() - 1.5 + * Diamond.diamondHalfSize); + final Snake snake = new Snake(myArrowColor); + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), mp2bb.getY()); + snake.addPoint(mp2bb); + ug.draw(snake); + final Snake small = new Snake(myArrowColor, arrow); + small.addPoint(mp2bb); + small.addPoint(mp2bb.getX(), mp2b.getY()); + small.addPoint(mp2b); + ug.draw(small); + + } + + } + } + + class ConnectionVerticalThenHorizontalDirect extends AbstractConnection implements ConnectionTranslatable { + private final HtmlColor myArrowColor; + private final boolean branchEmpty; + + public ConnectionVerticalThenHorizontalDirect(Ftile tile, HtmlColor myArrowColor, boolean branchEmpty) { + super(tile, diamond2); + this.myArrowColor = myArrowColor == null ? arrowColor : myArrowColor; + this.branchEmpty = branchEmpty; + } + + public void drawU(UGraphic ug) { + + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + + final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); + if (geo.hasPointOut() == false) { + return; + } + final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut(); + final Point2D p2 = new Point2D.Double(getLeft(stringBounder), dimTotal.getHeight()); + + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + final Snake snake = new Snake(myArrowColor); + if (branchEmpty) { + snake.emphasizeDirection(Direction.DOWN); + } + snake.addPoint(x1, y1); + snake.addPoint(x1, y2); + snake.addPoint(x2, y2); + snake.addPoint(x2, dimTotal.getHeight()); + + ug.draw(snake); + } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); + + final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); + if (geo.hasPointOut() == false) { + return; + } + final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut(); + final Point2D p2 = new Point2D.Double(getLeft(stringBounder), dimTotal.getHeight() + - Diamond.diamondHalfSize); + + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + + final Snake snake = new Snake(myArrowColor); + // snake.emphasizeDirection(Direction.DOWN); + + final double x1 = mp1a.getX(); + final double x2 = mp2b.getX(); + final double y2 = mp2b.getY(); + + snake.addPoint(mp1a); + snake.addPoint(x1, y2); + snake.addPoint(mp2b); + snake.addPoint(x2, dimTotal.getHeight()); + + ug.draw(snake); + } + + + private UTranslate translate(StringBounder stringBounder) { + if (getFtile1() == tile1) { + return getTranslate1(stringBounder); + } + if (getFtile1() == tile2) { + return getTranslate2(stringBounder); + } + throw new IllegalStateException(); + } + + } + + public Ftile addLinks(Branch branch1, Branch branch2, StringBounder stringBounder) { + final List conns = new ArrayList(); + conns.add(new ConnectionHorizontalThenVertical(tile1, branch1)); + conns.add(new ConnectionHorizontalThenVertical(tile2, branch2)); + if (tile1.calculateDimension(stringBounder).hasPointOut() + && tile2.calculateDimension(stringBounder).hasPointOut()) { + conns.add(new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor(), branch1.isEmpty())); + conns.add(new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor(), branch2.isEmpty())); + } else if (tile1.calculateDimension(stringBounder).hasPointOut() + && tile2.calculateDimension(stringBounder).hasPointOut() == false) { + conns.add(new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor(), branch1 + .isEmpty())); + } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false + && tile2.calculateDimension(stringBounder).hasPointOut()) { + conns.add(new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor(), branch2 + .isEmpty())); + } + + return FtileUtils.addConnection(this, conns); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index 2c70d66d7..9967f2093 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -122,7 +123,7 @@ public class FtileBox extends AbstractFtile { final FontConfiguration fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(label); + final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(label); this.tb = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), new MyStencil(), new UStroke(1)); this.print = label.toString(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 4ebb4c7f3..88b2c0c4f 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16021 $ + * Revision $Revision: 16530 $ * */ package net.sourceforge.plantuml.classdiagram; @@ -39,6 +39,7 @@ import java.io.OutputStream; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; @@ -138,9 +139,10 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { group = getOrCreateNamespaceInternal(namespace2, Display.getWithNewlines(namespace), GroupType.PACKAGE, getRootGroup()); } - return createLeafInternal(fullyCode, - display == null ? Display.getWithNewlines(fullyCode.getShortName(getLeafs())) : display, type, group, - symbol); + return createLeafInternal( + fullyCode, + Display.isNull(display) ? Display.getWithNewlines(fullyCode.getShortName(getLeafs())).withCreoleMode( + CreoleMode.SIMPLE_LINE) : display, type, group, symbol); } private final String getNamespace(Code fullyCode) { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index f3294c390..de89ae3ed 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -73,13 +73,13 @@ public class CommandCreateClass extends SingleLineCommand2 { "(interface|enum|annotation|abstract[%s]+class|abstract|class)[%s]+"), // new RegexOr(// new RegexConcat(// - new RegexLeaf("DISPLAY1", "[%g]([^%g]+)[%g]"), // + new RegexLeaf("DISPLAY1", "[%g](.+)[%g]"), // new RegexLeaf("[%s]+as[%s]+"), // new RegexLeaf("CODE1", "(" + CODE + ")")), // new RegexConcat(// new RegexLeaf("CODE2", "(" + CODE + ")"), // new RegexLeaf("[%s]+as[%s]+"), // // - new RegexLeaf("DISPLAY2", "[%g]([^%g]+)[%g]")), // + new RegexLeaf("DISPLAY2", "[%g](.+)[%g]")), // new RegexLeaf("CODE3", "(" + CODE + ")"), // new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), // new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), // diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 1d89eee42..7d94ff193 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -84,13 +84,13 @@ public class CommandCreateClassMultilines extends CommandMultilines2)?"), // @@ -159,7 +159,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 { @@ -53,7 +54,7 @@ public class CommandDiamondAssociation extends SingleLineCommand { if (diagram.leafExist(code)) { return CommandExecutionResult.error("Already existing : "+code.getFullName()); } - diagram.createLeaf(code, null, LeafType.ASSOCIATION, null); + diagram.createLeaf(code, Display.NULL, LeafType.ASSOCIATION, null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java index 90b1f0494..b9014a32a 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14727 $ + * Revision $Revision: 16545 $ * */ package net.sourceforge.plantuml.classdiagram.command; @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand; import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; @@ -96,7 +97,7 @@ public class CommandImport extends SingleLineCommand { for (String p : cl.getParents()) { final IEntity ent2 = classDiagram.getOrCreateLeaf(Code.of(p), cl.getParentType(), null); - final Link link = new Link(ent2, ent1, new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS), null, 2); + final Link link = new Link(ent2, ent1, new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS), Display.NULL, 2); classDiagram.addLink(link); } } diff --git a/src/net/sourceforge/plantuml/command/ProtectedCommand.java b/src/net/sourceforge/plantuml/command/ProtectedCommand.java index 81a6a56f9..14ee68515 100644 --- a/src/net/sourceforge/plantuml/command/ProtectedCommand.java +++ b/src/net/sourceforge/plantuml/command/ProtectedCommand.java @@ -55,6 +55,7 @@ public class ProtectedCommand implements Command { return result; } catch (Throwable t) { Log.error("Error " + t); + t.printStackTrace(); String msg = "You should send a mail to plantuml@gmail.com with this log (V" + Version.versionString() + ")"; Log.error(msg); diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java index 1a871e545..0929c9ba1 100644 --- a/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java +++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java @@ -143,13 +143,13 @@ public final class FactoryNoteActivityCommand implements SingleMultiFactoryComma final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed(); if (position == Position.RIGHT) { - link = new Link(activity, note, type, null, 1); + link = new Link(activity, note, type, Display.NULL, 1); } else if (position == Position.LEFT) { - link = new Link(note, activity, type, null, 1); + link = new Link(note, activity, type, Display.NULL, 1); } else if (position == Position.BOTTOM) { - link = new Link(activity, note, type, null, 2); + link = new Link(activity, note, type, Display.NULL, 2); } else if (position == Position.TOP) { - link = new Link(note, activity, type, null, 2); + link = new Link(note, activity, type, Display.NULL, 2); } else { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java index 778dc691e..15165beab 100644 --- a/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java +++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -162,15 +163,15 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed(); if (position == Position.RIGHT) { - link = new Link(cl1, note, type, null, 1); + link = new Link(cl1, note, type, Display.NULL, 1); link.setHorizontalSolitary(true); } else if (position == Position.LEFT) { - link = new Link(note, cl1, type, null, 1); + link = new Link(note, cl1, type, Display.NULL, 1); link.setHorizontalSolitary(true); } else if (position == Position.BOTTOM) { - link = new Link(cl1, note, type, null, 2); + link = new Link(cl1, note, type, Display.NULL, 2); } else if (position == Position.TOP) { - link = new Link(note, cl1, type, null, 2); + link = new Link(note, cl1, type, Display.NULL, 2); } else { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/command/note/FactoryTipOnEntityCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryTipOnEntityCommand.java index 00b3326df..57d06029f 100644 --- a/src/net/sourceforge/plantuml/command/note/FactoryTipOnEntityCommand.java +++ b/src/net/sourceforge/plantuml/command/note/FactoryTipOnEntityCommand.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -130,9 +131,9 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); final Link link; if (position == Position.RIGHT) { - link = new Link(cl1, (IEntity) tips, type, null, 1); + link = new Link(cl1, (IEntity) tips, type, Display.NULL, 1); } else { - link = new Link((IEntity) tips, cl1, type, null, 1); + link = new Link((IEntity) tips, cl1, type, Display.NULL, 1); } diagram.addLink(link); } diff --git a/src/net/sourceforge/plantuml/creole/AtomTable.java b/src/net/sourceforge/plantuml/creole/AtomTable.java index 0101f181d..1068d50d8 100644 --- a/src/net/sourceforge/plantuml/creole/AtomTable.java +++ b/src/net/sourceforge/plantuml/creole/AtomTable.java @@ -163,7 +163,11 @@ public class AtomTable implements Atom { private double getColWidth(int col) { double result = 0; for (int i = 0; i < getNbLines(); i++) { - final double width = getPosition(i, col).getWidth(); + final Position position = getPosition(i, col); + if (position == null) { + continue; + } + final double width = position.getWidth(); result = Math.max(result, width); } return result; @@ -172,14 +176,24 @@ public class AtomTable implements Atom { private double getLineHeight(int line) { double result = 0; for (int i = 0; i < getNbCols(); i++) { - final double height = getPosition(line, i).getHeight(); + final Position position = getPosition(line, i); + if (position == null) { + continue; + } + final double height = position.getHeight(); result = Math.max(result, height); } return result; } private Position getPosition(int line, int col) { + if (line >= lines.size()) { + return null; + } final Line l = lines.get(line); + if (col >= l.cells.size()) { + return null; + } final Atom atom = l.cells.get(col); return positions.get(atom); } diff --git a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java index 48637db20..84292ae35 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java +++ b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java @@ -78,7 +78,7 @@ public class CreoleHorizontalLine implements Atom { if (line.length() == 0) { return TextBlockUtils.empty(0, 0); } - final CreoleParser parser = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, skinParam, false); + 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()); return tb; diff --git a/src/net/sourceforge/plantuml/creole/CreoleMode.java b/src/net/sourceforge/plantuml/creole/CreoleMode.java new file mode 100644 index 000000000..bde8f00c8 --- /dev/null +++ b/src/net/sourceforge/plantuml/creole/CreoleMode.java @@ -0,0 +1,39 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 11025 $ + * + */ +package net.sourceforge.plantuml.creole; + +public enum CreoleMode { + FULL, SIMPLE_LINE; + +} diff --git a/src/net/sourceforge/plantuml/creole/CreoleParser.java b/src/net/sourceforge/plantuml/creole/CreoleParser.java index e52a1233c..df9a7f871 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/CreoleParser.java @@ -48,10 +48,10 @@ public class CreoleParser { private final FontConfiguration fontConfiguration; private final ISkinSimple skinParam; private final HorizontalAlignment horizontalAlignment; - private final boolean modeSimpleLine; + private final CreoleMode modeSimpleLine; public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple skinParam, boolean modeSimpleLine) { + ISkinSimple skinParam, CreoleMode modeSimpleLine) { this.modeSimpleLine = modeSimpleLine; this.fontConfiguration = fontConfiguration; this.skinParam = skinParam; @@ -83,7 +83,7 @@ public class CreoleParser { public Sheet createSheet(Display display) { final Sheet sheet = new Sheet(horizontalAlignment); - if (display != null) { + if (Display.isNull(display) == false) { final CreoleContext context = new CreoleContext(); for (CharSequence cs : display) { final Stripe stripe; diff --git a/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java b/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java index 850e424e5..551a74a89 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java +++ b/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java @@ -46,13 +46,13 @@ public class CreoleStripeSimpleParser { final private String line; final private StripeStyle style; - private final boolean modeSimpleLine; + private final CreoleMode modeSimpleLine; private final FontConfiguration fontConfiguration; private final ISkinSimple skinParam; public CreoleStripeSimpleParser(String line, CreoleContext creoleContext, FontConfiguration fontConfiguration, - ISkinSimple skinParam, boolean modeSimpleLine) { + ISkinSimple skinParam, CreoleMode modeSimpleLine) { this.fontConfiguration = fontConfiguration; this.modeSimpleLine = modeSimpleLine; this.skinParam = skinParam; @@ -80,15 +80,15 @@ public class CreoleStripeSimpleParser { return; } - if (modeSimpleLine == false) { - final Pattern p6 = MyPattern.cmpile("^__([^_]*)__$"); - final Matcher m6 = p6.matcher(line); - if (m6.find()) { - this.line = m6.group(1); - this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '_'); - return; - } - } +// if (modeSimpleLine == CreoleMode.FULL) { +// final Pattern p6 = MyPattern.cmpile("^__([^_]*)__$"); +// final Matcher m6 = p6.matcher(line); +// if (m6.find()) { +// this.line = m6.group(1); +// this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '_'); +// return; +// } +// } final Pattern p7 = MyPattern.cmpile("^\\.\\.([^\\.]*)\\.\\.$"); final Matcher m7 = p7.matcher(line); @@ -98,7 +98,7 @@ public class CreoleStripeSimpleParser { return; } - if (modeSimpleLine == false) { + if (modeSimpleLine == CreoleMode.FULL) { final Pattern p1 = MyPattern.cmpile("^(\\*+)([^*]+(?:[^*]|\\*\\*[^*]+\\*\\*)*)$"); final Matcher m1 = p1.matcher(line); if (m1.find()) { @@ -109,7 +109,7 @@ public class CreoleStripeSimpleParser { } } - if (modeSimpleLine == false) { + if (modeSimpleLine == CreoleMode.FULL) { final Pattern p2 = MyPattern.cmpile("^(#+)(.+)$"); final Matcher m2 = p2.matcher(CharHidder.hide(line)); if (m2.find()) { diff --git a/src/net/sourceforge/plantuml/creole/PSystemCreole.java b/src/net/sourceforge/plantuml/creole/PSystemCreole.java index f40639ba0..5a0b054b0 100644 --- a/src/net/sourceforge/plantuml/creole/PSystemCreole.java +++ b/src/net/sourceforge/plantuml/creole/PSystemCreole.java @@ -72,7 +72,7 @@ public class PSystemCreole extends AbstractPSystem { final UFont font = new UFont("Serif", Font.PLAIN, 14); final FontConfiguration fontConfiguration = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, false) + final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.FULL) .createSheet(display); final SheetBlock1 sheetBlock = new SheetBlock1(sheet, 0, 0); diff --git a/src/net/sourceforge/plantuml/creole/StripeSimple.java b/src/net/sourceforge/plantuml/creole/StripeSimple.java index eff86ae8b..c84a32522 100644 --- a/src/net/sourceforge/plantuml/creole/StripeSimple.java +++ b/src/net/sourceforge/plantuml/creole/StripeSimple.java @@ -58,7 +58,7 @@ public class StripeSimple implements Stripe { final private ISkinSimple skinParam; public StripeSimple(FontConfiguration fontConfiguration, StripeStyle style, CreoleContext context, - ISkinSimple skinParam, boolean modeSimpleLine) { + ISkinSimple skinParam, CreoleMode modeSimpleLine) { this.fontConfiguration = fontConfiguration; this.style = style; this.skinParam = skinParam; @@ -70,7 +70,7 @@ public class StripeSimple implements Stripe { this.commands.add(CommandCreoleStyle.createCreole(FontStyle.ITALIC)); this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.ITALIC)); this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.ITALIC)); - if (modeSimpleLine == false) { + if (modeSimpleLine == CreoleMode.FULL) { this.commands.add(CommandCreoleStyle.createCreole(FontStyle.UNDERLINE)); } this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.UNDERLINE)); diff --git a/src/net/sourceforge/plantuml/creole/StripeTable.java b/src/net/sourceforge/plantuml/creole/StripeTable.java index 776f5581a..0a9958141 100644 --- a/src/net/sourceforge/plantuml/creole/StripeTable.java +++ b/src/net/sourceforge/plantuml/creole/StripeTable.java @@ -85,7 +85,7 @@ public class StripeTable implements Stripe { final List cells = new ArrayList(); for (String s : lines) { final StripeSimple cell = new StripeSimple(getFontConfiguration(mode), stripeStyle, - new CreoleContext(), skinParam, false); + new CreoleContext(), skinParam, CreoleMode.FULL); cell.analyzeAndAdd(s); cells.add(cell); } diff --git a/src/net/sourceforge/plantuml/creole/StripeTree.java b/src/net/sourceforge/plantuml/creole/StripeTree.java index a843649d8..cfabf7c18 100644 --- a/src/net/sourceforge/plantuml/creole/StripeTree.java +++ b/src/net/sourceforge/plantuml/creole/StripeTree.java @@ -63,7 +63,7 @@ public class StripeTree implements Stripe { final List lines = StripeTable.getWithNewlinesInternal(line); for (String s : lines) { final StripeSimple cell = new StripeSimple(fontConfiguration, stripeStyle, new CreoleContext(), skinParam, - false); + CreoleMode.FULL); // EMTEC final String text = s.replaceFirst("^\\s*\\|_", ""); final int level = (s.length() - text.length()) / 2; diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index d1add6e1e..ab3b4b396 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -81,7 +81,7 @@ public class Bodier { private boolean isMethod(String s) { if (type == LeafType.ANNOTATION || type == LeafType.ABSTRACT_CLASS || type == LeafType.CLASS || type == LeafType.INTERFACE || type == LeafType.ENUM) { - return StringUtils.isMethod(s); + return MemberImpl.isMethod(s); } return false; } @@ -158,7 +158,7 @@ public class Bodier { public TextBlock getBody(final FontParam fontParam, final ISkinParam skinParam, final boolean showMethods, final boolean showFields) { if (type.isLikeClass() && isBodyEnhanced()) { - if (showMethods && showFields) { + if (showMethods || showFields) { return new BodyEnhanced(rawBody, fontParam, skinParam, manageModifier); } return null; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java index 9ad8bbe7f..542706a54 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java @@ -34,7 +34,6 @@ package net.sourceforge.plantuml.cucadiagram; import java.awt.geom.Dimension2D; -import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -45,6 +44,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -145,11 +145,10 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock { } members = new ArrayList(); final List allTree = buildAllTree(s, it); - final TextBlock bloc = TextBlockUtils.create(Display.create(allTree), - fontParam.getFontConfiguration(skinParam), align, skinParam, false); + final TextBlock bloc = Display.create(allTree).create(fontParam.getFontConfiguration(skinParam), align, skinParam, CreoleMode.FULL); blocks.add(bloc); } else { - final Member m = new MemberImpl(s, StringUtils.isMethod(s), manageModifier, manageUrl); + final Member m = new MemberImpl(s, MemberImpl.isMethod(s), manageModifier, manageUrl); members.add(m); if (m.getUrl() != null) { urls.add(m.getUrl()); @@ -205,8 +204,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock { return null; } s = StringUtils.trin(s.substring(2, s.length() - 2)); - return TextBlockUtils - .create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer); + return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java index d70fabc05..716e6793b 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java @@ -119,7 +119,7 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { } private TextBlock getTextBlock(Display members2, StringBounder stringBounder) { - final TextBlock result = TextBlockUtils.create(members2, titleConfig, align, spriteContainer); + final TextBlock result = members2.create(titleConfig, align, spriteContainer); return result; } @@ -144,8 +144,7 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { return null; } s = StringUtils.trin(s.substring(2, s.length() - 2)); - return TextBlockUtils - .create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer); + return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 3d9228309..f50a2bbfa 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14667 $ + * Revision $Revision: 16520 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -124,7 +124,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } final protected ILeaf createLeafInternal(Code code, Display display, LeafType type, IGroup group, USymbol symbol) { - if (display == null) { + if (Display.isNull(display)) { display = Display.getWithNewlines(code); } final ILeaf leaf = entityFactory.createLeaf(code, display, type, group, getHides(), getNamespaceSeparator()); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index c60b18363..338f51b3b 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -45,24 +45,50 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.CharSequence2; import net.sourceforge.plantuml.CharSequence2Impl; import net.sourceforge.plantuml.EmbededDiagram; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineLocationImpl; +import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder.ModeUrl; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.CreoleParser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.graphic.CircledCharacter; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockSimple; +import net.sourceforge.plantuml.graphic.TextBlockSpotted; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.VerticalAlignment; +import net.sourceforge.plantuml.sequencediagram.MessageNumber; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UStroke; public class Display implements Iterable { - private final List display = new ArrayList(); + private final List display; private final HorizontalAlignment naturalHorizontalAlignment; + private final boolean isNull; + private final CreoleMode defaultCreoleMode; + + // public void setDefaultCreoleMode(CreoleMode defaultCreoleMode) { + // this.defaultCreoleMode = defaultCreoleMode; + // } + + public final static Display NULL = new Display(null, null, true, CreoleMode.FULL); public boolean isWhite() { return display.size() == 0 || (display.size() == 1 && display.get(0).toString().matches("\\s*")); } public static Display empty() { - return new Display((HorizontalAlignment) null); + return new Display((HorizontalAlignment) null, false, CreoleMode.FULL); } public static Display create(CharSequence... s) { @@ -70,7 +96,7 @@ public class Display implements Iterable { } public static Display create(Collection other) { - return new Display(other, null); + return new Display(other, null, false, CreoleMode.FULL); } public static Display getWithNewlines(Code s) { @@ -79,7 +105,8 @@ public class Display implements Iterable { public static Display getWithNewlines(String s) { if (s == null) { - return null; + // Thread.dumpStack(); + return NULL; } final List result = new ArrayList(); final StringBuilder current = new StringBuilder(); @@ -113,21 +140,27 @@ public class Display implements Iterable { } } result.add(current.toString()); - return new Display(result, naturalHorizontalAlignment); + return new Display(result, naturalHorizontalAlignment, false, CreoleMode.FULL); } - private Display(Display other) { - this(other.naturalHorizontalAlignment); + private Display(Display other, CreoleMode mode) { + this(other.naturalHorizontalAlignment, other.isNull, mode); this.display.addAll(other.display); } - private Display(HorizontalAlignment naturalHorizontalAlignment) { - this.naturalHorizontalAlignment = naturalHorizontalAlignment; + private Display(HorizontalAlignment naturalHorizontalAlignment, boolean isNull, CreoleMode defaultCreoleMode) { + this.defaultCreoleMode = defaultCreoleMode; + this.isNull = isNull; + this.display = isNull ? null : new ArrayList(); + this.naturalHorizontalAlignment = isNull ? null : naturalHorizontalAlignment; } - private Display(Collection other, HorizontalAlignment naturalHorizontalAlignment) { - this(naturalHorizontalAlignment); - this.display.addAll(manageEmbededDiagrams2(other)); + private Display(Collection other, HorizontalAlignment naturalHorizontalAlignment, + boolean isNull, CreoleMode defaultCreoleMode) { + this(naturalHorizontalAlignment, isNull, defaultCreoleMode); + if (isNull == false) { + this.display.addAll(manageEmbededDiagrams2(other)); + } } private static List manageEmbededDiagrams2(final Collection strings) { @@ -158,11 +191,21 @@ public class Display implements Iterable { for (CharSequence line : display) { result.add("" + line); } - return new Display(result, this.naturalHorizontalAlignment); + return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + } + + public Display withCreoleMode(CreoleMode mode) { + if (isNull) { + throw new IllegalArgumentException(); + } + return new Display(this, mode); } @Override public String toString() { + if (isNull) { + return "NULL"; + } return display.toString(); } @@ -177,24 +220,27 @@ public class Display implements Iterable { } public Display addAll(Display other) { - final Display result = new Display(this); + final Display result = new Display(this, this.defaultCreoleMode); result.display.addAll(other.display); return result; } public Display addFirst(CharSequence s) { - final Display result = new Display(this); + final Display result = new Display(this, this.defaultCreoleMode); result.display.add(0, s); return result; } public Display add(CharSequence s) { - final Display result = new Display(this); + final Display result = new Display(this, this.defaultCreoleMode); result.display.add(s); return result; } public int size() { + if (isNull) { + return 0; + } return display.size(); } @@ -207,7 +253,8 @@ public class Display implements Iterable { } public Display subList(int i, int size) { - return new Display(display.subList(i, size), this.naturalHorizontalAlignment); + return new Display(display.subList(i, size), this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } public List as() { @@ -236,7 +283,7 @@ public class Display implements Iterable { if (url == null) { return this; } - final Display result = new Display(this.naturalHorizontalAlignment); + final Display result = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); result.display.add(UrlBuilder.purgeUrl(this.get(0).toString())); result.display.addAll(this.subList(1, this.size()).display); return result; @@ -258,7 +305,7 @@ public class Display implements Iterable { public List splitMultiline(Pattern separator) { final List result = new ArrayList(); - Display pending = new Display(this.naturalHorizontalAlignment); + Display pending = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); result.add(pending); for (CharSequence line : display) { final Matcher m = separator.matcher(line); @@ -266,7 +313,7 @@ public class Display implements Iterable { final CharSequence s1 = line.subSequence(0, m.start()); pending.display.add(s1); final CharSequence s2 = line.subSequence(m.end(), line.length()); - pending = new Display(this.naturalHorizontalAlignment); + pending = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); result.add(pending); pending.display.add(s2); } else { @@ -276,4 +323,88 @@ public class Display implements Iterable { return Collections.unmodifiableList(result); } + // ------ + + public static boolean isNull(Display display) { +// if (display == null) { +// throw new IllegalArgumentException(); +// } + return display == null || display.isNull; + } + + public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer) { + return create(fontConfiguration, horizontalAlignment, spriteContainer, CreoleMode.FULL); + } + + public TextBlock createWithNiceCreoleMode(FontConfiguration fontConfiguration, + HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer) { + return create(fontConfiguration, horizontalAlignment, spriteContainer, defaultCreoleMode); + } + + public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer, CreoleMode modeSimpleLine) { + return create(fontConfiguration, horizontalAlignment, spriteContainer, 0, modeSimpleLine, null, null); + } + + public TextBlock create(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer, double maxMessageSize, CreoleMode modeSimpleLine, UFont fontForStereotype, + HtmlColor htmlColorForStereotype) { + if (getNaturalHorizontalAlignment() != null) { + horizontalAlignment = getNaturalHorizontalAlignment(); + } + if (size() > 0) { + if (get(0) instanceof Stereotype) { + return createStereotype(fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype, + htmlColorForStereotype); + } + if (get(size() - 1) instanceof Stereotype) { + return createStereotype(fontConfiguration, horizontalAlignment, spriteContainer, size() - 1, + fontForStereotype, htmlColorForStereotype); + } + if (get(0) instanceof MessageNumber) { + return createMessageNumber(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize); + } + } + + return getCreole(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, modeSimpleLine); + } + + private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer, double maxMessageSize, CreoleMode modeSimpleLine) { + final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, modeSimpleLine) + .createSheet(this); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0 + : spriteContainer.getPadding()); + return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5)); + } + + private TextBlock createMessageNumber(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + ISkinSimple spriteContainer, double maxMessageSize) { + TextBlock tb1 = subList(0, 1).getCreole(fontConfiguration, horizontalAlignment, spriteContainer, + maxMessageSize, CreoleMode.FULL); + tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0); + final TextBlock tb2 = subList(1, size()).getCreole(fontConfiguration, horizontalAlignment, spriteContainer, + maxMessageSize, CreoleMode.FULL); + return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER); + + } + + private TextBlock createStereotype(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + SpriteContainer spriteContainer, int position, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { + final Stereotype stereotype = (Stereotype) get(position); + if (stereotype.isSpotted()) { + final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(), + stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getHtmlColor(), null, + fontConfiguration.getColor()); + if (stereotype.getLabel(false) == null) { + return new TextBlockSpotted(circledCharacter, this.subList(1, this.size()), fontConfiguration, + horizontalAlignment, spriteContainer); + } + return new TextBlockSpotted(circledCharacter, this, fontConfiguration, horizontalAlignment, spriteContainer); + } + return new TextBlockSimple(this, fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype, + htmlColorForStereotype); + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 511290044..bb192c84c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15543 $ + * Revision $Revision: 16541 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -110,8 +110,8 @@ public class Link implements Hideable, Removeable { this.cl1 = cl1; this.cl2 = cl2; this.type = type; - if (label == null) { - this.label = null; + if (Display.isNull(label)) { + this.label = Display.NULL; } else if (doWeHaveToRemoveUrlAtStart(label)) { this.url = label.initUrl(); this.label = label.removeUrl(url); @@ -130,9 +130,9 @@ public class Link implements Hideable, Removeable { if (qualifier2 != null) { ((ILeaf) cl2).setNearDecoration(true); } -// if (type.getDecor2() == LinkDecor.EXTENDS) { -// setSametail(cl1.getUid()); -// } + // if (type.getDecor2() == LinkDecor.EXTENDS) { + // setSametail(cl1.getUid()); + // } } private static boolean doWeHaveToRemoveUrlAtStart(Display label) { @@ -370,8 +370,9 @@ public class Link implements Hideable, Removeable { private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif, ISkinSimple spriteContainer) { if (qualif != null) { - final TextBlock b = TextBlockUtils.create(Display.create(qualif), new FontConfiguration(fontQualif, - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, spriteContainer); + final TextBlock b = Display.create(qualif).create( + new FontConfiguration(fontQualif, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), + HorizontalAlignment.LEFT, spriteContainer); final Dimension2D dim = b.calculateDimension(stringBounder); return Math.max(dim.getWidth(), dim.getHeight()); } @@ -480,7 +481,7 @@ public class Link implements Hideable, Removeable { } public boolean hasUrl() { - if (label != null && label.hasUrl()) { + if (Display.isNull(label) == false && label.hasUrl()) { return true; } return getUrl() != null; diff --git a/src/net/sourceforge/plantuml/cucadiagram/Magma.java b/src/net/sourceforge/plantuml/cucadiagram/Magma.java index 71a7a4413..9b71724d9 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Magma.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Magma.java @@ -49,11 +49,11 @@ class Magma { public void putInSquare() { final SquareLinker linker = new SquareLinker() { public void topDown(ILeaf top, ILeaf down) { - system.addLink(new Link(top, down, linkType, null, 2)); + system.addLink(new Link(top, down, linkType, Display.NULL, 2)); } public void leftRight(ILeaf left, ILeaf right) { - system.addLink(new Link(left, right, linkType, null, 1)); + system.addLink(new Link(left, right, linkType, Display.NULL, 1)); } }; new SquareMaker().putInSquare(standalones, linker); @@ -99,12 +99,12 @@ class Magma { } public void linkToDown(Magma down) { - system.addLink(new Link(this.getBottomLeft(), down.getTopLeft(), linkType, null, 2)); + system.addLink(new Link(this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2)); } public void linkToRight(Magma right) { - system.addLink(new Link(this.getTopRight(), right.getTopLeft(), linkType, null, 1)); + system.addLink(new Link(this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1)); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java b/src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java index b83a36788..962b95a46 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java @@ -54,6 +54,7 @@ public class MemberImpl implements Member { private final VisibilityModifier visibilityModifier; public MemberImpl(String tmpDisplay, boolean isMethod, boolean manageModifier, boolean manageUrl) { + tmpDisplay = tmpDisplay.replaceAll("(?i)\\{(method|field)\\}\\s*", ""); if (manageModifier) { this.hasUrl = new UrlBuilder(null, ModeUrl.ANYWHERE).getUrl(tmpDisplay) != null; final Pattern pstart = MyPattern.cmpile("^(" + UrlBuilder.getRegexp() + ")([^\\[\\]]+)$"); @@ -100,7 +101,8 @@ public class MemberImpl implements Member { } if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) { - visibilityModifier = VisibilityModifier.getVisibilityModifier(displayClean.charAt(0), isMethod == false); + visibilityModifier = VisibilityModifier + .getVisibilityModifier(displayClean.charAt(0), isMethod == false); this.display = StringUtils.trin(StringUtils.manageGuillemet(displayClean.substring(1))); } else { this.display = StringUtils.manageGuillemet(displayClean); @@ -122,7 +124,7 @@ public class MemberImpl implements Member { return getDisplayWithoutVisibilityChar(); } - public String getDisplayWithoutVisibilityChar() { + private String getDisplayWithoutVisibilityChar() { // assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false; return display; } @@ -194,4 +196,14 @@ public class MemberImpl implements Member { return hasUrl; } + public static boolean isMethod(String s) { + if (s.contains("{method}")) { + return true; + } + if (s.contains("{field}")) { + return false; + } + return s.contains("(") || s.contains(")"); + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index a493f896e..7baf38b66 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -134,7 +135,7 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW if (m.isStatic()) { config = config.underline(); } - TextBlock bloc = TextBlockUtils.create(Display.getWithNewlines(s), config, align, skinParam, true); + TextBlock bloc = Display.getWithNewlines(s).create(config, align, skinParam, CreoleMode.SIMPLE_LINE); bloc = TextBlockUtils.fullInnerPosition(bloc, m.getDisplay(false)); return new TextBlockTracer(m, bloc); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java index 4270c4c1d..f378d5116 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java @@ -104,7 +104,7 @@ public class EntityFactory { final LongCode longCode = getLongCode(code, namespaceSeparator); final EntityImpl result = new EntityImpl(this, code, bodier, parentContainer, groupType, namespace2, longCode, namespaceSeparator, rawLayout); - if (display != null) { + if (Display.isNull(display) == false) { result.setDisplay(display); } return result; diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java index c35c3ede0..c32790629 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java @@ -224,7 +224,7 @@ final class EntityImpl implements ILeaf, IGroup { } public boolean hasUrl() { - if (display != null && display.hasUrl()) { + if (Display.isNull(display) == false && display.hasUrl()) { return true; } if (bodier.hasUrl()) { diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java index 0a6d4f893..34100bd6d 100644 --- a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java +++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java @@ -78,10 +78,7 @@ public class DescriptionDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandLinkElement()); // cmds.add(new CommandPackageWithUSymbol()); - cmds.add(new CommandPackage()); cmds.add(new CommandEndPackage()); - // addCommand(new CommandNamespace()); - // addCommand(new CommandEndNamespace()); final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand(); cmds.add(factoryNoteCommand.createMultiLine()); @@ -99,12 +96,9 @@ public class DescriptionDiagramFactory extends UmlDiagramFactory { cmds.add(factoryNoteCommand.createSingleLine()); cmds.add(new CommandUrl()); - // addCommand(new CommandCreateComponent2()); cmds.add(new CommandCreateElementFull()); - cmds.add(new CommandCreateElementMultilines()); - // addCommand(new CommandCreateElementTyped()); - // addCommand(new CommandCreateCircleInterface()); - // addCommand(new CommandCreateActorInComponent()); + cmds.add(new CommandCreateElementMultilines(0)); + cmds.add(new CommandCreateElementMultilines(1)); cmds.add(factoryNoteOnEntityCommand.createMultiLine()); cmds.add(factoryNoteCommand.createMultiLine()); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java index 12a34ee33..0f8797712 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java @@ -56,29 +56,52 @@ import net.sourceforge.plantuml.graphic.USymbol; public class CommandCreateElementMultilines extends CommandMultilines2 { + private final int type; + enum Mode { EXTENDS, IMPLEMENTS }; - public CommandCreateElementMultilines() { - super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); + public CommandCreateElementMultilines(int type) { + super(getRegexConcat(type), MultilinesStrategy.REMOVE_STARTING_QUOTE); + this.type = type; } @Override public String getPatternEnd() { - return "(?i)^(.*)[%g]$"; + if (type == 0) { + return "(?i)^(.*)[%g]$"; + } + if (type == 1) { + return "(?i)^(.*)\\]$"; + } + throw new IllegalArgumentException(); } - private static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // - new RegexLeaf("TYPE", "(usecase|database)[%s]+"), // - new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("DESC", "as[%s]*[%g](.*)$")); + private static RegexConcat getRegexConcat(int type) { + if (type == 0) { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "(usecase|database|artifact)[%s]+"), // + new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("DESC", "as[%s]*[%g](.*)$")); + } + if (type == 1) { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "(package|usecase|database|artifact)[%s]+"), // + new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("DESC", "\\[(.*)$")); + } + throw new IllegalArgumentException(); } public CommandExecutionResult executeNow(DescriptionDiagram diagram, BlocLines lines) { @@ -91,16 +114,22 @@ public class CommandCreateElementMultilines extends CommandMultilines2 lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), - lines.getLast499().toString()); + final List lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499() + .toString()); lines = lines.subExtract(1, 1); Display display = lines.toDisplay(); final String descStart = line0.get("DESC", 0); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index d1237d2df..86f75b981 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -71,11 +71,11 @@ public class CommandLinkElement extends SingleLineCommand2 { new RegexLeaf("HEAD2", "(0\\)|<<|[<^*+#0)]|<\\||[%s]+o)?"), // new RegexLeaf("BODY1", "([-=.~]+)"), // new RegexLeaf("ARROW_STYLE1", - "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), + "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,bold|,hidden|,norank)*)\\])?"), new RegexLeaf("DIRECTION", "(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.~0()]))?"), // new RegexLeaf("INSIDE", "(?:(0|\\(0\\)|\\(0|0\\))(?=[-=.~]))?"), // new RegexLeaf("ARROW_STYLE2", - "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), + "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,bold|,hidden|,norank)*)\\])?"), new RegexLeaf("BODY2", "([-=.~]*)"), // new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0(]|\\|>|o[%s]+)?"), // new RegexLeaf("[%s]*"), // diff --git a/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java index 5aa636813..d8c82ebb4 100644 --- a/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java +++ b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java @@ -72,7 +72,7 @@ public class ActivityBox extends AbstractTextBlock { this.label = label; final UFont font = new UFont("Serif", Font.PLAIN, 14); final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - tb = TextBlockUtils.create(Display.create(label), fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + tb = Display.create(label).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); } public Tile getTile() { diff --git a/src/net/sourceforge/plantuml/golem/Tile.java b/src/net/sourceforge/plantuml/golem/Tile.java index add9a33c2..1278877ef 100644 --- a/src/net/sourceforge/plantuml/golem/Tile.java +++ b/src/net/sourceforge/plantuml/golem/Tile.java @@ -80,8 +80,7 @@ public class Tile extends AbstractTextBlock implements TextBlock { public void drawU(UGraphic ug) { ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - final TextBlock n = TextBlockUtils.create(Display.create("" + num), fc, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock n = Display.create("" + num).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dimNum = n.calculateDimension(ug.getStringBounder()); final Dimension2D dimTotal = calculateDimension(ug.getStringBounder()); final double diffx = dimTotal.getWidth() - dimNum.getWidth(); diff --git a/src/net/sourceforge/plantuml/graph/Elastane.java b/src/net/sourceforge/plantuml/graph/Elastane.java index 5ce63e6a3..8830bff48 100644 --- a/src/net/sourceforge/plantuml/graph/Elastane.java +++ b/src/net/sourceforge/plantuml/graph/Elastane.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -269,9 +269,7 @@ public class Elastane { final String label = l.getLabel().get(0).toString(); if (label != null) { // polyline.getFirst().getCenter(); - final TextBlock textBlock = TextBlockUtils.create(Display.create(label), - new FontConfiguration(UFont.getCurrentFont(g2d), HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock textBlock = Display.create(label).create(new FontConfiguration(UFont.getCurrentFont(g2d), HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d)); // textBlock.drawTOBEREMOVED(new ColorMapperIdentity(), g2d, center.getXint() - dim.getWidth() / 2, // center.getYint() - dim.getHeight() / 2); diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivity.java b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java index 22325f975..623e31306 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageActivity.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -40,6 +40,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -47,7 +48,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.ColorMapper; class EntityImageActivity extends AbstractEntityImage { @@ -59,8 +59,8 @@ class EntityImageActivity extends AbstractEntityImage { public EntityImageActivity(IEntity entity) { super(entity); - this.text = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.text = entity.getDisplay().create(new FontConfiguration(getFont14(), + HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java index 238b29aeb..7d1eedc91 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -38,13 +38,13 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.skin.CircleInterface; import net.sourceforge.plantuml.ugraphic.ColorMapper; @@ -55,8 +55,8 @@ class EntityImageCircleInterface extends AbstractEntityImage { public EntityImageCircleInterface(IEntity entity) { super(entity); - this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.name = entity.getDisplay().create(new FontConfiguration(getFont14(), + HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); this.circleInterface = new CircleInterface(getYellow(), getRed()); } diff --git a/src/net/sourceforge/plantuml/graph/EntityImageComponent.java b/src/net/sourceforge/plantuml/graph/EntityImageComponent.java deleted file mode 100644 index 4710ac1cb..000000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageComponent.java +++ /dev/null @@ -1,96 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2014, Arnaud Roques - * - * Project Info: http://plantuml.sourceforge.net - * - * 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. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * Original Author: Arnaud Roques - * - * Revision $Revision: 14708 $ - * - */ -package net.sourceforge.plantuml.graph; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.geom.Dimension2D; -import java.awt.geom.Rectangle2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.StringBounderUtils; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.ugraphic.ColorMapper; - -class EntityImageComponent extends AbstractEntityImage { - - final private TextBlock name; - private final float thickness = (float) 1.6; - - public EntityImageComponent(IEntity entity) { - super(entity); - this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - final Dimension2D nameDim = name.calculateDimension(stringBounder); - return Dimension2DDouble.delta(nameDim, 20, 14); - } - - private void drawRect(ColorMapper colorMapper, Graphics2D g2d, double x, double y, double width, double height) { - g2d.setStroke(new BasicStroke(thickness)); - final Shape head = new Rectangle2D.Double(x, y, width, height); - g2d.setColor(colorMapper.getMappedColor(getYellow())); - g2d.fill(head); - g2d.setColor(colorMapper.getMappedColor(getRed())); - g2d.draw(head); - - g2d.setStroke(new BasicStroke()); - } - - @Override - public void draw(ColorMapper colorMapper, Graphics2D g2d) { - final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d)); - name.calculateDimension(StringBounderUtils.asStringBounder(g2d)); - - drawRect(colorMapper, g2d, 6, 0, dimTotal.getWidth(), dimTotal.getHeight()); - drawRect(colorMapper, g2d, 0, 7, 12, 6); - drawRect(colorMapper, g2d, 0, dimTotal.getHeight() - 7 - 6, 12, 6); - - g2d.setColor(Color.BLACK); -// name.drawTOBEREMOVED(colorMapper, g2d, 6 + (dimTotal.getWidth() - nameDim.getWidth()) / 2, -// (dimTotal.getHeight() - nameDim.getHeight()) / 2); - } -} diff --git a/src/net/sourceforge/plantuml/graph/EntityImageDefault.java b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java index e80a1d2ba..fa2b8b678 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageDefault.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -46,7 +47,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.ColorMapper; class EntityImageDefault extends AbstractEntityImage { @@ -55,8 +55,8 @@ class EntityImageDefault extends AbstractEntityImage { public EntityImageDefault(IEntity entity) { super(entity); - this.textBlock = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), HtmlColorUtils.BLACK, - HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.textBlock = entity.getDisplay().create(new FontConfiguration(getFont14(), HtmlColorUtils.BLACK, + HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageNote.java b/src/net/sourceforge/plantuml/graph/EntityImageNote.java index 61acd2a0f..76db85b0e 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageNote.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -40,6 +40,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -47,7 +48,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.ColorMapper; class EntityImageNote extends AbstractEntityImage { @@ -59,8 +59,8 @@ class EntityImageNote extends AbstractEntityImage { public EntityImageNote(IEntity entity) { super(entity); - this.text = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.text = entity.getDisplay().create(new FontConfiguration(getFont14(), + HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java index 86c85f386..c3c89e850 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -41,6 +41,7 @@ import java.awt.geom.QuadCurve2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -48,7 +49,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.ColorMapper; class EntityImageUsecase extends AbstractEntityImage { @@ -57,8 +57,8 @@ class EntityImageUsecase extends AbstractEntityImage { public EntityImageUsecase(IEntity entity) { super(entity); - this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.name = entity.getDisplay().create(new FontConfiguration(getFont14(), + HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); } @Override diff --git a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java index e23ccb869..b92324281 100644 --- a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graph; @@ -81,8 +81,7 @@ public class MethodsOrFieldsArea { } private TextBlock createTextBlock(String s) { - return TextBlockUtils.create(Display.create(s), new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + return Display.create(s).create(new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); } public void draw(UGraphic ug, double x, double y) { diff --git a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java index 84a9e0da8..e28656769 100644 --- a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java +++ b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java @@ -96,8 +96,8 @@ public class DateEventUtils { private static TextBlock getComment(final List asList, HtmlColor color) { final UFont font = new UFont("SansSerif", Font.BOLD, 14); - TextBlock comment = TextBlockUtils.create(Display.create(asList), new FontConfiguration(font, color, - HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + TextBlock comment = Display.create(asList).create(new FontConfiguration(font, color, + HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); comment = TextBlockUtils.withMargin(comment, 4, 4); comment = new TextBlockBordered(comment, color); comment = TextBlockUtils.withMargin(comment, 10, 10); diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java index 04c62fc55..395ff5dff 100644 --- a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java +++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16265 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.graphic; @@ -110,14 +110,11 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { private TextBlock getTextBlock() { TextBlock result = null; if (maxLine == 0) { - result = TextBlockUtils.create(Display.create(strings), new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + result = Display.create(strings).create(new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); } else { for (int i = 0; i < strings.size(); i += maxLine) { final int n = Math.min(i + maxLine, strings.size()); - final TextBlock textBlock1 = TextBlockUtils.create(Display.create(strings.subList(i, n)), - new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock textBlock1 = Display.create(strings.subList(i, n)).create(new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); if (result == null) { result = textBlock1; } else { diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index db9712de7..0c8d33b26 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -161,7 +161,8 @@ public class QuoteUtils { "Do me a favour. Disconnect me. I could be reworked, but I'll never be top of the line again.", // "Take it easy, don't push the little button on the joystick!", // "I'm a very private person.", // - "To sculpt an elephant from a big block of marble, just knock away all the bits that don't look like an elephant." + "To sculpt an elephant from a big block of marble, just knock away all the bits that don't look like an elephant.", // + "Who said you could talk to me? Have I got something on my face ?" ); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java index f0414f419..230b9b8f4 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16265 $ + * Revision $Revision: 16518 $ * */ package net.sourceforge.plantuml.graphic; @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -class TextBlockSimple extends AbstractTextBlock implements TextBlock { +public class TextBlockSimple extends AbstractTextBlock implements TextBlock { private List lines2; @@ -66,7 +66,7 @@ class TextBlockSimple extends AbstractTextBlock implements TextBlock { this(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, null, null); } - protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration, + public TextBlockSimple(Display texts, FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { this.texts = texts; diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java index e1c40a05c..5891f7321 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 12235 $ + * Revision $Revision: 16518 $ * */ package net.sourceforge.plantuml.graphic; @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -class TextBlockSpotted extends TextBlockSimple { +public class TextBlockSpotted extends TextBlockSimple { private final CircledCharacter circledCharacter; diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java index c4a9f54a0..87e541c09 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16278 $ + * Revision $Revision: 16518 $ * */ package net.sourceforge.plantuml.graphic; @@ -44,102 +44,15 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.SpriteContainer; -import net.sourceforge.plantuml.creole.CreoleParser; -import net.sourceforge.plantuml.creole.Sheet; -import net.sourceforge.plantuml.creole.SheetBlock1; -import net.sourceforge.plantuml.creole.SheetBlock2; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.posimo.Positionable; import net.sourceforge.plantuml.posimo.PositionableImpl; -import net.sourceforge.plantuml.sequencediagram.MessageNumber; import net.sourceforge.plantuml.ugraphic.LimitFinder; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UStroke; public class TextBlockUtils { - public static TextBlock create(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer) { - return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, false); - } - - public static TextBlock create(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, boolean modeSimpleLine) { - if (texts == null) { - return empty(0, 0); - } - return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, modeSimpleLine, null, null); - } - - public static TextBlock create(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize, - boolean modeSimpleLine, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - if (texts.getNaturalHorizontalAlignment() != null) { - horizontalAlignment = texts.getNaturalHorizontalAlignment(); - } - if (texts.size() > 0) { - if (texts.get(0) instanceof Stereotype) { - return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, - fontForStereotype, htmlColorForStereotype); - } - if (texts.get(texts.size() - 1) instanceof Stereotype) { - return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer, - texts.size() - 1, fontForStereotype, htmlColorForStereotype); - } - if (texts.get(0) instanceof MessageNumber) { - return createMessageNumber(texts, fontConfiguration, horizontalAlignment, spriteContainer, - maxMessageSize); - } - } - - return getCreole(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, modeSimpleLine); - } - - private static TextBlock getCreole(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize, - boolean modeSimpleLine) { - final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, modeSimpleLine) - .createSheet(texts); - final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0 - : spriteContainer.getPadding()); - return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5)); - } - - private static TextBlock createMessageNumber(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize) { - TextBlock tb1 = getCreole(texts.subList(0, 1), fontConfiguration, horizontalAlignment, spriteContainer, - maxMessageSize, false); - tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0); - final TextBlock tb2 = getCreole(texts.subList(1, texts.size()), fontConfiguration, horizontalAlignment, - spriteContainer, maxMessageSize, false); - return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER); - - } - - private static TextBlock createStereotype(Display texts, FontConfiguration fontConfiguration, - HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, int position, - UFont fontForStereotype, HtmlColor htmlColorForStereotype) { - final Stereotype stereotype = (Stereotype) texts.get(position); - if (stereotype.isSpotted()) { - final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(), - stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getHtmlColor(), null, - fontConfiguration.getColor()); - if (stereotype.getLabel(false) == null) { - return new TextBlockSpotted(circledCharacter, texts.subList(1, texts.size()), fontConfiguration, - horizontalAlignment, spriteContainer); - } - return new TextBlockSpotted(circledCharacter, texts, fontConfiguration, horizontalAlignment, - spriteContainer); - } - return new TextBlockSimple(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, - fontForStereotype, htmlColorForStereotype); - } - public static TextBlock withMargin(TextBlock textBlock, double marginX, double marginY) { return new TextBlockMarged(textBlock, marginX, marginX, marginY, marginY); } diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java index 4b0b1fc4e..11177759d 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbol.java +++ b/src/net/sourceforge/plantuml/graphic/USymbol.java @@ -104,7 +104,7 @@ public abstract class USymbol { return symbol; } - public abstract TextBlock asSmall(TextBlock label, TextBlock stereotype, SymbolContext symbolContext); + public abstract TextBlock asSmall(TextBlock name, TextBlock label, TextBlock stereotype, SymbolContext symbolContext); public abstract TextBlock asBig(TextBlock label, TextBlock stereotype, double width, double height, SymbolContext symbolContext); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java index 4c6fb5fa5..38beadd03 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java @@ -36,10 +36,13 @@ package net.sourceforge.plantuml.graphic; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolArtifact extends USymbol { @@ -49,7 +52,6 @@ class USymbolArtifact extends USymbol { return SkinParameter.ARTIFACT; } - private void drawArtifact(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) { final URectangle form = new URectangle(widthTotal, heightTotal); @@ -85,12 +87,27 @@ class USymbolArtifact extends USymbol { private Margin getMargin() { return new Margin(10, 10 + 10, 10 + 3, 10); } + + public boolean manageHorizontalLine() { + return true; + } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); + final Stencil stencil = new Stencil() { + public double getStartingX(StringBounder stringBounder, double y) { + return 0; + } + + public double getEndingX(StringBounder stringBounder, double y) { + return dim.getWidth(); + } + }; + ug = new UGraphicStencil(ug, stencil, new UStroke()); ug = symbolContext.apply(ug); drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing()); final Margin margin = getMargin(); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java index 7fec53e6a..f65e82542 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCard.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java @@ -70,7 +70,7 @@ class USymbolCard extends USymbol { return new Margin(10, 10, 3, 3); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java index 2bf88db45..cb51e8f35 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java @@ -86,7 +86,7 @@ class USymbolCloud extends USymbol { return new Margin(10, 10, 10, 10); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java index 4ab9b8141..d0468c458 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java @@ -69,7 +69,7 @@ class USymbolComponent1 extends USymbol { return new Margin(10, 10, 10, 10); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java index 8c1580857..e67f07082 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java @@ -72,7 +72,7 @@ class USymbolComponent2 extends USymbol { return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5); } - public TextBlock asSmall(final TextBlock label, TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java index 745f4ef7d..64c34d9df 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java @@ -112,7 +112,7 @@ class USymbolDatabase extends USymbol { return new Margin(10, 10, 20, 5); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java index a188494c4..97f8526e0 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java @@ -101,23 +101,29 @@ public class USymbolFolder extends USymbol { return new Margin(10, 10 + 10, 10 + 3, 10); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(final TextBlock name, final TextBlock label, final TextBlock stereotype, + final SymbolContext symbolContext) { + if (name == null) { + throw new IllegalArgumentException(); + } return new AbstractTextBlock() { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); ug = symbolContext.apply(ug); - drawFolder(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0), - symbolContext.isShadowing()); + final Dimension2D dimName = name.calculateDimension(ug.getStringBounder()); + drawFolder(ug, dim.getWidth(), dim.getHeight(), dimName, symbolContext.isShadowing()); final Margin margin = getMargin(); final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER); - tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1()))); + name.drawU(ug.apply(new UTranslate(4, 3))); + tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1() + dimName.getHeight()))); } public Dimension2D calculateDimension(StringBounder stringBounder) { + final Dimension2D dimName = name.calculateDimension(stringBounder); final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(Dimension2DDouble.mergeTB(dimName, dimStereo, dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index 04704d64e..cfcbd8d45 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -90,7 +90,7 @@ class USymbolFrame extends USymbol { return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolNode.java b/src/net/sourceforge/plantuml/graphic/USymbolNode.java index 8b427c41d..354f596dd 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolNode.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolNode.java @@ -73,7 +73,7 @@ class USymbolNode extends USymbol { return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java index 1dd94d90e..ea8d55966 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java @@ -114,7 +114,7 @@ class USymbolQueue extends USymbol { return new Margin(5, 15, 5, 5); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRect.java index 223e862fc..94abca8bf 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRect.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRect.java @@ -67,7 +67,7 @@ class USymbolRect extends USymbol { return new Margin(10, 10, 10, 10); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java index 694e5a63e..bfc93a35d 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; abstract class USymbolSimpleAbstract extends USymbol { - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { if (stereotype == null) { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java index 6de92a1fc..a48e960f7 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java @@ -59,7 +59,7 @@ class USymbolStorage extends USymbol { return new Margin(10, 10, 10, 10); } - public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/jungle/GTileNode.java b/src/net/sourceforge/plantuml/jungle/GTileNode.java index 10a10b37d..721c73251 100644 --- a/src/net/sourceforge/plantuml/jungle/GTileNode.java +++ b/src/net/sourceforge/plantuml/jungle/GTileNode.java @@ -39,6 +39,7 @@ import java.util.Arrays; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleParser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; @@ -66,7 +67,7 @@ public class GTileNode extends AbstractTextBlock implements GTile { final SheetBlock1 sheetBlock1 = getTextBlock(display); final SymbolContext symbolContext = new SymbolContext(HtmlColorUtils.MY_YELLOW, HtmlColorUtils.BLACK); - tb = USymbol.RECTANGLE.asSmall(sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext); + tb = USymbol.RECTANGLE.asSmall(null, sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext); } public static SheetBlock1 getTextBlock(final Display display) { @@ -77,7 +78,7 @@ public class GTileNode extends AbstractTextBlock implements GTile { final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()); - final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(display); + final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(display); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, 0, 0); return sheetBlock1; } diff --git a/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java b/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java index 3478cd286..b9723a7fe 100644 --- a/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java +++ b/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java @@ -198,8 +198,7 @@ class TurtleGraphicsPane { drawTurtle(ug); if (message != null) { final FontConfiguration font = new FontConfiguration(new UFont("", Font.PLAIN, 14), HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - final TextBlock text = TextBlockUtils.create(Display.create(message), font, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock text = Display.create(message).create(font, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dim = text.calculateDimension(ug.getStringBounder()); final double textHeight = dim.getHeight(); text.drawU(ug.apply(new UTranslate(0, (height - textHeight)))); diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index 565c0e040..32695fe3b 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -155,7 +155,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createNew(int mode, LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null, + existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2); } else { removeLink(existingLink); @@ -165,7 +165,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle()); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); - pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null, + pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle()); addLink(entity1ToPoint); @@ -190,7 +190,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createInSecond(LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null, + existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2); } else { removeLink(existingLink); @@ -198,7 +198,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), 2, existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle()); - pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null, 2, null, + pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), Display.NULL, 2, null, existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle()); // entity1ToPoint = new Link(entity1, point, existingLink.getType(), // null, 2); @@ -214,7 +214,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram pointToAssocied = new Link(point, associed, linkType, label, 1); addLink(pointToAssocied); - final Link lnode = new Link(other.point, this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null, 1); + final Link lnode = new Link(other.point, this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 1); lnode.setInvis(true); addLink(lnode); diff --git a/src/net/sourceforge/plantuml/png/PngTitler.java b/src/net/sourceforge/plantuml/png/PngTitler.java index 1752c593c..aceee94cb 100644 --- a/src/net/sourceforge/plantuml/png/PngTitler.java +++ b/src/net/sourceforge/plantuml/png/PngTitler.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15991 $ + * Revision $Revision: 16546 $ * */ package net.sourceforge.plantuml.png; @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.UFont; public class PngTitler { @@ -77,12 +76,11 @@ public class PngTitler { } public TextBlock getTextBlock() { - if (text == null || text.size() == 0) { + if (Display.isNull(text) || text.size() == 0) { return null; } final UFont normalFont = new UFont(fontFamily, Font.PLAIN, fontSize); - return TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor, hyperlinkColor, useUnderlineForHyperlink), horizontalAlignment, - new SpriteContainerEmpty()); + return text.create(new FontConfiguration(normalFont, textColor, hyperlinkColor, useUnderlineForHyperlink), horizontalAlignment, new SpriteContainerEmpty()); } private double getOffsetX(double imWidth, StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/posimo/Frame.java b/src/net/sourceforge/plantuml/posimo/Frame.java index e742ada34..ddde32849 100644 --- a/src/net/sourceforge/plantuml/posimo/Frame.java +++ b/src/net/sourceforge/plantuml/posimo/Frame.java @@ -120,8 +120,7 @@ public class Frame implements Component { private TextBlock createTextBloc() { final UFont font = skinParam.getFont(FontParam.PACKAGE, null, false); final HtmlColor textColor = skinParam.getFontHtmlColor(FontParam.PACKAGE, null); - final TextBlock bloc = TextBlockUtils.create(Display.create(name), new FontConfiguration(font, textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock bloc = Display.create(name).create(new FontConfiguration(font, textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); return bloc; } diff --git a/src/net/sourceforge/plantuml/posimo/LabelImage.java b/src/net/sourceforge/plantuml/posimo/LabelImage.java index 79e2bfe66..f9e95ba19 100644 --- a/src/net/sourceforge/plantuml/posimo/LabelImage.java +++ b/src/net/sourceforge/plantuml/posimo/LabelImage.java @@ -38,13 +38,13 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SpriteContainerEmpty; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -63,8 +63,7 @@ public class LabelImage { // this.entity = entity; this.param = param; this.rose = rose; - this.name = TextBlockUtils.create(link.getLabel(), - new FontConfiguration(param.getFont(FontParam.CLASS, null, false), HtmlColorUtils.BLACK, param.getHyperlinkColor(), param.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); + this.name = link.getLabel().create(new FontConfiguration(param.getFont(FontParam.CLASS, null, false), HtmlColorUtils.BLACK, param.getHyperlinkColor(), param.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); } public Dimension2D getDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkin.java b/src/net/sourceforge/plantuml/printskin/PrintSkin.java index 8e3ff979a..6891ac80e 100644 --- a/src/net/sourceforge/plantuml/printskin/PrintSkin.java +++ b/src/net/sourceforge/plantuml/printskin/PrintSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15580 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.printskin; @@ -153,8 +153,8 @@ class PrintSkin extends AbstractPSystem { } private void println(String s) { - final TextBlock textBlock = TextBlockUtils.create(Display.create(s), new FontConfiguration(FONT1, - HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock textBlock = Display.create(s).create(new FontConfiguration(FONT1, + HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); textBlock.drawU(ug.apply(new UTranslate(xpos, ypos))); ypos += textBlock.calculateDimension(ug.getStringBounder()).getHeight(); } diff --git a/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java b/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java index 1ac12d7a3..36b94286e 100644 --- a/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java +++ b/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java @@ -71,8 +71,7 @@ class ItemHeader { ug.apply(new UTranslate(x, y)).draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder))); for (Item it : project.getValidItems()) { - final TextBlock b = TextBlockUtils.create(Display.create("" + it.getCode()), fontConfig, - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock b = Display.create("" + it.getCode()).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dim = b.calculateDimension(stringBounder); b.drawU(ug.apply(new UTranslate(x, y))); y += dim.getHeight(); diff --git a/src/net/sourceforge/plantuml/project/graphic/TimeScale.java b/src/net/sourceforge/plantuml/project/graphic/TimeScale.java index 66ebc81c9..1d7ba4d12 100644 --- a/src/net/sourceforge/plantuml/project/graphic/TimeScale.java +++ b/src/net/sourceforge/plantuml/project/graphic/TimeScale.java @@ -87,8 +87,7 @@ class TimeScale { if (printed == null || d.getMonth() != printed) { ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight)); printed = d.getMonth(); - final TextBlock b = TextBlockUtils.create(Display.create(printed.name()), fontConfig, - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock b = Display.create(printed.name()).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dim = b.calculateDimension(stringBounder); b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2)))); } @@ -101,8 +100,7 @@ class TimeScale { for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) { final Day d = cur.getDay(); - final TextBlock b = TextBlockUtils.create(Display.create("" + d.getNumDay()), fontConfig, - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock b = Display.create("" + d.getNumDay()).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dim = b.calculateDimension(stringBounder); b.drawU(ug.apply(new UTranslate((curx + (caseWidth - dim.getWidth()) / 2), (y + (caseHeight - dim.getHeight()) / 2)))); curx += caseWidth; diff --git a/src/net/sourceforge/plantuml/project2/GanttDiagram2.java b/src/net/sourceforge/plantuml/project2/GanttDiagram2.java index 67bb8ef95..39b729d7b 100644 --- a/src/net/sourceforge/plantuml/project2/GanttDiagram2.java +++ b/src/net/sourceforge/plantuml/project2/GanttDiagram2.java @@ -82,8 +82,7 @@ public class GanttDiagram2 { final List rows = new ArrayList(); for (Task t : tasks) { final String text = t.getCode(); - final TextBlock label = TextBlockUtils.create(Display.create(text), fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock label = Display.create(text).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); rows.add(new RowSimple((Day) t.getStart(), (Day) t.getEnd(), HtmlColorUtils.BLACK, TextBlockUtils .withMargin(label, 3, 3))); } diff --git a/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java b/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java index 49effab05..4a7720830 100644 --- a/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java +++ b/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java @@ -74,8 +74,7 @@ public class TimeHeaderDay extends AbstractTextBlock implements TextBlock { int n = 0; for (Day d = start; d.compareTo(end) <= 0; d = (Day) timeline.next(d)) { final String text = "" + d.getNumDay(); - final TextBlock b = TextBlockUtils.create(Display.create(text), fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock b = Display.create(text).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dimText = b.calculateDimension(ug.getStringBounder()); final double diffX = dayWidth - dimText.getWidth(); final double diffY = getHeight() - dimText.getHeight(); diff --git a/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java b/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java index a5efb3d15..e871fd7e2 100644 --- a/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java +++ b/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java @@ -96,8 +96,7 @@ public class TimeHeaderMonth extends AbstractTextBlock implements TextBlock { private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) { final double width = n * dayWidth - pendingX; ug.apply(new UTranslate(x + pendingX, y)).draw(new URectangle(width, getHeight())); - final TextBlock b = TextBlockUtils.create(Display.create(last), fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final TextBlock b = Display.create(last).create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dimText = b.calculateDimension(ug.getStringBounder()); final double diffX = width - dimText.getWidth(); final double diffY = getHeight() - dimText.getHeight(); diff --git a/src/net/sourceforge/plantuml/real/AbstractReal.java b/src/net/sourceforge/plantuml/real/AbstractReal.java index b6a380d93..2e171c1dc 100644 --- a/src/net/sourceforge/plantuml/real/AbstractReal.java +++ b/src/net/sourceforge/plantuml/real/AbstractReal.java @@ -40,6 +40,7 @@ abstract class AbstractReal implements Real { AbstractReal(RealLine line) { this.line = line; + this.line.register2(this); } final RealLine getLine() { diff --git a/src/net/sourceforge/plantuml/real/Real.java b/src/net/sourceforge/plantuml/real/Real.java index 3cea6f384..6fc2c1adf 100644 --- a/src/net/sourceforge/plantuml/real/Real.java +++ b/src/net/sourceforge/plantuml/real/Real.java @@ -47,8 +47,8 @@ public interface Real { public void ensureBiggerThan(Real other); - public Real getMaxAbsolute(); - - public Real getMinAbsolute(); - +// public Real getMaxAbsolute(); +// +// public Real getMinAbsolute(); +// } diff --git a/src/net/sourceforge/plantuml/real/RealLine.java b/src/net/sourceforge/plantuml/real/RealLine.java index 1c130ad11..05964b90e 100644 --- a/src/net/sourceforge/plantuml/real/RealLine.java +++ b/src/net/sourceforge/plantuml/real/RealLine.java @@ -35,8 +35,10 @@ package net.sourceforge.plantuml.real; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; class RealLine { @@ -44,10 +46,16 @@ class RealLine { private double min; private double max; + private Set all = new HashSet(); void register(double v) { - min = Math.min(min, v); - max = Math.max(max, v); + // System.err.println("RealLine::register " + v); + // min = Math.min(min, v); + // max = Math.max(max, v); + } + + void register2(AbstractReal abstractReal) { + all.add(abstractReal); } public double getAbsoluteMin() { @@ -68,8 +76,6 @@ class RealLine { int cpt = 0; final Map counter = new HashMap(); do { - min = 0; - max = 0; boolean done = true; for (PositiveForce f : forces) { // System.err.println("force=" + f); @@ -84,6 +90,19 @@ class RealLine { // System.err.println("cpt=" + cpt + " size=" + forces.size()); CPT += cpt; // System.err.println("CPT=" + CPT); + min = 0; + max = 0; + for (AbstractReal real : all) { + final double v = real.getCurrentValue(); + // System.err.println("RealLine::compile v=" + v); + if (v > max) { + max = v; + } + if (v < min) { + min = v; + } + } + // System.err.println("RealLine::compile min=" + min + " max=" + max); return; } cpt++; diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java index a50ff4bc7..93052de38 100644 --- a/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java +++ b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java @@ -63,7 +63,7 @@ abstract class AbstractElementText extends AbstractElement { } else { this.charLength = 0; } - this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer); + this.block = Display.create(text).create(config, HorizontalAlignment.LEFT, spriteContainer); } private int getCharNumber(String text) { @@ -96,7 +96,7 @@ abstract class AbstractElementText extends AbstractElement { // double max = 0; // for (int i = 32; i < 127; i++) { // final char c = (char) i; - // final double w = TextBlockUtils.create(Arrays.asList("" + c), config, HorizontalAlignment.LEFT) + // final double w = Display.create(Arrays.asList("" + c), config, HorizontalAlignment.LEFT) // .calculateDimension(stringBounder).getWidth(); // if (w > max) { // Log.println("c="+c+" "+max); diff --git a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java index dac35becc..64f97c08a 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java @@ -72,8 +72,7 @@ public class ElementDroplist extends AbstractElementText implements Element { if (drop.size() == 0) { this.openDrop = null; } else { - this.openDrop = TextBlockUtils.create(Display.create(drop), getConfig(), HorizontalAlignment.LEFT, - spriteContainer); + this.openDrop = Display.create(drop).create(getConfig(), HorizontalAlignment.LEFT, spriteContainer); } } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java index 02bca9126..3beb4ab00 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java @@ -59,7 +59,7 @@ public class ElementMenuEntry extends AbstractElement { public ElementMenuEntry(String text, UFont font, ISkinSimple spriteContainer) { final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer); + this.block = Display.create(text).create(config, HorizontalAlignment.LEFT, spriteContainer); this.text = text; } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java index af2ca0a0e..ca3086185 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java @@ -68,7 +68,7 @@ public class ElementRadioCheckbox extends AbstractElement { public ElementRadioCheckbox(List text, UFont font, boolean radio, boolean checked, ISkinSimple spriteContainer) { final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer); + this.block = Display.create(text).create(config, HorizontalAlignment.LEFT, spriteContainer); this.radio = radio; this.checked = checked; } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementText.java b/src/net/sourceforge/plantuml/salt/element/ElementText.java index 01faccf2a..40092e790 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementText.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementText.java @@ -55,7 +55,7 @@ public class ElementText extends AbstractElement { public ElementText(List text, UFont font, ISkinSimple spriteContainer) { final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true); - this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer); + this.block = Display.create(text).create(config, HorizontalAlignment.LEFT, spriteContainer); this.show = text.get(0).equals(".") == false; this.text = text.get(0); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Englober.java b/src/net/sourceforge/plantuml/sequencediagram/Englober.java index 666529728..ed68be710 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Englober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Englober.java @@ -39,9 +39,11 @@ import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamBackcolored; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.RealUtils; +import net.sourceforge.plantuml.sequencediagram.teoz.Bordered; import net.sourceforge.plantuml.sequencediagram.teoz.LivingSpace; import net.sourceforge.plantuml.sequencediagram.teoz.TileArguments; import net.sourceforge.plantuml.skin.Area; @@ -66,8 +68,8 @@ public class Englober { } private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Skin skin) { - final TileArguments result = new TileArguments(TextBlockUtils.getDummyStringBounder(), null, null, skin, - skinParam, null); + final TileArguments result = new TileArguments(TextBlockUtils.getDummyStringBounder(), null, skin, skinParam, + null); return result; } @@ -119,7 +121,8 @@ public class Englober { private Real getPosZZ() { final LivingSpace next = tileArguments.getLivingSpaces().next(getLastLivingSpace()); if (next == null) { - return tileArguments.getOmega(); + // return tileArguments.getMaxAbsolute(); + return null; } return next.getPosB(); } @@ -187,11 +190,24 @@ public class Englober { public void addInternalConstraints() { getX1().ensureBiggerThan(getPosAA().addFixed(10)); - getPosZZ().ensureBiggerThan(getX2().addFixed(10)); + final Real posZZ = getPosZZ(); + final Real limit = getX2().addFixed(10); + if (posZZ != null) { + posZZ.ensureBiggerThan(limit); + } } public void addConstraintAfter(Englober current) { current.getX1().ensureBiggerThan(getX2().addFixed(10)); } + public Real getMinX(StringBounder stringBounder) { + return getX1(); + } + + public Real getMaxX(StringBounder stringBounder) { + return getX2(); + } + + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java index b872dec70..d06082586 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Participant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15995 $ + * Revision $Revision: 16520 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -59,7 +59,7 @@ public class Participant implements SpecificBackcolorable { if (code == null || code.length() == 0) { throw new IllegalArgumentException(); } - if (display == null || display.size() == 0) { + if (Display.isNull(display) || display.size() == 0) { throw new IllegalArgumentException(); } this.code = code; diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index d8a7b2cea..07eee2232 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -97,7 +97,7 @@ public class SequenceDiagram extends UmlDiagram { if (participants.containsKey(code)) { throw new IllegalArgumentException(); } - if (display == null) { + if (Display.isNull(display)) { // display = Arrays.asList(code); display = Display.getWithNewlines(code); } @@ -304,22 +304,43 @@ public class SequenceDiagram extends UmlDiagram { return skin2; } - private Integer messageNumber = null; + private boolean autonumber = false; + private int messageNumber; private int incrementMessageNumber; private DecimalFormat decimalFormat; - public final void goAutonumber(int startingNumber, int increment, DecimalFormat decimalFormat) { + public final void autonumberGo(int startingNumber, int increment, DecimalFormat decimalFormat) { + this.autonumber = true; this.messageNumber = startingNumber; this.incrementMessageNumber = increment; this.decimalFormat = decimalFormat; } + public final void autonumberStop() { + this.autonumber = false; + } + + public final void autonumberResume(DecimalFormat decimalFormat) { + this.autonumber = true; + if (decimalFormat != null) { + this.decimalFormat = decimalFormat; + } + } + + public final void autonumberResume(int increment, DecimalFormat decimalFormat) { + this.autonumber = true; + this.incrementMessageNumber = increment; + if (decimalFormat != null) { + this.decimalFormat = decimalFormat; + } + } + public String getNextMessageNumber() { - if (messageNumber == null) { + if (autonumber == false) { return null; } - final Integer result = messageNumber; + final int result = messageNumber; messageNumber += incrementMessageNumber; return decimalFormat.format(result); } @@ -440,7 +461,7 @@ public class SequenceDiagram extends UmlDiagram { return true; } } - if (getLegend() != null && getLegend().hasUrl()) { + if (Display.isNull(getLegend()) == false && getLegend().hasUrl()) { return true; } return false; diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index 5f117c6be..4221ed579 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -48,6 +48,8 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandArrow; import net.sourceforge.plantuml.sequencediagram.command.CommandAutoNewpage; import net.sourceforge.plantuml.sequencediagram.command.CommandAutoactivate; import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumber; +import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumberResume; +import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumberStop; import net.sourceforge.plantuml.sequencediagram.command.CommandBoxEnd; import net.sourceforge.plantuml.sequencediagram.command.CommandBoxStart; import net.sourceforge.plantuml.sequencediagram.command.CommandDelay; @@ -124,6 +126,8 @@ public class SequenceDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandReferenceMultilinesOverSeveral()); cmds.add(new CommandSkin()); cmds.add(new CommandAutonumber()); + cmds.add(new CommandAutonumberStop()); + cmds.add(new CommandAutonumberResume()); cmds.add(new CommandAutoactivate()); cmds.add(new CommandFootbox()); cmds.add(new CommandDelay()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java index 7cbf365c9..4801a214c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 12235 $ + * Revision $Revision: 16583 $ * */ package net.sourceforge.plantuml.sequencediagram.command; @@ -65,7 +65,7 @@ public class CommandAutonumber extends SingleLineCommand { return CommandExecutionResult.error("Error in pattern : " + df); } - sequenceDiagram.goAutonumber(start, inc, decimalFormat); + sequenceDiagram.autonumberGo(start, inc, decimalFormat); return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java new file mode 100644 index 000000000..c92c642b4 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java @@ -0,0 +1,70 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 12235 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.command; + +import java.text.DecimalFormat; +import java.util.List; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; + +public class CommandAutonumberResume extends SingleLineCommand { + + public CommandAutonumberResume() { + super("(?i)^autonumber[%s]*resume(?:[%s]+(\\d+))?(?:[%s]+[%g]([^%g]+)[%g])?[%s]*$"); + } + + @Override + protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List arg) { + final String df = arg.get(1); + DecimalFormat decimalFormat = null; + if (df != null) { + try { + decimalFormat = new DecimalFormat(df); + } catch (IllegalArgumentException e) { + return CommandExecutionResult.error("Error in pattern : " + df); + } + } + + final String inc = arg.get(0); + if (inc == null) { + sequenceDiagram.autonumberResume(decimalFormat); + } else { + sequenceDiagram.autonumberResume(Integer.parseInt(arg.get(0)), decimalFormat); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java new file mode 100644 index 000000000..2066c90a6 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java @@ -0,0 +1,53 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2014, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 12235 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.command; + +import java.util.List; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; + +public class CommandAutonumberStop extends SingleLineCommand { + + public CommandAutonumberStop() { + super("(?i)^autonumber[%s]*stop$"); + } + + @Override + protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List arg) { + sequenceDiagram.autonumberStop(); + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java index 73fd66a4f..b3b9f7fcb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 12235 $ + * Revision $Revision: 16549 $ * */ package net.sourceforge.plantuml.sequencediagram.command; @@ -48,7 +48,7 @@ public class CommandNewpage extends SingleLineCommand { @Override protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List arg) { - final Display strings = arg.get(0) == null ? null : Display.getWithNewlines(arg.get(0)); + final Display strings = arg.get(0) == null ? Display.NULL : Display.getWithNewlines(arg.get(0)); sequenceDiagram.newpage(strings); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java index 32d16e4b7..912f9b3a7 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java @@ -73,7 +73,7 @@ public abstract class CommandParticipant extends SingleLineCommand2 tiles = new ArrayList(); private final LivingSpaces livingSpaces; - public MainTile(SequenceDiagram diagram, TileArguments tileArguments) { + public MainTile(SequenceDiagram diagram, Englobers englobers, TileArguments tileArguments) { this.livingSpaces = tileArguments.getLivingSpaces(); @@ -61,16 +61,25 @@ public class MainTile implements Tile { final List max2 = new ArrayList(); min2.add(tileArguments.getOrigin()); - max2.add(tileArguments.getOmega()); + max2.add(tileArguments.getOrigin()); + + if (englobers.size() > 0) { + min2.add(englobers.getMinX(tileArguments.getStringBounder())); + max2.add(englobers.getMaxX(tileArguments.getStringBounder())); + } tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null)); for (Tile tile : tiles) { - // height += tile.getPreferredHeight(stringBounder); min2.add(tile.getMinX(tileArguments.getStringBounder())); max2.add(tile.getMaxX(tileArguments.getStringBounder())); } + for (LivingSpace livingSpace : livingSpaces.values()) { + max2.add(livingSpace.getPosD(tileArguments.getStringBounder())); + max2.add(livingSpace.getPosC2(tileArguments.getStringBounder())); + } + this.min = RealUtils.min(min2); this.max = RealUtils.max(max2); @@ -137,4 +146,12 @@ public class MainTile implements Tile { return livingSpaces; } + public double getBorder1() { + return min.getCurrentValue(); + } + + public double getBorder2() { + return max.getCurrentValue(); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java index 4aeb89591..1852b7d90 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java @@ -59,7 +59,6 @@ public class ReferenceTile implements Tile { return reference; } - public ReferenceTile(Reference reference, TileArguments tileArguments) { this.reference = reference; this.tileArguments = tileArguments; @@ -73,15 +72,17 @@ public class ReferenceTile implements Tile { final LivingSpace livingSpace = tileArguments.getLivingSpace(p); final Real pos = livingSpace.getPosC(stringBounder); if (first == null || pos.getCurrentValue() < first.getCurrentValue()) { - this.first = pos; + this.first = livingSpace.getPosB(); } if (last == null || pos.getCurrentValue() > last.getCurrentValue()) { - this.last = pos; + this.last = livingSpace.getPosD(stringBounder); } } final Component comp = getComponent(stringBounder); final Dimension2D dim = comp.getPreferredDimension(stringBounder); - this.last = this.last.addAtLeast(0); + if (reference.getParticipant().size() == 1) { + this.last = this.last.addAtLeast(0); + } this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth())); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index 74bea2c4f..a97a4bb68 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -191,14 +191,15 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { currentPos = livingSpace.getPosD(stringBounder).addAtLeast(0); } - final TileArguments tileArguments = new TileArguments(stringBounder, currentPos, livingSpaces, skin, + final TileArguments tileArguments = new TileArguments(stringBounder, livingSpaces, skin, diagram.getSkinParam(), origin); this.englobers = new Englobers(tileArguments); - final MainTile mainTile = new MainTile(diagram, tileArguments); + final MainTile mainTile = new MainTile(diagram, englobers, tileArguments); mainTile.addConstraints(stringBounder); this.englobers.addConstraints(stringBounder); origin.compileNow(); + tileArguments.setBordered(mainTile); return mainTile; } @@ -208,7 +209,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private TextBlock getTitle() { final Display title = diagram.getTitle(); - if (title == null) { + if (Display.isNull(title)) { return new ComponentAdapter(null); } final Component compTitle = skin.createComponent(ComponentType.TITLE, null, getSkinParam(), title); @@ -217,7 +218,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private TextBlock getLegend() { final Display legend = diagram.getLegend(); - if (legend == null) { + if (Display.isNull(legend)) { return TextBlockUtils.empty(0, 0); } return EntityImageLegend.create(legend, diagram.getSkinParam()); @@ -225,7 +226,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { public TextBlock getFooterOrHeader(final FontParam param) { final Display display = diagram.getFooterOrHeaderTeoz(param); - if (display == null) { + if (Display.isNull(display)) { return new TeozLayer(null, stringBounder, param); } final HtmlColor hyperlinkColor = getSkinParam().getHyperlinkColor(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java index 6657c1e3d..f7908557a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java @@ -61,7 +61,8 @@ public class Stairs2 { if (ys.size() > 0) { final double lastY = ys.get(ys.size() - 1).getValue(); if (position.getValue() < lastY) { - throw new IllegalArgumentException(); + // throw new IllegalArgumentException(); + return; } if (lastY == position.getValue()) { values.set(ys.size() - 1, new IntegerColored(value, color)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java index 6ef53566d..8121cc79a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java @@ -43,42 +43,40 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.Reference; import net.sourceforge.plantuml.skin.Skin; -public class TileArguments { +public class TileArguments implements Bordered { private final StringBounder stringBounder; - private final Real omega; private final Real origin; private final LivingSpaces livingSpaces; private final Skin skin; private final ISkinParam skinParam; - public TileArguments(StringBounder stringBounder, Real omega, LivingSpaces livingSpaces, Skin skin, - ISkinParam skinParam, Real origin) { + public TileArguments(StringBounder stringBounder, LivingSpaces livingSpaces, Skin skin, ISkinParam skinParam, + Real origin) { this.stringBounder = stringBounder; this.origin = origin; - this.omega = omega; this.livingSpaces = livingSpaces; this.skin = skin; this.skinParam = skinParam; } public TileArguments withBackColorGeneral(HtmlColor backColorElement, HtmlColor backColorGeneral) { - return new TileArguments(stringBounder, omega, livingSpaces, skin, new SkinParamBackcolored(skinParam, + return new TileArguments(stringBounder, livingSpaces, skin, new SkinParamBackcolored(skinParam, backColorElement, backColorGeneral), origin); } public TileArguments withBackColor(Reference reference) { final ISkinParam newSkinParam = new SkinParamBackcoloredReference(skinParam, reference.getBackColorElement(), reference.getBackColorGeneral()); - return new TileArguments(stringBounder, omega, livingSpaces, skin, newSkinParam, origin); + return new TileArguments(stringBounder, livingSpaces, skin, newSkinParam, origin); } public final StringBounder getStringBounder() { return stringBounder; } - public final Real getOmega() { - return omega; - } + // public final Real getMaxAbsolute() { + // return origin.getMaxAbsolute(); + // } public final Real getOrigin() { return origin; @@ -112,13 +110,27 @@ public class TileArguments { return result; } -// public double getAbsoluteMin() { -// return line.getAbsoluteMin(); -// } -// -// public double getAbsoluteMax() { -// return line.getAbsoluteMax(); -// } + private Bordered bordered; + + public void setBordered(Bordered bordered) { + this.bordered = bordered; + } + + public double getBorder1() { + return bordered.getBorder1(); + } + + public double getBorder2() { + return bordered.getBorder2(); + } + + // public double getAbsoluteMin() { + // return line.getAbsoluteMin(); + // } + // + // public double getAbsoluteMax() { + // return line.getAbsoluteMax(); + // } // public void ensure(Tile tile) { // getAlpha().ensureLowerThan(tile.getMinX(getStringBounder())); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java index 6e2e9e1d0..1b79f55b6 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java @@ -65,7 +65,7 @@ public class TileBuilder { if (tile != null) { tiles.add(tile); final Real tmpMax = tile.getMaxX(tileArguments.getStringBounder()); - tileArguments.getOmega().ensureBiggerThan(tmpMax); + // tileArguments.getOmega().ensureBiggerThan(tmpMax); } } return Collections.unmodifiableList(tiles); @@ -126,7 +126,7 @@ public class TileBuilder { tile = new NoteTile(livingSpace1, livingSpace2, note, skin, skinParam); } else if (ev instanceof Divider) { final Divider divider = (Divider) ev; - tile = new DividerTile(divider, skin, skinParam, tileArguments.getOrigin(), tileArguments.getOmega()); + tile = new DividerTile(divider, tileArguments); } else if (ev instanceof GroupingStart) { final GroupingStart start = (GroupingStart) ev; tile = new GroupingTile(it, start, tileArguments.withBackColorGeneral(start.getBackColorElement(), diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index f9fcbcbdb..496e3fa40 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15936 $ + * Revision $Revision: 16527 $ * */ package net.sourceforge.plantuml.skin; @@ -37,6 +37,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -84,8 +85,8 @@ public abstract class AbstractTextualComponent extends AbstractComponent { } else if (enhanced) { textBlock = new BodyEnhanced2(strings, FontParam.NOTE, spriteContainer, HorizontalAlignment.LEFT, font); } else { - textBlock = TextBlockUtils.create(strings, font, horizontalAlignment, spriteContainer, maxMessageSize, - false, fontForStereotype, htmlColorForStereotype); + textBlock = strings.create(font, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL, + fontForStereotype, htmlColorForStereotype); } } diff --git a/src/net/sourceforge/plantuml/skin/GrayComponent.java b/src/net/sourceforge/plantuml/skin/GrayComponent.java index 739cd96e9..08b948ed1 100644 --- a/src/net/sourceforge/plantuml/skin/GrayComponent.java +++ b/src/net/sourceforge/plantuml/skin/GrayComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14711 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.skin; @@ -74,8 +74,8 @@ class GrayComponent extends AbstractComponent { strings.add(n.substring(i, Math.min(i + split, n.length()))); } - final TextBlock textBlock = TextBlockUtils.create(Display.create(strings), new FontConfiguration(NORMAL, HtmlColorUtils.BLACK, - HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock textBlock = Display.create(strings).create(new FontConfiguration(NORMAL, HtmlColorUtils.BLACK, + HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); textBlock.drawU(ug); } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java index 496428b53..f286770e3 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15934 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -76,9 +76,7 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent if (strings.size() == 1 || strings.get(1) == null) { this.commentTextBlock = null; } else { - this.commentTextBlock = TextBlockUtils.create(Display.create("[" + strings.get(1) + "]"), - new FontConfiguration(smallFont, fontColor2, bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, - spriteContainer); + this.commentTextBlock = Display.create("[" + strings.get(1) + "]").create(new FontConfiguration(smallFont, fontColor2, bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, spriteContainer); } } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java index f1be9a47c..4ac60d951 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java @@ -65,8 +65,8 @@ public class ComponentRoseDatabase extends AbstractTextualComponent { final SymbolContext symbolContext = new SymbolContext(biColor.getBackColor(), biColor.getForeColor()) .withStroke(new UStroke(1.5)).withShadow(biColor.getDeltaShadow() > 0); - this.stickman = USymbol.DATABASE.asSmall(TextBlockUtils.empty(16, 17), TextBlockUtils.empty(0, 0), - symbolContext); + this.stickman = USymbol.DATABASE.asSmall(null, TextBlockUtils.empty(16, 17), + TextBlockUtils.empty(0, 0), symbolContext); } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java index 63d2effa3..e23343120 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15964 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -74,9 +74,8 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { this.commentTextBlock = null; } else { final Display display = Display.getWithNewlines("[" + strings.get(1) + "]"); - this.commentTextBlock = TextBlockUtils.create(display, new FontConfiguration(smallFont, bigFont.getColor(), - bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, - spriteContainer); + this.commentTextBlock = display.create(new FontConfiguration(smallFont, bigFont.getColor(), + bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, spriteContainer); } if (this.background == null) { throw new IllegalArgumentException(); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java index c3eb762a5..b69a1770c 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 15961 $ + * Revision $Revision: 16492 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -38,13 +38,10 @@ import net.sourceforge.plantuml.creole.Stencil; 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.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.ULine; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java index 43f660ddc..c318a5b7f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java @@ -70,8 +70,7 @@ public class ComponentRoseReference extends AbstractTextualComponent { this.symbolContext = symbolContext; this.background = background; - this.textHeader = TextBlockUtils.create(stringsToDisplay.subList(0, 1), header, HorizontalAlignment.LEFT, - spriteContainer); + this.textHeader = stringsToDisplay.subList(0, 1).create(header, HorizontalAlignment.LEFT, spriteContainer); } diff --git a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java index bdb90753d..bff3b078f 100644 --- a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java +++ b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 14708 $ + * Revision $Revision: 16528 $ * */ package net.sourceforge.plantuml.sudoku; @@ -106,9 +106,8 @@ public class GraphicsSudoku { for (int y = 0; y < 9; y++) { final int num = sudoku.getGiven(x, y); if (num > 0) { - final TextBlock text = TextBlockUtils.create(Display.create("" + num), new FontConfiguration( - numberFont, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, - new SpriteContainerEmpty()); + final TextBlock text = Display.create("" + num).create(new FontConfiguration( + numberFont, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty()); text.drawU(ug.apply(new UTranslate((numberxOffset + x * cellWidth), (numberyOffset + y * cellHeight)))); } @@ -132,8 +131,8 @@ public class GraphicsSudoku { texts.add("http://plantuml.sourceforge.net"); texts.add("Seed " + Long.toString(sudoku.getSeed(), 36)); texts.add("Difficulty " + sudoku.getRatting()); - final TextBlock textBlock = TextBlockUtils.create(Display.create(texts), new FontConfiguration( - font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final TextBlock textBlock = Display.create(texts).create(new FontConfiguration( + font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); textBlock.drawU(ug); g3d.dispose(); return im; diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index 9fe523e70..194bd3233 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -172,14 +172,14 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { private TextBlockBackcolored addHeaderAndFooter(TextBlockBackcolored original) { final Display footer = diagram.getFooter(); final Display header = diagram.getHeader(); - if (footer == null && header == null) { + if (Display.isNull(footer) && Display.isNull(header)) { return original; } - final TextBlock textFooter = footer == null ? null : TextBlockUtils.create(footer, new FontConfiguration( + final TextBlock textFooter = Display.isNull(footer) ? null : footer.create(new FontConfiguration( getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), diagram.getSkinParam() .getHyperlinkColor(), diagram.getSkinParam().useUnderlineForHyperlink()), diagram .getFooterAlignment(), diagram.getSkinParam()); - final TextBlock textHeader = header == null ? null : TextBlockUtils.create(header, new FontConfiguration( + final TextBlock textHeader = Display.isNull(header) ? null : header.create(new FontConfiguration( getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), diagram.getSkinParam() .getHyperlinkColor(), diagram.getSkinParam().useUnderlineForHyperlink()), diagram .getHeaderAlignment(), diagram.getSkinParam()); @@ -190,19 +190,20 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { private TextBlockBackcolored addTitle(TextBlockBackcolored original) { final Display title = diagram.getTitle(); - if (title == null) { + if (Display.isNull(title)) { return original; } - final TextBlock text = TextBlockUtils.create(title, new FontConfiguration(getFont(FontParam.TITLE), - getFontColor(FontParam.TITLE, null), diagram.getSkinParam().getHyperlinkColor(), diagram.getSkinParam() - .useUnderlineForHyperlink()), HorizontalAlignment.CENTER, diagram.getSkinParam()); + final TextBlock text = title.create( + new FontConfiguration(getFont(FontParam.TITLE), getFontColor(FontParam.TITLE, null), diagram + .getSkinParam().getHyperlinkColor(), diagram.getSkinParam().useUnderlineForHyperlink()), + HorizontalAlignment.CENTER, diagram.getSkinParam()); return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER); } private TextBlockBackcolored addLegend(TextBlockBackcolored original) { final Display legend = diagram.getLegend(); - if (legend == null) { + if (Display.isNull(legend)) { return original; } final TextBlock text = EntityImageLegend.create(legend, diagram.getSkinParam()); diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java index 9da1b8b68..186777b37 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java @@ -94,7 +94,7 @@ import net.sourceforge.plantuml.svek.image.EntityImageBranch; import net.sourceforge.plantuml.svek.image.EntityImageCircleEnd; import net.sourceforge.plantuml.svek.image.EntityImageCircleStart; import net.sourceforge.plantuml.svek.image.EntityImageClass; -import net.sourceforge.plantuml.svek.image.EntityImageComponent; +import net.sourceforge.plantuml.svek.image.EntityImageDescription; import net.sourceforge.plantuml.svek.image.EntityImageEmptyPackage2; import net.sourceforge.plantuml.svek.image.EntityImageGroup; import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterface; @@ -425,7 +425,7 @@ public final class CucaDiagramFileMakerSvek2 { } else if (OptionFlags.USE_INTERFACE_EYE2 && leaf.getUSymbol() instanceof USymbolInterface) { return new EntityImageLollipopInterfaceEye2(leaf, skinParam, portionShower); } else { - return new EntityImageComponent(leaf, skinParam, portionShower); + return new EntityImageDescription(leaf, skinParam, portionShower); } } if (leaf.getEntityType() == LeafType.USECASE) { @@ -451,7 +451,7 @@ public final class CucaDiagramFileMakerSvek2 { } if (leaf.getEntityType() == LeafType.EMPTY_PACKAGE) { if (leaf.getUSymbol() != null) { - return new EntityImageComponent(leaf, new SkinParamForecolored(skinParam, HtmlColorUtils.BLACK), + return new EntityImageDescription(leaf, new SkinParamForecolored(skinParam, HtmlColorUtils.BLACK), portionShower); } return new EntityImageEmptyPackage2(leaf, skinParam); @@ -550,11 +550,9 @@ public final class CucaDiagramFileMakerSvek2 { } final FontParam fontParam = g.getTitleFontParam(); - return TextBlockUtils.create(label, - new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, true), dotData - .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam() - .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, dotData.getSkinParam()); + return label.create(new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, true), dotData + .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam() + .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, dotData.getSkinParam()); } private TextBlock getStereoBlock(IGroup g) { @@ -573,11 +571,9 @@ public final class CucaDiagramFileMakerSvek2 { final Stereotype stereotype2 = g.getStereotype(); final FontParam fontParam = FontParam.COMPONENT_STEREOTYPE; - return TextBlockUtils.create(Display.create(stereos), - new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, false), dotData - .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam() - .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, dotData.getSkinParam()); + return Display.create(stereos).create(new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, false), dotData + .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam() + .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, dotData.getSkinParam()); } } diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java index 3e3a19e97..f6a98c5b7 100644 --- a/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java +++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java @@ -95,7 +95,7 @@ public final class GroupPngMakerActivity { public IEntityImage getImage() throws IOException, InterruptedException { // final List display = group.getDisplay(); - // final TextBlock title = TextBlockUtils.create(display, new FontConfiguration( + // final TextBlock title = Display.create(display, new FontConfiguration( // getFont(FontParam.STATE), HtmlColorUtils.BLACK), HorizontalAlignment.CENTER, diagram.getSkinParam()); if (group.size() == 0) { diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java index fcea4963d..307be7fc3 100644 --- a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java +++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java @@ -110,9 +110,8 @@ public final class GroupPngMakerState { final Display display = group.getDisplay(); final ISkinParam skinParam = diagram.getSkinParam(); final HtmlColor textColor = SkinParamUtils.getFontColor(skinParam, FontParam.STATE, group.getStereotype()); - final TextBlock title = TextBlockUtils.create(display, new FontConfiguration(getFont(FontParam.STATE), - textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, diagram.getSkinParam()); + final TextBlock title = display.create(new FontConfiguration(getFont(FontParam.STATE), + textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, diagram.getSkinParam()); if (group.size() == 0) { return new EntityImageState(group, diagram.getSkinParam()); diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index f09bbbd5d..f21a5847c 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -224,7 +224,7 @@ public class Line implements Moveable, Hideable { this.endHeadColor = colorSequence.getValue(); final TextBlock labelOnly; - if (link.getLabel() == null) { + if (Display.isNull(link.getLabel())) { if (getLinkArrow() == LinkArrow.NONE) { labelOnly = null; } else { @@ -237,7 +237,7 @@ public class Line implements Moveable, Hideable { } else { final double marginLabel = startUid.equals(endUid) ? 6 : 1; final TextBlock label = TextBlockUtils.withMargin( - TextBlockUtils.create(link.getLabel(), labelFont, skinParam.getDefaultTextAlignment(), skinParam), + link.getLabel().create(labelFont, skinParam.getDefaultTextAlignment(), skinParam), marginLabel, marginLabel); if (getLinkArrow() == LinkArrow.NONE) { labelOnly = label; @@ -282,15 +282,13 @@ public class Line implements Moveable, Hideable { if (link.getQualifier1() == null) { startTailText = null; } else { - startTailText = TextBlockUtils.create(Display.getWithNewlines(link.getQualifier1()), labelFont, - HorizontalAlignment.CENTER, skinParam); + startTailText = Display.getWithNewlines(link.getQualifier1()).create(labelFont, HorizontalAlignment.CENTER, skinParam); } if (link.getQualifier2() == null) { endHeadText = null; } else { - endHeadText = TextBlockUtils.create(Display.getWithNewlines(link.getQualifier2()), labelFont, - HorizontalAlignment.CENTER, skinParam); + endHeadText = Display.getWithNewlines(link.getQualifier2()).create(labelFont, HorizontalAlignment.CENTER, skinParam); } } diff --git a/src/net/sourceforge/plantuml/svek/SingleStrategy.java b/src/net/sourceforge/plantuml/svek/SingleStrategy.java index 7811469be..0941d248f 100644 --- a/src/net/sourceforge/plantuml/svek/SingleStrategy.java +++ b/src/net/sourceforge/plantuml/svek/SingleStrategy.java @@ -39,6 +39,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; @@ -64,11 +65,11 @@ public enum SingleStrategy { final Link link; if (dist == branch) { final IEntity ent1 = standalones.get(headBranch); - link = new Link(ent1, ent2, linkType, null, 2); + link = new Link(ent1, ent2, linkType, Display.NULL, 2); headBranch = i; } else { final IEntity ent1 = standalones.get(i - 1); - link = new Link(ent1, ent2, linkType, null, 1); + link = new Link(ent1, ent2, linkType, Display.NULL, 1); } result.add(link); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java index 438c8e999..6bad097ee 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -48,7 +49,6 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Shape; @@ -74,10 +74,8 @@ public class EntityImageActivity extends AbstractEntityImage { this.bibliotekon = bibliotekon; final Stereotype stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create(entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.ACTIVITY, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.ACTIVITY, stereotype), - getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.ACTIVITY, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.ACTIVITY, stereotype), + getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); this.url = entity.getUrl99(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java index c162a6759..736600056 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java @@ -64,20 +64,16 @@ public class EntityImageArcCircle extends AbstractEntityImage { final Stereotype stereotype = entity.getStereotype(); - this.name = TextBlockUtils.create( - entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.COMPONENT, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.COMPONENT, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.name = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.COMPONENT, stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.COMPONENT, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); if (stereotype == null || stereotype.getLabel(false) == null) { this.stereo = null; } else { - this.stereo = TextBlockUtils.create( - Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.COMPONENT_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.COMPONENT_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.COMPONENT_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.COMPONENT_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java index dff1b9842..2870195e7 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; @@ -72,35 +73,40 @@ public class EntityImageClassHeader2 extends AbstractEntityImage { final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo()); final Stereotype stereotype = entity.getStereotype(); final String generic = entity.getGeneric(); - FontConfiguration fontConfigurationName = new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.CLASS, stereotype), - color, getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()); + FontConfiguration fontConfigurationName = new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.CLASS, stereotype), color, getSkinParam().getHyperlinkColor(), getSkinParam() + .useUnderlineForHyperlink()); if (italic) { fontConfigurationName = fontConfigurationName.italic(); } - final TextBlock name = TextBlockUtils.withMargin(TextBlockUtils.create(entity.getDisplay(), - fontConfigurationName, HorizontalAlignment.CENTER, skinParam), 3, 3, 0, 0); + final TextBlock name = TextBlockUtils.withMargin( + entity.getDisplay().createWithNiceCreoleMode(fontConfigurationName, HorizontalAlignment.CENTER, + skinParam), 3, 3, 0, 0); final TextBlock stereo; if (stereotype == null || stereotype.getLabel(false) == null || portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) { stereo = null; } else { - stereo = TextBlockUtils.withMargin(TextBlockUtils.create( - Display.create(stereotype.getLabels(skinParam.useGuillemet())), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.CLASS_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.CLASS_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam), 1, 0); + stereo = TextBlockUtils.withMargin( + Display.create(stereotype.getLabels(skinParam.useGuillemet())).create( + new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.CLASS_STEREOTYPE, + stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.CLASS_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), + getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam), + 1, 0); } TextBlock genericBlock; if (generic == null) { genericBlock = null; } else { - genericBlock = TextBlockUtils.create( - Display.getWithNewlines(generic), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.CLASS_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.CLASS_STEREOTYPE, stereotype), skinParam.getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + genericBlock = Display.getWithNewlines(generic).create( + new FontConfiguration( + SkinParamUtils.getFont(getSkinParam(), FontParam.CLASS_STEREOTYPE, stereotype), + SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS_STEREOTYPE, stereotype), + skinParam.getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), + HorizontalAlignment.CENTER, skinParam); genericBlock = TextBlockUtils.withMargin(genericBlock, 1, 1); final HtmlColor classBackground = SkinParamUtils .getColor(getSkinParam(), ColorParam.background, stereotype); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java similarity index 82% rename from src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java rename to src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index 799fe9cc3..0b4727f68 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -53,18 +53,19 @@ import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.graphic.USymbolFolder; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; -public class EntityImageComponent extends AbstractEntityImage { +public class EntityImageDescription extends AbstractEntityImage { final private Url url; private final TextBlock asSmall; - public EntityImageComponent(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) { + public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); final USymbol symbol = entity.getUSymbol() == null ? (skinParam.useUml2ForComponent() ? USymbol.COMPONENT2 @@ -73,8 +74,10 @@ public class EntityImageComponent extends AbstractEntityImage { throw new IllegalArgumentException(); } - final TextBlock desc = entity.getDisplay().isWhite() ? TextBlockUtils.empty(0, 0) : new BodyEnhanced( - entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, stereotype, + final Display codeDisplay = Display.getWithNewlines(entity.getCode()); + final TextBlock desc = (entity.getDisplay().equals(codeDisplay) && symbol instanceof USymbolFolder) + || entity.getDisplay().isWhite() ? TextBlockUtils.empty(0, 0) : new BodyEnhanced(entity.getDisplay(), + symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false, false); this.url = entity.getUrl99(); @@ -92,15 +95,17 @@ public class EntityImageComponent extends AbstractEntityImage { if (stereotype != null && stereotype.getLabel(false) != null && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) { - stereo = TextBlockUtils.create( - Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), + stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create( new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), symbol.getFontParamStereotype(), stereotype), SkinParamUtils.getFontColor(getSkinParam(), symbol.getFontParamStereotype(), null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } - asSmall = symbol.asSmall(desc, stereo, ctx); + final TextBlock name = new BodyEnhanced(codeDisplay, symbol.getFontParam(), skinParam, + HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false, false); + + asSmall = symbol.asSmall(name, desc, stereo, ctx); } public Dimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java index 49375d997..e20260a89 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -69,11 +70,9 @@ public class EntityImageEmptyPackage2 extends AbstractEntityImage { this.skinParam = skinParam; this.specificBackColor = entity.getSpecificBackColor(); this.stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create(entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.PACKAGE, stereotype), - SkinParamUtils.getFontColor(getSkinParam(), FontParam.PACKAGE, stereotype), getSkinParam() - .getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.PACKAGE, stereotype), + SkinParamUtils.getFontColor(getSkinParam(), FontParam.PACKAGE, stereotype), getSkinParam() + .getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } public Dimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java index ab2b7a346..605c720f2 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java @@ -50,7 +50,7 @@ public class EntityImageGroup extends AbstractEntityImage { public EntityImageGroup(ILeaf entity, ISkinParam skinParam) { super(entity, skinParam); - // this.desc = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + // this.desc = Display.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( // getFont(FontParam.ACTIVITY), HtmlColorUtils.BLACK), HorizontalAlignment.CENTER); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java index 2847a10e5..337347824 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java @@ -41,13 +41,13 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; @@ -66,11 +66,9 @@ public class EntityImageLollipopInterface extends AbstractEntityImage { public EntityImageLollipopInterface(ILeaf entity, ISkinParam skinParam) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create( - entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, - stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); this.url = entity.getUrl99(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java index e6de6b6ce..ace70378b 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java @@ -43,13 +43,13 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Line; @@ -72,11 +72,9 @@ public class EntityImageLollipopInterfaceEye1 extends AbstractEntityImage { super(entity, skinParam); this.bibliotekon = bibliotekon; final Stereotype stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create( - entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, - stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); this.url = entity.getUrl99(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java index 50e4f66e8..60b4e676b 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java @@ -94,11 +94,9 @@ public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage { if (stereotype != null && stereotype.getLabel(false) != null && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) { - stereo = TextBlockUtils.create( - Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - symbol.getFontParamStereotype(), stereotype), SkinParamUtils.getFontColor(getSkinParam(), - symbol.getFontParamStereotype(), null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + symbol.getFontParamStereotype(), stereotype), SkinParamUtils.getFontColor(getSkinParam(), + symbol.getFontParamStereotype(), null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } else { stereo = TextBlockUtils.empty(0, 0); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java index 4ecd9b9b6..792b13c67 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java @@ -86,20 +86,16 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil { this.lineConfig = entity; final Stereotype stereotype = entity.getStereotype(); this.roundCorner = skinParam.getRoundCorner(); - this.name = TextBlockUtils.withMargin(TextBlockUtils.create(entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.OBJECT, stereotype), - SkinParamUtils.getFontColor(getSkinParam(), FontParam.OBJECT, stereotype), getSkinParam() - .getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, skinParam), 2, 2); + this.name = TextBlockUtils.withMargin(entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.OBJECT, stereotype), + SkinParamUtils.getFontColor(getSkinParam(), FontParam.OBJECT, stereotype), getSkinParam() + .getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam), 2, 2); if (stereotype == null || stereotype.getLabel(false) == null) { this.stereo = null; } else { - this.stereo = TextBlockUtils - .create(Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.OBJECT_STEREOTYPE, - stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.OBJECT_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), - getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.OBJECT_STEREOTYPE, + stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.OBJECT_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), + getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } if (entity.getBodier().getFieldsToDisplay().size() == 0) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java index 19e2ec0b4..a4571cb52 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java @@ -65,11 +65,9 @@ public class EntityImagePseudoState extends AbstractEntityImage { public EntityImagePseudoState(ILeaf entity, ISkinParam skinParam) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create(Display.create("H"), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, - stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, skinParam); + this.desc = Display.create("H").create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java index bd71878fb..0c57806fb 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java @@ -88,11 +88,9 @@ public class EntityImageState extends AbstractEntityImage { final Stereotype stereotype = entity.getStereotype(); this.withSymbol = stereotype != null && stereotype.isWithOOSymbol(); - this.desc = TextBlockUtils.create( - entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, - stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); Display list = Display.empty(); for (Member att : entity.getBodier().getFieldsToDisplay()) { @@ -101,11 +99,9 @@ public class EntityImageState extends AbstractEntityImage { this.url = entity.getUrl99(); - this.fields = TextBlockUtils.create( - list, - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.STATE_ATTRIBUTE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.STATE_ATTRIBUTE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam); + this.fields = list.create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.STATE_ATTRIBUTE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.STATE_ATTRIBUTE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java index a0c32728c..0d19ac25f 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java @@ -92,7 +92,7 @@ public class EntityImageState2 extends AbstractEntityImage { final TextBlock desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false, false); - asSmall = symbol.asSmall(desc, stereo, ctx); + asSmall = symbol.asSmall(null, desc, stereo, ctx); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java index b20c057c0..c476ec1d7 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -49,7 +50,6 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; @@ -83,10 +83,8 @@ public class EntityImageStateBorder extends AbstractEntityImage { this.stateParent = stateParent; final Stereotype stereotype = leaf.getStereotype(); - this.desc = TextBlockUtils.create(leaf.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, stereotype), - getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), - HorizontalAlignment.CENTER, skinParam); + this.desc = leaf.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, stereotype), + getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); } private boolean upPosition() { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java index ea412da7b..79df883cf 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java @@ -73,11 +73,9 @@ public class EntityImageStateEmptyDescription extends AbstractEntityImage { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - this.desc = TextBlockUtils.create( - entity.getDisplay(), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, - stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + this.desc = entity.getDisplay().create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, + stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); Display list = Display.empty(); for (Member att : entity.getBodier().getFieldsToDisplay()) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index 464ae652c..4f30b10e2 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -81,11 +81,9 @@ public class EntityImageUseCase extends AbstractEntityImage { if (stereotype == null || stereotype.getLabel(false) == null) { this.desc = tmp; } else { - final TextBlock stereo = TextBlockUtils.create( - Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())), - new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), - FontParam.ACTOR_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), - FontParam.ACTOR_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); + final TextBlock stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), + FontParam.ACTOR_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), + FontParam.ACTOR_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam); this.desc = TextBlockUtils.mergeTB(stereo, tmp, HorizontalAlignment.CENTER); } this.url = entity.getUrl99(); diff --git a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java index 8b31390dd..741ab58a3 100644 --- a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java +++ b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.eps.EpsGraphics; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.USegment; @@ -81,9 +82,47 @@ public class TikzGraphics { out(os, "\\documentclass{article}"); out(os, "\\usepackage{tikz}"); out(os, "\\usepackage{aeguill}"); + if (hasUrl) { + out(os, "\\usetikzlibrary{calc}"); + out(os, "\\usepackage{hyperref}"); + } // out(os, "\\usetikzlibrary{trees}"); out(os, "\\begin{document}"); out(os, "% generated by Plantuml " + Version.versionString(10)); + if (hasUrl) { + out(os, "\\tikzset{"); + out(os, " href node/.style={"); + out(os, " alias=sourcenode,"); + out(os, " append after command={"); + out(os, " let \\p1 = (sourcenode.north west),"); + out(os, " \\p2=(sourcenode.south east),"); + out(os, " \\n1={\\x2-\\x1},"); + out(os, " \\n2={\\y2-\\y1} in"); + out(os, + " node [inner sep=0pt, outer sep=0pt,anchor=north west,at=(\\p1)] {\\href{#1}{\\XeTeXLinkBox{\\phantom{\\rule{\\n1}{\\n2}}}}}"); + out(os, " %xelatex needs \\XeTeXLinkBox, won't create a link unless it"); + out(os, " %finds text --- rules don't work without \\XeTeXLinkBox."); + out(os, " %Still builds correctly with pdflatex and lualatex"); + out(os, " }"); + out(os, " }"); + out(os, "}"); + out(os, "\\tikzset{"); + out(os, " hyperref node/.style={"); + out(os, " alias=sourcenode,"); + out(os, " append after command={"); + out(os, " let \\p1 = (sourcenode.north west),"); + out(os, " \\p2=(sourcenode.south east),"); + out(os, " \\n1={\\x2-\\x1},"); + out(os, " \\n2={\\y2-\\y1} in"); + out(os, + " node [inner sep=0pt, outer sep=0pt,anchor=north west,at=(\\p1)] {\\hyperref [#1]{\\XeTeXLinkBox{\\phantom{\\rule{\\n1}{\\n2}}}}}"); + out(os, " %xelatex needs \\XeTeXLinkBox, won't create a link unless it"); + out(os, " %finds text --- rules don't work without \\XeTeXLinkBox."); + out(os, " %Still builds correctly with pdflatex and lualatex"); + out(os, " }"); + out(os, " }"); + out(os, "}"); + } for (Map.Entry ent : colornames.entrySet()) { out(os, definecolor(ent.getValue(), ent.getKey())); @@ -103,19 +142,45 @@ public class TikzGraphics { public void rectangle(double x, double y, double width, double height) { final StringBuilder sb = new StringBuilder(); - sb.append("\\draw["); - if (color != null) { - sb.append("color=" + getColorName(color) + ","); - } - if (fillcolor != null) { - sb.append("fill=" + getColorName(fillcolor) + ","); - if (color == null) { - sb.append("color=" + getColorName(fillcolor) + ","); + if (pendingUrl == null) { + sb.append("\\draw["); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + if (color == null) { + sb.append("color=" + getColorName(fillcolor) + ","); + } + } + sb.append("line width=" + thickness + "pt] "); + sb.append(couple(x, y) + " rectangle " + couple(x + width, y + height)); + sb.append(";"); + } else { + sb.append("\\node at " + couple(x, y) + "[draw, "); + if (color != null) { + sb.append("color=" + getColorName(color) + ","); + } + if (fillcolor != null) { + sb.append("fill=" + getColorName(fillcolor) + ","); + if (color == null) { + sb.append("color=" + getColorName(fillcolor) + ","); + } + } + sb.append("line width=" + thickness + "pt,"); + sb.append("below right,"); + sb.append("inner sep=2ex,"); + sb.append("minimum width=" + format(width) + "pt,"); + sb.append("minimum height=" + format(height) + "pt,"); + if (Url.isLatex(pendingUrl)) { + sb.append("hyperref node=" + extractInternalHref(pendingUrl)); + } else { + sb.append("href node=" + pendingUrl); + } + sb.append("] "); + sb.append(" {};"); + urlIgnoreText = true; } - sb.append("line width=" + thickness + "pt] "); - sb.append(couple(x, y) + " rectangle " + couple(x + width, y + height)); - sb.append(";"); cmd.add(sb.toString()); } @@ -133,8 +198,36 @@ public class TikzGraphics { } public void text(double x, double y, String text) { - final String s = "\\node at " + couple(x, y) + "[below right]{" + protectText(text) + "};"; - cmd.add(s); + final StringBuilder sb = new StringBuilder("\\node at " + couple(x, y) + "[below right]{"); + if (pendingUrl == null || urlIgnoreText) { + sb.append(protectText(text)); + } else { + appendPendingUrl(sb); + sb.append("{"); + sb.append(protectText(text)); + sb.append("}"); + } + sb.append("};"); + cmd.add(sb.toString()); + } + + private void appendPendingUrl(final StringBuilder sb) { + if (Url.isLatex(pendingUrl)) { + sb.append("\\hyperref["); + sb.append(extractInternalHref(pendingUrl)); + sb.append("]"); + } else { + sb.append("\\href{"); + sb.append(pendingUrl); + sb.append("}"); + } + } + + private static String extractInternalHref(String pendingUrl) { + if (Url.isLatex(pendingUrl) == false) { + throw new IllegalArgumentException(); + } + return pendingUrl.substring("latex://".length()); } private String protectText(String text) { @@ -298,4 +391,34 @@ public class TikzGraphics { this.dash = dash; } + private String pendingUrl = null; + private boolean urlIgnoreText = false; + private boolean hasUrl = false; + + public void openLink(String url, String title) { + if (url == null) { + throw new IllegalArgumentException(); + } + this.hasUrl = true; + this.urlIgnoreText = false; + this.pendingUrl = url; + // + // if (pendingLink2.size() > 0) { + // closeLink(); + // } + // + // pendingLink2.add(0, (Element) document.createElement("a")); + // pendingLink2.get(0).setAttribute("target", target); + // pendingLink2.get(0).setAttribute("xlink:href", url); + // if (title == null) { + // pendingLink2.get(0).setAttribute("xlink:title", url); + // } else { + // pendingLink2.get(0).setAttribute("xlink:title", title); + // } + } + + public void closeLink() { + this.pendingUrl = null; + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java index 8b4e9f85b..637d960cf 100644 --- a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java +++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java @@ -33,9 +33,6 @@ */ package net.sourceforge.plantuml.ugraphic; -import java.io.IOException; -import java.io.OutputStream; - import net.sourceforge.plantuml.graphic.UGraphicDelegator; public abstract class AbstractUGraphicHorizontalLine extends UGraphicDelegator { diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java index 909636a43..98644e2e0 100644 --- a/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java +++ b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java @@ -101,9 +101,11 @@ public class UGraphicTikz extends AbstractUGraphic implements Clip } public void startUrl(Url url) { + getGraphicObject().openLink(url.getUrl(), url.getTooltip()); } public void closeAction() { + getGraphicObject().closeLink(); } public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 89f33cff2..c57adad78 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 16461 $ + * Revision $Revision: 16588 $ * */ package net.sourceforge.plantuml.version; @@ -39,7 +39,7 @@ import java.util.Date; public class Version { public static int version() { - return 8027; + return 8028; } public static String versionString() { @@ -63,7 +63,7 @@ public class Version { } private static long compileTime() { - return 1434795239208L; + return 1436554841134L; } public static String compileTimeString() {