From fb108ebb5afa93915787d7ce6e686ef526edfd96 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 26 Jun 2019 21:24:49 +0200 Subject: [PATCH] version 1.2019.7 --- pom.xml | 2 +- .../sourceforge/plantuml/AlignmentParam.java | 1 + src/net/sourceforge/plantuml/BlockUml.java | 16 +- .../sourceforge/plantuml/BlockUmlBuilder.java | 11 +- src/net/sourceforge/plantuml/ColorParam.java | 1 + .../plantuml/DefinitionsContainer.java | 3 +- src/net/sourceforge/plantuml/ISkinParam.java | 3 + .../plantuml/LineLocationImpl.java | 7 - src/net/sourceforge/plantuml/Log.java | 29 ++- .../sourceforge/plantuml/PSystemBuilder.java | 15 +- src/net/sourceforge/plantuml/Run.java | 14 +- src/net/sourceforge/plantuml/SkinParam.java | 13 ++ .../plantuml/SkinParamDelegator.java | 5 + .../sourceforge/plantuml/StringLocated.java | 23 ++- src/net/sourceforge/plantuml/StringUtils.java | 3 - src/net/sourceforge/plantuml/UmlDiagram.java | 4 + .../activitydiagram/ActivityDiagram.java | 5 + .../ActivityDiagramFactory.java | 10 +- .../activitydiagram/command/CommandElse.java | 22 ++- .../command/CommandEndPartition.java | 27 ++- .../activitydiagram/command/CommandEndif.java | 24 ++- .../activitydiagram/command/CommandIf.java | 19 +- .../command/CommandInnerConcurrent.java | 25 ++- .../command/CommandLinkActivity.java | 32 ++-- .../command/CommandLinkLongActivity.java | 28 +-- .../command/CommandPartition.java | 14 +- .../activitydiagram3/ActivityDiagram3.java | 14 +- .../ActivityDiagramFactory3.java | 9 +- .../activitydiagram3/InstructionIf.java | 7 +- .../activitydiagram3/InstructionRepeat.java | 12 +- .../command/CommandActivity3.java | 9 +- .../command/CommandActivityLegacy1.java | 7 +- .../command/CommandActivityLong3.java | 9 +- .../command/CommandArrow3.java | 9 +- .../command/CommandArrowLong3.java | 11 +- .../command/CommandBackward3.java | 10 +- .../command/CommandBreak.java | 10 +- .../activitydiagram3/command/CommandCase.java | 11 +- .../command/CommandCircleSpot3.java | 9 +- .../command/CommandElse3.java | 16 +- .../command/CommandElseIf2.java | 30 ++-- .../command/CommandElseLegacy1.java | 16 +- .../activitydiagram3/command/CommandEnd3.java | 9 +- .../command/CommandEndPartition3.java | 30 ++-- .../command/CommandEndSwitch.java | 9 +- .../command/CommandEndif3.java | 10 +- .../command/CommandFork3.java | 9 +- .../command/CommandForkAgain3.java | 13 +- .../command/CommandForkEnd3.java | 31 +++- .../activitydiagram3/command/CommandGoto.java | 9 +- .../command/CommandGroup3.java | 10 +- .../command/CommandGroupEnd3.java | 8 +- .../activitydiagram3/command/CommandIf2.java | 34 +++- .../activitydiagram3/command/CommandIf4.java | 20 ++- .../command/CommandIfLegacy1.java | 20 ++- .../command/CommandKill3.java | 9 +- .../command/CommandLabel.java | 9 +- .../command/CommandLink3.java | 10 +- .../command/CommandNolink.java | 7 +- .../command/CommandNote3.java | 19 +- .../command/CommandNoteLong3.java | 18 +- .../command/CommandPartition3.java | 18 +- .../command/CommandRepeat3.java | 13 +- .../command/CommandRepeatWhile3.java | 38 ++-- .../CommandRepeatWhile3Multilines.java | 18 +- .../command/CommandSplit3.java | 9 +- .../command/CommandSplitAgain3.java | 13 +- .../command/CommandSplitEnd3.java | 23 ++- .../command/CommandStart3.java | 9 +- .../command/CommandStop3.java | 9 +- .../command/CommandSwimlane.java | 7 +- .../command/CommandSwimlane2.java | 21 ++- .../command/CommandSwitch.java | 11 +- .../command/CommandWhile3.java | 16 +- .../command/CommandWhileEnd3.java | 26 ++- .../activitydiagram3/ftile/FtileFactory.java | 2 +- .../ftile/FtileFactoryDelegator.java | 4 +- .../activitydiagram3/ftile/FtileGeometry.java | 8 +- .../activitydiagram3/ftile/Snake.java | 10 +- .../activitydiagram3/ftile/SwimlanesB.java | 28 ++- .../vcompact/FtileFactoryDelegatorIf.java | 7 +- .../vcompact/FtileFactoryDelegatorSwitch.java | 21 +-- .../ftile/vcompact/FtileIfDown.java | 156 ++++++++++++++-- .../ftile/vcompact/FtileRepeat.java | 47 ++++- .../ftile/vcompact/VCompactFactory.java | 2 +- .../vcompact/cond/ConditionalBuilder.java | 41 +++-- .../ftile/vcompact/cond/FtileIfWithLinks.java | 155 ++++++++++++++-- .../ftile/vcompact/cond/FtileSwitchNude.java | 2 +- .../cond/FtileSwitchWithDiamonds.java | 86 +++++++-- .../cond/FtileSwitchWithManyLinks.java | 18 +- .../plantuml/bpm/CommandDockedEvent.java | 7 +- .../plantuml/bpm/CommandElseBranch.java | 9 +- .../plantuml/bpm/CommandEndBranch.java | 7 +- .../sourceforge/plantuml/bpm/CommandGoto.java | 9 +- .../plantuml/bpm/CommandMerge.java | 7 +- .../plantuml/bpm/CommandNewBranch.java | 7 +- .../plantuml/bpm/CommandResume.java | 9 +- .../classdiagram/AbstractEntityDiagram.java | 5 + .../plantuml/classdiagram/ClassDiagram.java | 5 + .../classdiagram/ClassDiagramFactory.java | 20 ++- .../command/CommandAddMethod.java | 29 ++- .../command/CommandAllowMixing.java | 7 +- .../command/CommandCreateClass.java | 34 ++-- .../command/CommandCreateClassMultilines.java | 49 +++-- .../command/CommandCreateElementFull2.java | 35 ++-- .../command/CommandDiamondAssociation.java | 27 ++- .../command/CommandHideShow2.java | 9 +- .../command/CommandHideShowByGender.java | 16 +- .../command/CommandHideShowByVisibility.java | 15 +- .../command/CommandHideShowSpecificClass.java | 44 ++--- .../CommandHideShowSpecificStereotype.java | 18 +- .../classdiagram/command/CommandImport.java | 30 +++- .../command/CommandLayoutNewLine.java | 7 +- .../command/CommandLinkClass.java | 42 +++-- .../command/CommandLinkLollipop.java | 30 ++-- .../command/CommandNamespaceSeparator.java | 29 ++- .../command/CommandRemoveRestore.java | 10 +- .../command/CommandStereotype.java | 30 +++- .../classdiagram/command/CommandUrl.java | 34 +++- .../plantuml/command/BlocLines.java | 6 +- .../command/CommandAffineTransform.java | 21 ++- .../plantuml/command/CommandCaption.java | 25 ++- .../plantuml/command/CommandEndPackage.java | 19 +- .../command/CommandFootboxIgnored.java | 20 ++- .../plantuml/command/CommandFooter.java | 31 +++- .../plantuml/command/CommandHeader.java | 33 +++- .../plantuml/command/CommandHideUnlinked.java | 22 ++- .../plantuml/command/CommandMainframe.java | 25 ++- .../plantuml/command/CommandMinwidth.java | 25 ++- .../plantuml/command/CommandMultilines.java | 4 +- .../plantuml/command/CommandMultilines2.java | 14 +- .../plantuml/command/CommandMultilines3.java | 12 +- .../command/CommandMultilinesBracket.java | 4 +- .../command/CommandMultilinesFooter.java | 2 +- .../command/CommandMultilinesHeader.java | 2 +- .../command/CommandMultilinesLegend.java | 21 ++- .../plantuml/command/CommandNamespace.java | 19 +- .../plantuml/command/CommandNope.java | 19 +- .../plantuml/command/CommandPackage.java | 27 +-- .../plantuml/command/CommandPackageEmpty.java | 45 +++-- .../plantuml/command/CommandPage.java | 29 ++- .../plantuml/command/CommandPragma.java | 30 +++- .../plantuml/command/CommandRankDir.java | 22 ++- .../plantuml/command/CommandRotate.java | 20 ++- .../plantuml/command/CommandScale.java | 38 +++- .../command/CommandScaleMaxHeight.java | 26 ++- .../command/CommandScaleMaxWidth.java | 26 ++- .../CommandScaleMaxWidthAndHeight.java | 30 +++- .../command/CommandScaleWidthAndHeight.java | 28 ++- .../command/CommandScaleWidthOrHeight.java | 26 ++- .../plantuml/command/CommandSkinParam.java | 26 ++- .../command/CommandSkinParamMultilines.java | 2 +- .../plantuml/command/CommandSpriteFile.java | 16 +- .../plantuml/command/CommandTitle.java | 25 ++- .../command/FactorySpriteCommand.java | 42 +++-- .../plantuml/command/MultilinesStrategy.java | 2 +- .../plantuml/command/PSystemBasicFactory.java | 2 +- .../plantuml/command/SingleLineCommand.java | 113 ------------ .../plantuml/command/SingleLineCommand2.java | 31 ++-- .../plantuml/command/UmlDiagramFactory.java | 18 +- .../note/FactoryNoteActivityCommand.java | 39 ++-- .../command/note/FactoryNoteCommand.java | 46 +++-- .../note/FactoryNoteOnEntityCommand.java | 61 ++++--- .../note/FactoryNoteOnLinkCommand.java | 43 +++-- .../note/FactoryTipOnEntityCommand.java | 27 +-- .../FactorySequenceNoteAccrossCommand.java | 170 ++++++++++++++++++ .../sequence/FactorySequenceNoteCommand.java | 56 +++--- .../FactorySequenceNoteOnArrowCommand.java | 44 +++-- ...FactorySequenceNoteOverSeveralCommand.java | 61 ++++--- .../plantuml/command/regex/FoxSignature.java | 91 ++++++++++ .../plantuml/command/regex/IRegex.java | 6 + .../plantuml/command/regex/RegexComposed.java | 32 +++- .../plantuml/command/regex/RegexConcat.java | 100 +++++++++-- .../plantuml/command/regex/RegexLeaf.java | 65 ++++++- .../plantuml/command/regex/RegexOptional.java | 20 ++- .../plantuml/command/regex/RegexOr.java | 24 +-- .../compositediagram/CompositeDiagram.java | 5 + .../CompositeDiagramFactory.java | 9 +- .../command/CommandCreateBlock.java | 34 +++- .../command/CommandCreatePackageBlock.java | 35 +++- .../command/CommandEndPackageBlock.java | 21 ++- .../command/CommandLinkBlock.java | 58 ++++-- .../sourceforge/plantuml/creole/AtomImg.java | 36 ++-- .../sourceforge/plantuml/creole/AtomText.java | 8 +- .../plantuml/creole/StripeSimple.java | 2 +- .../plantuml/cucadiagram/CucaDiagram.java | 6 + .../plantuml/cucadiagram/Display.java | 9 - .../plantuml/cucadiagram/Link.java | 11 ++ .../plantuml/cucadiagram/Stereotype.java | 28 ++- .../descdiagram/CommandCreateDomain.java | 18 +- .../descdiagram/DescriptionDiagram.java | 6 + .../DescriptionDiagramFactory.java | 29 +-- .../descdiagram/command/CommandArchimate.java | 49 +++-- .../command/CommandArchimateMultilines.java | 27 +-- .../command/CommandCreateElementFull.java | 51 ++++-- .../CommandCreateElementMultilines.java | 24 ++- .../command/CommandLinkElement.java | 29 +-- .../descdiagram/command/CommandNewpage.java | 8 +- .../command/CommandPackageWithUSymbol.java | 93 ++++++---- .../flowdiagram/CommandLineSimple.java | 17 +- .../plantuml/flowdiagram/CommandLink.java | 15 +- .../plantuml/graphic/QuoteUtils.java | 4 +- .../plantuml/graphic/USymbolStack.java | 23 ++- .../plantuml/help/CommandHelp.java | 7 +- .../plantuml/help/CommandHelpColor.java | 10 +- .../plantuml/help/CommandHelpFont.java | 10 +- .../plantuml/help/CommandHelpKeyword.java | 10 +- .../plantuml/help/CommandHelpSkinparam.java | 10 +- .../plantuml/help/CommandHelpType.java | 10 +- .../plantuml/jungle/CommandAddLevel.java | 10 +- .../plantuml/jungle/CommandEmpty.java | 8 +- .../mindmap/CommandMindMapDirection.java | 8 +- .../plantuml/mindmap/CommandMindMapLeft.java | 12 +- .../mindmap/CommandMindMapLeftNumber.java | 14 +- .../mindmap/CommandMindMapOrgmode.java | 20 ++- .../plantuml/mindmap/CommandMindMapPlus.java | 12 +- .../plantuml/mindmap/CommandMindMapRight.java | 13 +- .../mindmap/CommandMindMapRightNumber.java | 14 +- .../plantuml/mindmap/CommandMindMapRoot.java | 12 +- .../mindmap/CommandMindMapTabulation.java | 12 +- .../plantuml/mindmap/FingerImpl2.java | 12 +- .../sourceforge/plantuml/mindmap/Idea.java | 15 +- .../plantuml/mindmap/MindMapDiagram.java | 17 +- .../plantuml/nwdiag/CommandComment.java | 9 +- .../plantuml/nwdiag/CommandElement.java | 12 +- .../plantuml/nwdiag/CommandEndSomething.java | 10 +- .../plantuml/nwdiag/CommandGroup.java | 15 +- .../plantuml/nwdiag/CommandLink.java | 17 +- .../plantuml/nwdiag/CommandNetwork.java | 14 +- .../plantuml/nwdiag/CommandNwDiagInit.java | 10 +- .../plantuml/nwdiag/CommandProperty.java | 16 +- .../AbstractClassOrObjectDiagram.java | 5 + .../plantuml/objectdiagram/ObjectDiagram.java | 6 +- .../objectdiagram/ObjectDiagramFactory.java | 13 +- .../objectdiagram/command/CommandAddData.java | 29 ++- .../command/CommandCreateEntityObject.java | 23 +-- .../CommandCreateEntityObjectMultilines.java | 21 ++- src/net/sourceforge/plantuml/posimo/data.txt | 38 ---- .../plantuml/postit/CommandCreatePostIt.java | 11 +- .../plantuml/postit/CommandWidth.java | 25 ++- .../preproc/PreprocessorChangeModeReader.java | 2 +- .../sourceforge/plantuml/preproc/Sub2.java | 4 +- .../preproc2/PreprocessorInclude.java | 2 +- .../plantuml/project3/CommandGanttArrow.java | 12 +- .../plantuml/project3/CommandGanttArrow2.java | 12 +- .../plantuml/project3/CommandPage.java | 30 +++- .../plantuml/project3/CommandSeparator.java | 10 +- .../plantuml/project3/ComplementDate.java | 8 +- .../plantuml/project3/ComplementDates.java | 4 +- .../plantuml/project3/NaturalCommand.java | 14 +- .../plantuml/project3/NaturalCommandAnd.java | 14 +- .../project3/NaturalCommandAndAnd.java | 20 +-- .../plantuml/project3/SubjectDaysAsDates.java | 17 +- .../plantuml/project3/SubjectTask.java | 9 +- .../SequenceDiagramFactory.java | 4 + .../command/CommandActivate.java | 17 +- .../command/CommandActivate2.java | 30 +++- .../sequencediagram/command/CommandArrow.java | 76 ++++---- .../command/CommandAutoNewpage.java | 24 ++- .../command/CommandAutoactivate.java | 24 ++- .../command/CommandAutonumber.java | 20 ++- .../command/CommandAutonumberIncrement.java | 14 +- .../command/CommandAutonumberResume.java | 20 ++- .../command/CommandAutonumberStop.java | 25 ++- .../command/CommandBoxEnd.java | 26 ++- .../command/CommandBoxStart.java | 21 ++- .../command/CommandDeactivateShort.java | 8 +- .../sequencediagram/command/CommandDelay.java | 27 ++- .../command/CommandDivider.java | 28 ++- .../command/CommandExoArrowAny.java | 4 +- .../command/CommandExoArrowLeft.java | 23 ++- .../command/CommandExoArrowRight.java | 23 ++- .../command/CommandFootbox.java | 26 ++- .../command/CommandFootboxOld.java | 27 ++- .../command/CommandGrouping.java | 21 ++- .../command/CommandHSpace.java | 28 ++- .../command/CommandIgnoreNewpage.java | 24 ++- .../command/CommandLinkAnchor.java | 12 +- .../command/CommandNewpage.java | 30 +++- .../command/CommandParticipant.java | 12 +- .../command/CommandParticipantA.java | 28 +-- .../command/CommandParticipantA2.java | 22 +-- .../command/CommandParticipantA3.java | 23 +-- .../command/CommandParticipantA4.java | 19 +- ...CommandReferenceMultilinesOverSeveral.java | 2 +- .../command/CommandReferenceOverSeveral.java | 15 +- .../command/CommandReturn.java | 22 ++- .../sequencediagram/command/CommandSkin.java | 23 ++- .../sequencediagram/command/CommandUrl.java | 34 +++- .../graphic/DrawableSetInitializer.java | 8 + .../graphic/MessageExoArrow.java | 4 +- .../graphic/SequenceDiagramArea.java | 4 + .../SequenceDiagramFileMakerPuma2.java | 1 + .../sequencediagram/teoz/TileBuilder.java | 9 +- .../plantuml/statediagram/StateDiagram.java | 6 + .../statediagram/StateDiagramFactory.java | 20 ++- .../statediagram/command/CommandAddField.java | 12 +- .../command/CommandConcurrentState.java | 23 ++- .../command/CommandCreatePackageState.java | 33 ++-- .../command/CommandCreateState.java | 35 ++-- .../statediagram/command/CommandEndState.java | 21 ++- .../command/CommandHideEmptyDescription.java | 29 ++- .../command/CommandLinkState.java | 19 +- .../ConditionEndStyle.java} | 30 ++-- src/net/sourceforge/plantuml/svek/Line.java | 22 ++- .../plantuml/syntax/LanguageDescriptor.java | 2 + src/net/sourceforge/plantuml/tim/Eater.java | 5 + .../plantuml/tim/EaterDeclareFunction.java | 2 +- .../EaterIncludeDef.java} | 39 ++-- .../plantuml/tim/EaterLegacyDefine.java | 2 +- .../plantuml/tim/EaterLegacyDefineLong.java | 2 +- .../sourceforge/plantuml/tim/EaterUndef.java | 2 +- .../sourceforge/plantuml/tim/TContext.java | 74 ++++++-- .../sourceforge/plantuml/tim/TLineType.java | 5 +- .../sourceforge/plantuml/tim/TimLoader.java | 7 +- .../expression/ReversePolishInterpretor.java | 7 +- .../plantuml/tim/stdlib/DateFunction.java | 1 - .../plantuml/tim/stdlib/Dirpath.java | 4 - .../plantuml/tim/stdlib/FileExists.java | 2 - .../plantuml/tim/stdlib/Filename.java | 4 - .../plantuml/tim/stdlib/Getenv.java | 3 - .../plantuml/tim/stdlib/Strlen.java | 2 - .../plantuml/tim/stdlib/Strpos.java | 2 - .../plantuml/tim/stdlib/Substr.java | 4 - .../timingdiagram/CommandAtPlayer.java | 7 +- .../plantuml/timingdiagram/CommandAtTime.java | 7 +- .../plantuml/timingdiagram/CommandBinary.java | 12 +- .../timingdiagram/CommandChangeState.java | 3 +- .../CommandChangeStateByPlayerCode.java | 24 ++- .../CommandChangeStateByTime.java | 26 ++- .../plantuml/timingdiagram/CommandClock.java | 24 ++- .../timingdiagram/CommandConstraint.java | 21 ++- .../timingdiagram/CommandDefineStateLong.java | 16 +- .../CommandDefineStateShort.java | 12 +- .../timingdiagram/CommandHideTimeAxis.java | 13 +- .../plantuml/timingdiagram/CommandNote.java | 20 ++- .../timingdiagram/CommandNoteLong.java | 18 +- .../timingdiagram/CommandRobustConcise.java | 12 +- .../timingdiagram/CommandScalePixel.java | 16 +- .../timingdiagram/CommandTimeMessage.java | 21 ++- .../sourceforge/plantuml/version/Version.java | 4 +- .../plantuml/wbs/CommandWBSOrgmode.java | 10 +- .../plantuml/wbs/CommandWBSPlus.java | 10 +- .../plantuml/wbs/CommandWBSTabulation.java | 10 +- src/sprites/archimate/assessment-filled.png | Bin 0 -> 249 bytes src/sprites/archimate/constraint-filled.png | Bin 0 -> 246 bytes src/sprites/archimate/deliverable-filled.png | Bin 0 -> 240 bytes src/sprites/archimate/driver-filled.png | Bin 0 -> 306 bytes src/sprites/archimate/gap-filled.png | Bin 0 -> 263 bytes src/sprites/archimate/goal-filled.png | Bin 0 -> 298 bytes src/sprites/archimate/principle-filled.png | Bin 0 -> 233 bytes src/sprites/archimate/representation.png | Bin 0 -> 223 bytes src/sprites/archimate/requirement-filled.png | Bin 0 -> 241 bytes src/sprites/archimate/stakeholder-filled.png | Bin 0 -> 251 bytes src/sprites/archimate/workpackage-filled.png | Bin 0 -> 227 bytes stdlib/home.repx | 1 + stdlib/osa-abx.repx | Bin 0 -> 2617 bytes stdlib/osa-dex.repx | Bin 0 -> 40617 bytes 358 files changed, 4638 insertions(+), 2259 deletions(-) delete mode 100644 src/net/sourceforge/plantuml/command/SingleLineCommand.java create mode 100644 src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAccrossCommand.java create mode 100644 src/net/sourceforge/plantuml/command/regex/FoxSignature.java delete mode 100644 src/net/sourceforge/plantuml/posimo/data.txt rename src/net/sourceforge/plantuml/{command/CommandComment.java => svek/ConditionEndStyle.java} (73%) rename src/net/sourceforge/plantuml/{descdiagram/command/CommandNamespaceSeparator.java => tim/EaterIncludeDef.java} (62%) create mode 100644 src/sprites/archimate/assessment-filled.png create mode 100644 src/sprites/archimate/constraint-filled.png create mode 100644 src/sprites/archimate/deliverable-filled.png create mode 100644 src/sprites/archimate/driver-filled.png create mode 100644 src/sprites/archimate/gap-filled.png create mode 100644 src/sprites/archimate/goal-filled.png create mode 100644 src/sprites/archimate/principle-filled.png create mode 100644 src/sprites/archimate/representation.png create mode 100644 src/sprites/archimate/requirement-filled.png create mode 100644 src/sprites/archimate/stakeholder-filled.png create mode 100644 src/sprites/archimate/workpackage-filled.png create mode 100644 stdlib/osa-abx.repx create mode 100644 stdlib/osa-dex.repx diff --git a/pom.xml b/pom.xml index 85aeca85b..16dbc0ebc 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2019.7-SNAPSHOT + 1.2019.8-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/AlignmentParam.java b/src/net/sourceforge/plantuml/AlignmentParam.java index e7a45d6c3..ed1bbdfd0 100644 --- a/src/net/sourceforge/plantuml/AlignmentParam.java +++ b/src/net/sourceforge/plantuml/AlignmentParam.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; public enum AlignmentParam { arrowMessageAlignment(HorizontalAlignment.LEFT), + stateMessageAlignment(HorizontalAlignment.CENTER), sequenceMessageAlignment(HorizontalAlignment.LEFT), sequenceMessageTextAlignment(HorizontalAlignment.LEFT), sequenceReferenceAlignment(HorizontalAlignment.CENTER), diff --git a/src/net/sourceforge/plantuml/BlockUml.java b/src/net/sourceforge/plantuml/BlockUml.java index 73102e17b..9b448360a 100644 --- a/src/net/sourceforge/plantuml/BlockUml.java +++ b/src/net/sourceforge/plantuml/BlockUml.java @@ -104,13 +104,14 @@ public class BlockUml { public BlockUml(List strings, Defines defines, ISkinSimple skinParam, PreprocessorModeSet mode) { this.localDefines = defines; this.skinParam = skinParam; - final String s0 = strings.get(0).getStringTrimmed(); + final String s0 = strings.get(0).getTrimmed().getString(); if (StartUtils.startsWithSymbolAnd("start", s0) == false) { throw new IllegalArgumentException(); } if (mode != null && mode.getPreprocessorMode() == PreprocessorMode.V2_NEW_TIM) { this.pmode = mode.getPreprocessorMode(); - final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, mode.getCharset()); + final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, mode.getCharset(), + (DefinitionsContainer) mode); timLoader.load(strings); this.data = timLoader.getResult(); this.debug = timLoader.getDebug(); @@ -201,6 +202,17 @@ public class BlockUml { return Collections.unmodifiableList(data2.subList(1, data2.size() - 1)); } + public List getDefinition2(boolean withHeader) { + final List data2 = new ArrayList(); + for (StringLocated s : debug) { + data2.add(s.getString()); + } + if (withHeader) { + return Collections.unmodifiableList(data2); + } + return Collections.unmodifiableList(data2.subList(1, data2.size() - 1)); + } + public Defines getLocalDefines() { return localDefines; } diff --git a/src/net/sourceforge/plantuml/BlockUmlBuilder.java b/src/net/sourceforge/plantuml/BlockUmlBuilder.java index 6048abe71..c25cb7a33 100644 --- a/src/net/sourceforge/plantuml/BlockUmlBuilder.java +++ b/src/net/sourceforge/plantuml/BlockUmlBuilder.java @@ -139,7 +139,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer { return Collections.unmodifiableSet(usedFiles); } - public List getDefinition(String name) { + public List getDefinition1(String name) { for (BlockUml block : blocks) { if (block.isStartDef(name)) { this.defines.importFrom(block.getLocalDefines()); @@ -149,6 +149,15 @@ public final class BlockUmlBuilder implements DefinitionsContainer { return Collections.emptyList(); } + public List getDefinition2(String name) { + for (BlockUml block : blocks) { + if (block.isStartDef(name)) { + return block.getDefinition2(false); + } + } + return Collections.emptyList(); + } + public PreprocessorMode getPreprocessorMode() { return mode; } diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index ff0f2d8ce..b1b8b0b9c 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -52,6 +52,7 @@ public enum ColorParam { activityEnd(HtmlColorUtils.BLACK), activityBar(HtmlColorUtils.BLACK), swimlaneBorder(HtmlColorUtils.BLACK), + swimlaneTitleBackground(null), usecaseBorder(HtmlColorUtils.MY_RED, ColorType.LINE), usecaseBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), diff --git a/src/net/sourceforge/plantuml/DefinitionsContainer.java b/src/net/sourceforge/plantuml/DefinitionsContainer.java index 5640191a8..0c9517710 100644 --- a/src/net/sourceforge/plantuml/DefinitionsContainer.java +++ b/src/net/sourceforge/plantuml/DefinitionsContainer.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.preproc2.PreprocessorModeSet; public interface DefinitionsContainer extends PreprocessorModeSet { - public List getDefinition(String name); + public List getDefinition1(String name); + public List getDefinition2(String name); } diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 14e5422b1..2dda7edfd 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.SkinParameter; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.UFont; @@ -117,6 +118,8 @@ public interface ISkinParam extends ISkinSimple { public ConditionStyle getConditionStyle(); + public ConditionEndStyle getConditionEndStyle(); + public double minClassWidth(); public boolean sameClassWidth(); diff --git a/src/net/sourceforge/plantuml/LineLocationImpl.java b/src/net/sourceforge/plantuml/LineLocationImpl.java index 9fa9fbde4..f90701dd3 100644 --- a/src/net/sourceforge/plantuml/LineLocationImpl.java +++ b/src/net/sourceforge/plantuml/LineLocationImpl.java @@ -63,13 +63,6 @@ public class LineLocationImpl implements LineLocation { return new LineLocationImpl(desc, parent, position + 1); } - public static LineLocation fromLine(CharSequence cs) { - if (cs instanceof StringLocated) { - return ((StringLocated) cs).getLocation(); - } - return null; - } - public int getPosition() { return position; } diff --git a/src/net/sourceforge/plantuml/Log.java b/src/net/sourceforge/plantuml/Log.java index ad5d3086f..d5172e72d 100644 --- a/src/net/sourceforge/plantuml/Log.java +++ b/src/net/sourceforge/plantuml/Log.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml; - public abstract class Log { private static final long start = System.currentTimeMillis(); @@ -60,7 +59,7 @@ public abstract class Log { // final HealthCheck healthCheck = Performance.getHealthCheck(); // final long cpu = healthCheck.jvmCpuTime() / 1000L / 1000L; // final long dot = healthCheck.dotTime().getSum(); - + final long freeMemory = Runtime.getRuntime().freeMemory(); final long maxMemory = Runtime.getRuntime().maxMemory(); final long totalMemory = Runtime.getRuntime().totalMemory(); @@ -72,19 +71,19 @@ public abstract class Log { sb.append(delta / 1000L); sb.append("."); sb.append(String.format("%03d", delta % 1000L)); -// if (cpu != -1) { -// sb.append(" - "); -// sb.append(cpu / 1000L); -// sb.append("."); -// sb.append(String.format("%03d", cpu % 1000L)); -// } -// sb.append(" - "); -// sb.append(dot / 1000L); -// sb.append("."); -// sb.append(String.format("%03d", dot % 1000L)); -// sb.append("("); -// sb.append(healthCheck.dotTime().getNb()); -// sb.append(")"); + // if (cpu != -1) { + // sb.append(" - "); + // sb.append(cpu / 1000L); + // sb.append("."); + // sb.append(String.format("%03d", cpu % 1000L)); + // } + // sb.append(" - "); + // sb.append(dot / 1000L); + // sb.append("."); + // sb.append(String.format("%03d", dot % 1000L)); + // sb.append("("); + // sb.append(healthCheck.dotTime().getNb()); + // sb.append(")"); sb.append(" - "); final long total = totalMemory / 1024 / 1024; final long free = freeMemory / 1024 / 1024; diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 03de86db0..62d7e1774 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3; import net.sourceforge.plantuml.api.PSystemFactory; import net.sourceforge.plantuml.bpm.BpmDiagramFactory; import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory; +import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.DiagramType; @@ -135,6 +136,8 @@ public class PSystemBuilder { if (result != null && OptionFlags.getInstance().isEnableStats()) { StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass()); } + Log.info("Compilation duration " + (System.currentTimeMillis() - now)); + RegexConcat.printCacheInfo(); } } @@ -144,12 +147,12 @@ public class PSystemBuilder { factories.add(new PSystemWelcomeFactory()); factories.add(new PSystemColorsFactory()); factories.add(new SequenceDiagramFactory(skinParam)); - factories.add(new ClassDiagramFactory()); - factories.add(new ActivityDiagramFactory()); - factories.add(new DescriptionDiagramFactory()); - factories.add(new StateDiagramFactory()); - factories.add(new ActivityDiagramFactory3()); - factories.add(new CompositeDiagramFactory()); + factories.add(new ClassDiagramFactory(skinParam)); + factories.add(new ActivityDiagramFactory(skinParam)); + factories.add(new DescriptionDiagramFactory(skinParam)); + factories.add(new StateDiagramFactory(skinParam)); + factories.add(new ActivityDiagramFactory3(skinParam)); + factories.add(new CompositeDiagramFactory(skinParam)); factories.add(new BpmDiagramFactory(DiagramType.BPM)); // factories.add(new PostIdDiagramFactory()); factories.add(new PSystemLicenseFactory()); diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 05f17f7f3..03c25594a 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -337,12 +337,12 @@ public class Run { private static void managePattern() { printPattern(new SequenceDiagramFactory(null)); - printPattern(new ClassDiagramFactory()); - printPattern(new ActivityDiagramFactory()); - printPattern(new DescriptionDiagramFactory()); + printPattern(new ClassDiagramFactory(null)); + printPattern(new ActivityDiagramFactory(null)); + printPattern(new DescriptionDiagramFactory(null)); // printPattern(new ComponentDiagramFactory()); - printPattern(new StateDiagramFactory()); - printPattern(new ObjectDiagramFactory()); + printPattern(new StateDiagramFactory(null)); + printPattern(new ObjectDiagramFactory(null)); } private static void printPattern(UmlDiagramFactory factory) { @@ -387,6 +387,7 @@ public class Run { final List files = new ArrayList(); for (String s : option.getResult()) { if (option.isDecodeurl()) { + error.goOk(); final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder(); System.out.println("@startuml"); System.out.println(transcoder.decode(s)); @@ -465,6 +466,7 @@ public class Run { System.out.println(f); // new Metadata().readAndDisplayMetadata(f); System.out.println(); + error.goOk(); final String data = new MetadataTag(f, "plantuml").getData(); // File file = new File("tmp.txt"); // PrintWriter pw = new PrintWriter(file, "UTF-8"); @@ -486,12 +488,14 @@ public class Run { sourceFileReader.setCheckMetadata(option.isCheckMetadata()); if (option.isComputeurl()) { + error.goOk(); for (BlockUml s : sourceFileReader.getBlocks()) { System.out.println(s.getEncodedUrl()); } return; } if (option.isCheckOnly()) { + error.goOk(); final boolean hasError = sourceFileReader.hasError(); if (hasError) { error.goWithError(); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index c55465dea..9036e1bca 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.SkinParameter; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.ColorMapper; @@ -415,6 +416,7 @@ public class SkinParam implements ISkinParam { result.add("Style"); result.add("SequenceParticipant"); result.add("ConditionStyle"); + result.add("ConditionEndStyle"); result.add("SameClassWidth"); result.add("HyperlinkUnderline"); result.add("Padding"); @@ -535,6 +537,8 @@ public class SkinParam implements ISkinParam { final HorizontalAlignment result = HorizontalAlignment.fromString(value); if (result == null && param == AlignmentParam.noteTextAlignment) { return getDefaultTextAlignment(HorizontalAlignment.LEFT); + } else if (result == null && param == AlignmentParam.stateMessageAlignment) { + return getDefaultTextAlignment(HorizontalAlignment.CENTER); } else if (result == null) { return param.getDefaultValue(); } @@ -847,6 +851,15 @@ public class SkinParam implements ISkinParam { return p; } + public ConditionEndStyle getConditionEndStyle() { + final String value = getValue("conditionEndStyle"); + final ConditionEndStyle p = ConditionEndStyle.fromString(value); + if (p == null) { + return ConditionEndStyle.DIAMOND; + } + return p; + } + public double minClassWidth() { final String value = getValue("minclasswidth"); if (value != null && value.matches("\\d+")) { diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index c09d5adfe..535ea752e 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.SkinParameter; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.ColorMapper; @@ -178,6 +179,10 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getConditionStyle(); } + public ConditionEndStyle getConditionEndStyle() { + return skinParam.getConditionEndStyle(); + } + public double minClassWidth() { return skinParam.minClassWidth(); } diff --git a/src/net/sourceforge/plantuml/StringLocated.java b/src/net/sourceforge/plantuml/StringLocated.java index ad60720be..e0949efc4 100644 --- a/src/net/sourceforge/plantuml/StringLocated.java +++ b/src/net/sourceforge/plantuml/StringLocated.java @@ -35,7 +35,9 @@ */ package net.sourceforge.plantuml; -public class StringLocated { +import net.sourceforge.plantuml.command.regex.FoxSignature; + +final public class StringLocated { private final String s; private final LineLocation location; @@ -68,8 +70,15 @@ public class StringLocated { this.getPreprocessorError()); } - public String getStringTrimmed() { - return StringUtils.trin(this.getString()); + private StringLocated trimmed; + + public StringLocated getTrimmed() { + if (trimmed == null) { + this.trimmed = new StringLocated(StringUtils.trin(this.getString()), location, preprocessorError); + trimmed.fox = this.fox; + trimmed.trimmed = trimmed; + } + return trimmed; } public StringLocated removeInnerComment() { @@ -114,4 +123,12 @@ public class StringLocated { return preprocessorError; } + private long fox = -1; + + public long getFoxSignature() { + if (fox == -1) { + fox = FoxSignature.getFoxSignature(getString()); + } + return fox; + } } diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index 24e0996e4..f439d59ca 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -460,9 +460,6 @@ public class StringUtils { } public static String trinNoTrace(CharSequence s) { -// if (s instanceof CharSequence2) { -// return ((CharSequence2) s).getString().trim(); -// } return s.toString().trim(); } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 0da77ac8f..e177a673c 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -451,5 +451,9 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot } return i; } + + public void setHideEmptyDescription(boolean hideEmptyDescription) { + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java index 65224ce9c..2bf836ef3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java @@ -39,6 +39,7 @@ import java.util.Arrays; import java.util.List; import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.cucadiagram.Code; @@ -58,6 +59,10 @@ public class ActivityDiagram extends CucaDiagram { private IEntity lastEntityBrancheConsulted; private ConditionalContext currentContext; + public ActivityDiagram(ISkinSimple skinParam) { + super(skinParam); + } + public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) { return getOrCreateLeafDefault(code, type, symbol); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java index b3dc2c628..2c5146cb7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.activitydiagram; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.activitydiagram.command.CommandElse; import net.sourceforge.plantuml.activitydiagram.command.CommandEndPartition; import net.sourceforge.plantuml.activitydiagram.command.CommandEndif; @@ -55,9 +56,16 @@ import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand; public class ActivityDiagramFactory extends UmlDiagramFactory { + private final ISkinSimple skinParam; + + public ActivityDiagramFactory(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + + @Override public ActivityDiagram createEmptyDiagram() { - return new ActivityDiagram(); + return new ActivityDiagram(skinParam); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java index a7d1812df..72ef72d7b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java @@ -35,21 +35,31 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.IEntity; -public class CommandElse extends SingleLineCommand { +public class CommandElse extends SingleLineCommand2 { public CommandElse() { - super("(?i)^else$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandElse.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("else"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ActivityDiagram system, List arg) { + protected CommandExecutionResult executeArg(ActivityDiagram system, LineLocation location, RegexResult arg) { if (system.getLastEntityConsulted() == null) { return CommandExecutionResult.error("No if for this else"); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java index 210824fda..b45e12670 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java @@ -35,21 +35,36 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.IEntity; -public class CommandEndPartition extends SingleLineCommand { +public class CommandEndPartition extends SingleLineCommand2 { public CommandEndPartition() { - super("(?i)^(end[%s]?partition|\\})$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndPartition.class.getName(), RegexLeaf.start(), // + new RegexOr( // + new RegexConcat( // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("partition")), // + new RegexLeaf("\\}")), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, List arg) { + protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { final IEntity currentPackage = diagram.getCurrentGroup(); if (currentPackage == null) { return CommandExecutionResult.error("No partition defined"); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java index 434a9fdb5..bcf4c4439 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java @@ -35,20 +35,32 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; -public class CommandEndif extends SingleLineCommand { +public class CommandEndif extends SingleLineCommand2 { public CommandEndif() { - super("(?i)^end[%s]?if$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndif.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("if"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, List arg) { + protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { if (diagram.getLastEntityConsulted() == null) { return CommandExecutionResult.error("No if for this endif"); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index 5acadb3ba..8db8a86f6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; @@ -59,23 +60,25 @@ public class CommandIf extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandIf.class.getName(), RegexLeaf.start(), // new RegexOptional(// new RegexOr("FIRST", // new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), // new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// new RegexLeaf("IF1", "if[%s]*[%g]([^%g]*)[%g][%s]*(?:as[%s]+([\\p{L}0-9_.]+)[%s]+)?"), // - new RegexLeaf("IF2", "if[%s]+(.+?)[%s]*")), // - new RegexLeaf("(?:then)?$")); + new RegexLeaf("IF2", "if[%s]+(.+?)")), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("then")), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java index fd816f20c..67a5e0710 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java @@ -35,25 +35,36 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.EntityUtils; -public class CommandInnerConcurrent extends SingleLineCommand { +public class CommandInnerConcurrent extends SingleLineCommand2 { public CommandInnerConcurrent() { - super("(?i)^--\\s*(.*)$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandInnerConcurrent.class.getName(), RegexLeaf.start(), // + new RegexLeaf("--"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("NAME", "(.*)"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, List arg) { + protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { if (EntityUtils.groupRoot(diagram.getCurrentGroup())) { return CommandExecutionResult.error("No inner activity"); } - diagram.concurrentActivity(arg.get(0)); + diagram.concurrentActivity(arg.get("NAME", 0)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 83b331c6e..4e5381ad6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; @@ -71,19 +72,19 @@ public class CommandLinkActivity extends SingleLineCommand2 { super(getRegexConcat()); } - private static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandLinkActivity.class.getName(), RegexLeaf.start(), // new RegexOptional(// new RegexOr("FIRST", // new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), // new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // ColorParser.exp2(), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // new RegexLeaf("ARROW_BODY1", "([-.]+)"), // @@ -92,9 +93,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr("FIRST2", // new RegexLeaf("STAR2", "(\\(\\*(top|\\d+)?\\))"), // new RegexLeaf("OPENBRACKET2", "(\\{)"), // @@ -102,13 +103,18 @@ public class CommandLinkActivity extends SingleLineCommand2 { new RegexLeaf("BAR2", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?"), // new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("PARTITION2", "(?:in[%s]+([%g][^%g]+[%g]|\\S+))?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("in"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("PARTITION2", "([%g][^%g]+[%g]|\\S+)") // + )), // + RegexLeaf.spaceZeroOrMore(), // ColorParser.exp3(), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 041cb0ad8..9f5889bd6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -80,19 +81,19 @@ public class CommandLinkLongActivity extends CommandMultilines2 return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$"; } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandLinkLongActivity.class.getName(), RegexLeaf.start(), // new RegexOptional(// new RegexOr("FIRST", // new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), // new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("BACKCOLOR", "(#\\w+)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // new RegexLeaf("ARROW_BODY1", "([-.]+)"), // @@ -101,17 +102,17 @@ public class CommandLinkLongActivity extends CommandMultilines2 new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("DESC", "[%g]([^%g]*?)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) { lines = lines.trim(false); - final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed()); + final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true); if (entity1 == null) { @@ -121,9 +122,10 @@ public class CommandLinkLongActivity extends CommandMultilines2 if (line0.get("STEREOTYPE", 0) != null) { entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0))); } - if (line0.get("BACKCOLOR", 0) != null) { + final String stringColor = line0.get("BACKCOLOR", 0); + if (stringColor != null) { entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(line0.get("BACKCOLOR", 0))); + .getColorIfValid(stringColor)); } final StringBuilder sb = new StringBuilder(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index 16a80b577..3a59f2961 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; @@ -60,17 +61,18 @@ public class CommandPartition extends SingleLineCommand2 { super(getRegexConcat()); } - private static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandPartition.class.getName(), RegexLeaf.start(), // new RegexLeaf("partition"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// color().getRegex(), // new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), // - new RegexLeaf("[%s]*\\{?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("\\{?"), + RegexLeaf.end()); } private static ColorParser color() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index fd37e2388..250a262f7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagramType; @@ -74,6 +75,11 @@ public class ActivityDiagram3 extends UmlDiagram { private SwimlaneStrategy swimlaneStrategy; private final SwimlanesC swinlanes = new SwimlanesC(getSkinParam(), getPragma()); + + public ActivityDiagram3(ISkinSimple skinParam) { + super(skinParam); + } + private void manageSwimlaneStrategy() { if (swimlaneStrategy == null) { @@ -319,10 +325,10 @@ public class ActivityDiagram3 extends UmlDiagram { return CommandExecutionResult.error("Cannot find switch"); } - public void startIf(Display test, Display whenThen, HtmlColor color) { + public void startIf(Display test, Display whenThen, HtmlColor color, Url url) { manageSwimlaneStrategy(); final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test, - whenThen, nextLinkRenderer(), color, getSkinParam()); + whenThen, nextLinkRenderer(), color, getSkinParam(), url); current().add(instructionIf); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(instructionIf); @@ -379,7 +385,7 @@ public class ActivityDiagram3 extends UmlDiagram { if (current() instanceof InstructionRepeat) { final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel); - instructionRepeat.setTest(label, yes, out, nextLinkRenderer(), back); + instructionRepeat.setTest(label, yes, out, nextLinkRenderer(), back, swinlanes.getCurrentSwimlane()); setCurrent(instructionRepeat.getParent()); this.setNextLinkRendererInternal(LinkRendering.none()); return CommandExecutionResult.ok(); @@ -393,7 +399,7 @@ public class ActivityDiagram3 extends UmlDiagram { if (current() instanceof InstructionRepeat) { final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); // final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel); - instructionRepeat.setBackward(label); + instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane()); // setCurrent(instructionRepeat.getParent()); // this.setNextLinkRendererInternal(LinkRendering.none()); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java index 87d993e07..2a83e2060 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.activitydiagram3.command.CommandActivity3; import net.sourceforge.plantuml.activitydiagram3.command.CommandActivityLegacy1; import net.sourceforge.plantuml.activitydiagram3.command.CommandActivityLong3; @@ -89,6 +90,12 @@ import net.sourceforge.plantuml.command.UmlDiagramFactory; public class ActivityDiagramFactory3 extends UmlDiagramFactory { + private final ISkinSimple skinParam; + + public ActivityDiagramFactory3(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + @Override protected List createCommands() { @@ -157,7 +164,7 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory { @Override public ActivityDiagram3 createEmptyDiagram() { - return new ActivityDiagram3(); + return new ActivityDiagram3(skinParam); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index 67cb1c66e..fc850eb0b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.Set; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileDecorateWelding; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; @@ -60,6 +61,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC private Branch elseBranch; private boolean endifCalled = false; private final ISkinParam skinParam; + private final Url url; private final Instruction parent; @@ -82,7 +84,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC } public InstructionIf(Swimlane swimlane, Instruction parent, Display labelTest, Display whenThen, - LinkRendering inlinkRendering, HtmlColor color, ISkinParam skinParam) { + LinkRendering inlinkRendering, HtmlColor color, ISkinParam skinParam, Url url) { + this.url = url; this.parent = parent; this.skinParam = skinParam; this.topInlinkRendering = inlinkRendering; @@ -106,7 +109,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL); } elseBranch.updateFtile(factory); - Ftile result = factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering); + Ftile result = factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering, url); if (getPositionedNotes().size() > 0) { result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index ff2a18dd7..ef21f3b56 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -54,6 +54,7 @@ public class InstructionRepeat implements Instruction { private final Instruction parent; private final LinkRendering nextLinkRenderer; private final Swimlane swimlane; + private Swimlane swimlaneOut; private final HtmlColor color; private boolean killed = false; @@ -65,12 +66,11 @@ public class InstructionRepeat implements Instruction { private boolean testCalled = false; private LinkRendering endRepeatLinkRendering = LinkRendering.none(); private LinkRendering backRepeatLinkRendering = LinkRendering.none(); - + public boolean containsBreak() { return repeatList.containsBreak(); } - public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer, HtmlColor color, Display startLabel) { this.startLabel = startLabel; @@ -90,8 +90,9 @@ public class InstructionRepeat implements Instruction { return false; } - public void setBackward(Display label) { + public void setBackward(Display label, Swimlane swimlaneOut) { this.backward = label; + this.swimlaneOut = swimlaneOut; } public void add(Instruction ins) { @@ -101,7 +102,7 @@ public class InstructionRepeat implements Instruction { public Ftile createFtile(FtileFactory factory) { final Ftile back = Display.isNull(backward) ? null : factory.activity(backward, swimlane, BoxStyle.PLAIN, Colors.empty()); - final Ftile result = factory.repeat(swimlane, repeatList.getSwimlaneOut(), startLabel, + final Ftile result = factory.repeat(swimlane, swimlaneOut, startLabel, factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering), test, yes, out, color, backRepeatLinkRendering, back, isLastOfTheParent()); if (killed) { @@ -115,7 +116,8 @@ public class InstructionRepeat implements Instruction { } public void setTest(Display test, Display yes, Display out, LinkRendering endRepeatLinkRendering, - LinkRendering backRepeatLinkRendering) { + LinkRendering backRepeatLinkRendering, Swimlane swimlaneOut) { + this.swimlaneOut = swimlaneOut; this.test = test; this.yes = yes; this.out = out; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index da784205e..88e2f04b5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -59,15 +60,15 @@ public class CommandActivity3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandActivity3.class.getName(), RegexLeaf.start(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // color().getRegex(), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf(":"), // new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("STYLE", ENDING_GROUP), // - new RegexLeaf("$")); + RegexLeaf.end()); } private static ColorParser color() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java index a39fa2c00..fdf22a979 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -52,11 +53,11 @@ public class CommandActivityLegacy1 extends SingleLineCommand2 super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandActivityLegacy1.class.getName(), RegexLeaf.start(), // new RegexLeaf("-"), // new RegexLeaf("LABEL", "(.*)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java index 62fb98ea3..67b7288f0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -63,17 +64,17 @@ public class CommandActivityLong3 extends CommandMultilines2 { return ColorParser.simpleColor(ColorType.BACK); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandActivityLong3.class.getName(), RegexLeaf.start(), // color().getRegex(), // new RegexLeaf(":"), // new RegexLeaf("DATA", "(.*)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) { lines = lines.removeEmptyColumns(); - final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed()); + final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)); final BoxStyle style = BoxStyle.fromChar(lines.getLastChar()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java index d9d9217fb..19f893308 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; @@ -53,16 +54,16 @@ public class CommandArrow3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandArrow3.class.getName(), RegexLeaf.start(), // new RegexOr(// new RegexLeaf("->"), // new RegexLeaf("COLOR", CommandLinkElement.STYLE_COLORS_MULTIPLES)), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// new RegexLeaf("LABEL", "(.*);"), // new RegexLeaf("")), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java index 3d9649192..3c7397c1c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; @@ -60,19 +61,19 @@ public class CommandArrowLong3 extends CommandMultilines2 { return "^(.*);$"; } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandArrowLong3.class.getName(), RegexLeaf.start(), // new RegexOr(// new RegexLeaf("->"), // new RegexLeaf("COLOR", CommandLinkElement.STYLE_COLORS_MULTIPLES)), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("LABEL", "(.*)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) { lines = lines.removeEmptyColumns(); - final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed()); + final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)); // diagram.setColorNextArrow(HtmlColorAndStyle.fromColor(color)); final String colorString = line0.get("COLOR", 0); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java index 434e5bdfa..42bb41326 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -50,13 +51,14 @@ public class CommandBackward3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandBackward3.class.getName(), RegexLeaf.start(), // new RegexLeaf("backward"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf(":"), // new RegexLeaf("LABEL", "(.*)"), // - new RegexLeaf(";$")); + new RegexLeaf(";"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBreak.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBreak.java index c09744f93..1bdf9fb08 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBreak.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBreak.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,12 @@ public class CommandBreak extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandBreak.class.getName(), // + RegexLeaf.start(), // new RegexLeaf("break"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCase.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCase.java index 0c79e6479..c9026392a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCase.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCase.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -50,13 +51,13 @@ public class CommandCase extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandCase.class.getName(), RegexLeaf.start(), // new RegexLeaf("case"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java index 38a8fb88c..ade877b10 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandCircleSpot3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandCircleSpot3.class.getName(), RegexLeaf.start(), // new RegexLeaf("SPOT", "\\((\\S)\\)"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java index 6cedc53d2..5ab2e5c4c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; @@ -50,12 +52,16 @@ public class CommandElse3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandElse3.class.getName(), RegexLeaf.start(), // new RegexLeaf("else"), // - new RegexLeaf("WHEN", "(?:[%s]*(?:\\(([^()]*)\\))?)?"), // - new RegexLeaf(";?$")); + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("WHEN", "(?:\\(([^()]*)\\))?") // + )), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java index 9f1415296..540dc7cf2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -52,18 +54,26 @@ public class CommandElseIf2 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandElseIf2.class.getName(), RegexLeaf.start(), // ColorParser.exp4(), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("INLABEL", "(?:\\((.+?)\\))?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("else[%s]*if"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("INLABEL", "\\((.+?)\\)")), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("else"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("if"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("WHEN", "(?:then[%s]*(?:\\((.+?)\\))?)?"), // - new RegexLeaf(";?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("then"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("WHEN", "\\((.+?)\\)")) // + )), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java index fe14df79c..17a8880c9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -50,12 +51,15 @@ public class CommandElseLegacy1 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("else[%s]when"), // - new RegexLeaf("WHEN", "[%s]+(.*)"), // - new RegexLeaf(";?$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandElseLegacy1.class.getName(), RegexLeaf.start(), // + new RegexLeaf("else"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("when"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("WHEN", "(.*)"), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEnd3.java index c52410dba..2d7b8f037 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEnd3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandEnd3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEnd3.class.getName(), RegexLeaf.start(), // new RegexLeaf("end"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java index 6f318e61e..30c1b9149 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java @@ -35,24 +35,34 @@ */ package net.sourceforge.plantuml.activitydiagram3.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; -public class CommandEndPartition3 extends SingleLineCommand { +public class CommandEndPartition3 extends SingleLineCommand2 { public CommandEndPartition3() { - super("(?i)^(\\})$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndPartition3.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("(\\})"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, List arg) { -// final IEntity currentPackage = diagram.getCurrentGroup(); -// if (currentPackage == null) { -// return CommandExecutionResult.error("No partition defined"); -// } + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + // final IEntity currentPackage = diagram.getCurrentGroup(); + // if (currentPackage == null) { + // return CommandExecutionResult.error("No partition defined"); + // } return diagram.endGroup(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndSwitch.java index 137d49e3b..402f90b1b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndSwitch.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandEndSwitch extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndSwitch.class.getName(), RegexLeaf.start(), // new RegexLeaf("endswitch"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java index 7453363a5..dd1b8c985 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,12 @@ public class CommandEndif3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndif3.class.getName(), // + RegexLeaf.start(), // new RegexLeaf("endif"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java index 7b2c3e0bc..9228f141d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandFork3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandFork3.class.getName(), RegexLeaf.start(), // new RegexLeaf("fork"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java index 25d180806..231a517d8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,13 @@ public class CommandForkAgain3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("fork[%s]?again"), // - new RegexLeaf(";?$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandForkAgain3.class.getName(), RegexLeaf.start(), // + new RegexLeaf("fork"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("again"), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java index 9f818abd8..47c4c883c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java @@ -40,8 +40,10 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.activitydiagram3.ForkStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; public class CommandForkEnd3 extends SingleLineCommand2 { @@ -50,13 +52,30 @@ public class CommandForkEnd3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("STYLE", "(end[%s]?fork|fork[%s]?end|end[%s]?merge)"), // - new RegexLeaf("\\s*"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandForkEnd3.class.getName(), // + RegexLeaf.start(), // + new RegexOr("STYLE", // + new RegexConcat( // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("fork") // + ), // + new RegexConcat( // + new RegexLeaf("fork"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("end") // + ), // + new RegexConcat( // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("merge") // + ) // + ), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("LABEL", "(\\{.+\\})?"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java index 97e8f3253..fe27174ac 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,13 +50,13 @@ public class CommandGoto extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandGoto.class.getName(), RegexLeaf.start(), // new RegexLeaf("goto"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), // new RegexLeaf(";?"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java index ae1c5dfce..f0eab11c2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -51,12 +52,13 @@ public class CommandGroup3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandGroup3.class.getName(), RegexLeaf.start(), // new RegexLeaf("group"), // - new RegexLeaf("\\s*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("NAME", "(.*)"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java index d40b1194e..9aa1ddd7b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,10 +50,11 @@ public class CommandGroupEnd3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandGroupEnd3.class.getName(), RegexLeaf.start(), // new RegexLeaf("(end ?group|group ?end)"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java index 932b12089..70a459732 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java @@ -36,11 +36,16 @@ package net.sourceforge.plantuml.activitydiagram3.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.UrlBuilder.ModeUrl; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -52,15 +57,22 @@ public class CommandIf2 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandIf2.class.getName(), RegexLeaf.start(), // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // ColorParser.exp4(), // new RegexLeaf("if"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("WHEN", "(?:then[%s]*(?:\\((.+?)\\))?)?"), // - new RegexLeaf(";?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("then"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("WHEN", "\\((.+?)\\)")) // + )), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override @@ -72,7 +84,15 @@ public class CommandIf2 extends SingleLineCommand2 { test = null; } - diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color); + final Url url; + if (arg.get("URL", 0) == null) { + url = null; + } else { + final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT); + url = urlBuilder.getUrl(arg.get("URL", 0)); + } + + diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, url); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java index 348bf0cfb..e0281dd3c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -52,16 +53,21 @@ public class CommandIf4 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandIf4.class.getName(), RegexLeaf.start(), // ColorParser.exp4(), // new RegexLeaf("if"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*(is|equals?)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(is|equals?)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("WHEN", "\\((.+?)\\)"), // - new RegexLeaf("[%s]*then[%s]*"), // - new RegexLeaf(";?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("then"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override @@ -72,7 +78,7 @@ public class CommandIf4 extends SingleLineCommand2 { if (test.length() == 0) { test = null; } - diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color); + diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java index ddf24a2a2..12f3b64fe 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -50,20 +51,25 @@ public class CommandIfLegacy1 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandIfLegacy1.class.getName(), RegexLeaf.start(), // new RegexLeaf("if"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.+?)\\)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("WHEN", "then[%s]when[%s]+(.*)"), // - new RegexLeaf(";?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("then"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("when"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("WHEN", "(.*)"), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - diagram.startIf(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("WHEN", 0)), null); + diagram.startIf(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("WHEN", 0)), null, null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java index caeca28dc..a104e2674 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandKill3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandKill3.class.getName(), // + RegexLeaf.start(), // new RegexLeaf("kill|detach"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java index 0f9696bb9..a26b5d038 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,13 +50,13 @@ public class CommandLabel extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandLabel.class.getName(), RegexLeaf.start(), // new RegexLeaf("label"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), // new RegexLeaf(";?"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java index bddc6147f..c2f364433 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -51,12 +52,13 @@ public class CommandLink3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // - new RegexLeaf("link[%s]+"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandLink3.class.getName(), RegexLeaf.start(), // + new RegexLeaf("link"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("COLOR", "(#\\w+)"), // new RegexLeaf(";?"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java index 584f92f83..4dbc8e99a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -50,11 +51,11 @@ public class CommandNolink extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandNolink.class.getName(), RegexLeaf.start(), // new RegexLeaf("nolink"), // new RegexLeaf(";?"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java index 35f9e06da..6a32573e4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -54,21 +55,23 @@ public class CommandNote3 extends SingleLineCommand2 { public CommandNote3() { super(getRegexConcat()); } - + private static ColorParser color() { return ColorParser.simpleColor(ColorType.BACK); } - - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandNote3.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", "(note|floating note)"), // - new RegexLeaf("POSITION", "[%s]*(left|right)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("POSITION", "(left|right)?"), // + RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - new RegexLeaf("[%s]*:[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf(":"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("NOTE", "(.*)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java index ccc8cd094..7ec7f946c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -55,19 +56,18 @@ public class CommandNoteLong3 extends CommandMultilines2 { public CommandNoteLong3() { super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); } - + private static ColorParser color() { return ColorParser.simpleColor(ColorType.BACK); } - public String getPatternEnd() { return "(?i)^end[%s]?note$"; } protected CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) { // final List in = StringUtils.removeEmptyColumns2(lines.subList(1, lines.size() - 1)); - final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getStringTrimmed()); + final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); final NotePosition position = NotePosition.defaultLeft(line0.get("POSITION", 0)); @@ -77,13 +77,13 @@ public class CommandNoteLong3 extends CommandMultilines2 { return diagram.addNote(note, position, type, colors); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandNoteLong3.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", "(note|floating note)"), // - new RegexLeaf("POSITION", "[%s]*(left|right)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("POSITION", "(left|right)?"), // + RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - new RegexLeaf("$")); + RegexLeaf.end()); } - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index bb6289686..aa4478fe4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; @@ -60,23 +61,24 @@ public class CommandPartition3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandPartition3.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", "(partition|package|rectangle|card)"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexOptional(// new RegexConcat( // color("BACK1").getRegex(),// - new RegexLeaf("[%s]+"))), // + RegexLeaf.spaceOneOrMore())), // new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), // new RegexOptional(// new RegexConcat( // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // color("BACK2").getRegex())), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("\\{?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("\\{?"), // + RegexLeaf.end()); } private USymbol getUSymbol(String type) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java index 0bb76c32d..1f9dfff74 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -52,13 +54,14 @@ public class CommandRepeat3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandRepeat3.class.getName(), RegexLeaf.start(), // ColorParser.exp4(), // new RegexLeaf("repeat"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("LABEL", "(?::(.*?))?"), // - new RegexLeaf(";?$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("LABEL", ":(.*?)")), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java index 53f37fe99..2f9fccbc2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; @@ -54,37 +55,48 @@ public class CommandRepeatWhile3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("repeat[%s]?while"), // - new RegexLeaf("[%s]*"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandRepeatWhile3.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("repeat"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("while"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// new RegexConcat(new RegexLeaf("TEST3", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*(is|equals?)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(is|equals?)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("WHEN3", "\\((.+?)\\)"), // - new RegexLeaf("[%s]*(not)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(not)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("OUT3", "\\((.+?)\\)")), // new RegexConcat(new RegexLeaf("TEST4", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*(not)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(not)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("OUT4", "\\((.+?)\\)")), // new RegexConcat(new RegexLeaf("TEST2", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*(is|equals?)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(is|equals?)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("WHEN2", "\\((.+?)\\)") // ), // - new RegexLeaf("TEST1", "(?:\\((.*)\\))?") // + new RegexOptional(new RegexLeaf("TEST1", "\\((.*)\\)")) // ), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOptional(new RegexConcat( // new RegexOr(// new RegexLeaf("->"), // new RegexLeaf("COLOR", CommandLinkElement.STYLE_COLORS_MULTIPLES)), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("")) // )), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java index 70bf3a596..285eeff46 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines3; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -62,16 +63,19 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSplit3.class.getName(), // + RegexLeaf.start(), // new RegexLeaf("split"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java index af76eb168..2d6de0a2e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,13 @@ public class CommandSplitAgain3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("split[%s]?again"), // - new RegexLeaf(";?$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSplitAgain3.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("split"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("again"), // + new RegexLeaf(";?"), RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java index 44bfc09a7..49b696509 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; public class CommandSplitEnd3 extends SingleLineCommand2 { @@ -49,11 +51,22 @@ public class CommandSplitEnd3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // - new RegexLeaf("(end[%s]?split|split[%s]?end)"), // - new RegexLeaf(";?$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSplitEnd3.class.getName(), RegexLeaf.start(), // + new RegexOr( // + new RegexConcat( // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("split") // + ), // + new RegexConcat( // + new RegexLeaf("split"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("end") // + ) // + ), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java index eeaf29a34..b9633caff 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandStart3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandStart3.class.getName(), RegexLeaf.start(), // new RegexLeaf("start"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java index 7f8c33a3d..4997d69f0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandStop3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandStop3.class.getName(), RegexLeaf.start(), // new RegexLeaf("stop"), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java index 9bfb2c1ff..15b580bbc 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -52,14 +53,14 @@ public class CommandSwimlane extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSwimlane.class.getName(), RegexLeaf.start(), // new RegexLeaf("\\|"), // ColorParser.exp6(), // new RegexLeaf("SWIMLANE", "([^|]+)"), // new RegexLeaf("\\|"), // new RegexLeaf("LABEL", "([^|]+)?"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java index 289f71edb..5a1ba1462 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -52,14 +54,21 @@ public class CommandSwimlane2 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // - new RegexLeaf("swimlane[%s]+"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSwimlane2.class.getName(), RegexLeaf.start(), // + new RegexLeaf("swimlane"), // + RegexLeaf.spaceOneOrMore(), // ColorParser.exp7(), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("SWIMLANE", "([^|]+)"), // - new RegexLeaf("LABEL", "(?:[%s]+as[%s]+([^|]+))?"), // - new RegexLeaf("$")); + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("as"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("LABEL", "([^|]+)") // + )), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java index 9fa90f023..2fe67d5af 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -52,14 +53,14 @@ public class CommandSwitch extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSwitch.class.getName(), RegexLeaf.start(), // ColorParser.exp4(), // new RegexLeaf("switch"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TEST", "\\((.*?)\\)"), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java index ab454f1b5..7d7426f01 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; @@ -53,16 +54,19 @@ public class CommandWhile3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(// - new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandWhile3.class.getName(), RegexLeaf.start(), // ColorParser.exp4(), // new RegexLeaf("while"), // - new RegexLeaf("TEST", "[%s]*\\((.*?)\\)"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("TEST", "\\((.*?)\\)"), // new RegexOptional(new RegexConcat(// - new RegexLeaf("[%s]*(is|equals?)[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("(is|equals?)"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("YES", "\\((.+?)\\)"))), // - new RegexLeaf(";?$")); + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java index e021634ba..146b3b76c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java @@ -39,8 +39,11 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; +import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; @@ -50,11 +53,24 @@ public class CommandWhileEnd3 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // - new RegexLeaf("(end[%s]?while|while[%s]?end)"), // - new RegexLeaf("OUT", "[%s]*(?:\\((.+?)\\))?"), // - new RegexLeaf(";?$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandWhileEnd3.class.getName(), RegexLeaf.start(), // + new RegexOr( // + new RegexConcat( // + new RegexLeaf("end"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("while") // + ), // + new RegexConcat( // + new RegexLeaf("while"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("end") // + ) // + ), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf("OUT", "\\((.+?)\\)")), // + new RegexLeaf(";?"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index a25828c02..8683a4a74 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -85,7 +85,7 @@ public interface FtileFactory { LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut); public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering); + LinkRendering topInlinkRendering, Url url); public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Display labelTest); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 05fe465e4..fcbf080c9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -159,8 +159,8 @@ public class FtileFactoryDelegator implements FtileFactory { } public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering) { - return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering); + LinkRendering topInlinkRendering, Url url) { + return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering, url); } public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java index 6c7bdf894..7e2f714d1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java @@ -76,7 +76,7 @@ public class FtileGeometry extends Dimension2D { } return new Point2D.Double(0, (inY + outY) / 2); } - + public Point2D getPointOut() { if (outY == Double.MIN_NORMAL) { throw new UnsupportedOperationException(); @@ -84,8 +84,6 @@ public class FtileGeometry extends Dimension2D { return new Point2D.Double(left, outY); } - - public FtileGeometry(Dimension2D dim, double left, double inY) { this(dim.getWidth(), dim.getHeight(), left, inY); } @@ -145,6 +143,10 @@ public class FtileGeometry extends Dimension2D { return left; } + public final double getRight() { + return width - left; + } + public double getOutY() { return outY; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java index bf20b18be..23f2d56a0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java @@ -63,6 +63,7 @@ public class Snake implements UShape { private UPolygon endDecoration; private final Rainbow color; private TextBlock textBlock; + private String textBlockPosition; private MergeStrategy mergeable = MergeStrategy.FULL; private Direction emphasizeDirection; private final HorizontalAlignment horizontalAlignment; @@ -110,6 +111,11 @@ public class Snake implements UShape { this(null, horizontalAlignment, color, null); } + public void setLabel(TextBlock label, String position) { + this.textBlock = label; + this.textBlockPosition = position; + } + public void setLabel(TextBlock label) { this.textBlock = label; } @@ -206,7 +212,9 @@ public class Snake implements UShape { double x = Math.max(pt1.getX(), pt2.getX()) + 4; final boolean zigzag = worm.getDirectionsCode().startsWith("DLD") || worm.getDirectionsCode().startsWith("DRD"); double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2; - if (horizontalAlignment == HorizontalAlignment.CENTER && zigzag) { + if ("bottom".equalsIgnoreCase(textBlockPosition)) { + x = worm.getLast().getX(); + } else if (horizontalAlignment == HorizontalAlignment.CENTER && zigzag) { final Point2D pt3 = worm.get(2); x = (pt2.getX() + pt3.getX()) / 2 - dim.getWidth() / 2; } else if (horizontalAlignment == HorizontalAlignment.RIGHT && zigzag) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java index 9edded76e..1f4e9edbb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java @@ -35,15 +35,21 @@ */ package net.sourceforge.plantuml.activitydiagram3.ftile; +import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.Pragma; 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.ugraphic.UChangeBackColor; +import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.utils.MathUtils; @@ -59,6 +65,13 @@ public class SwimlanesB extends SwimlanesA { double x2 = 0; final StringBounder stringBounder = ug.getStringBounder(); + + final HtmlColor color = skinParam.getHtmlColor(ColorParam.swimlaneTitleBackground, null, false); + if (color != null) { + final double titleHeight = getTitlesHeight(stringBounder); + final URectangle back = new URectangle(getTitlesWidth(stringBounder), titleHeight); + ug.apply(new UChangeBackColor(color)).apply(new UChangeColor(color)).draw(back); + } for (Swimlane swimlane : swimlanes) { final TextBlock swTitle = getTitle(swimlane); final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth(); @@ -68,6 +81,14 @@ public class SwimlanesB extends SwimlanesA { } } + private double getTitlesWidth(StringBounder stringBounder) { + double x2 = 0; + for (Swimlane swimlane : swimlanes) { + x2 += swimlane.getActualWidth(); + } + return x2; + } + private TextBlock getTitle(Swimlane swimlane) { final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.SWIMLANE_TITLE, null); @@ -101,12 +122,17 @@ public class SwimlanesB extends SwimlanesA { @Override protected UTranslate getTitleHeightTranslate(final StringBounder stringBounder) { + double titlesHeight = getTitlesHeight(stringBounder); + return new UTranslate(0, titlesHeight > 0 ? titlesHeight + 5 : 0); + } + + private double getTitlesHeight(StringBounder stringBounder) { double titlesHeight = 0; for (Swimlane swimlane : swimlanes) { final TextBlock swTitle = getTitle(swimlane); titlesHeight = Math.max(titlesHeight, swTitle.calculateDimension(stringBounder).getHeight()); } - return new UTranslate(0, titlesHeight); + return titlesHeight; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java index 67a480425..dcd2437c5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Pragma; +import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -51,6 +52,7 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { @@ -64,9 +66,10 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { @Override public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering) { + LinkRendering topInlinkRendering, Url url) { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); + final ConditionEndStyle conditionEndStyle = skinParam().getConditionEndStyle(); final Branch branch0 = thens.get(0); final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); @@ -89,7 +92,7 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { conditionStyle, thens, elseBranch, fcArrow, topInlinkRendering, afterEndwhile, fcTest); } return ConditionalBuilder.create(swimlane, borderColor, backColor, arrowColor, getFactory(), conditionStyle, - thens.get(0), elseBranch, skinParam(), getStringBounder(), fcArrow, fcTest); + conditionEndStyle, thens.get(0), elseBranch, skinParam(), getStringBounder(), fcArrow, fcTest, url); } private HtmlColor fontColor(FontParam param) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java index dee9622be..1507edec9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java @@ -70,23 +70,6 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator { @Override public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Display labelTest) { - // final ConditionStyle conditionStyle = skinParam().getConditionStyle(); - // - // final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); - // final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground); - // final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); - // - // final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); - // - // final FontParam testParam = conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND - // : FontParam.ARROW; - // final FontConfiguration fcTest = new FontConfiguration(skinParam(), testParam, null) - // .changeColor(fontColor(FontParam.ACTIVITY_DIAMOND)); - // - // return FtileSwitch.create(swimlane, borderColor, backColor, arrowColor, getFactory(), conditionStyle, - // branches, - // fcArrow, topInlinkRendering, afterEndwhile, fcTest); - // return createNude(swimlane, branches); // return createWithDiamonds(swimlane, branches, labelTest); return createWithLinks(swimlane, branches, labelTest); @@ -113,11 +96,11 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator { private Ftile createWithLinks(Swimlane swimlane, List branches, Display labelTest) { final List ftiles = new ArrayList(); + final Ftile diamond1 = getDiamond1(swimlane, branches.get(0), labelTest); + final Ftile diamond2 = getDiamond2(swimlane, branches.get(0)); for (Branch branch : branches) { ftiles.add(new FtileMinWidth(branch.getFtile(), 30)); } - final Ftile diamond1 = getDiamond1(swimlane, branches.get(0), labelTest); - final Ftile diamond2 = getDiamond2(swimlane, branches.get(0)); final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); if (ftiles.size() == 1) { final FtileSwitchWithOneLink result = new FtileSwitchWithOneLink(ftiles, branches, swimlane, diamond1, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java index a53f77ab2..a0739c312 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java @@ -56,12 +56,14 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; 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.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -72,6 +74,7 @@ public class FtileIfDown extends AbstractFtile { private final Ftile diamond1; private final Ftile diamond2; private final Ftile optionalStop; + private final ConditionEndStyle conditionEndStyle; @Override public Collection getMyChildren() { @@ -98,27 +101,34 @@ public class FtileIfDown extends AbstractFtile { return thenBlock.getSwimlaneOut(); } - private FtileIfDown(Ftile thenBlock, Ftile diamond1, Ftile diamond2, Ftile optionalStop) { + private FtileIfDown(Ftile thenBlock, Ftile diamond1, Ftile diamond2, Ftile optionalStop, + ConditionEndStyle conditionEndStyle) { super(thenBlock.skinParam()); this.thenBlock = thenBlock; this.diamond1 = diamond1; this.diamond2 = diamond2; this.optionalStop = optionalStop; + this.conditionEndStyle = conditionEndStyle; } public static Ftile create(Ftile diamond1, Ftile diamond2, Swimlane swimlane, Ftile thenBlock, Rainbow arrowColor, - FtileFactory ftileFactory, Ftile optionalStop, Rainbow elseColor) { + ConditionEndStyle conditionEndStyle, FtileFactory ftileFactory, Ftile optionalStop, Rainbow elseColor) { elseColor = elseColor.withDefault(arrowColor); final FtileIfDown result = new FtileIfDown(thenBlock, diamond1, optionalStop == null ? diamond2 - : new FtileEmpty(ftileFactory.skinParam()), optionalStop); + : new FtileEmpty(ftileFactory.skinParam()), optionalStop, conditionEndStyle); final List conns = new ArrayList(); conns.add(result.new ConnectionIn(thenBlock.getInLinkRendering().getRainbow(arrowColor))); final boolean hasPointOut1 = thenBlock.calculateDimension(ftileFactory.getStringBounder()).hasPointOut(); if (optionalStop == null) { if (hasPointOut1) { - conns.add(result.new ConnectionElse(elseColor)); + if (conditionEndStyle == ConditionEndStyle.DIAMOND) { + conns.add(result.new ConnectionElse(elseColor)); + } else if (conditionEndStyle == ConditionEndStyle.HLINE) { + conns.add(result.new ConnectionElseHline(elseColor)); + conns.add(result.new ConnectionHline(elseColor)); + } } else { conns.add(result.new ConnectionElseNoDiamond(elseColor)); } @@ -228,6 +238,14 @@ public class FtileIfDown extends AbstractFtile { getFtile2().calculateDimension(stringBounder).getPointIn()); } + private Point2D getP2hline(final StringBounder stringBounder) { + final FtileGeometry dimDiamond2 = getFtile2().calculateDimension(stringBounder); + final double x = dimDiamond2.getWidth(); + final double half = (dimDiamond2.getOutY() - dimDiamond2.getInY()) / 2; + return getTranslateDiamond2(stringBounder) + .getTranslated(new Point2D.Double(x, dimDiamond2.getInY() + half)); + } + public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); @@ -237,7 +255,12 @@ public class FtileIfDown extends AbstractFtile { final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); snake.addPoint(getP1(stringBounder)); - snake.addPoint(getP2(stringBounder)); + + if (conditionEndStyle == ConditionEndStyle.DIAMOND) { + snake.addPoint(getP2(stringBounder)); + } else if (conditionEndStyle == ConditionEndStyle.HLINE) { + snake.addPoint(getP2hline(stringBounder)); + } ug.draw(snake); } @@ -271,7 +294,7 @@ public class FtileIfDown extends AbstractFtile { this.endInlinkColor = endInlinkColor; } - private Point2D getP1(StringBounder stringBounder) { + protected Point2D getP1(StringBounder stringBounder) { final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); final double x = dimDiamond1.getWidth(); final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2; @@ -290,7 +313,6 @@ public class FtileIfDown extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); final Point2D p1 = getP1(stringBounder); if (calculateDimension(stringBounder).hasPointOut() == false) { return; @@ -302,24 +324,72 @@ public class FtileIfDown extends AbstractFtile { final double x2 = p2.getX(); final double y2 = p2.getY(); - snake.addPoint(x1, y1); - final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth()); + final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + snake.addPoint(x1, y1); snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); snake.addPoint(x2, y2); snake.emphasizeDirection(Direction.DOWN); ug.apply(new UTranslate(x2, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); - ug.draw(snake); } } + class ConnectionElseHline extends ConnectionElse { + private final Rainbow endInlinkColor; + + public ConnectionElseHline(Rainbow endInlinkColor) { + super(endInlinkColor); + this.endInlinkColor = endInlinkColor; + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final Point2D p1 = getP1(stringBounder); + if (calculateDimension(stringBounder).hasPointOut() == false) { + return; + } + 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 FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); + final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() + + thenGeom.getWidth()); + + /* + * if( conditionEndStyle == ConditionEndStyle.DIAMOND ) { final Snake snake = new + * Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); snake.addPoint(x1, y1); + * snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); snake.addPoint(x2, y2); + * snake.emphasizeDirection(Direction.DOWN); ug.apply(new UTranslate(x2, y2 - + * Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); ug.draw(snake); } + */ + final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToDown()); + snake.addPoint(x1, y1); + snake.addPoint(xmax, y1); + snake.addPoint(xmax, y2); + ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); + ug.draw(snake); + /* + * final Snake snake2 = new Snake(arrowHorizontalAlignment(), endInlinkColor); snake2.addPoint(xmax, y2); + * snake2.addPoint(x2, y2); ug.draw(snake2); + */ + + } + + } + class ConnectionElseNoDiamond extends ConnectionElse { public ConnectionElseNoDiamond(Rainbow endInlinkColor) { @@ -333,6 +403,72 @@ public class FtileIfDown extends AbstractFtile { } + // copied from FtileIfLongHorizontal to use with ConditionEndStyle.HLINE + class ConnectionHline extends AbstractConnection { + private final Rainbow endInlinkColor; + + public ConnectionHline(Rainbow endInlinkColor) { + super(diamond1, diamond2); + this.endInlinkColor = endInlinkColor; + } + + private Point2D getP1(StringBounder stringBounder) { + final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); + final double x = dimDiamond1.getWidth(); + final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2; + return getTranslateDiamond1(stringBounder) + .getTranslated(new Point2D.Double(x, dimDiamond1.getInY() + half)); + } + + protected Point2D getP2(final StringBounder stringBounder) { + final FtileGeometry dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x = dimDiamond2.getWidth(); + final double half = (dimDiamond2.getOutY() - dimDiamond2.getInY()) / 2; + return getTranslateDiamond2(stringBounder) + .getTranslated(new Point2D.Double(x, dimDiamond2.getInY() + half)); + } + + // the bottom or south point of the diamond that we omitted + protected Point2D getP3(final StringBounder stringBounder) { + final FtileGeometry dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x = dimDiamond2.getWidth(); + return getTranslateDiamond2(stringBounder).getTranslated(new Point2D.Double(x, dimDiamond2.getOutY())); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final Point2D p1 = getP1(stringBounder); + if (calculateDimension(stringBounder).hasPointOut() == false) { + return; + } + final Point2D p2 = getP2(stringBounder); + final Point2D p3 = getP3(stringBounder); + + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + final double x3 = p3.getX(); + final double y3 = p3.getY(); + + final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); + final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() + + thenGeom.getWidth()); + + final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor); + snake.addPoint(xmax, y2); + // ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, + // Diamond.diamondHalfSize)); + snake.addPoint(x2, y2); + snake.addPoint(x3, y3); + snake.goUnmergeable(MergeStrategy.NONE); + ug.draw(snake); + + } + } + public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); ug.apply(getTranslateForThen(stringBounder)).draw(thenBlock); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index 339806304..323e3ace0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -73,6 +73,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; class FtileRepeat extends AbstractFtile { @@ -124,6 +125,7 @@ class FtileRepeat extends AbstractFtile { final TextBlock outTb = out.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer); final Ftile diamond1; + assert swimlane == repeat.getSwimlaneIn(); if (backStart == null) { diamond1 = new FtileDiamond(repeat.skinParam(), backColor, borderColor, repeat.getSwimlaneIn()); } else { @@ -159,7 +161,7 @@ class FtileRepeat extends AbstractFtile { final Display backLink1 = backRepeatLinkRendering.getDisplay(); final TextBlock tbbackLink1 = backLink1 == null ? null : backLink1.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer, CreoleMode.SIMPLE_LINE); - if (repeat.getSwimlaneIn() == repeat.getSwimlaneOut()) { + if (repeat.getSwimlaneIn() == swimlaneOut) { if (backward == null) { conns.add(result.new ConnectionBackSimple(backRepeatLinkRendering.getRainbow(arrowColor), tbbackLink1)); } else { @@ -295,8 +297,6 @@ class FtileRepeat extends AbstractFtile { public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); - snake.emphasizeDirection(Direction.UP); final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); Point2D p1 = getP1(stringBounder); @@ -306,11 +306,20 @@ class FtileRepeat extends AbstractFtile { final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); final double y1 = p1.getY() + dimDiamond2.getHeight() / 2; - final double x2 = p2.getX() + dimDiamond1.getWidth(); + double x2 = p2.getX() + dimDiamond1.getWidth(); final double y2 = p2.getY() + dimDiamond1.getHeight() / 2; final double xmax = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2 + Diamond.diamondHalfSize; + + UPolygon arrow = Arrows.asToLeft(); + if (xmax < x2) { + arrow = Arrows.asToRight(); + x2 = p2.getX(); + } + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, arrow); + snake.emphasizeDirection(Direction.UP); + snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); snake.addPoint(x2, y2); @@ -434,7 +443,7 @@ class FtileRepeat extends AbstractFtile { } - class ConnectionBackSimple extends AbstractConnection { + class ConnectionBackSimple extends AbstractConnection implements ConnectionTranslatable { private final Rainbow arrowColor; private final TextBlock tbback; @@ -477,6 +486,34 @@ class FtileRepeat extends AbstractFtile { ug.draw(snake); } + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); + snake.setLabel(tbback); + snake.emphasizeDirection(Direction.UP); + final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); + + Point2D p1 = getP1(stringBounder); + Point2D p2 = getP2(stringBounder); + p1 = translate1.getTranslated(p1); + p2 = translate2.getTranslated(p2); + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x1 = p1.getX() + dimDiamond2.getWidth(); + final double y1 = p1.getY() + dimDiamond2.getHeight() / 2; + final double x2 = p2.getX() + dimDiamond1.getWidth(); + final double y2 = p2.getY() + dimDiamond1.getHeight() / 2; + + snake.addPoint(x1, y1); + final double xmax = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2 + + Diamond.diamondHalfSize; + snake.addPoint(xmax, y1); + snake.addPoint(xmax, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index 34c91ace8..fb35db333 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -136,7 +136,7 @@ public class VCompactFactory implements FtileFactory { } public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering) { + LinkRendering topInlinkRendering, Url url) { final List ftiles = new ArrayList(); for (Branch branch : thens) { ftiles.add(branch.getFtile()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java index 16438ea65..fc0d75573 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -46,6 +47,7 @@ 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.FtileWithUrl; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileIfDown; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; @@ -62,6 +64,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; public class ConditionalBuilder { @@ -72,6 +75,7 @@ public class ConditionalBuilder { private final Rainbow arrowColor; private final FtileFactory ftileFactory; private final ConditionStyle conditionStyle; + private final ConditionEndStyle conditionEndStyle; private final Branch branch1; private final Branch branch2; private final ISkinParam skinParam; @@ -81,22 +85,26 @@ public class ConditionalBuilder { private final Ftile tile1; private final Ftile tile2; + private final Url url; public ConditionalBuilder(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, Rainbow arrowColor, - FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch branch1, Branch branch2, - ISkinParam skinParam, StringBounder stringBounder, FontConfiguration fontArrow, FontConfiguration fontTest) { + FtileFactory ftileFactory, ConditionStyle conditionStyle, ConditionEndStyle conditionEndStyle, + Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder, + FontConfiguration fontArrow, FontConfiguration fontTest, Url url) { this.swimlane = swimlane; this.borderColor = borderColor; this.backColor = backColor; this.arrowColor = arrowColor; this.ftileFactory = ftileFactory; this.conditionStyle = conditionStyle; + this.conditionEndStyle = conditionEndStyle; this.branch1 = branch1; this.branch2 = branch2; this.skinParam = skinParam; this.stringBounder = stringBounder; this.fontArrow = fontArrow; this.fontTest = fontTest; + this.url = url; this.tile1 = new FtileMinWidth(branch1.getFtile(), 30); this.tile2 = new FtileMinWidth(branch2.getFtile(), 30); @@ -104,10 +112,12 @@ public class ConditionalBuilder { } static public Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, Rainbow arrowColor, - FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch branch1, Branch branch2, - ISkinParam skinParam, StringBounder stringBounder, FontConfiguration fcArrow, FontConfiguration fcTest) { + FtileFactory ftileFactory, ConditionStyle conditionStyle, ConditionEndStyle conditionEndStyle, + Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder, + FontConfiguration fcArrow, FontConfiguration fcTest, Url url) { final ConditionalBuilder builder = new ConditionalBuilder(swimlane, borderColor, backColor, arrowColor, - ftileFactory, conditionStyle, branch1, branch2, skinParam, stringBounder, fcArrow, fcTest); + ftileFactory, conditionStyle, conditionEndStyle, branch1, branch2, skinParam, stringBounder, fcArrow, + fcTest, url); if (isEmptyOrOnlySingleStopOrSpot(branch2) && isEmptyOrOnlySingleStopOrSpot(branch1) == false) { return builder.createDown(builder.branch1, builder.branch2); } @@ -138,18 +148,20 @@ public class ConditionalBuilder { final Ftile diamond2 = getDiamond2(branch1, branch2, true); if (branch2.isOnlySingleStopOrSpot()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), - arrowColor, ftileFactory, branch2.getFtile(), branch2.getInlinkRenderingColorAndStyle()); + arrowColor, conditionEndStyle, ftileFactory, branch2.getFtile(), + branch2.getInlinkRenderingColorAndStyle()); } if (branch1.isOnlySingleStopOrSpot()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10), - arrowColor, ftileFactory, branch1.getFtile(), branch1.getInlinkRenderingColorAndStyle()); + arrowColor, conditionEndStyle, ftileFactory, branch1.getFtile(), + branch1.getInlinkRenderingColorAndStyle()); } if (branch1.isEmpty()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10), - arrowColor, ftileFactory, null, null); + arrowColor, conditionEndStyle, ftileFactory, null, null); } return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), arrowColor, - ftileFactory, null, branch2.getInlinkRenderingColorAndStyle()); + conditionEndStyle, ftileFactory, null, branch2.getInlinkRenderingColorAndStyle()); } private Ftile createNude() { @@ -173,12 +185,15 @@ public class ConditionalBuilder { } private Ftile createWithLinks() { - final Ftile diamond1 = getDiamond1(true); + Ftile diamond1 = getDiamond1(true); + if (url != null) { + diamond1 = new FtileWithUrl(diamond1, url); + } final Ftile diamond2 = getDiamond2(branch1, branch2, false); final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10); final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10); final FtileIfWithLinks ftile = new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor, - stringBounder); + conditionEndStyle, stringBounder); final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder); final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder); final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1); @@ -232,6 +247,10 @@ public class ConditionalBuilder { private Ftile getDiamond2(Branch branch1, Branch branch2, boolean useNorth) { final Ftile diamond2; + if (conditionEndStyle == ConditionEndStyle.HLINE) { + return new FtileEmpty(tile1.skinParam(), 0, Diamond.diamondHalfSize, swimlane, swimlane); + } + // else use default ConditionEndStyle.DIAMOND if (hasTwoBranches()) { final Display out1 = branch1.getFtile().getOutLinkRendering().getDisplay(); final TextBlock tbout1 = out1 == null ? null : out1.create(fontArrow, HorizontalAlignment.LEFT, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java index c6b55621a..afcf468f3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java @@ -54,20 +54,25 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorOneSwimlane; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.svek.ConditionEndStyle; 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 ConditionEndStyle conditionEndStyle; private final Rainbow arrowColor; public FtileIfWithLinks(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, Swimlane in, Rainbow arrowColor, - StringBounder stringBounder) { + ConditionEndStyle conditionEndStyle, StringBounder stringBounder) { super(diamond1, tile1, tile2, diamond2, in, stringBounder); this.arrowColor = arrowColor; + this.conditionEndStyle = conditionEndStyle; if (arrowColor.size() == 0) { throw new IllegalArgumentException(); } @@ -369,25 +374,149 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { } + // copied from FtileIfLongHorizontal to use with ConditionEndStyle.HLINE + class ConnectionVerticalOut extends AbstractConnection { + + private final Rainbow color; + private final TextBlock out2; + + public ConnectionVerticalOut(Ftile tile, Rainbow color, TextBlock out2) { + super(tile, null); + this.color = color; + this.out2 = out2; + } + + 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 double totalHeight = calculateDimensionInternal(stringBounder).getHeight(); + // final Point2D p1 = getP1(stringBounder); + if (p1 == null) { + return; + } + final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight); + + final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); + snake.setLabel(out2); + snake.addPoint(p1); + snake.addPoint(p2); + ug.draw(snake); + } + + private UTranslate translate(StringBounder stringBounder) { + if (getFtile1() == tile1) { + return getTranslate1(stringBounder); + } + if (getFtile1() == tile2) { + return getTranslate2(stringBounder); + } + throw new IllegalStateException(); + } + /* + * private Point2D getP1(StringBounder stringBounder) { + * + * final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); if (geo.hasPointOut() == false) { + * return null; } final Point2D p = geo.getPointOut(); return getTranslate1(stringBounder).getTranslated(p); } + */ + } + + // copied from FtileIfLongHorizontal to use with ConditionEndStyle.HLINE + class ConnectionHline extends AbstractConnection { + + private final Rainbow arrowColor; + + public ConnectionHline(Rainbow arrowColor) { + super(null, null); + this.arrowColor = arrowColor; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D totalDim = calculateDimensionInternal(stringBounder); + + final Swimlane intoSw; + if (ug instanceof UGraphicInterceptorOneSwimlane) { + intoSw = ((UGraphicInterceptorOneSwimlane) ug).getSwimlane(); + } else { + intoSw = null; + } + + final List all = new ArrayList(); + all.add(tile1); + all.add(tile2); + double minX = totalDim.getWidth() / 2; + double maxX = totalDim.getWidth() / 2; + boolean atLeastOne = false; + for (Ftile tmp : all) { + if (tmp.calculateDimension(stringBounder).hasPointOut() == false) { + continue; + } + if (intoSw != null && tmp.getSwimlanes().contains(intoSw) == false) { + continue; + } + if (intoSw != null && tmp.getSwimlaneOut() != intoSw) { + continue; + } + atLeastOne = true; + final UTranslate ut = getTranslateFor(tmp, stringBounder); + final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft(); + minX = Math.min(minX, out); + maxX = Math.max(maxX, out); + } + if (atLeastOne == false) { + return; + } + + final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor); + s.goUnmergeable(MergeStrategy.NONE); + final double height = totalDim.getHeight(); + s.addPoint(minX, height); + s.addPoint(maxX, height); + ug.draw(s); + } + } + 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)); final boolean hasPointOut1 = tile1.calculateDimension(stringBounder).hasPointOut(); final boolean hasPointOut2 = tile2.calculateDimension(stringBounder).hasPointOut(); - if (hasPointOut1 && hasPointOut2) { - conns.add(new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColorAndStyle(), branch1 - .isEmpty())); - conns.add(new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColorAndStyle(), branch2 - .isEmpty())); - } else if (hasPointOut1 && hasPointOut2 == false) { - conns.add(new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColorAndStyle(), - branch1.isEmpty())); - } else if (hasPointOut1 == false && hasPointOut2) { - conns.add(new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColorAndStyle(), - branch2.isEmpty())); + if (conditionEndStyle == ConditionEndStyle.DIAMOND) { + if (hasPointOut1 && hasPointOut2) { + conns.add(new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColorAndStyle(), + branch1.isEmpty())); + conns.add(new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColorAndStyle(), + branch2.isEmpty())); + } else if (hasPointOut1 && hasPointOut2 == false) { + conns.add(new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColorAndStyle(), + branch1.isEmpty())); + } else if (hasPointOut1 == false && hasPointOut2) { + conns.add(new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColorAndStyle(), + branch2.isEmpty())); + } + } else if (conditionEndStyle == ConditionEndStyle.HLINE) { + if (hasPointOut1 && hasPointOut2) { + conns.add(new ConnectionVerticalOut(tile1, arrowColor, null)); + conns.add(new ConnectionVerticalOut(tile2, arrowColor, null)); + conns.add(new ConnectionHline(arrowColor)); + } else if (hasPointOut1 && hasPointOut2 == false) { + // this is called when the "else" has a break statement + conns.add(new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColorAndStyle(), + branch1.isEmpty())); + } else if (hasPointOut1 == false && hasPointOut2) { + // this is called when the "if" has a break statement + conns.add(new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColorAndStyle(), + branch2.isEmpty())); + } } - return FtileUtils.addConnection(this, conns); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java index 094191b59..347ad7615 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java @@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class FtileSwitchNude extends FtileDimensionMemoize { - protected final double xSeparation = 20; + protected double xSeparation = 20; protected final List tiles; private final Swimlane in; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java index a6ea5a6cc..f69ffd62a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java @@ -55,9 +55,18 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class FtileSwitchWithDiamonds extends FtileSwitchNude { + private static final double SUPP15 = 15; + + static enum Mode { + BIG_DIAMOND, SMALL_DIAMOND + }; + protected final Ftile diamond1; protected final Ftile diamond2; protected final List branches; + private Mode mode; + private final double w13; + private final double w9; public FtileSwitchWithDiamonds(List tiles, List branches, Swimlane in, Ftile diamond1, Ftile diamond2, StringBounder stringBounder) { @@ -65,6 +74,24 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { this.branches = branches; this.diamond1 = diamond1; this.diamond2 = diamond2; + + w13 = diamond1.calculateDimension(stringBounder).getWidth() + - tiles.get(0).calculateDimension(stringBounder).getRight() + - tiles.get(tiles.size() - 1).calculateDimension(stringBounder).getLeft(); + w9 = getW9(stringBounder); + if (w13 > w9) { + mode = Mode.BIG_DIAMOND; + } else { + mode = Mode.SMALL_DIAMOND; + } + } + + private double getW9(StringBounder stringBounder) { + double result = 0; + for (int i = 1; i < tiles.size() - 1; i++) { + result += tiles.get(i).calculateDimension(stringBounder).getWidth(); + } + return result; } @Override @@ -75,11 +102,11 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { return Collections.unmodifiableCollection(result); } - public int getYdelta1a(StringBounder stringBounder) { + public double getYdelta1a(StringBounder stringBounder) { return 20; } - public int getYdelta1b(StringBounder stringBounder) { + public double getYdelta1b(StringBounder stringBounder) { return 10; } @@ -88,11 +115,21 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { final FtileGeometry dim1 = diamond1.calculateDimension(stringBounder); final FtileGeometry dim2 = diamond2.calculateDimension(stringBounder); - final FtileGeometry dimNude = super.calculateDimensionInternalSlow(stringBounder); + final double nudeHeight = super.calculateDimensionInternalSlow(stringBounder).getHeight(); - final FtileGeometry all = dim1.appendBottom(dimNude).appendBottom(dim2); + if (mode == Mode.BIG_DIAMOND) { + final double height = dim1.getHeight() + nudeHeight + dim2.getHeight() + getYdelta1a(stringBounder) + + getYdelta1b(stringBounder); + final FtileGeometry tile0 = tiles.get(0).calculateDimension(stringBounder); + final double width = tile0.getWidth() + SUPP15 + w13 + SUPP15 + + +tiles.get(tiles.size() - 1).calculateDimension(stringBounder).getWidth(); + return new FtileGeometry(width, height, tile0.getLeft() + SUPP15 + dim1.getLeft(), 0, height); - return all.addDim(0, getYdelta1a(stringBounder) + getYdelta1b(stringBounder)); + } else { + final FtileGeometry dimNude = super.calculateDimensionInternalSlow(stringBounder); + final FtileGeometry all = dim1.appendBottom(dimNude).appendBottom(dim2); + return all.addDim(0, getYdelta1a(stringBounder) + getYdelta1b(stringBounder)); + } } @@ -101,13 +138,42 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { final StringBounder stringBounder = ug.getStringBounder(); ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1); - super.drawU(ug.apply(getTranslateMain(stringBounder))); + if (mode == Mode.BIG_DIAMOND) { + for (Ftile tile : tiles) { + tile.drawU(ug.apply(getTranslateOf(tile, stringBounder))); + } + } else { + super.drawU(ug.apply(getTranslateMain(stringBounder))); + } ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2); } + protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { + final UTranslate main = getTranslateMain(stringBounder); + if (mode == Mode.BIG_DIAMOND) { + double dx = 0; + final double suppx = (w13 - w9) / (tiles.size() - 1); + for (int i = 0; i < tiles.size() - 1; i++) { + if (tile == tiles.get(i)) { + return main.compose(new UTranslate(dx, 0)); + } + dx += tiles.get(i).calculateDimension(stringBounder).getWidth() + suppx; + + } + if (tile == tiles.get(tiles.size() - 1)) { + final double dx9 = tiles.get(0).calculateDimension(stringBounder).getWidth() + w13 + SUPP15 + SUPP15; + return main.compose(new UTranslate(dx9, 0)); + } + throw new IllegalArgumentException(); + + } + return getTranslateNude(tile, stringBounder).compose(main); + } + protected UTranslate getTranslateMain(StringBounder stringBounder) { final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); - return new UTranslate(0, dimDiamond1.getHeight() + getYdelta1a(stringBounder)); + final double dy1 = dimDiamond1.getHeight() + getYdelta1a(stringBounder); + return new UTranslate(0, dy1); } protected UTranslate getTranslateDiamond1(StringBounder stringBounder) { @@ -126,15 +192,9 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { return new UTranslate(x2, y2); } - protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { - return getTranslateNude(tile, stringBounder).compose(getTranslateMain(stringBounder)); - } - protected TextBlock getLabelPositive(Branch branch) { final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); return branch.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, skinParam(), CreoleMode.SIMPLE_LINE); } - - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java index cb43d0b09..3cf2ce70c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java @@ -162,10 +162,10 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } - protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { - return getTranslateNude(tile, stringBounder).compose(getTranslateMain(stringBounder)); - - } + // protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { + // return getTranslateNude(tile, stringBounder).compose(getTranslateMain(stringBounder)); + // + // } class ConnectionVerticalTop extends AbstractConnection { @@ -189,7 +189,7 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { final double y2 = p2.getY(); final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(getLabelPositive(branch)); + snake.setLabel(getLabelPositive(branch), "BOTTOM"); if (x2 < p1d.getX() - margin || x2 > p1b.getX() + margin) { snake.addPoint(x2, p1d.getY()); snake.addPoint(x2, y2); @@ -263,6 +263,14 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } + public double getYdelta1a(StringBounder stringBounder) { + double max = 10; + for (Branch branch : branches) { + max = Math.max(max, getLabelPositive(branch).calculateDimension(stringBounder).getHeight()); + } + return max + 10; + } + public Ftile addLinks() { final List conns = new ArrayList(); conns.add(new ConnectionHorizontalThenVertical(tiles.get(0), branches.get(0))); diff --git a/src/net/sourceforge/plantuml/bpm/CommandDockedEvent.java b/src/net/sourceforge/plantuml/bpm/CommandDockedEvent.java index 0f75f491e..2cd4e05e7 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandDockedEvent.java +++ b/src/net/sourceforge/plantuml/bpm/CommandDockedEvent.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,12 +49,12 @@ public class CommandDockedEvent extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandDockedEvent.class.getName(), RegexLeaf.start(), // new RegexLeaf(":"), // new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("STYLE", ";"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandElseBranch.java b/src/net/sourceforge/plantuml/bpm/CommandElseBranch.java index dbdc9ea3d..22e167f06 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandElseBranch.java +++ b/src/net/sourceforge/plantuml/bpm/CommandElseBranch.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,10 +49,10 @@ public class CommandElseBranch extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // - new RegexLeaf("else"), // - new RegexLeaf("$")); + static IRegex getRegexConcat() { + return RegexConcat.build(CommandElseBranch.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("else"), RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandEndBranch.java b/src/net/sourceforge/plantuml/bpm/CommandEndBranch.java index 42543dc70..19b327b78 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandEndBranch.java +++ b/src/net/sourceforge/plantuml/bpm/CommandEndBranch.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,10 +49,10 @@ public class CommandEndBranch extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEndBranch.class.getName(), RegexLeaf.start(), // new RegexLeaf("end branch"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandGoto.java b/src/net/sourceforge/plantuml/bpm/CommandGoto.java index b2395a0ec..ab373af36 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandGoto.java +++ b/src/net/sourceforge/plantuml/bpm/CommandGoto.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,12 +49,12 @@ public class CommandGoto extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandGoto.class.getName(), RegexLeaf.start(), // new RegexLeaf("goto"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandMerge.java b/src/net/sourceforge/plantuml/bpm/CommandMerge.java index eb125332e..20c2d4549 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandMerge.java +++ b/src/net/sourceforge/plantuml/bpm/CommandMerge.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,12 +49,12 @@ public class CommandMerge extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandMerge.class.getName(), RegexLeaf.start(), // new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), // new RegexLeaf(":?"), // new RegexLeaf("\\<\\+\\>"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandNewBranch.java b/src/net/sourceforge/plantuml/bpm/CommandNewBranch.java index 1664095d0..536fa6d21 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandNewBranch.java +++ b/src/net/sourceforge/plantuml/bpm/CommandNewBranch.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,10 +49,10 @@ public class CommandNewBranch extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandNewBranch.class.getName(), RegexLeaf.start(), // new RegexLeaf("new branch"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/bpm/CommandResume.java b/src/net/sourceforge/plantuml/bpm/CommandResume.java index cb57fa684..69ca85fb6 100644 --- a/src/net/sourceforge/plantuml/bpm/CommandResume.java +++ b/src/net/sourceforge/plantuml/bpm/CommandResume.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.bpm; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -48,12 +49,12 @@ public class CommandResume extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandResume.class.getName(), RegexLeaf.start(), // new RegexLeaf("resume"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java index f5b33e3b3..a219e41ed 100644 --- a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java @@ -40,11 +40,16 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; public abstract class AbstractEntityDiagram extends CucaDiagram { + public AbstractEntityDiagram(ISkinSimple orig) { + super(orig); + } + final protected List getDotStrings() { final List def = Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];", "node [fontsize=11,height=.35,width=.55];"); diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 5b20ddc83..fc24089bc 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.OutputStream; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.creole.CreoleMode; @@ -58,6 +59,10 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder; public class ClassDiagram extends AbstractClassOrObjectDiagram { + public ClassDiagram(ISkinSimple skinParam) { + super(skinParam); + } + private final String getNamespace(Code fullyCode) { return getNamespace(fullyCode, fullyCode.getSeparator()); } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java index aaf88693a..dbe7568ce 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.classdiagram; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod; import net.sourceforge.plantuml.classdiagram.command.CommandAllowMixing; @@ -77,10 +78,15 @@ import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectM public class ClassDiagramFactory extends UmlDiagramFactory { + private final ISkinSimple skinParam; + + public ClassDiagramFactory(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + @Override public ClassDiagram createEmptyDiagram() { - return new ClassDiagram(); - + return new ClassDiagram(skinParam); } @Override @@ -93,7 +99,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandPage()); cmds.add(new CommandAddMethod()); - + addCommonHides(cmds); cmds.add(new CommandHideShow2()); @@ -110,7 +116,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandEndPackage()); cmds.add(new CommandPackageEmpty()); cmds.add(new CommandPackageWithUSymbol()); - + cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD)); cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX)); final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand(); @@ -124,13 +130,13 @@ public class ClassDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandImport()); - final FactoryTipOnEntityCommand factoryTipOnEntityCommand = new FactoryTipOnEntityCommand(new RegexLeaf( + final FactoryTipOnEntityCommand factoryTipOnEntityCommand = new FactoryTipOnEntityCommand("a", new RegexLeaf( "ENTITY", "(" + CommandCreateClass.CODE_NO_DOTDOT + "|[%g][^%g]+[%g])::([%g][^%g]+[%g]|[^%s]+)")); cmds.add(factoryTipOnEntityCommand.createMultiLine(true)); cmds.add(factoryTipOnEntityCommand.createMultiLine(false)); - final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf( - "ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])")); + final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand("class", + new RegexLeaf("ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])")); cmds.add(factoryNoteOnEntityCommand.createSingleLine()); cmds.add(new CommandUrl()); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java index 926c2587f..65d200f40 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java @@ -35,26 +35,39 @@ */ package net.sourceforge.plantuml.classdiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.skin.VisibilityModifier; -public class CommandAddMethod extends SingleLineCommand { +public class CommandAddMethod extends SingleLineCommand2 { public CommandAddMethod() { - super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+:[%s]+(.*)$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandAddMethod.class.getName(), RegexLeaf.start(), // + new RegexLeaf("NAME", "([\\p{L}0-9_.]+|[%g][^%g]+[%g])"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf(":"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("DATA", "(.*)"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ClassDiagram system, List arg) { - final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get(0)), null, null); + protected CommandExecutionResult executeArg(ClassDiagram system, LineLocation location, RegexResult arg) { + final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get("NAME", 0)), null, null); - final String field = arg.get(1); + final String field = arg.get("DATA", 0); if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) { system.setVisibilityModifierPresent(true); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java index 3665869e9..9028fded5 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,11 +50,11 @@ public class CommandAllowMixing extends SingleLineCommand2 { super(getRegexConcat()); } - private static RegexConcat getRegexConcat() { + private static IRegex getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + return RegexConcat.build(CommandAllowMixing.class.getName(), RegexLeaf.start(), // new RegexLeaf("allow_?mixing"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 2c8d8eab1..828cad7e2 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -44,8 +44,10 @@ import net.sourceforge.plantuml.UrlBuilder.ModeUrl; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; @@ -73,35 +75,39 @@ public class CommandCreateClass extends SingleLineCommand2 { super(getRegexConcat()); } - private static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", // "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond)[%s]+"), // new RegexOr(// new RegexConcat(// new RegexLeaf("DISPLAY1", DISPLAY_WITH_GENERIC), // - new RegexLeaf("[%s]+as[%s]+"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("as"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE1", "(" + CODE + ")")), // new RegexConcat(// new RegexLeaf("CODE2", "(" + CODE + ")"), // - new RegexLeaf("[%s]+as[%s]+"), // // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("as"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("DISPLAY2", DISPLAY_WITH_GENERIC)), // new RegexLeaf("CODE3", "(" + CODE + ")"), // new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), // - new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), // - new RegexLeaf("[%s]*"), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("GENERIC", "\\<(" + GenericRegexProducer.PATTERN + ")\\>"))), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS", Stereotag.pattern() + "?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), // - new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), // - new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + RegexLeaf.end()); } private static ColorParser color() { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 78cef5920..8fb68e0e9 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -46,8 +46,10 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; @@ -85,35 +87,44 @@ public class CommandCreateClassMultilines extends CommandMultilines2)?"), // - new RegexLeaf("[%s]*"), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("GENERIC", "\\<(" + GenericRegexProducer.PATTERN + ")\\>"))), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS", Stereotag.pattern() + "?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - new RegexLeaf("[%s]*"), // - new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), // - new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CODES + "))?"), // - new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), // - new RegexLeaf("[%s]*\\{[%s]*$")); + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("\\{"), // + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end() // + ); } @Override @@ -127,7 +138,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 if (mode == Mode.WITH_MIX_PREFIX) { regex = "mix_" + regex; } - return new RegexConcat(new RegexLeaf("^"), // + return RegexConcat.build(CommandCreateElementFull2.class.getName() + mode, RegexLeaf.start(), // new RegexLeaf("SYMBOL", regex), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexOr(// new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), // new RegexConcat(// new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), // - new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), // - new RegexLeaf("[%s]*as[%s]+"), // + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("STEREOTYPE2", "(\\<\\<.+\\>\\>)") // + )), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("as"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE2", CommandCreateElementFull.CODE)) // ), // - new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), // - new RegexLeaf("[%s]*"), // + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("STEREOTYPE", "(\\<\\<.+\\>\\>)")// + )), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS", Stereotag.pattern() + "?"), // - new RegexLeaf("[%s]*"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // - new RegexLeaf("[%s]*"), // - ColorParser.exp1(), // - new RegexLeaf("$")); + RegexLeaf.spaceZeroOrMore(), // + ColorParser.exp1(), RegexLeaf.end()); } - - @Override final protected boolean isForbidden(CharSequence line) { if (line.toString().matches("^[\\p{L}0-9_.]+$")) { @@ -113,8 +121,7 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 @Override protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) { - return CommandExecutionResult - .error("Use 'allowmixing' if you want to mix classes and other UML elements."); + return CommandExecutionResult.error("Use 'allowmixing' if you want to mix classes and other UML elements."); } String codeRaw = arg.getLazzy("CODE", 0); final String displayRaw = arg.getLazzy("DISPLAY", 0); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java index cd94dead4..d684d8b85 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java @@ -35,26 +35,37 @@ */ package net.sourceforge.plantuml.classdiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.LeafType; -public class CommandDiamondAssociation extends SingleLineCommand { +public class CommandDiamondAssociation extends SingleLineCommand2 { public CommandDiamondAssociation() { - super("(?i)^\\<\\>[%s]*([\\p{L}0-9_.]+)$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandDiamondAssociation.class.getName(), RegexLeaf.start(), // + new RegexLeaf("\\<\\>"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, List arg) { - final Code code = Code.of(arg.get(0)); + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + final Code code = Code.of(arg.get("CODE", 0)); if (diagram.leafExist(code)) { - return CommandExecutionResult.error("Already existing : "+code.getFullName()); + return CommandExecutionResult.error("Already existing : " + code.getFullName()); } diagram.createLeaf(code, Display.NULL, LeafType.ASSOCIATION, null); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow2.java index 295273c3e..2750991a2 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow2.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow2.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,12 +50,12 @@ public class CommandHideShow2 extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandHideShow2.class.getName(), RegexLeaf.start(), // new RegexLeaf("COMMAND", "(hide|hide-class|show|show-class)"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("WHAT", "(.+)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java index 727a54b3b..d214a8dd1 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java @@ -43,8 +43,10 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.EntityGender; @@ -68,15 +70,19 @@ public class CommandHideShowByGender extends SingleLineCommand2 { super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandHideShowByGender.class.getName(), RegexLeaf.start(), // new RegexLeaf("COMMAND", "(hide|show)"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("GENDER", "(?:(class|object|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), // - new RegexLeaf("EMPTY", "(?:(empty)[%s]+)?"), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("EMPTY", "(empty)"), // + RegexLeaf.spaceOneOrMore()) // + ), // new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)"), // - new RegexLeaf("$")); + RegexLeaf.end()); } private final EntityGender emptyByGender(Set portion) { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java index af8a73a46..f9823fe19 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -62,17 +63,16 @@ public class CommandHideShowByVisibility extends SingleLineCommand2 super(getRegexConcat()); } - static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), // + static IRegex getRegexConcat() { + return RegexConcat.build(CommandHideShowByVisibility.class.getName(), RegexLeaf.start(), // new RegexLeaf("COMMAND", "(hide|show)"), // - new RegexLeaf("[%s]+"), // + RegexLeaf.spaceOneOrMore(), // new RegexLeaf("VISIBILITY", "((?:public|private|protected|package)?(?:[,%s]+(?:public|private|protected|package))*)"), // - new RegexLeaf("[%s]+"), // - new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), // - new RegexLeaf("$")); + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), RegexLeaf.end()); } - + @Override protected CommandExecutionResult executeArg(UmlDiagram classDiagram, LineLocation location, RegexResult arg) { if (classDiagram instanceof ClassDiagram) { @@ -82,7 +82,6 @@ public class CommandHideShowByVisibility extends SingleLineCommand2 return CommandExecutionResult.ok(); } - private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) { final Set portion = getEntityPortion(arg.get("PORTION", 0)); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java index 484ff4f94..c6fc0fe02 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; @@ -49,34 +50,33 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2