From 48ae51e8c3ee3cd5713834350f682b086db208d8 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Fri, 4 Nov 2022 18:36:03 +0100 Subject: [PATCH] wip --- .../sourceforge/plantuml/EmbeddedDiagram.java | 163 +-- src/net/sourceforge/plantuml/FileSystem.java | 8 +- src/net/sourceforge/plantuml/ISkinSimple.java | 10 + .../sourceforge/plantuml/PSystemUtils.java | 21 +- src/net/sourceforge/plantuml/SkinParam.java | 26 + .../plantuml/SkinParamDelegator.java | 15 + .../plantuml/SpriteContainerEmpty.java | 29 + .../activitydiagram/ActivityDiagram.java | 6 +- .../activitydiagram/ConditionalContext.java | 2 +- .../activitydiagram/command/CommandElse.java | 2 +- .../command/CommandEndPartition.java | 2 +- .../activitydiagram/command/CommandIf.java | 6 +- .../command/CommandLinkActivity.java | 13 +- .../command/CommandLinkLongActivity.java | 12 +- .../command/CommandPartition.java | 4 +- .../activitydiagram3/InstructionSplit.java | 19 +- .../activitydiagram3/ftile/Swimlane.java | 22 +- .../activitydiagram3/ftile/Swimlanes.java | 42 +- .../ftile/vcompact/FloatingNote.java | 5 +- .../FtileFactoryDelegatorCreateParallel.java | 10 +- .../ftile/vcompact/FtileIfAndStop.java | 4 +- .../ftile/vcompact/FtileIfDown.java | 69 +- .../ftile/vcompact/FtileIfLongHorizontal.java | 8 +- .../ftile/vcompact/FtileNoteAlone.java | 5 +- .../ftile/vcompact/FtileRepeat.java | 81 +- .../ftile/vcompact/FtileSplit1.java | 116 --- .../ftile/vcompact/FtileSwitch.java | 4 +- .../ftile/vcompact/FtileWithNoteOpale.java | 3 +- .../ftile/vcompact/FtileWithNotes.java | 5 +- .../vcompact/cond/ConditionalBuilder.java | 6 +- .../ftile/vcompact/cond/FtileIfNude.java | 2 +- .../ftile/vcompact/cond/FtileSwitchNude.java | 4 +- .../ftile/vertical/FtileBox.java | 12 +- .../ftile/vertical/FtileBox2.java | 11 +- .../ftile/vertical/FtileBoxOld.java | 8 +- .../ftile/vertical/FtileDiamondInside.java | 5 +- .../ftile/vertical/FtileDiamondInside2.java | 5 +- .../ftile/vertical/FtileDiamondSquare.java | 2 +- .../ftile/vertical/FtileDiamondWIP.java | 11 +- .../activitydiagram3/gtile/GtileAssembly.java | 2 +- .../activitydiagram3/gtile/GtileBox.java | 12 +- .../activitydiagram3/gtile/GtileGroup.java | 2 +- .../gtile/GtileHexagonInside.java | 5 +- .../activitydiagram3/gtile/GtileIfAlone.java | 2 +- .../gtile/GtileIfHexagon.java | 4 +- .../activitydiagram3/gtile/GtileRepeat.java | 2 +- .../activitydiagram3/gtile/GtileSplit.java | 2 +- .../gtile/GtileWithMargin.java | 2 +- .../gtile/GtileWithNoteOpale.java | 3 +- .../gtile/GtileWithNotes.java | 5 +- .../activitydiagram3/gtile/Gtiles.java | 5 +- .../plantuml/awt/geom/XDimension2D.java | 56 +- .../sourceforge/plantuml/baraye/Plasma.java | 100 ++ .../sourceforge/plantuml/baraye/Quark.java | 143 +++ .../a}/CucaDiagram.java | 39 +- .../entity => baraye/a}/EntityFactory.java | 75 +- .../a/EntityImp.java} | 37 +- .../{cucadiagram => baraye/a}/IEntity.java | 12 +- .../{cucadiagram => baraye/a}/IGroup.java | 6 +- .../{cucadiagram => baraye/a}/ILeaf.java | 5 +- .../plantuml/baraye/b/CucaDiagram.java | 940 ++++++++++++++++++ .../plantuml/baraye/b/EntityImp.java | 896 +++++++++++++++++ .../plantuml/baraye/b/IEntity.java | 126 +++ .../sourceforge/plantuml/baraye/b/IGroup.java | 82 ++ .../sourceforge/plantuml/baraye/b/ILeaf.java | 83 ++ .../plantuml/baraye/b/ZEntityFactory.java | 501 ++++++++++ .../classdiagram/AbstractEntityDiagram.java | 2 +- .../plantuml/classdiagram/ClassDiagram.java | 4 +- .../command/CommandAddMethod.java | 2 +- .../command/CommandCreateClass.java | 2 +- .../command/CommandCreateClassMultilines.java | 16 +- .../command/CommandCreateElementFull2.java | 2 +- .../command/CommandHideShow2.java | 2 +- .../command/CommandHideShowByGender.java | 2 +- .../command/CommandHideShowSpecificClass.java | 2 +- .../command/CommandLinkClass.java | 11 +- .../command/CommandLinkClass2.java | 765 ++++++++++++++ .../command/CommandLinkLollipop.java | 8 +- .../command/CommandNamespaceSeparator.java | 2 +- .../command/CommandRemoveRestore.java | 2 +- .../command/CommandStereotype.java | 2 +- .../classdiagram/command/CommandUrl.java | 2 +- .../plantuml/command/CommandEndPackage.java | 2 +- .../plantuml/command/CommandNamespace.java | 4 +- .../plantuml/command/CommandNamespace2.java | 4 +- .../command/CommandNamespaceEmpty.java | 4 +- .../plantuml/command/CommandPackage.java | 4 +- .../plantuml/command/CommandPackageEmpty.java | 4 +- .../command/PSystemCommandFactory.java | 18 +- .../note/CommandConstraintOnLinks.java | 2 +- .../command/note/CommandFactoryNote.java | 2 +- .../note/CommandFactoryNoteActivity.java | 22 +- .../note/CommandFactoryNoteOnEntity.java | 14 +- .../note/CommandFactoryNoteOnLink.java | 2 +- .../note/CommandFactoryTipOnEntity.java | 10 +- .../compositediagram/CompositeDiagram.java | 2 +- .../command/CommandCreateBlock.java | 2 +- .../command/CommandCreatePackageBlock.java | 2 +- .../command/CommandEndPackageBlock.java | 2 +- .../command/CommandLinkBlock.java | 5 +- .../plantuml/creole/CreoleHorizontalLine.java | 3 +- .../sourceforge/plantuml/creole/Parser.java | 27 +- .../plantuml/creole/SheetBlock1.java | 8 +- .../plantuml/creole/atom/AtomWithMargin.java | 2 +- .../plantuml/creole/legacy/CreoleParser.java | 48 +- .../plantuml/creole/legacy/PSystemCreole.java | 6 +- .../plantuml/cucadiagram/Bodier.java | 1 + .../plantuml/cucadiagram/BodierJSon.java | 1 + .../cucadiagram/BodierLikeClassOrObject.java | 1 + .../plantuml/cucadiagram/BodierMap.java | 1 + .../plantuml/cucadiagram/BodierSimple.java | 1 + .../plantuml/cucadiagram/BodyEnhanced1.java | 82 +- .../plantuml/cucadiagram/BodyEnhanced2.java | 9 +- .../plantuml/cucadiagram/BodyFactory.java | 1 + .../plantuml/cucadiagram/CodeImpl.java | 6 +- .../plantuml/cucadiagram/Display.java | 164 +-- .../plantuml/cucadiagram/EntityGender.java | 2 + .../cucadiagram/EntityGenderUtils.java | 2 + .../plantuml/cucadiagram/EntityUtils.java | 57 +- .../plantuml/cucadiagram/GroupHierarchy.java | 7 +- .../plantuml/cucadiagram/GroupPrinter.java | 2 + .../plantuml/cucadiagram/GroupRoot.java | 4 +- .../plantuml/cucadiagram/HideOrShow2.java | 20 +- .../plantuml/cucadiagram/ICucaDiagram.java | 95 ++ .../plantuml/cucadiagram/Ident.java | 18 +- .../plantuml/cucadiagram/Link.java | 32 +- .../plantuml/cucadiagram/Magma.java | 22 +- .../plantuml/cucadiagram/MagmaList.java | 4 +- .../cucadiagram/MethodsOrFieldsArea.java | 66 +- .../plantuml/cucadiagram/PortionShower.java | 2 + .../cucadiagram/TextBlockCucaJSon.java | 2 +- .../dot/CucaDiagramSimplifierActivity.java | 8 +- .../dot/CucaDiagramSimplifierState.java | 8 +- .../cucadiagram/dot/CucaDiagramTxtMaker.java | 6 +- .../plantuml/cucadiagram/dot/DotData.java | 8 +- .../cucadiagram/dot/Neighborhood.java | 2 +- .../IEntityFactory.java} | 18 +- .../dedication/DedicationCrypted.java | 3 +- .../plantuml/dedication/DedicationSimple.java | 3 +- .../dedication/PSystemDedication.java | 26 - .../descdiagram/CommandCreateDomain.java | 4 +- .../descdiagram/DescriptionDiagram.java | 2 +- .../EntityImageDesignedDomain.java | 2 +- .../descdiagram/EntityImageDomain.java | 2 +- .../descdiagram/EntityImageMachine.java | 2 +- .../descdiagram/EntityImageRequirement.java | 2 +- .../descdiagram/command/CommandArchimate.java | 2 +- .../command/CommandArchimateMultilines.java | 2 +- .../command/CommandCreateElementFull.java | 4 +- .../CommandCreateElementMultilines.java | 2 +- .../CommandCreateElementParenthesis.java | 4 +- .../command/CommandLinkElement.java | 10 +- .../command/CommandPackageWithUSymbol.java | 4 +- .../sourceforge/plantuml/ebnf/ETileBox.java | 7 +- .../plantuml/ebnf/EbnfExpression.java | 13 +- .../plantuml/ebnf/ShuntingYard.java | 2 +- .../plantuml/eggs/GraphicsPath.java | 2 +- .../plantuml/elk/CucaDiagramFileMakerElk.java | 14 +- src/net/sourceforge/plantuml/elk/ElkPath.java | 6 +- src/net/sourceforge/plantuml/emoji/Emoji.java | 35 + .../plantuml/emoji/SvgNanoParser.java | 35 + .../plantuml/emoji/UGraphicWithScale.java | 35 + .../plantuml/flowdiagram/ActivityBox.java | 2 +- .../sourceforge/plantuml/gitlog/MagicBox.java | 4 +- .../plantuml/graphic/FontConfiguration.java | 38 + .../plantuml/graphic/GraphicStrings.java | 2 +- .../plantuml/graphic/HorizontalAlignment.java | 20 +- .../graphic/SimpleTextBlockBordered.java | 2 +- .../plantuml/graphic/TextBlockBordered.java | 19 +- .../plantuml/graphic/TextBlockHorizontal.java | 2 +- .../plantuml/graphic/TextBlockLineBefore.java | 2 +- .../plantuml/graphic/TextBlockMarged.java | 2 +- .../plantuml/graphic/TextBlockMinWidth.java | 2 +- .../plantuml/graphic/TextBlockSimple.java | 26 +- .../plantuml/graphic/TextBlockVertical2.java | 2 +- .../plantuml/graphic/USymbolArtifact.java | 2 +- .../plantuml/graphic/USymbolCard.java | 2 +- .../plantuml/graphic/USymbolCloud.java | 2 +- .../plantuml/graphic/USymbolCollections.java | 2 +- .../plantuml/graphic/USymbolComponent1.java | 2 +- .../plantuml/graphic/USymbolComponent2.java | 2 +- .../plantuml/graphic/USymbolDatabase.java | 2 +- .../plantuml/graphic/USymbolFile.java | 2 +- .../plantuml/graphic/USymbolFolder.java | 2 +- .../plantuml/graphic/USymbolFrame.java | 2 +- .../plantuml/graphic/USymbolHexagon.java | 2 +- .../plantuml/graphic/USymbolLabel.java | 2 +- .../plantuml/graphic/USymbolNode.java | 2 +- .../plantuml/graphic/USymbolPerson.java | 4 +- .../plantuml/graphic/USymbolQueue.java | 2 +- .../plantuml/graphic/USymbolRectangle.java | 2 +- .../plantuml/graphic/USymbolStack.java | 2 +- .../plantuml/graphic/USymbolStorage.java | 2 +- .../graphml/CucaDiagramGraphmlMaker.java | 6 +- .../graphml/GraphmlDescriptionDiagram.java | 2 +- src/net/sourceforge/plantuml/help/Help.java | 3 +- .../plantuml/html/CucaDiagramHtmlMaker.java | 4 +- .../plantuml/html/LinkHtmlPrinter.java | 2 +- .../plantuml/logo/PSystemLogo.java | 8 +- .../plantuml/mda/MDADiagramImpl.java | 4 +- .../plantuml/mda/MDAEntityImpl.java | 2 +- .../plantuml/mda/MDAPackageImpl.java | 4 +- .../AbstractClassOrObjectDiagram.java | 58 +- .../objectdiagram/command/CommandAddData.java | 2 +- .../command/CommandCreateEntityObject.java | 2 +- .../CommandCreateEntityObjectMultilines.java | 2 +- .../command/CommandCreateJson.java | 2 +- .../command/CommandCreateJsonSingleLine.java | 2 +- .../command/CommandCreateMap.java | 11 +- .../plantuml/openiconic/Movement.java | 6 + .../plantuml/openiconic/SvgCommandLetter.java | 6 +- .../plantuml/openiconic/SvgPath.java | 49 +- src/net/sourceforge/plantuml/png/PngIO.java | 36 +- .../sourceforge/plantuml/png/PngSplitter.java | 14 +- .../plantuml/posimo/PositionableUtils.java | 2 +- .../project/draw/TaskDrawRegular.java | 6 +- .../quantization/ArbitraryComparator.java | 78 ++ .../plantuml/quantization/ColorQuantizer.java | 19 + .../plantuml/quantization/Ditherer.java | 15 + .../quantization/FloydSteinbergDitherer.java | 53 + .../plantuml/quantization/HashMultiset.java | 133 +++ .../quantization/KMeansQuantizer.java | 76 ++ .../quantization/MedianCutQuantizer.java | 136 +++ .../plantuml/quantization/Multiset.java | 33 + .../plantuml/quantization/QColor.java | 145 +++ .../plantuml/quantization/QImage.java | 92 ++ .../plantuml/quantization/Quantizer.java | 37 + .../sourceforge/plantuml/salt/Dictionary.java | 29 + .../plantuml/salt/element/ElementButton.java | 4 +- .../salt/element/ElementDroplist.java | 14 +- .../salt/element/ElementPyramidScrolled.java | 6 +- .../salt/element/ElementRadioCheckbox.java | 2 +- .../salt/element/ElementTextField.java | 2 +- .../salt/element/ElementTreeEntry.java | 2 +- .../sdot/CucaDiagramFileMakerSmetana.java | 18 +- .../plantuml/sdot/SmetanaPath.java | 6 +- .../sourceforge/plantuml/security/SFile.java | 79 +- .../plantuml/security/SecurityProfile.java | 10 +- .../plantuml/skin/CircleInterface.java | 2 +- src/net/sourceforge/plantuml/skin/Padder.java | 5 +- .../plantuml/sprite/SpriteImage.java | 2 + .../plantuml/statediagram/StateDiagram.java | 6 +- .../statediagram/command/CommandAddField.java | 2 +- .../command/CommandCreatePackage2.java | 4 +- .../command/CommandCreatePackageState.java | 4 +- .../command/CommandCreateState.java | 2 +- .../statediagram/command/CommandEndState.java | 2 +- .../command/CommandLinkStateCommon.java | 11 +- .../plantuml/sudoku/GraphicsSudoku.java | 12 +- .../plantuml/svek/AbstractEntityImage.java | 2 +- .../plantuml/svek/Bibliotekon.java | 6 +- .../sourceforge/plantuml/svek/Cluster.java | 16 +- .../plantuml/svek/ClusterHeader.java | 12 +- .../svek/CucaDiagramFileMakerSvek.java | 6 +- .../plantuml/svek/DecorateEntityImage.java | 4 +- .../plantuml/svek/DotStringFactory.java | 8 +- .../plantuml/svek/EntityImageDegenerated.java | 2 +- .../plantuml/svek/EntityImageProtected.java | 2 +- .../plantuml/svek/GeneralImageBuilder.java | 12 +- .../plantuml/svek/GroupPngMakerActivity.java | 20 +- .../plantuml/svek/GroupPngMakerState.java | 24 +- .../plantuml/svek/InnerStateAutonom.java | 5 +- src/net/sourceforge/plantuml/svek/Kal.java | 8 +- .../sourceforge/plantuml/svek/SvekLine.java | 16 +- .../sourceforge/plantuml/svek/SvekNode.java | 26 +- .../sourceforge/plantuml/svek/SvekResult.java | 2 +- .../svek/image/AbstractEntityImageBorder.java | 2 +- .../svek/image/EntityImageActivity.java | 4 +- .../svek/image/EntityImageArcCircle.java | 4 +- .../svek/image/EntityImageAssociation.java | 2 +- .../image/EntityImageAssociationPoint.java | 2 +- .../svek/image/EntityImageBranch.java | 2 +- .../svek/image/EntityImageCircleEnd.java | 2 +- .../svek/image/EntityImageCircleStart.java | 2 +- .../plantuml/svek/image/EntityImageClass.java | 8 +- .../svek/image/EntityImageClassHeader.java | 2 +- .../svek/image/EntityImageDeepHistory.java | 2 +- .../svek/image/EntityImageDescription.java | 6 +- .../svek/image/EntityImageEmptyPackage.java | 10 +- .../plantuml/svek/image/EntityImageGroup.java | 2 +- .../plantuml/svek/image/EntityImageJson.java | 2 +- .../image/EntityImageLollipopInterface.java | 2 +- .../EntityImageLollipopInterfaceEye1.java | 2 +- .../EntityImageLollipopInterfaceEye2.java | 2 +- .../plantuml/svek/image/EntityImageMap.java | 2 +- .../plantuml/svek/image/EntityImageNote.java | 4 +- .../svek/image/EntityImageObject.java | 2 +- .../plantuml/svek/image/EntityImagePort.java | 2 +- .../svek/image/EntityImagePseudoState.java | 2 +- .../plantuml/svek/image/EntityImageState.java | 9 +- .../svek/image/EntityImageState2.java | 2 +- .../svek/image/EntityImageStateBorder.java | 2 +- .../svek/image/EntityImageStateCommon.java | 8 +- .../EntityImageStateEmptyDescription.java | 6 +- .../svek/image/EntityImageSynchroBar.java | 2 +- .../plantuml/svek/image/EntityImageTips.java | 4 +- .../svek/image/EntityImageUseCase.java | 2 +- .../sourceforge/plantuml/svg/SvgGraphics.java | 51 +- .../plantuml/timingdiagram/PlayerAnalog.java | 5 +- .../plantuml/timingdiagram/PlayerBinary.java | 2 +- .../plantuml/timingdiagram/TimingNote.java | 5 +- .../plantuml/ugraphic/FontChecker.java | 2 +- .../plantuml/ugraphic/UImageSvg.java | 12 +- .../plantuml/ugraphic/UStroke.java | 12 + .../plantuml/ugraphic/g2d/UGraphicG2d.java | 2 +- .../plantuml/ugraphic/svg/UGraphicSvg.java | 6 +- .../plantuml/version/PSystemVersion.java | 5 +- .../sourceforge/plantuml/version/Version.java | 2 +- .../plantuml/xmi/CucaDiagramXmiMaker.java | 6 +- .../plantuml/xmi/XmiClassDiagramAbstract.java | 4 +- .../plantuml/xmi/XmiClassDiagramArgo.java | 2 +- .../plantuml/xmi/XmiClassDiagramStandard.java | 2 +- .../plantuml/xmi/XmiClassDiagramStar.java | 2 +- .../plantuml/xmi/XmiDescriptionDiagram.java | 4 +- .../plantuml/xmi/XmiStateDiagram.java | 4 +- .../xmlsc/ScxmlStateDiagramStandard.java | 6 +- 316 files changed, 6377 insertions(+), 1293 deletions(-) delete mode 100644 src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java create mode 100644 src/net/sourceforge/plantuml/baraye/Plasma.java create mode 100644 src/net/sourceforge/plantuml/baraye/Quark.java rename src/net/sourceforge/plantuml/{cucadiagram => baraye/a}/CucaDiagram.java (95%) rename src/net/sourceforge/plantuml/{cucadiagram/entity => baraye/a}/EntityFactory.java (86%) rename src/net/sourceforge/plantuml/{cucadiagram/entity/EntityImpl.java => baraye/a/EntityImp.java} (94%) rename src/net/sourceforge/plantuml/{cucadiagram => baraye/a}/IEntity.java (83%) rename src/net/sourceforge/plantuml/{cucadiagram => baraye/a}/IGroup.java (89%) rename src/net/sourceforge/plantuml/{cucadiagram => baraye/a}/ILeaf.java (96%) create mode 100644 src/net/sourceforge/plantuml/baraye/b/CucaDiagram.java create mode 100644 src/net/sourceforge/plantuml/baraye/b/EntityImp.java create mode 100644 src/net/sourceforge/plantuml/baraye/b/IEntity.java create mode 100644 src/net/sourceforge/plantuml/baraye/b/IGroup.java create mode 100644 src/net/sourceforge/plantuml/baraye/b/ILeaf.java create mode 100644 src/net/sourceforge/plantuml/baraye/b/ZEntityFactory.java create mode 100644 src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java create mode 100644 src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java rename src/net/sourceforge/plantuml/cucadiagram/{SuperGroup.java => entity/IEntityFactory.java} (80%) create mode 100644 src/net/sourceforge/plantuml/quantization/ArbitraryComparator.java create mode 100644 src/net/sourceforge/plantuml/quantization/ColorQuantizer.java create mode 100644 src/net/sourceforge/plantuml/quantization/Ditherer.java create mode 100644 src/net/sourceforge/plantuml/quantization/FloydSteinbergDitherer.java create mode 100644 src/net/sourceforge/plantuml/quantization/HashMultiset.java create mode 100644 src/net/sourceforge/plantuml/quantization/KMeansQuantizer.java create mode 100644 src/net/sourceforge/plantuml/quantization/MedianCutQuantizer.java create mode 100644 src/net/sourceforge/plantuml/quantization/Multiset.java create mode 100644 src/net/sourceforge/plantuml/quantization/QColor.java create mode 100644 src/net/sourceforge/plantuml/quantization/QImage.java create mode 100644 src/net/sourceforge/plantuml/quantization/Quantizer.java diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 78805dee3..db3f0fe7b 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -38,13 +38,14 @@ package net.sourceforge.plantuml; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.creole.atom.Atom; -import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.Line; @@ -59,20 +60,96 @@ import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImageSvg; import net.sourceforge.plantuml.ugraphic.UShape; -class EmbeddedDiagramDraw extends AbstractTextBlock implements Line, Atom { - private BufferedImage image; +public class EmbeddedDiagram extends AbstractTextBlock implements Line, Atom { + + public static final String EMBEDDED_START = "{{"; + public static final String EMBEDDED_END = "}}"; + + public static String getEmbeddedType(CharSequence cs) { + if (cs == null) + return null; + + final String s = StringUtils.trin(cs.toString()); + if (s.startsWith(EMBEDDED_START) == false) + return null; + + if (s.equals(EMBEDDED_START)) + return "uml"; + + if (s.equals(EMBEDDED_START)) + return "uml"; + + if (s.equals(EMBEDDED_START + "uml")) + return "uml"; + + if (s.equals(EMBEDDED_START + "wbs")) + return "wbs"; + + if (s.equals(EMBEDDED_START + "mindmap")) + return "mindmap"; + + if (s.equals(EMBEDDED_START + "gantt")) + return "gantt"; + + if (s.equals(EMBEDDED_START + "json")) + return "json"; + + if (s.equals(EMBEDDED_START + "yaml")) + return "yaml"; + + if (s.equals(EMBEDDED_START + "wire")) + return "wire"; + + if (s.equals(EMBEDDED_START + "creole")) + return "creole"; + + if (s.equals(EMBEDDED_START + "board")) + return "board"; + + if (s.equals(EMBEDDED_START + "ebnf")) + return "ebnf"; + + return null; + } + + public static EmbeddedDiagram createAndSkip(String type, Iterator it, ISkinSimple skinParam) { + final List result = new ArrayList(); + result.add("@start" + type); + int nested = 1; + while (it.hasNext()) { + final CharSequence s2 = it.next(); + if (EmbeddedDiagram.getEmbeddedType(StringUtils.trinNoTrace(s2)) != null) + // if (StringUtils.trinNoTrace(s2).startsWith(EmbeddedDiagram.EMBEDDED_START)) + nested++; + else if (StringUtils.trinNoTrace(s2).equals(EmbeddedDiagram.EMBEDDED_END)) { + nested--; + if (nested == 0) + break; + } + result.add(s2.toString()); + } + result.add("@end" + type); + return EmbeddedDiagram.from(skinParam, result); + + } + + private final List list; private final ISkinSimple skinParam; - private final List as2; + private BufferedImage image; + + private EmbeddedDiagram(ISkinSimple skinParam, List system) { + this.list = system; + this.skinParam = skinParam; + } + + public static EmbeddedDiagram from(ISkinSimple skinParam, List strings) { + return new EmbeddedDiagram(skinParam, BlockUml.convert(strings)); + } public List splitInTwo(StringBounder stringBounder, double width) { return Arrays.asList((Atom) this); } - EmbeddedDiagramDraw(ISkinSimple skinParam, List as2) { - this.skinParam = skinParam; - this.as2 = as2; - } - public double getStartingAltitude(StringBounder stringBounder) { return 0; } @@ -137,75 +214,9 @@ class EmbeddedDiagramDraw extends AbstractTextBlock implements Line, Atom { } private Diagram getSystem() throws IOException, InterruptedException { - final BlockUml blockUml = new BlockUml(as2, Defines.createEmpty(), skinParam, null, null); + final BlockUml blockUml = new BlockUml(list, Defines.createEmpty(), skinParam, null, null); return blockUml.getDiagram(); } -} - -public class EmbeddedDiagram implements CharSequence { - - public static String getEmbeddedType(CharSequence s) { - if (s == null) - return null; - - s = StringUtils.trin(s.toString()); - if (s.equals("{{")) - return "uml"; - - if (s.equals("{{uml")) - return "uml"; - - if (s.equals("{{wbs")) - return "wbs"; - - if (s.equals("{{mindmap")) - return "mindmap"; - - if (s.equals("{{gantt")) - return "gantt"; - - if (s.equals("{{json")) - return "json"; - - if (s.equals("{{yaml")) - return "yaml"; - - if (s.equals("{{wire")) - return "wire"; - - if (s.equals("{{creole")) - return "creole"; - - if (s.equals("{{board")) - return "board"; - - if (s.equals("{{ebnf")) - return "ebnf"; - - return null; - } - - private final Display system; - - public EmbeddedDiagram(Display system) { - this.system = system; - } - - public int length() { - return toString().length(); - } - - public char charAt(int index) { - return toString().charAt(index); - } - - public CharSequence subSequence(int start, int end) { - return toString().subSequence(start, end); - } - - public EmbeddedDiagramDraw asDraw(ISkinSimple skinParam) { - return new EmbeddedDiagramDraw(skinParam, system.as2()); - } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/FileSystem.java b/src/net/sourceforge/plantuml/FileSystem.java index 97915209c..04e232861 100644 --- a/src/net/sourceforge/plantuml/FileSystem.java +++ b/src/net/sourceforge/plantuml/FileSystem.java @@ -72,13 +72,17 @@ public class FileSystem { } public SFile getFile(String nameOrPath) throws IOException { - if (isAbsolute(nameOrPath)) - return new SFile(nameOrPath).getCanonicalFile(); + if (isAbsolute(nameOrPath)) { + final SFile result = new SFile(nameOrPath); + Log.info("Trying " + result.getAbsolutePath()); + return result.getCanonicalFile(); + } final SFile dir = getCurrentDir(); SFile filecurrent = null; if (dir != null) { filecurrent = dir.getAbsoluteFile().file(nameOrPath); + Log.info("Current dir is " + dir.getAbsolutePath() + " so trying " + filecurrent.getAbsolutePath()); if (filecurrent.exists()) return filecurrent.getCanonicalFile(); diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java index 4dae8a9c8..da71fd63b 100644 --- a/src/net/sourceforge/plantuml/ISkinSimple.java +++ b/src/net/sourceforge/plantuml/ISkinSimple.java @@ -37,6 +37,10 @@ package net.sourceforge.plantuml; import java.util.Map; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.SheetBuilder; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.ugraphic.color.HColorSet; public interface ISkinSimple extends SpriteContainer { @@ -59,4 +63,10 @@ public interface ISkinSimple extends SpriteContainer { public void copyAllFrom(Map other); + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode); + + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode, FontConfiguration stereo); + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java index 4ea2f442d..1c001de8c 100644 --- a/src/net/sourceforge/plantuml/PSystemUtils.java +++ b/src/net/sourceforge/plantuml/PSystemUtils.java @@ -44,9 +44,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker; import net.sourceforge.plantuml.png.PngSplitter; import net.sourceforge.plantuml.project.GanttDiagram; @@ -169,19 +169,14 @@ public class PSystemUtils { return maker.create(); } - private static List splitPng(TitledDiagram diagram, SuggestedFile pngFile, ImageData imageData, FileFormatOption fileFormatOption) - throws IOException { + private static List splitPng(TitledDiagram diagram, SuggestedFile pngFile, ImageData imageData, + FileFormatOption fileFormatOption) throws IOException { - final List files = new PngSplitter( - pngFile, - diagram.getSplitPagesHorizontal(), - diagram.getSplitPagesVertical(), - fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, - diagram.getSkinParam().getDpi(), - diagram instanceof GanttDiagram - ? new SplitParam(HColors.BLACK, null, 5) // for backwards compatibility - : diagram.getSkinParam().getSplitParam() - ).getFiles(); + final List files = new PngSplitter(fileFormatOption.getColorMapper(), pngFile, + diagram.getSplitPagesHorizontal(), diagram.getSplitPagesVertical(), + fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, diagram.getSkinParam().getDpi(), + diagram instanceof GanttDiagram ? new SplitParam(HColors.BLACK, null, 5) // for backwards compatibility + : diagram.getSkinParam().getSplitParam()).getFiles(); final List result = new ArrayList<>(); for (SFile f : files) { diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index bed4c5923..788f85f04 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -39,6 +39,7 @@ import java.awt.Font; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; @@ -56,11 +57,15 @@ import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.Pattern2; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.SheetBuilder; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.cucadiagram.LinkStyle; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.log.Logme; @@ -1195,4 +1200,25 @@ public class SkinParam implements ISkinParam { return paramSameClassWidth; } + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode) { + final FontConfiguration stereotype = fontConfiguration.forceFont(null, null); + return sheet(fontConfiguration, horizontalAlignment, creoleMode, stereotype); + } + + private final Map cache = new HashMap<>(); + + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode, FontConfiguration stereo) { + final Object key = Arrays.asList(horizontalAlignment, creoleMode, fontConfiguration, stereo); + CreoleParser result = cache.get(key); + if (result == null) { + result = new CreoleParser(fontConfiguration, horizontalAlignment, this, creoleMode, stereo); + cache.put(key, result); + } + return result; + } + } diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index df4c3e46f..4e9cb9e1a 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -38,9 +38,12 @@ package net.sourceforge.plantuml; import java.util.Collection; import java.util.Map; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.SheetBuilder; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ActorStyle; @@ -443,4 +446,16 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getParamSameClassWidth(); } + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode) { + return skinParam.sheet(fontConfiguration, horizontalAlignment, creoleMode); + } + + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode, FontConfiguration stereo) { + return skinParam.sheet(fontConfiguration, horizontalAlignment, creoleMode, stereo); + } + } diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java index 3e543cb95..0df0c99f7 100644 --- a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java +++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java @@ -37,7 +37,12 @@ package net.sourceforge.plantuml; import java.util.Map; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.SheetBuilder; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.sprite.SpriteImage; import net.sourceforge.plantuml.style.Style; @@ -45,46 +50,57 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet; public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { + @Override public Sprite getSprite(String name) { return SpriteImage.fromInternal(name); } + @Override public String getValue(String key) { return null; } + @Override public double getPadding() { return 0; } + @Override public Guillemet guillemet() { return Guillemet.DOUBLE_COMPARATOR; } + @Override public String getMonospacedFamily() { return Parser.MONOSPACED; } + @Override public int getTabSize() { return 8; } + @Override public HColorSet getIHtmlColorSet() { return HColorSet.instance(); } + @Override public int getDpi() { return 96; } + @Override public LineBreakStrategy wrapWidth() { return LineBreakStrategy.NONE; } + @Override public void copyAllFrom(Map other) { throw new UnsupportedOperationException(); } + @Override public Map values() { throw new UnsupportedOperationException(); } @@ -93,8 +109,21 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { return 0; } + @Override public String transformStringForSizeHack(String s) { return s; } + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode) { + throw new UnsupportedOperationException(); + } + + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode, FontConfiguration stereo) { + return new CreoleParser(fontConfiguration, horizontalAlignment, this, creoleMode, stereo); + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java index f5f297800..f4d46cb74 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java @@ -42,14 +42,14 @@ import java.util.Objects; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; diff --git a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java index 66e984c67..3bb03eae3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.activitydiagram; import java.util.Objects; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.LeafType; public class ConditionalContext { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java index d183f6487..84e07b586 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java @@ -37,13 +37,13 @@ package net.sourceforge.plantuml.activitydiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; 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; -import net.sourceforge.plantuml.cucadiagram.IEntity; public class CommandElse extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java index 9d8630303..45467fafd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.activitydiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -44,7 +45,6 @@ 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 SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index 0bd523e76..0269e1859 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -49,7 +50,6 @@ 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; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; @@ -125,8 +125,8 @@ public class CommandIf extends SingleLineCommand2 { final IEntity branch = diagram.getCurrentContext().getBranch(); final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght); - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, - new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel) + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, + branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); if (arg.get("ARROW", 0) != null) { final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 7aebbd1f2..399ac8c26 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -42,6 +42,8 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -55,8 +57,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -134,8 +134,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { if (arg.get("BACKCOLOR", 0) != null) { String s = arg.get("BACKCOLOR", 0); - entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } final IEntity entity2 = getEntity(diagram, arg, false); @@ -144,8 +143,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { if (arg.get("BACKCOLOR2", 0) != null) { String s = arg.get("BACKCOLOR2", 0); - entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } if (arg.get("STEREOTYPE2", 0) != null) entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0))); @@ -166,7 +164,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { type = type.goDotted(); final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg); + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, + entity2, type, linkArg); if (arrowDirection.contains("*")) link.setConstraint(false); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 8dc4687ac..f2b15d496 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -61,7 +62,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -131,8 +131,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 final String stringColor = line0.get("BACKCOLOR", 0); if (stringColor != null) { - entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColor(stringColor)); + entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor)); } final StringBuilder sb = new StringBuilder(); @@ -199,8 +199,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 if (lineLast.get(4) != null) { String s = lineLast.get(4); - entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0)); @@ -218,7 +217,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 type = type.goDotted(); final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg); + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, + entity2, type, linkArg); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); if (direction == Direction.LEFT || direction == Direction.UP) link = link.getInv(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index 13d37b66e..fa7f8ba24 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -38,6 +38,8 @@ package net.sourceforge.plantuml.activitydiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -48,8 +50,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index de380dbcd..10d18b713 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -73,11 +73,10 @@ public class InstructionSplit extends AbstractInstruction implements Instruction @Override public boolean containsBreak() { - for (InstructionList split : splits) { - if (split.containsBreak()) { + for (InstructionList split : splits) + if (split.containsBreak()) return true; - } - } + return false; } @@ -112,9 +111,9 @@ public class InstructionSplit extends AbstractInstruction implements Instruction @Override public Ftile createFtile(FtileFactory factory) { final List all = new ArrayList<>(); - for (InstructionList list : splits) { + for (InstructionList list : splits) all.add(list.createFtile(factory)); - } + return factory.createParallel(all, ForkStyle.SPLIT, null, swimlaneIn, swimlaneOut); } @@ -123,17 +122,17 @@ public class InstructionSplit extends AbstractInstruction implements Instruction } public void splitAgain(LinkRendering inlinkRendering) { - if (inlinkRendering != null) { + if (inlinkRendering != null) getLast().setOutRendering(inlinkRendering); - } + final InstructionList list = new InstructionList(swimlaneIn); this.splits.add(list); } public void endSplit(LinkRendering inlinkRendering, Swimlane endSwimlane) { - if (inlinkRendering != null) { + if (inlinkRendering != null) getLast().setOutRendering(inlinkRendering); - } + this.swimlaneOut = endSwimlane; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java index b78e6e4b1..b877f9606 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.activitydiagram3.ftile; +import java.util.Set; + import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -43,17 +45,19 @@ import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class Swimlane implements SpecificBackcolorable { +public class Swimlane implements SpecificBackcolorable, Comparable { private final String name; + private final int order; private Display display; private UTranslate translate = new UTranslate(); private double actualWidth; - public Swimlane(String name) { + public Swimlane(String name, int order) { this.name = name; this.display = Display.getWithNewlines(name); + this.order = order; } @@ -116,4 +120,18 @@ public class Swimlane implements SpecificBackcolorable { public MinMax getMinMax() { return minMax; } + + @Override + public int compareTo(Swimlane other) { + return Integer.compare(this.order, other.order); + } + + public boolean isSmallerThanAllOthers(Set others) { + if (others.size() == 1 && others.contains(this)) + return false; + for (Swimlane sw : others) + if (sw.compareTo(this) < 0) + return false; + return true; + } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java index f05c4f908..b42cd4648 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java @@ -110,7 +110,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable private List swimlanesSpecial() { if (swimlanesSpecial.size() == 0) { swimlanesSpecial.addAll(swimlanesRaw); - final Swimlane last = new Swimlane(""); + final Swimlane last = new Swimlane("", Integer.MAX_VALUE); last.setMinMax(MinMax.getEmpty(true)); swimlanesSpecial.add(last); } @@ -151,21 +151,20 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable public void swimlane(String name, HColor color, Display label) { currentSwimlane = getOrCreate(name); - if (color != null) { + if (color != null) currentSwimlane.setSpecificColorTOBEREMOVED(ColorType.BACK, color); - } - if (Display.isNull(label) == false) { + + if (Display.isNull(label) == false) currentSwimlane.setDisplay(label); - } + } private Swimlane getOrCreate(String name) { - for (Swimlane s : swimlanes()) { - if (s.getName().equals(name)) { + for (Swimlane s : swimlanes()) + if (s.getName().equals(name)) return s; - } - } - final Swimlane result = new Swimlane(name); + + final Swimlane result = new Swimlane(name, swimlanesRaw.size()); swimlanesRaw.add(result); return result; } @@ -186,9 +185,9 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable final Ftile tile1 = connection.getFtile1(); final Ftile tile2 = connection.getFtile2(); - if (tile1 == null || tile2 == null) { + if (tile1 == null || tile2 == null) return; - } + if (tile1.getSwimlaneOut() != tile2.getSwimlaneIn()) { final ConnectionCross connectionCross = new ConnectionCross(connection); connectionCross.drawU(getUg()); @@ -364,11 +363,10 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable double min = skinParam.swimlaneWidth(); - if (min == ISkinParam.SWIMLANE_WIDTH_SAME) { - for (Swimlane swimlane : swimlanes()) { + if (min == ISkinParam.SWIMLANE_WIDTH_SAME) + for (Swimlane swimlane : swimlanes()) min = Math.max(min, getWidthWithoutTitle(swimlane)); - } - } + final StringBounder stringBounder = ug.getStringBounder(); for (int i = 0; i < swimlanesSpecial().size(); i++) { @@ -400,15 +398,15 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable } public double getHalfMissingSpace(StringBounder stringBounder, int i, double min) { - if (i == 0 || i > swimlanesSpecial().size()) { + if (i == 0 || i > swimlanesSpecial().size()) return 5; - } + final Swimlane swimlane = swimlanesSpecial().get(i - 1); final double swimlaneActualWidth = Math.max(min, getWidthWithoutTitle(swimlane)); final double titleWidth = getTitle(swimlane).calculateDimension(stringBounder).getWidth(); - if (titleWidth <= swimlaneActualWidth) { + if (titleWidth <= swimlaneActualWidth) return 5; - } + assert titleWidth > swimlaneActualWidth; return Math.max(5, 5 + (titleWidth - swimlaneActualWidth) / 2); } @@ -445,9 +443,9 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable @Override public MinMax getMinMax(StringBounder stringBounder) { - if (cachedMinMax == null) { + if (cachedMinMax == null) cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder, false); - } + return cachedMinMax; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java index 9d610aa8e..cda70fcf4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -76,8 +75,8 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc final UStroke stroke = style.getStroke(); final double shadowing = style.value(PName.Shadowing).asDouble(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(note); final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), this, stroke); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java index 478996a42..956fb220d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java @@ -53,15 +53,15 @@ public final class FtileFactoryDelegatorCreateParallel extends FtileFactoryDeleg public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out) { AbstractParallelFtilesBuilder builder; - if (style == ForkStyle.SPLIT) { + if (style == ForkStyle.SPLIT) builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), all); - } else if (style == ForkStyle.MERGE) { + else if (style == ForkStyle.MERGE) builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), all); - } else if (style == ForkStyle.FORK) { + else if (style == ForkStyle.FORK) builder = new ParallelBuilderFork(skinParam(), getStringBounder(), label, in, out, all); - } else { + else throw new IllegalStateException(); - } + final Ftile inner = super.createParallel(builder.list99, style, label, in, out); return builder.build(inner); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java index a76ff4d4c..33c2cb03b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java @@ -125,8 +125,8 @@ class FtileIfAndStop extends AbstractFtile { final UStroke thickness = tileNonStop.getThickness(style); final FontConfiguration fcTest = FontConfiguration.create(skinParam, style); - final Sheet sheet = Parser - .build(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(labelTest); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java index 74a7ef07b..2efa89076 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java @@ -115,6 +115,7 @@ public class FtileIfDown extends AbstractFtile { 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, conditionEndStyle); @@ -125,7 +126,13 @@ public class FtileIfDown extends AbstractFtile { if (optionalStop == null) { if (hasPointOut1) { if (conditionEndStyle == ConditionEndStyle.DIAMOND) { - conns.add(result.new ConnectionElse(elseColor)); + if (swimlane != null && swimlane.isSmallerThanAllOthers(thenBlock.getSwimlanes())) { + conns.add(result.new ConnectionElse1(elseColor)); + if (diamond1 instanceof FtileDiamondInside) + ((FtileDiamondInside) diamond1).swapEastWest(); + } else { + conns.add(result.new ConnectionElse2(elseColor)); + } } else if (conditionEndStyle == ConditionEndStyle.HLINE) { conns.add(result.new ConnectionElseHline(elseColor)); conns.add(result.new ConnectionHline(elseColor)); @@ -285,10 +292,62 @@ public class FtileIfDown extends AbstractFtile { } } - class ConnectionElse extends AbstractConnection { + class ConnectionElse1 extends AbstractConnection { private final Rainbow endInlinkColor; - public ConnectionElse(Rainbow endInlinkColor) { + public ConnectionElse1(Rainbow endInlinkColor) { + super(diamond1, diamond2); + this.endInlinkColor = endInlinkColor; + } + + protected XPoint2D getP1(StringBounder stringBounder) { + final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); + final double x = 0; + final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2; + return getTranslateDiamond1(stringBounder).getTranslated(new XPoint2D(x, dimDiamond1.getInY() + half)); + } + + protected XPoint2D getP2(final StringBounder stringBounder) { + final FtileGeometry dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x = 0; + final double half = (dimDiamond2.getOutY() - dimDiamond2.getInY()) / 2; + return getTranslateDiamond2(stringBounder).getTranslated(new XPoint2D(x, dimDiamond2.getInY() + half)); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final XPoint2D p1 = getP1(stringBounder); + if (calculateDimension(stringBounder).hasPointOut() == false) + return; + + final XPoint2D p2 = getP2(stringBounder); + + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + final double t11 = getTranslateForThen(stringBounder).getDx(); + final double xmin = Math.min(x1 - Hexagon.hexagonHalfSize, getTranslateForThen(stringBounder).getDx()); + + final Snake snake = Snake.create(skinParam(), endInlinkColor, Arrows.asToRight()) + .emphasizeDirection(Direction.DOWN); + snake.addPoint(x1, y1); + snake.addPoint(xmin, y1); + snake.addPoint(xmin, y2); + snake.addPoint(x2, y2); + ug.apply(new UTranslate(x2, y2 - Hexagon.hexagonHalfSize)).draw(new UEmpty(5, Hexagon.hexagonHalfSize)); + ug.draw(snake); + + } + + } + + class ConnectionElse2 extends AbstractConnection { + private final Rainbow endInlinkColor; + + public ConnectionElse2(Rainbow endInlinkColor) { super(diamond1, diamond2); this.endInlinkColor = endInlinkColor; } @@ -338,7 +397,7 @@ public class FtileIfDown extends AbstractFtile { } - class ConnectionElseHline extends ConnectionElse { + class ConnectionElseHline extends ConnectionElse2 { private final Rainbow endInlinkColor; public ConnectionElseHline(Rainbow endInlinkColor) { @@ -389,7 +448,7 @@ public class FtileIfDown extends AbstractFtile { } - class ConnectionElseNoDiamond extends ConnectionElse { + class ConnectionElseNoDiamond extends ConnectionElse2 { public ConnectionElseNoDiamond(Rainbow endInlinkColor) { super(endInlinkColor); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java index 434b5c826..21f2fa8c4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java @@ -667,12 +667,12 @@ class FtileIfLongHorizontal extends AbstractFtile { private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) { XDimension2D result = new XDimension2D(0, 0); for (Ftile couple : couples) { - result = XDimension2D.mergeLR(result, couple.calculateDimension(stringBounder)); + result = result.mergeLR(couple.calculateDimension(stringBounder)); } XDimension2D dimTile2 = tile2.calculateDimension(stringBounder); - dimTile2 = XDimension2D.delta(dimTile2, 0, getDiamondsHeight(stringBounder) / 2); - result = XDimension2D.mergeLR(result, dimTile2); - result = XDimension2D.delta(result, xSeparation * couples.size(), 100); + dimTile2 = dimTile2.delta(0, getDiamondsHeight(stringBounder) / 2); + result = result.mergeLR(dimTile2); + result = result.delta(xSeparation * couples.size(), 100); return new FtileGeometry(result, result.getWidth() / 2, 0); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java index 59badd61a..72d329c3f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java @@ -48,7 +48,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -112,8 +111,8 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil, Styleable final FontConfiguration fc = FontConfiguration.create(skinParam, FontParam.NOTE, null); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(note); final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), this, stroke); opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, false, stroke); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index 070409675..ee727c06c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -180,7 +180,10 @@ class FtileRepeat extends AbstractFtile { final Rainbow rainbow2 = incoming2.getRainbow(arrowColor); conns.add(result.new ConnectionBackBackward2(rainbow2, backArrowLabel)); } else if (repeat.getSwimlaneIn() == null || repeat.getSwimlaneIn() == swimlaneOut) { - conns.add(result.new ConnectionBackSimple(incoming1.getRainbow(arrowColor), incomingText)); + if (repeat.getSwimlaneIn() != null && repeat.getSwimlaneIn().isSmallerThanAllOthers(repeat.getSwimlanes())) + conns.add(result.new ConnectionBackSimple1(incoming1.getRainbow(arrowColor), incomingText)); + else + conns.add(result.new ConnectionBackSimple2(incoming1.getRainbow(arrowColor), incomingText)); } else { conns.add(result.new ConnectionBackComplex1(incoming1.getRainbow(arrowColor))); } @@ -496,11 +499,83 @@ class FtileRepeat extends AbstractFtile { } - class ConnectionBackSimple extends AbstractConnection implements ConnectionTranslatable { + class ConnectionBackSimple1 extends AbstractConnection implements ConnectionTranslatable { private final Rainbow arrowColor; private final TextBlock tbback; - public ConnectionBackSimple(Rainbow arrowColor, TextBlock tbback) { + public ConnectionBackSimple1(Rainbow arrowColor, TextBlock tbback) { + super(diamond2, repeat); + this.arrowColor = arrowColor; + this.tbback = tbback; + } + + private XPoint2D getP1(final StringBounder stringBounder) { + return getTranslateDiamond2(stringBounder).getTranslated(new XPoint2D(0, 0)); + } + + private XPoint2D getP2(final StringBounder stringBounder) { + return getTranslateDiamond1(stringBounder).getTranslated(new XPoint2D(0, 0)); + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + final Snake snake = Snake.create(skinParam(), arrowColor, Arrows.asToRight()) + .emphasizeDirection(Direction.UP).withLabel(tbback, arrowHorizontalAlignment()); + // final XDimension2D dimTotal = calculateDimensionInternal(stringBounder); + final XPoint2D p1 = getP1(stringBounder); + final XPoint2D p2 = getP2(stringBounder); + final XDimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final XDimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x1 = p1.getX(); + final double y1 = p1.getY() + dimDiamond2.getHeight() / 2; + final double x2 = p2.getX(); + final double y2 = p2.getY() + dimDiamond1.getHeight() / 2; + + snake.addPoint(x1, y1); + final double xmin = -Hexagon.hexagonHalfSize; + snake.addPoint(xmin, y1); + snake.addPoint(xmin, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + final Snake snake = Snake.create(skinParam(), arrowColor, Arrows.asToLeft()) + .emphasizeDirection(Direction.UP).withLabel(tbback, arrowHorizontalAlignment()); + final XDimension2D dimRepeat = repeat.calculateDimension(stringBounder); + + XPoint2D p1 = getP1(stringBounder); + XPoint2D p2 = getP2(stringBounder); + p1 = translate1.getTranslated(p1); + p2 = translate2.getTranslated(p2); + final XDimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + final XDimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); + final double x1 = p1.getX(); + final double y1 = p1.getY() + dimDiamond2.getHeight() / 2; + final double x2 = p2.getX(); + final double y2 = p2.getY() + dimDiamond1.getHeight() / 2; + + snake.addPoint(x1, y1); + final double xmax = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2 + + Hexagon.hexagonHalfSize; + snake.addPoint(xmax, y1); + snake.addPoint(xmax, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + + } + + class ConnectionBackSimple2 extends AbstractConnection implements ConnectionTranslatable { + private final Rainbow arrowColor; + private final TextBlock tbback; + + public ConnectionBackSimple2(Rainbow arrowColor, TextBlock tbback) { super(diamond2, repeat); this.arrowColor = arrowColor; this.tbback = tbback; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java deleted file mode 100644 index e6ada85af..000000000 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java +++ /dev/null @@ -1,116 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2023, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; -import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -class FtileSplit1 extends AbstractFtile { - - private final List forks = new ArrayList<>(); - - public FtileSplit1(List forks) { - super(forks.get(0).skinParam()); - for (Ftile ftile : forks) { - this.forks.add(ftile); - } - } - - public Swimlane getSwimlaneIn() { - return forks.get(0).getSwimlaneIn(); - } - - public Swimlane getSwimlaneOut() { - return null; - // return getSwimlaneIn(); - } - - public Set getSwimlanes() { - return mergeSwimlanes(forks); - } - - public static Set mergeSwimlanes(List tiles) { - final Set result = new HashSet<>(); - for (Ftile tile : tiles) { - result.addAll(tile.getSwimlanes()); - } - return Collections.unmodifiableSet(result); - } - - public void drawU(UGraphic ug) { - final StringBounder stringBounder = ug.getStringBounder(); - - for (Ftile ftile : forks) { - ug.apply(getTranslateFor(ftile, stringBounder)).draw(ftile); - } - } - - @Override - protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { - double height = 0; - double width = 0; - for (Ftile ftile : forks) { - final XDimension2D dim = ftile.calculateDimension(stringBounder); - if (dim.getWidth() > width) { - width = dim.getWidth(); - } - if (dim.getHeight() > height) { - height = dim.getHeight(); - } - } - final XDimension2D dimTotal = new XDimension2D(width, height); - return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight()); - } - - public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) { - final XDimension2D dim = searched.calculateDimension(stringBounder); - final double xpos = calculateDimension(stringBounder).getWidth() - dim.getWidth(); - return UTranslate.dx(xpos / 2); - } - -} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java index 1fcc8d581..9f74e25e6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java @@ -166,9 +166,9 @@ class FtileSwitch extends AbstractFtile { private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) { XDimension2D result = new XDimension2D(0, 0); for (Ftile couple : tiles) - result = XDimension2D.mergeLR(result, couple.calculateDimension(stringBounder)); + result = result.mergeLR(couple.calculateDimension(stringBounder)); - result = XDimension2D.delta(result, xSeparation * (tiles.size() - 1), 100); + result = result.delta(xSeparation * (tiles.size() - 1), 100); return new FtileGeometry(result, result.getWidth() / 2, 0); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index f62f46318..12482c0b3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -52,7 +52,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -146,7 +145,7 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false, null); - final Sheet sheet = Parser.build(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); + final Sheet sheet = skinParam.sheet(fc, align, CreoleMode.FULL).createSheet(note.getDisplay()); final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), this, stroke); opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, withLink, stroke); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java index c63f6952f..d87008043 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java @@ -47,7 +47,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -116,8 +115,8 @@ public class FtileWithNotes extends AbstractFtile { final LineBreakStrategy wrapWidth = style.wrapWidth(); final UStroke stroke = style.getStroke(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(note.getDisplay()); final SheetBlock1 sheet1 = new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()); final SheetBlock2 sheet2 = new SheetBlock2(sheet1, new Stencil() { 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 05e825c73..869f6474b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -53,7 +53,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInsi import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondSquare; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -237,8 +236,9 @@ public class ConditionalBuilder { private Ftile getShape1(boolean eastWest, TextBlock tb1, TextBlock tb2) { final Display labelTest = branch1.getLabelTest(); - final Sheet sheet = Parser.build(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), - skinParam, CreoleMode.FULL).createSheet(labelTest); + final Sheet sheet = skinParam + .sheet(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) + .createSheet(labelTest); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, diamondLineBreak, skinParam.getPadding()); final UStroke thickness = tile1 diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java index be76d0bce..9d9ad19e9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfNude.java @@ -145,7 +145,7 @@ public class FtileIfNude extends FtileDimensionMemoize { final double innerMargin = widthInner(stringBounder); final double width = dim1.getLeft() + innerMargin + (dim2.getWidth() - dim2.getLeft()); - final XDimension2D dim12 = XDimension2D.mergeLR(dim1, dim2); + final XDimension2D dim12 = dim1.mergeLR(dim2); return new FtileGeometry(width, dim12.getHeight(), dim1.getLeft() + innerMargin / 2, 0); } 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 8377f676e..0917730e5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchNude.java @@ -127,9 +127,9 @@ public class FtileSwitchNude extends FtileDimensionMemoize { protected FtileGeometry calculateDimensionInternalSlow(StringBounder stringBounder) { XDimension2D result = new XDimension2D(0, 0); for (Ftile couple : tiles) - result = XDimension2D.mergeLR(result, couple.calculateDimension(stringBounder)); + result = result.mergeLR(couple.calculateDimension(stringBounder)); - result = XDimension2D.delta(result, xSeparation * (tiles.size() - 1), 100); + result = result.delta(xSeparation * (tiles.size() - 1), 100); return new FtileGeometry(result, result.getWidth() / 2, 0); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index ec19bc0cf..8b6ce3e6f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -149,8 +148,7 @@ public class FtileBox extends AbstractFtile { this.boxStyle = boxStyle; this.swimlane = swimlane; - this.inRendering = LinkRendering - .create(Rainbow.build(styleArrow, getIHtmlColorSet())); + this.inRendering = LinkRendering.create(Rainbow.build(styleArrow, getIHtmlColorSet())); Colors specBack = null; if (skinParam instanceof SkinParamColors) specBack = ((SkinParamColors) skinParam).getColors(); @@ -170,8 +168,7 @@ public class FtileBox extends AbstractFtile { final LineBreakStrategy wrapWidth = style.wrapWidth(); this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam.sheet(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), CreoleMode.FULL) .createSheet(label); this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), new UStroke(1)); @@ -222,9 +219,8 @@ public class FtileBox extends AbstractFtile { @Override protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { XDimension2D dimRaw = tb.calculateDimension(stringBounder); - dimRaw = XDimension2D.delta(dimRaw, padding.getLeft() + padding.getRight(), - padding.getBottom() + padding.getTop()); - dimRaw = XDimension2D.atLeast(dimRaw, minimumWidth, 0); + dimRaw = dimRaw.delta(padding.getLeft() + padding.getRight(), padding.getBottom() + padding.getTop()); + dimRaw = dimRaw.atLeast(minimumWidth, 0); return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, dimRaw.getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java index 2df1a94ec..72022e838 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -155,8 +154,7 @@ public class FtileBox2 extends AbstractFtile { this.boxStyle = boxStyle; this.swimlane = swimlane; - this.inRendering = LinkRendering - .create(Rainbow.build(styleArrow, getIHtmlColorSet())); + this.inRendering = LinkRendering.create(Rainbow.build(styleArrow, getIHtmlColorSet())); this.borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.backColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); @@ -172,8 +170,7 @@ public class FtileBox2 extends AbstractFtile { this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam.sheet(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), CreoleMode.FULL) .createSheet(label); this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), new UStroke(1)); @@ -235,9 +232,9 @@ public class FtileBox2 extends AbstractFtile { private XDimension2D getDimRaw(StringBounder stringBounder) { XDimension2D dimRaw = tb.calculateDimension(stringBounder); - dimRaw = XDimension2D.delta(dimRaw, padding.getLeft() + padding.getRight() + boxStyle.getShield(), + dimRaw = dimRaw.delta(padding.getLeft() + padding.getRight() + boxStyle.getShield(), padding.getBottom() + padding.getTop()); - dimRaw = XDimension2D.atLeast(dimRaw, minimumWidth, 0); + dimRaw = dimRaw.atLeast(minimumWidth, 0); return dimRaw; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java index 9fb6c25ad..10f066c94 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -154,8 +153,7 @@ public class FtileBoxOld extends AbstractFtile { this.boxStyle = boxStyle; this.swimlane = swimlane; - this.inRendering = LinkRendering - .create(Rainbow.build(styleArrow, getIHtmlColorSet())); + this.inRendering = LinkRendering.create(Rainbow.build(styleArrow, getIHtmlColorSet())); this.borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.backColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); final FontConfiguration fc = style.getFontConfiguration(getIHtmlColorSet()); @@ -168,7 +166,7 @@ public class FtileBoxOld extends AbstractFtile { // final HorizontalAlignment alignment = // skinParam.getDefaultTextAlignment(horizontalAlignment); - final Sheet sheet = Parser.build(fc, horizontalAlignment, skinParam, CreoleMode.FULL).createSheet(label); + final Sheet sheet = skinParam.sheet(fc, horizontalAlignment, CreoleMode.FULL).createSheet(label); // this.tb = new SheetBlock1(sheet, wrapWidth, 0, this.padding.getLeft(), this.padding.getRight()); // this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, 0, this.padding.getLeft(), this.padding.getRight()), // new MyStencil(), new UStroke(1)); @@ -233,7 +231,7 @@ public class FtileBoxOld extends AbstractFtile { XDimension2D dimRaw = tb.calculateDimension(stringBounder); // dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight(), // padding.getBottom() + padding.getTop()); - dimRaw = XDimension2D.atLeast(dimRaw, minimumWidth, 0); + dimRaw = dimRaw.atLeast(minimumWidth, 0); return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, dimRaw.getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java index 4df400acb..d427c1094 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java @@ -109,9 +109,8 @@ public class FtileDiamondInside extends FtileDiamondWIP { if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) { dim = new XDimension2D(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); } else { - dim = XDimension2D.delta( - XDimension2D.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2), - Hexagon.hexagonHalfSize * 2, 0); + dim = dimLabel.atLeast(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2) + .delta(Hexagon.hexagonHalfSize * 2, 0); } return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java index 2b8adefa7..6de01304b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java @@ -104,9 +104,8 @@ public class FtileDiamondInside2 extends FtileDiamondWIP { if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) { dim = new XDimension2D(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); } else { - dim = XDimension2D.delta( - XDimension2D.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2), - Hexagon.hexagonHalfSize * 2, 0); + dim = dimLabel.atLeast(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2) + .delta(Hexagon.hexagonHalfSize * 2, 0); } return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java index c0d3e16e3..2d6a2db29 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java @@ -117,7 +117,7 @@ public class FtileDiamondSquare extends FtileDiamondWIP { return new XDimension2D(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); XDimension2D result = dimLabel; - result = XDimension2D.delta(result, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); + result = result.delta(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); return result; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java index c4fb1f326..04301f61f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java @@ -61,11 +61,18 @@ abstract class FtileDiamondWIP extends AbstractFtile implements Styleable { protected final TextBlock north; protected final TextBlock south; - protected final TextBlock west; - protected final TextBlock east; + protected /* final */ TextBlock west; + protected /* final */ TextBlock east; protected final double shadowing; + public void swapEastWest() { + final TextBlock tmp = this.west; + this.west = this.east; + this.east = tmp; + + } + final public StyleSignatureBasic getStyleSignature() { return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java index f16da7dfe..74330a461 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java @@ -77,7 +77,7 @@ public class GtileAssembly extends GtileTopDown { final XDimension2D raw = super.calculateDimension(stringBounder); final double textBlockWidth = textBlock.calculateDimension(stringBounder).getWidth(); final double pos1 = tile1.getCoord(GPoint.SOUTH_HOOK).compose(getPos1()).getDx(); - return XDimension2D.atLeast(raw, pos1 + textBlockWidth, 0); + return raw.atLeast(pos1 + textBlockWidth, 0); } protected final TextBlock getTextBlock(Display display) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java index 154f3578c..5c4a6679c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -133,8 +132,7 @@ public class GtileBox extends AbstractGtile { this.style = style; this.boxStyle = boxStyle; - this.inRendering = LinkRendering - .create(Rainbow.build(styleArrow, getIHtmlColorSet())); + this.inRendering = LinkRendering.create(Rainbow.build(styleArrow, getIHtmlColorSet())); this.borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.backColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); final FontConfiguration fc = style.getFontConfiguration(getIHtmlColorSet()); @@ -146,8 +144,7 @@ public class GtileBox extends AbstractGtile { final LineBreakStrategy wrapWidth = style.wrapWidth(); this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam.sheet(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), CreoleMode.FULL) .createSheet(label); this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), new UStroke(1)); @@ -199,9 +196,8 @@ public class GtileBox extends AbstractGtile { @Override public final XDimension2D calculateDimension(StringBounder stringBounder) { XDimension2D dimRaw = tb.calculateDimension(stringBounder); - dimRaw = XDimension2D.delta(dimRaw, padding.getLeft() + padding.getRight(), - padding.getBottom() + padding.getTop()); - dimRaw = XDimension2D.atLeast(dimRaw, minimumWidth, 0); + dimRaw = dimRaw.delta(padding.getLeft() + padding.getRight(), padding.getBottom() + padding.getTop()); + dimRaw = dimRaw.atLeast(minimumWidth, 0); return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, dimRaw.getHeight()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java index 485b30cae..a9361da0a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java @@ -133,7 +133,7 @@ public class GtileGroup extends AbstractGtileRoot { @Override public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D orig = inner.calculateDimension(stringBounder); - return XDimension2D.delta(orig, 18, suppHeight(stringBounder)); + return orig.delta(18, suppHeight(stringBounder)); } private double suppHeight(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHexagonInside.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHexagonInside.java index 4c450adf1..978ae8e4c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHexagonInside.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHexagonInside.java @@ -101,9 +101,8 @@ public class GtileHexagonInside extends AbstractGtile { if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) { dim = new XDimension2D(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); } else { - dim = XDimension2D.delta( - XDimension2D.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2), - Hexagon.hexagonHalfSize * 2, 0); + dim = dimLabel.atLeast(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2) + .delta(Hexagon.hexagonHalfSize * 2, 0); } return dim; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java index 39752596f..9b178b6f9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java @@ -87,7 +87,7 @@ public class GtileIfAlone extends GtileTopDown3 { @Override public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(super.calculateDimension(stringBounder), SUPP_WIDTH, 0); + return super.calculateDimension(stringBounder).delta(SUPP_WIDTH, 0); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java index e367dc6c9..028c432f4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java @@ -162,7 +162,7 @@ public class GtileIfHexagon extends GtileColumns { if (branches.size() == 2) { final XDimension2D shape1Dim = shape1.calculateDimension(stringBounder); final double shape1max = this.positionShape1.getDx() + shape1Dim.getWidth(); - return XDimension2D.atLeast(rawDim, shape1max, 0); + return rawDim.atLeast(shape1max, 0); } // return MathUtils.max(rawDim, shape1Dim); @@ -173,7 +173,7 @@ public class GtileIfHexagon extends GtileColumns { final double height2 = shape2.calculateDimension(stringBounder).getHeight(); final XDimension2D nude = super.calculateDimension(stringBounder); // +30 to be done only when branches.size()==1 ? - return XDimension2D.delta(nude, 0, height2 + 30); + return nude.delta(0, height2 + 30); } final public StyleSignatureBasic getDefaultStyleDefinitionActivity() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java index 5020c2d9c..4979afa83 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java @@ -95,7 +95,7 @@ public class GtileRepeat extends GtileTopDown3 { @Override public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(super.calculateDimension(stringBounder), SUPP_WIDTH, 0); + return super.calculateDimension(stringBounder).delta(SUPP_WIDTH, 0); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java index 582e32e80..f579cc798 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java @@ -90,7 +90,7 @@ public class GtileSplit extends GtileColumns { @Override public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(super.calculateDimension(stringBounder), 0, 0); + return super.calculateDimension(stringBounder).delta(0, 0); } // @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithMargin.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithMargin.java index 260895937..46bdbc374 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithMargin.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithMargin.java @@ -73,7 +73,7 @@ public class GtileWithMargin extends AbstractGtileRoot implements Gtile { @Override public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D result = orig.calculateDimension(stringBounder); - return XDimension2D.delta(result, east, north + south); + return result.delta(east, north + south); } private UTranslate getTranslate() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java index b0138051f..9a982ed30 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -117,7 +116,7 @@ public class GtileWithNoteOpale extends AbstractGtile implements Stencil, Stylea final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false, null); - final Sheet sheet = Parser.build(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); + final Sheet sheet = skinParam.sheet(fc, align, CreoleMode.FULL).createSheet(note.getDisplay()); final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), this, new UStroke(1)); this.opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, withLink, stroke); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java index 0583eca93..424cf68fc 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -116,8 +115,8 @@ public class GtileWithNotes extends AbstractGtile { final LineBreakStrategy wrapWidth = style.wrapWidth(); final UStroke stroke = style.getStroke(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(note.getDisplay()); final SheetBlock1 sheet1 = new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()); final SheetBlock2 sheet2 = new SheetBlock2(sheet1, new Stencil() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtiles.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtiles.java index 1d66ff588..b20211cd8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtiles.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtiles.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; @@ -68,8 +67,8 @@ public class Gtiles { : color; final FontConfiguration fcTest = style.getFontConfiguration(skinParam.getIHtmlColorSet()); - final Sheet sheet = Parser - .build(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(label); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1), new UStroke()); diff --git a/src/net/sourceforge/plantuml/awt/geom/XDimension2D.java b/src/net/sourceforge/plantuml/awt/geom/XDimension2D.java index 15110d6b9..a7676080c 100644 --- a/src/net/sourceforge/plantuml/awt/geom/XDimension2D.java +++ b/src/net/sourceforge/plantuml/awt/geom/XDimension2D.java @@ -69,54 +69,44 @@ public class XDimension2D { return width; } - public static XDimension2D delta(XDimension2D dim, double delta) { - return delta(dim, delta, delta); + public XDimension2D delta(double delta) { + return this.delta(delta, delta); } public XDimension2D withWidth(double newWidth) { return new XDimension2D(newWidth, height); } - public static XDimension2D delta(XDimension2D dim, double deltaWidth, double deltaHeight) { + public XDimension2D delta(double deltaWidth, double deltaHeight) { if (deltaHeight == 0 && deltaWidth == 0) - return dim; + return this; - return new XDimension2D(dim.getWidth() + deltaWidth, dim.getHeight() + deltaHeight); + return new XDimension2D(getWidth() + deltaWidth, getHeight() + deltaHeight); } - public static XDimension2D mergeTB(XDimension2D top, XDimension2D bottom) { - final double width = Math.max(top.getWidth(), bottom.getWidth()); - final double height = top.getHeight() + bottom.getHeight(); + public XDimension2D mergeTB(XDimension2D bottom) { + final double width = Math.max(this.getWidth(), bottom.getWidth()); + final double height = this.getHeight() + bottom.getHeight(); return new XDimension2D(width, height); } - public static XDimension2D mergeTB(XDimension2D a, XDimension2D b, XDimension2D c) { - final double width = MathUtils.max(a.getWidth(), b.getWidth(), c.getWidth()); - final double height = a.getHeight() + b.getHeight() + c.getHeight(); + public XDimension2D mergeTB(XDimension2D b, XDimension2D c) { + final double width = MathUtils.max(this.getWidth(), b.getWidth(), c.getWidth()); + final double height = this.getHeight() + b.getHeight() + c.getHeight(); return new XDimension2D(width, height); } - public static XDimension2D mergeLR(XDimension2D left, XDimension2D right) { - final double height = Math.max(left.getHeight(), right.getHeight()); - final double width = left.getWidth() + right.getWidth(); + public XDimension2D mergeLR(XDimension2D right) { + final double height = Math.max(this.getHeight(), right.getHeight()); + final double width = this.getWidth() + right.getWidth(); return new XDimension2D(width, height); } - public static XDimension2D mergeLayoutT12B3(XDimension2D top1, XDimension2D top2, XDimension2D bottom) { - final double width = MathUtils.max(top1.getWidth(), top2.getWidth(), bottom.getWidth()); - final double height = top1.getHeight() + top2.getHeight() + bottom.getHeight(); - return new XDimension2D(width, height); - } - - public static XDimension2D max(XDimension2D dim1, XDimension2D dim2) { - return atLeast(dim1, dim2.getWidth(), dim2.getHeight()); - } - - public static XDimension2D atLeast(XDimension2D dim, double minWidth, double minHeight) { - double h = dim.getHeight(); - double w = dim.getWidth(); + public XDimension2D atLeast(double minWidth, double minHeight) { + double h = getHeight(); + double w = getWidth(); if (w > minWidth && h > minHeight) - return dim; + return this; if (h < minHeight) h = minHeight; @@ -131,4 +121,14 @@ public class XDimension2D { return new XDimension2D(dimension.getWidth(), dimension.getHeight()); } + public static XDimension2D mergeLayoutT12B3(XDimension2D top1, XDimension2D top2, XDimension2D bottom) { + final double width = MathUtils.max(top1.getWidth(), top2.getWidth(), bottom.getWidth()); + final double height = top1.getHeight() + top2.getHeight() + bottom.getHeight(); + return new XDimension2D(width, height); + } + + public static XDimension2D max(XDimension2D dim1, XDimension2D dim2) { + return dim1.atLeast(dim2.getWidth(), dim2.getHeight()); + } + } diff --git a/src/net/sourceforge/plantuml/baraye/Plasma.java b/src/net/sourceforge/plantuml/baraye/Plasma.java new file mode 100644 index 000000000..e5a48ec1c --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/Plasma.java @@ -0,0 +1,100 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Plasma { + + private String separator; + private final Quark root; + private final Map, Quark> quarks = new HashMap<>(); + + public Plasma(String separator) { + final List empty = Collections.emptyList(); + this.root = ensurePresent(empty); + this.separator = separator; + } + + public Quark root() { + return root; + } + + public final String getSeparator() { + return separator; + } + + public final void setSeparator(String separator) { + this.separator = separator; + } + + public Quark parse(Quark root, String full) { + + final List result = root.getSignature(); + while (true) { + int idx = full.indexOf(separator); + if (idx == -1) { + result.add(full); + return ensurePresent(result); + } + if (idx > 0) { + result.add(full.substring(0, idx)); + ensurePresent(result); + } + + full = full.substring(idx + separator.length()); + } + } + + Quark ensurePresent(List result) { + Quark quark = quarks.get(result); + if (quark == null) { + quark = new Quark(this, result); + quarks.put(result, quark); + } + return quark; + + } + + public Collection quarks() { + return Collections.unmodifiableCollection(quarks.values()); + } + +} diff --git a/src/net/sourceforge/plantuml/baraye/Quark.java b/src/net/sourceforge/plantuml/baraye/Quark.java new file mode 100644 index 000000000..89ba22a9c --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/Quark.java @@ -0,0 +1,143 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.cucadiagram.Code; + +public class Quark implements Code { + + private final Plasma plasma; + private final List parts; + private Object data; + + Quark(Plasma plasma, List parts) { + this.plasma = plasma; + this.parts = new ArrayList(parts); + } + + public Quark getParent() { + if (parts.size() == 0) + return null; + return plasma.ensurePresent(parts.subList(0, parts.size() - 1)); + } + + @Override + public String toString() { + return parts.toString(); + } + + public List getSignature() { + return new ArrayList<>(parts); + } + + public boolean containsLarge(Quark other) { + return other.parts.size() > this.parts.size() && other.parts.subList(0, this.parts.size()).equals(this.parts); + } + +// @Override +// public boolean equals(Object obj) { +// final Quark other = (Quark) obj; +// if (this.plasma != other.plasma) +// throw new IllegalArgumentException(); +// return this.parts.equals(other.parts); +// } +// +// @Override +// public int hashCode() { +// return parts.hashCode(); +// } + + public boolean startsWith(Quark other) { + if (other.parts.size() > this.parts.size()) + return false; + + for (int i = 0; i < other.parts.size(); i++) + if (other.parts.get(i).equals(this.parts.get(i)) == false) + return false; + + return true; + } + + public String toString(String sep) { + if (sep == null) + sep = "."; + + final StringBuilder sb = new StringBuilder(); + for (String s : parts) { + if (sb.length() > 0) + sb.append(sep); + + sb.append(s); + } + return sb.toString(); + } + + public String getName() { + if (parts.size() == 0) + return ""; + + return parts.get(parts.size() - 1); + } + + public boolean isRoot() { + return parts.size() == 0; + } + +// public int size() { +// return parts.size(); +// } + + public final Plasma getPlasma() { + return plasma; + } + + public final Object getData() { + return data; + } + + public final void setData(Object data) { + this.data = data; + } + + @Override + public Code eventuallyRemoveStartingAndEndingDoubleQuote(String format) { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/baraye/a/CucaDiagram.java similarity index 95% rename from src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java rename to src/net/sourceforge/plantuml/baraye/a/CucaDiagram.java index 3b51b5500..a02be7825 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/baraye/a/CucaDiagram.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.cucadiagram; +package net.sourceforge.plantuml.baraye.a; import java.io.IOException; import java.io.OutputStream; @@ -58,8 +58,27 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.CodeImpl; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityGender; +import net.sourceforge.plantuml.cucadiagram.EntityPortion; +import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.EntityUtils; +import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.HideOrShow2; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkConstraint; +import net.sourceforge.plantuml.cucadiagram.Magma; +import net.sourceforge.plantuml.cucadiagram.MagmaList; +import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; +import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; +import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphml.CucaDiagramGraphmlMaker; @@ -73,7 +92,7 @@ import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; -public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower { +public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { static private final boolean G1972 = false; @@ -101,10 +120,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return this.V1972() && this.getUmlDiagramType() == UmlDiagramType.CLASS; } - public Set getAllSuperGroups() { - return entityFactory.getAllSuperGroups(); - } - private final List hides2 = new ArrayList<>(); private final List removed = new ArrayList<>(); protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this); @@ -499,10 +514,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return entityFactory.getRootGroup(); } - public SuperGroup getRootSuperGroup() { - return entityFactory.getRootSuperGroup(); - } - public final Collection getLeafsvalues() { return entityFactory.leafs2(); } @@ -607,8 +618,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, throw new UnsupportedOperationException(); } - entityFactory.buildSuperGroups(); - final CucaDiagramFileMaker maker; if (this.isUseElk()) maker = new CucaDiagramFileMakerElk(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); @@ -838,6 +847,10 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return lastEntity; } + final public IEntityFactory getIEntityFactory() { + return entityFactory; + } + final public EntityFactory getEntityFactory() { return entityFactory; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/baraye/a/EntityFactory.java similarity index 86% rename from src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java rename to src/net/sourceforge/plantuml/baraye/a/EntityFactory.java index 962cce1cc..8fb897b95 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/baraye/a/EntityFactory.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.cucadiagram.entity; +package net.sourceforge.plantuml.baraye.a; import java.util.ArrayList; import java.util.Collection; @@ -54,36 +54,32 @@ import net.sourceforge.plantuml.cucadiagram.BodierJSon; import net.sourceforge.plantuml.cucadiagram.BodierMap; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.HideOrShow2; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotag; -import net.sourceforge.plantuml.cucadiagram.SuperGroup; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.skin.VisibilityModifier; -public final class EntityFactory { +public final class EntityFactory implements IEntityFactory { private final Map leafsByCode; private final Map groupsByCode; - /* private */final Map leafs2 = new LinkedHashMap(); - /* private */final Map groups2 = new LinkedHashMap(); + /* private */public final Map leafs2 = new LinkedHashMap(); + /* private */public final Map groups2 = new LinkedHashMap(); private final List links = new ArrayList<>(); private int rawLayout; private final IGroup rootGroup = new GroupRoot(this); - private final SuperGroup rootSuperGroup = new SuperGroup(rootGroup); private final List hides2; private final List removed; @@ -95,30 +91,10 @@ public final class EntityFactory { return emptyGroupsAsNode.get(g); } - public SuperGroup getRootSuperGroup() { - return rootSuperGroup; - } - - private Set superGroups = null; - final Map groupToSuper = new LinkedHashMap(); - - public Set getAllSuperGroups() { - return Collections.unmodifiableSet(superGroups); - } - - public void buildSuperGroups() { - superGroups = new HashSet<>(); - for (IGroup g : groups2.values()) { - final SuperGroup sg = new SuperGroup(g); - superGroups.add(sg); - groupToSuper.put(g, sg); - } - } - public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) { final ILeaf folder = this.createLeaf(g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator()); - ((EntityImpl) folder).setOriginalGroup(g); + ((EntityImp) folder).setOriginalGroup(g); final USymbol symbol = g.getUSymbol(); folder.setUSymbol(symbol); folder.setStereotype(g.getStereotype()); @@ -128,17 +104,6 @@ public final class EntityFactory { for (Stereotag tag : g.stereotags()) folder.addStereotag(tag); -// if (UseStyle.useBetaStyle()) { -// // System.err.println("Backcolor ?"); -// } else { -// if (g.getColors().getColor(ColorType.BACK) == null) { -// final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack(); -// final HColor c1 = skinParam.getHtmlColor(param, g.getStereotype(), false); -// folder.setSpecificColorTOBEREMOVED(ColorType.BACK, c1 == null ? skinParam.getBackgroundColor() : c1); -// } else { -// folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors().getColor(ColorType.BACK)); -// } -// } emptyGroupsAsNode.put(g, folder); return folder; } @@ -173,7 +138,7 @@ public final class EntityFactory { if (link.contains(parent)) return null; - ((EntityImpl) g).setIntricated(true); + ((EntityImp) g).setIntricated(true); hiddenBecauseOfIntrication.add(parent.getIdent()); return g; } @@ -207,6 +172,14 @@ public final class EntityFactory { return hidden; } + public boolean isRemoved(Stereotype stereotype) { + boolean result = false; + for (HideOrShow2 hide : removed) + result = hide.apply(result, stereotype); + + return result; + } + public boolean isRemoved(ILeaf leaf) { final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); if (other instanceof ILeaf) @@ -255,7 +228,7 @@ public final class EntityFactory { else bodier = BodyFactory.createLeaf(entityType, hides); - final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, entityType, + final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, entityType, namespaceSeparator, rawLayout); bodier.setLeaf(result); result.setDisplay(display); @@ -270,7 +243,7 @@ public final class EntityFactory { return ent.getValue(); final Bodier bodier = BodyFactory.createGroup(hides); - final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace, + final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, groupType, namespace, namespaceSeparator, rawLayout); if (Display.isNull(display) == false) result.setDisplay(display); @@ -300,7 +273,7 @@ public final class EntityFactory { getParentContainer(ident, null); } - void removeGroup(String name) { + public /* private */ void removeGroup(String name) { if (namespaceSeparator.V1972()) throw new UnsupportedOperationException(); final IEntity removed = Objects.requireNonNull(groupsByCode.remove(name)); @@ -310,7 +283,7 @@ public final class EntityFactory { } } - void removeGroup(Ident ident) { + public /* private */ void removeGroup(Ident ident) { Objects.requireNonNull(groups2.remove(Objects.requireNonNull(ident))); } @@ -320,7 +293,7 @@ public final class EntityFactory { // throw new IllegalArgumentException(); } - void removeLeaf(String name) { + public /* private */ void removeLeaf(String name) { if (namespaceSeparator.V1972()) throw new UnsupportedOperationException(); final IEntity removed = Objects.requireNonNull(leafsByCode.remove(Objects.requireNonNull(name))); @@ -330,7 +303,7 @@ public final class EntityFactory { } } - void removeLeaf(Ident ident) { + public /* private */ void removeLeaf(Ident ident) { final IEntity removed = leafs2.remove(Objects.requireNonNull(ident)); if (removed == null) { System.err.println("leafs2=" + leafs2.keySet()); @@ -350,7 +323,7 @@ public final class EntityFactory { if (namespaceSeparator.V1972()) throw new UnsupportedOperationException(); final ILeaf leaf = leafsByCode.get(name); - ((EntityImpl) leaf).muteToGroup(namespace, type, parent); + ((EntityImp) leaf).muteToGroup(namespace, type, parent); final IGroup result = (IGroup) leaf; removeLeaf(name); return result; @@ -364,7 +337,7 @@ public final class EntityFactory { leaf = getLeafVerySmart(ident); else leaf = leafs2.get(ident); - ((EntityImpl) leaf).muteToGroup(namespace, type, parent); + ((EntityImp) leaf).muteToGroup(namespace, type, parent); final IGroup result = (IGroup) leaf; removeLeaf1972(leaf); return result; diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/baraye/a/EntityImp.java similarity index 94% rename from src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java rename to src/net/sourceforge/plantuml/baraye/a/EntityImp.java index e8e693bc8..67a2735d4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java +++ b/src/net/sourceforge/plantuml/baraye/a/EntityImp.java @@ -34,7 +34,7 @@ * Contribution: Miguel Esteves * */ -package net.sourceforge.plantuml.cucadiagram.entity; +package net.sourceforge.plantuml.baraye.a; import java.util.ArrayList; import java.util.Collection; @@ -58,7 +58,6 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.cucadiagram.Bodier; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; @@ -66,8 +65,6 @@ import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -94,7 +91,7 @@ import net.sourceforge.plantuml.svek.image.EntityImageStateCommon; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.color.HColor; -final public class EntityImpl implements ILeaf, IGroup { +final public class EntityImp implements ILeaf, IGroup { private final EntityFactory entityFactory; @@ -161,7 +158,7 @@ final public class EntityImpl implements ILeaf, IGroup { } // Back to Entity - private EntityImpl(Ident ident, EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, + private EntityImp(Ident ident, EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, String namespaceSeparator, int rawLayout) { this.ident = Objects.requireNonNull(ident); this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence()); @@ -175,8 +172,8 @@ final public class EntityImpl implements ILeaf, IGroup { this.rawLayout = rawLayout; } - EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, - LeafType leafType, String namespaceSeparator, int rawLayout) { + public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, + IGroup parentContainer, LeafType leafType, String namespaceSeparator, int rawLayout) { this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator, rawLayout); // System.err.println("ID for leaf=" + code + " " + ident); @@ -184,7 +181,7 @@ final public class EntityImpl implements ILeaf, IGroup { this.leafType = leafType; } - EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, + public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, GroupType groupType, Code namespace, String namespaceSeparator, int rawLayout) { this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator, rawLayout); @@ -429,7 +426,7 @@ final public class EntityImpl implements ILeaf, IGroup { throw new UnsupportedOperationException(); for (ILeaf ent : getLeafsDirect()) - ((EntityImpl) ent).parentContainer = dest; + ((EntityImp) ent).parentContainer = dest; for (IGroup g : dest.getChildren()) // ((EntityImpl) g).parentContainer = dest; @@ -439,7 +436,7 @@ final public class EntityImpl implements ILeaf, IGroup { if (g == dest) continue; - ((EntityImpl) g).parentContainer = dest; + ((EntityImp) g).parentContainer = dest; } } @@ -468,8 +465,8 @@ final public class EntityImpl implements ILeaf, IGroup { entityFactory.leafs2.remove(ident); ident = ident.move(firstIdent, destIdent); // System.err.println(" to ident2=" + ident); - ((EntityImpl) ent).ident = ident; - ((EntityImpl) ent).code = ident; + ((EntityImp) ent).ident = ident; + ((EntityImp) ent).code = ident; entityFactory.leafs2.put(ident, ent); } } @@ -486,8 +483,8 @@ final public class EntityImpl implements ILeaf, IGroup { entityFactory.groups2.remove(ident); ident = ident.move(firstIdent, destIdent); // System.err.println(" to ident2=" + ident); - ((EntityImpl) ent).ident = ident; - ((EntityImpl) ent).code = ident; + ((EntityImp) ent).ident = ident; + ((EntityImp) ent).code = ident; entityFactory.groups2.put(ident, ent); // System.err.println("-->groups2=" + entityFactory.groups2()); } @@ -574,7 +571,7 @@ final public class EntityImpl implements ILeaf, IGroup { this.leafType = leafType; } - void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { + public /* private */ void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { checkNotGroup(); if (parentContainer.isGroup() == false) throw new IllegalArgumentException(); @@ -619,11 +616,11 @@ final public class EntityImpl implements ILeaf, IGroup { return false; for (ILeaf leaf : getLeafsDirect()) - if (((EntityImpl) leaf).isHiddenInternal() == false) + if (((EntityImp) leaf).isHiddenInternal() == false) return false; for (IGroup g : getChildren()) - if (((EntityImpl) g).isHiddenInternal() == false) + if (((EntityImp) g).isHiddenInternal() == false) return false; return true; @@ -647,11 +644,11 @@ final public class EntityImpl implements ILeaf, IGroup { return false; for (ILeaf leaf : getLeafsDirect()) - if (((EntityImpl) leaf).isRemovedInternal() == false) + if (((EntityImp) leaf).isRemovedInternal() == false) return false; for (IGroup g : getChildren()) - if (((EntityImpl) g).isRemovedInternal() == false) + if (((EntityImp) g).isRemovedInternal() == false) return false; return true; diff --git a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java b/src/net/sourceforge/plantuml/baraye/a/IEntity.java similarity index 83% rename from src/net/sourceforge/plantuml/cucadiagram/IEntity.java rename to src/net/sourceforge/plantuml/baraye/a/IEntity.java index 6055e6035..91e720fc3 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java +++ b/src/net/sourceforge/plantuml/baraye/a/IEntity.java @@ -33,7 +33,7 @@ * Contribution: Miguel Esteves * */ -package net.sourceforge.plantuml.cucadiagram; +package net.sourceforge.plantuml.baraye.a; import java.util.List; import java.util.Map; @@ -46,6 +46,16 @@ import net.sourceforge.plantuml.Removeable; import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Bodier; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.CucaNote; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Stereostyles; +import net.sourceforge.plantuml.cucadiagram.Stereotag; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.Colors; diff --git a/src/net/sourceforge/plantuml/cucadiagram/IGroup.java b/src/net/sourceforge/plantuml/baraye/a/IGroup.java similarity index 89% rename from src/net/sourceforge/plantuml/cucadiagram/IGroup.java rename to src/net/sourceforge/plantuml/baraye/a/IGroup.java index df83b975c..5d4044111 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/IGroup.java +++ b/src/net/sourceforge/plantuml/baraye/a/IGroup.java @@ -33,11 +33,15 @@ * * */ -package net.sourceforge.plantuml.cucadiagram; +package net.sourceforge.plantuml.baraye.a; import java.util.Collection; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.svek.IEntityImage; import net.sourceforge.plantuml.svek.PackageStyle; diff --git a/src/net/sourceforge/plantuml/cucadiagram/ILeaf.java b/src/net/sourceforge/plantuml/baraye/a/ILeaf.java similarity index 96% rename from src/net/sourceforge/plantuml/cucadiagram/ILeaf.java rename to src/net/sourceforge/plantuml/baraye/a/ILeaf.java index c2a2247d0..9b88ed436 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/ILeaf.java +++ b/src/net/sourceforge/plantuml/baraye/a/ILeaf.java @@ -33,10 +33,11 @@ * * */ -package net.sourceforge.plantuml.cucadiagram; +package net.sourceforge.plantuml.baraye.a; import java.util.Collection; +import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.skin.VisibilityModifier; @@ -45,8 +46,6 @@ import net.sourceforge.plantuml.svek.Margins; public interface ILeaf extends IEntity { - public EntityPosition getEntityPosition(); - public void setContainer(IGroup container); public Margins getMargins(); diff --git a/src/net/sourceforge/plantuml/baraye/b/CucaDiagram.java b/src/net/sourceforge/plantuml/baraye/b/CucaDiagram.java new file mode 100644 index 000000000..dab177ea8 --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/CucaDiagram.java @@ -0,0 +1,940 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import net.sourceforge.plantuml.BackSlash; +import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.api.ImageDataSimple; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.CodeImpl; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityGender; +import net.sourceforge.plantuml.cucadiagram.EntityPortion; +import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.EntityUtils; +import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.HideOrShow2; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkConstraint; +import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; +import net.sourceforge.plantuml.cucadiagram.PortionShower; +import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; +import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; +import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk; +import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.graphml.CucaDiagramGraphmlMaker; +import net.sourceforge.plantuml.sdot.CucaDiagramFileMakerSmetana; +import net.sourceforge.plantuml.security.SecurityUtils; +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; +import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; +import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; + +public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { + + static private final boolean G1972 = false; + + // private String namespaceSeparator = "."; + // private String namespaceSeparator1 = GO1972 ? "::" : "."; + private String namespaceSeparator = null; + private boolean namespaceSeparatorHasBeenSet = false; + + public final boolean V1972() { + return false; + } + + public final boolean mergeIntricated() { + if (getNamespaceSeparator() == null) { + return false; + } + return this.V1972() && this.getUmlDiagramType() == UmlDiagramType.CLASS; + } + + private final List hides2 = new ArrayList<>(); + private final List removed = new ArrayList<>(); + protected final ZEntityFactory entityFactory = new ZEntityFactory(hides2, removed, this); + // protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this); +// protected final EntityFactory entityFactory = null; +// private IGroup currentGroup = entityFactory.getRootGroup(); + private List stacks2 = new ArrayList<>(); + private List stacks = new ArrayList<>(); + + private boolean visibilityModifierPresent; + + public abstract IEntity getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol); + + public Ident cleanIdent(Ident ident) { + return ident; + } + + public CucaDiagram(UmlSource source, UmlDiagramType type, Map orig) { + super(source, type, orig); + this.stacks2.add(Ident.empty()); + } + + private Ident getLastID() { + if (stacks2.size() == 0) { + // Thread.dumpStack(); + return Ident.empty(); + // throw new IllegalArgumentException(); + } + return this.stacks2.get(stacks2.size() - 1); + } + + final public void setNamespaceSeparator(String namespaceSeparator) { + this.namespaceSeparatorHasBeenSet = true; + this.namespaceSeparator = namespaceSeparator; + } + + final public String getNamespaceSeparator() { + if (namespaceSeparatorHasBeenSet == false) + return V1972() ? "::" : "."; + + return namespaceSeparator; + } + + @Override + public boolean hasUrl() { +// for (IEntity entity : getGroups(true)) +// if (entity.hasUrl()) +// return true; +// +// for (IEntity entity : entityFactory.leafs()) +// if (entity.hasUrl()) +// return true; +// +// for (Link link : getLinks()) +// if (link.hasUrl()) +// return true; + + return false; + } + + final public void setLastEntity(ILeaf foo) { + this.lastEntity = foo; + } + + final protected ILeaf getOrCreateLeafDefault(Ident idNewLong, Code code, LeafType type, USymbol symbol) { + Objects.requireNonNull(idNewLong); + Objects.requireNonNull(type); + throw new UnsupportedOperationException(); +// ILeaf result; +// if (this.V1972()) +// result = entityFactory.getLeafStrict(idNewLong); +// else +// result = entityFactory.getLeaf(code); +// +// if (result == null) { +// result = createLeafInternal(idNewLong, code, Display.getWithNewlines(code), type, symbol); +// result.setUSymbol(symbol); +// } +// +// if (result.getLeafType() == LeafType.CLASS && type == LeafType.OBJECT) +// if (result.muteToType(type, symbol) == false) +// return null; +// +// this.lastEntity = result; +// return result; + } + + public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) { + Objects.requireNonNull(idNewLong); + throw new UnsupportedOperationException(); +// if (entityFactory.getLeafStrict(idNewLong) != null) { +// return null; +// } +// return createLeafInternal(idNewLong, code, display, type, symbol); + } + + final protected ILeaf createLeafInternal(Ident newIdent, Code code, Display display, LeafType type, + USymbol symbol) { + Objects.requireNonNull(newIdent); + throw new UnsupportedOperationException(); +// if (Display.isNull(display)) +// display = Display.getWithNewlines(code).withCreoleMode(CreoleMode.SIMPLE_LINE); +// +// final ILeaf leaf = entityFactory.createLeaf(newIdent, code, display, type, getCurrentGroup(), getHides(), +// getNamespaceSeparator()); +// entityFactory.addLeaf(leaf); +// this.lastEntity = leaf; +// leaf.setUSymbol(symbol); +// return leaf; + } + + final public Ident buildLeafIdent(String id) { + return getLastID().add(id, getNamespaceSeparator()); + } + + final public Ident buildLeafIdentSpecial(String id) { + return buildFullyQualified(id); + } + + private Ident buildLeafIdentSpecialUnused(String id) { +// if (namespaceSeparator != null) { +// if (id.contains(namespaceSeparator)) { + return Ident.empty().add(id, "."); +// } +// } +// return getLastID().add(id, namespaceSeparator); + } + + final public Ident buildFullyQualified(String id) { + throw new UnsupportedOperationException(); + // return entityFactory.buildFullyQualified(getLastID(), Ident.empty().add(id, getNamespaceSeparator())); + } + + final public Code buildCode(String s) { + if (this.V1972()) + throw new UnsupportedOperationException(); + return CodeImpl.of(s); + } + + public boolean leafExist(Code code) { + throw new UnsupportedOperationException(); +// if (this.V1972()) +// throw new UnsupportedOperationException(); +// return entityFactory.getLeaf(code) != null; + } + + public boolean leafExistSmart(Ident ident) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeafSmart(ident) != null; + } + + public boolean leafExistStrict(Ident ident) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeafStrict(ident) != null; + } + + final public Collection getChildrenGroups(IGroup parent) { + if (this.V1972()) + return getChildrenGroupsIdent1972(parent); + final Collection result = new ArrayList<>(); + for (IGroup gg : getGroups(false)) + if (gg.getParentContainer() == parent) + result.add(gg); + + return Collections.unmodifiableCollection(result); + } + + private Collection getChildrenGroupsIdent1972(IGroup parent) { + throw new UnsupportedOperationException(); +// final Collection result = new ArrayList<>(); +// for (IGroup gg : entityFactory.groups2()) +// if (gg.getIdent().parent().equals(parent.getIdent())) +// result.add(gg); +// +// return Collections.unmodifiableCollection(result); + } + + final public void gotoGroup(Ident ident, Code code, Display display, GroupType type, IGroup parent, + NamespaceStrategy strategy) { + if (this.V1972()) { + gotoGroupInternalWithNamespace(ident, code, display, code, type, parent); + return; + + } + if (strategy == NamespaceStrategy.MULTIPLE) { + if (getNamespaceSeparator() != null) + code = getFullyQualifiedCode1972(code); + + gotoGroupInternalWithNamespace(ident, code, display, code, type, parent); + } else if (strategy == NamespaceStrategy.SINGLE) { + final Ident newIdLong = buildLeafIdentSpecial(ident.toString(this.getNamespaceSeparator())); + gotoGroupExternal(newIdLong, code, display, null, type, parent); + stacks2.add(newIdLong); + } else { + throw new IllegalArgumentException(); + } + } + + protected final String getNamespace1972(Code fullyCode, String separator) { + throw new UnsupportedOperationException(); +// String name = fullyCode.getName(); +// Objects.requireNonNull(separator); +// do { +// final int x = name.lastIndexOf(separator); +// if (x == -1) +// return null; +// +// name = name.substring(0, x); +// } while (entityFactory.getLeaf(buildCode(name)) != null); +// return name; + } + + private void gotoGroupInternalWithNamespace(Ident idNewLong, Code code, Display display, Code namespaceNew, + GroupType type, IGroup parent) { + throw new UnsupportedOperationException(); +// this.stacks.add(currentGroup); +// this.stacks2.add(idNewLong); +// +// if (this.V1972()) { +// gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent); +// return; +// } +// if (getNamespaceSeparator() == null) { +// gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent); +// return; +// } +// +// final String namespaceCurrent = getNamespace1972(code, getNamespaceSeparator()); +// if (namespaceCurrent == null) { +// gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent); +// return; +// } +// final IGroup realParent = entityFactory.getGroup(buildCode(namespaceCurrent)); +// if (realParent == null) { +// gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent); +// return; +// } +// display = Display.create(idNewLong.getLast()); +// IGroup result = entityFactory.createGroup(idNewLong, code, display, namespaceNew, type, realParent, getHides(), +// getNamespaceSeparator()); +// +// entityFactory.addGroup(result); +// currentGroup = result; + + } + + public void endGroup() { + throw new UnsupportedOperationException(); +// if (stacks2.size() > 0) { +// // Thread.dumpStack(); +// stacks2.remove(stacks2.size() - 1); +// } +// if (EntityUtils.groupRoot(currentGroup)) { +// Log.error("No parent group"); +// return; +// } +// if (stacks.size() > 0) +// currentGroup = stacks.remove(stacks.size() - 1); +// else +// currentGroup = currentGroup.getParentContainer(); + } + + private void gotoGroupInternal(Ident idNewLong, final Code code, Display display, final Code namespace, + GroupType type, IGroup parent) { + throw new UnsupportedOperationException(); +// if (this.V1972()) { +// gotoGroupInternal1972(idNewLong, code, display, namespace, type, parent); +// return; +// } +// +// IGroup result = entityFactory.getGroup(code); +// if (result != null) { +// currentGroup = result; +// return; +// } +// if (entityFactory.getLeafStrict(idNewLong) != null) { +// result = entityFactory.muteToGroup(code.getName(), namespace, type, parent); +// result.setDisplay(display); +// } else { +// result = entityFactory.createGroup(idNewLong, code, display, namespace, type, parent, getHides(), +// getNamespaceSeparator()); +// } +// entityFactory.addGroup(result); +// currentGroup = result; + } + + private void gotoGroupInternal1972(Ident idNewLong, final Code code, Display display, final Code namespace, + GroupType type, IGroup parent) { + throw new UnsupportedOperationException(); +// IGroup result = entityFactory.getGroupStrict(idNewLong); +// if (result != null) { +// currentGroup = result; +// return; +// } +// final boolean mutation; +// if (getNamespaceSeparator() == null) +// mutation = entityFactory.getLeafVerySmart(idNewLong) != null; +// else +// mutation = entityFactory.getLeafStrict(idNewLong) != null; +// if (mutation) { +// result = entityFactory.muteToGroup1972(idNewLong, namespace, type, parent); +// result.setDisplay(display); +// } else { +// result = entityFactory.createGroup(idNewLong, code, display, namespace, type, parent, getHides(), +// getNamespaceSeparator()); +// } +// entityFactory.addGroup(result); +// currentGroup = result; +// stacks2.set(stacks2.size() - 1, result.getIdent()); + } + + final protected void gotoGroupExternal(Ident newIdLong, final Code code, Display display, final Code namespace, + GroupType type, IGroup parent) { + throw new UnsupportedOperationException(); +// IGroup result = entityFactory.getGroup(code); +// if (result != null) { +// currentGroup = result; +// return; +// } +// if (entityFactory.getLeaf(code) != null) { +// result = entityFactory.muteToGroup(code.getName(), namespace, type, parent); +// result.setDisplay(display); +// } else { +// result = entityFactory.createGroup(newIdLong, code, display, namespace, type, parent, getHides(), +// getNamespaceSeparator()); +// } +// entityFactory.addGroup(result); +// // entityFactory.thisIsNotArealGroup(newIdLong); +// currentGroup = result; + } + + public final void gotoThisGroup(IGroup group) { + throw new UnsupportedOperationException(); +// currentGroup = group; + } + + final protected Code getFullyQualifiedCode1972(Code code) { + throw new UnsupportedOperationException(); +// final String separator = Objects.requireNonNull(getNamespaceSeparator()); +// final String full = code.getName(); +// if (full.startsWith(separator)) +// return buildCode(full.substring(separator.length())); +// +// if (full.contains(separator)) +// return buildCode(full); +// +// if (EntityUtils.groupRoot(currentGroup)) +// return buildCode(full); +// +// final Code namespace = currentGroup.getNamespace(); +// if (namespace == null) +// return buildCode(full); +// +// return buildCode(namespace.getName() + separator + full); + } + + public final IGroup getCurrentGroup() { + throw new UnsupportedOperationException(); +// return currentGroup; + } + + public final IGroup getGroup(Code code) { + throw new UnsupportedOperationException(); +// final IGroup p = entityFactory.getGroup(code); +// return Objects.requireNonNull(p); + } + + public final IGroup getGroupStrict(Ident ident) { + throw new UnsupportedOperationException(); +// if (!this.V1972()) +// throw new UnsupportedOperationException(); +// final IGroup p = entityFactory.getGroupStrict(ident); +// return Objects.requireNonNull(p); + } + + public final IGroup getGroupVerySmart(Ident ident) { + throw new UnsupportedOperationException(); +// if (!this.V1972()) +// throw new UnsupportedOperationException(); +// final IGroup p = entityFactory.getGroupVerySmart(ident); +// return Objects.requireNonNull(p); + } + + public final boolean isGroup(Code code) { + throw new UnsupportedOperationException(); +// if (this.V1972()) +// return isGroupStrict((Ident) code); +// return leafExist(code) == false && entityFactory.getGroup(code) != null; + } + + public final boolean isGroupStrict(Ident ident) { + throw new UnsupportedOperationException(); +// if (!this.V1972()) +// throw new UnsupportedOperationException(); +// return leafExistStrict(ident) == false && entityFactory.getGroupStrict(ident) != null; + } + + public final boolean isGroupVerySmart(Ident ident) { + throw new UnsupportedOperationException(); +// if (!this.V1972()) +// throw new UnsupportedOperationException(); +// return leafExistSmart(ident) == false && entityFactory.getGroupVerySmart(ident) != null; + } + + public final Collection getGroups(boolean withRootGroup) { + throw new UnsupportedOperationException(); +// if (withRootGroup == false) +// return entityFactory.groups(); +// +// final Collection result = new ArrayList<>(); +// result.add(getRootGroup()); +// result.addAll(entityFactory.groups()); +// return Collections.unmodifiableCollection(result); + } + + public IGroup getRootGroup() { + throw new UnsupportedOperationException(); +// return entityFactory.getRootGroup(); + } + + public final Collection getLeafsvalues() { + throw new UnsupportedOperationException(); +// return entityFactory.leafs2(); + } + + public final int getLeafssize() { + return getLeafsvalues().size(); + } + + public final ILeaf getLeaf(Code code) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeaf(code); + } + + public final ILeaf getLeafStrict(Ident ident) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeafStrict(ident); + } + + public final ILeaf getLeafSmart(Ident ident) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeafSmart(ident); + } + + public /* final */ ILeaf getLeafVerySmart(Ident ident) { + throw new UnsupportedOperationException(); +// return entityFactory.getLeafVerySmart(ident); + } + + final public void addLink(Link link) { + entityFactory.addLink(link); + } + + final protected void removeLink(Link link) { + entityFactory.removeLink(link); + } + + final public List getLinks() { + return entityFactory.getLinks(); + } + + abstract protected List getDotStrings(); + + final public String[] getDotStringSkek() { + final List result = new ArrayList<>(); + for (String s : getDotStrings()) + if (s.startsWith("nodesep") || s.startsWith("ranksep") || s.startsWith("layout")) + result.add(s); + + String aspect = getPragma().getValue("aspect"); + if (aspect != null) { + aspect = aspect.replace(',', '.'); + result.add("aspect=" + aspect + ";"); + } + final String ratio = getPragma().getValue("ratio"); + if (ratio != null) + result.add("ratio=" + ratio + ";"); + + return result.toArray(new String[result.size()]); + } + + private void createFilesGraphml(OutputStream suggestedFile) throws IOException { + final CucaDiagramGraphmlMaker maker = new CucaDiagramGraphmlMaker(this); + maker.createFiles(suggestedFile); + } + + private void createFilesXmi(OutputStream suggestedFile, FileFormat fileFormat) throws IOException { + final CucaDiagramXmiMaker maker = new CucaDiagramXmiMaker(this, fileFormat); + maker.createFiles(suggestedFile); + } + + private void createFilesScxml(OutputStream suggestedFile) throws IOException { +// final StateDiagramScxmlMaker maker = new StateDiagramScxmlMaker((StateDiagram) this); +// maker.createFiles(suggestedFile); + throw new UnsupportedOperationException(); + } + + @Override + protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) + throws IOException { + final FileFormat fileFormat = fileFormatOption.getFileFormat(); + + if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) { + try { + createFilesTxt(os, index, fileFormat); + } catch (Throwable t) { + t.printStackTrace(SecurityUtils.createPrintStream(os)); + } + return ImageDataSimple.ok(); + } + + if (fileFormat == FileFormat.GRAPHML) { + createFilesGraphml(os); + return ImageDataSimple.ok(); + } + + if (fileFormat.name().startsWith("XMI")) { + createFilesXmi(os, fileFormat); + return ImageDataSimple.ok(); + } + + if (fileFormat == FileFormat.SCXML) { + createFilesScxml(os); + return ImageDataSimple.ok(); + } + + if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) { + throw new UnsupportedOperationException(); + } + + final CucaDiagramFileMaker maker; + if (this.isUseElk()) + maker = new CucaDiagramFileMakerElk(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); + else if (this.isUseSmetana()) + maker = new CucaDiagramFileMakerSmetana(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); + else + maker = new CucaDiagramFileMakerSvek(this); + + final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption); + + if (result == null) + return ImageDataSimple.error(); + + this.warningOrError = result.getWarningOrError(); + return result; + } + + private String warningOrError; + + @Override + public String getWarningOrError() { + final String generalWarningOrError = super.getWarningOrError(); + if (warningOrError == null) + return generalWarningOrError; + + if (generalWarningOrError == null) + return warningOrError; + + return generalWarningOrError + BackSlash.NEWLINE + warningOrError; + } + + private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException { + final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat); + maker.createFiles(os, index); + } + + public boolean isAutarkic(IGroup g) { + if (g.getGroupType() == GroupType.PACKAGE) + return false; + + if (g.getGroupType() == GroupType.INNER_ACTIVITY) + return true; + + if (g.getGroupType() == GroupType.CONCURRENT_ACTIVITY) + return true; + + if (g.getGroupType() == GroupType.CONCURRENT_STATE) + return true; + + if (getChildrenGroups(g).size() > 0) + return false; + + for (Link link : getLinks()) + if (EntityUtils.isPureInnerLink3(g, link) == false) + return false; + + for (ILeaf leaf : g.getLeafsDirect()) + if (leaf.getEntityPosition() != EntityPosition.NORMAL) + return false; + + return true; + } + + private static boolean isNumber(String s) { + return s.matches("[+-]?(\\.?\\d+|\\d+\\.\\d*)"); + } + + public void resetPragmaLabel() { + getPragma().undefine("labeldistance"); + getPragma().undefine("labelangle"); + } + + public String getLabeldistance() { + if (getPragma().isDefine("labeldistance")) { + final String s = getPragma().getValue("labeldistance"); + if (isNumber(s)) + return s; + + } + if (getPragma().isDefine("defaultlabeldistance")) { + final String s = getPragma().getValue("defaultlabeldistance"); + if (isNumber(s)) + return s; + + } + // Default in dot 1.0 + return "1.7"; + } + + public String getLabelangle() { + if (getPragma().isDefine("labelangle")) { + final String s = getPragma().getValue("labelangle"); + if (isNumber(s)) + return s; + + } + if (getPragma().isDefine("defaultlabelangle")) { + final String s = getPragma().getValue("defaultlabelangle"); + if (isNumber(s)) + return s; + + } + // Default in dot -25 + return "25"; + } + + final public boolean isEmpty(IGroup gToTest) { + for (IEntity gg : getGroups(false)) { + if (gg == gToTest) + continue; + + if (gg.getParentContainer() == gToTest) + return false; + + } + return gToTest.size() == 0; + } + + public final boolean isVisibilityModifierPresent() { + return visibilityModifierPresent; + } + + public final void setVisibilityModifierPresent(boolean visibilityModifierPresent) { + this.visibilityModifierPresent = visibilityModifierPresent; + } + + public final boolean showPortion(EntityPortion portion, IEntity entity) { + if (getSkinParam().strictUmlStyle() && portion == EntityPortion.CIRCLED_CHARACTER) + return false; + + boolean result = true; + for (HideOrShow cmd : hideOrShows) + if (cmd.portion == portion && cmd.gender.contains(entity)) + result = cmd.show; + + return result; + } + + public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) { + for (EntityPortion portion : portions.asSet()) + this.hideOrShows.add(new HideOrShow(gender, portion, show)); + + } + + public void hideOrShow(Set visibilities, boolean show) { + if (show) + hides.removeAll(visibilities); + else + hides.addAll(visibilities); + } + + public void hideOrShow2(String what, boolean show) { + this.hides2.add(new HideOrShow2(what, show)); + } + + public void removeOrRestore(String what, boolean show) { + this.removed.add(new HideOrShow2(what, show)); + } + + private final List hideOrShows = new ArrayList<>(); + private final Set hides = new HashSet<>(); + + static class HideOrShow { + private final EntityGender gender; + private final EntityPortion portion; + private final boolean show; + + public HideOrShow(EntityGender gender, EntityPortion portion, boolean show) { + this.gender = gender; + this.portion = portion; + this.show = show; + } + } + + public final Set getHides() { + return Collections.unmodifiableSet(hides); + } + + final public boolean isStandalone(IEntity ent) { + for (final Link link : getLinks()) + if (link.getEntity1() == ent || link.getEntity2() == ent) + return false; + + return true; + } + + final public boolean isStandaloneForArgo(IEntity ent) { + for (final Link link : getLinks()) { + if (link.isHidden() || link.isInvis()) + continue; + if (link.getEntity1() == ent || link.getEntity2() == ent) + return false; + } + + return true; + } + + final public Link getLastLink() { + final List links = getLinks(); + for (int i = links.size() - 1; i >= 0; i--) { + final Link link = links.get(i); + if (link.getEntity1().getLeafType() != LeafType.NOTE && link.getEntity2().getLeafType() != LeafType.NOTE) + return link; + + } + return null; + } + + final public List getTwoLastLinks() { + final List result = new ArrayList<>(); + final List links = getLinks(); + for (int i = links.size() - 1; i >= 0; i--) { + final Link link = links.get(i); + if (link.getEntity1().getLeafType() != LeafType.NOTE && link.getEntity2().getLeafType() != LeafType.NOTE) { + result.add(link); + if (result.size() == 2) + return Collections.unmodifiableList(result); + + } + } + return null; + } + + private ILeaf lastEntity = null; + + final public ILeaf getLastEntity() { + return lastEntity; + } + + final public IEntityFactory getIEntityFactory() { + return entityFactory; + } + + final public EntityFactory getEntityFactory() { + throw new UnsupportedOperationException(); + // return entityFactory; + } + + public void applySingleStrategy() { +// final MagmaList magmaList = new MagmaList(); +// +// for (IGroup g : getGroups(true)) { +// final List standalones = new ArrayList<>(); +// +// for (ILeaf ent : g.getLeafsDirect()) +// if (isStandalone(ent)) +// standalones.add(ent); +// +// if (standalones.size() < 3) +// continue; +// +// final Magma magma = new Magma(this, standalones); +// magma.putInSquare(); +// magmaList.add(magma); +// } +// +// for (IGroup g : getGroups(true)) { +// final MagmaList magmas = magmaList.getMagmas(g); +// if (magmas.size() < 3) +// continue; +// +// magmas.putInSquare(); +// } + + } + + public boolean isHideEmptyDescriptionForState() { + return false; + } + + protected void incRawLayout() { + entityFactory.incRawLayout(); + } + + public CommandExecutionResult constraintOnLinks(Link link1, Link link2, Display display) { + final LinkConstraint linkConstraint = new LinkConstraint(link1, link2, display); + link1.setLinkConstraint(linkConstraint); + link2.setLinkConstraint(linkConstraint); + return CommandExecutionResult.ok(); + } + + @Override + public ClockwiseTopRightBottomLeft getDefaultMargins() { + // Strange numbers here for backwards compatibility + return ClockwiseTopRightBottomLeft.topRightBottomLeft(0, 5, 5, 0); + } + + private final AtomicInteger cpt = new AtomicInteger(1); + + public int getUniqueSequence() { + return cpt.addAndGet(1); + } + + public String getUniqueSequence(String prefix) { + return prefix + getUniqueSequence(); + } + +} diff --git a/src/net/sourceforge/plantuml/baraye/b/EntityImp.java b/src/net/sourceforge/plantuml/baraye/b/EntityImp.java new file mode 100644 index 000000000..45a33151c --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/EntityImp.java @@ -0,0 +1,896 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * Contribution: Hisashi Miyashita + * Contribution: Miguel Esteves + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.Guillemet; +import net.sourceforge.plantuml.Hideable; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineConfigurable; +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.Removeable; +import net.sourceforge.plantuml.SpecificBackcolorable; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.baraye.Quark; +import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Bodier; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.CucaNote; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; +import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.EntityUtils; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.Stereostyles; +import net.sourceforge.plantuml.cucadiagram.Stereotag; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockEmpty; +import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.graphic.USymbols; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.svek.IEntityImage; +import net.sourceforge.plantuml.svek.Kal; +import net.sourceforge.plantuml.svek.Margins; +import net.sourceforge.plantuml.svek.PackageStyle; +import net.sourceforge.plantuml.svek.SingleStrategy; +import net.sourceforge.plantuml.svek.image.EntityImageStateCommon; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +final public class EntityImp + implements SpecificBackcolorable, Hideable, Removeable, LineConfigurable, ILeaf, IGroup { + + private final ZEntityFactory entityFactory; + + private Quark quark; + + private Url url; + + private final Bodier bodier; + private final String uid; + private Display display = Display.empty(); + private DisplayPositioned legend = null; + + private LeafType leafType; + private Stereotype stereotype; + private Stereostyles stereostyles = Stereostyles.NONE; + private String generic; + + private GroupType groupType; + + // Other + private Margins margins = Margins.NONE; + private final Collection portShortNames = new HashSet<>(); + private int xposition; + private IEntityImage svekImage; + + private USymbol symbol; + private final int rawLayout; + private char concurrentSeparator; + private LineLocation codeLine; + + private Set tags = new LinkedHashSet<>(); + private final List notesTop = new ArrayList<>(); + private final List notesBottom = new ArrayList<>(); + + // @Override + public void addNote(Display note, Position position, Colors colors) { + if (position == Position.TOP) + notesTop.add(CucaNote.build(note, position, colors)); + else if (position == Position.BOTTOM) + notesBottom.add(CucaNote.build(note, position, colors)); + } + + // @Override + public List getNotes(Position position) { + if (position == Position.TOP) + return Collections.unmodifiableList(notesTop); + if (position == Position.BOTTOM) + return Collections.unmodifiableList(notesBottom); + throw new IllegalArgumentException(); + } + + public void addStereotag(Stereotag tag) { + this.tags.add(tag); + } + + public Set stereotags() { + return Collections.unmodifiableSet(tags); + } + + // Back to Entity + private EntityImp(Quark quark, ZEntityFactory entityFactory, Bodier bodier, int rawLayout) { + this.quark = Objects.requireNonNull(quark); + this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence()); + this.entityFactory = entityFactory; + this.bodier = bodier; + this.rawLayout = rawLayout; + } + + EntityImp(Quark quark, ZEntityFactory entityFactory, Bodier bodier, LeafType leafType, int rawLayout) { + this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout); + // System.err.println("ID for leaf=" + code + " " + ident); + // ident.checkSameAs(code, namespaceSeparator); + this.leafType = leafType; + } + + EntityImp(Quark quark, ZEntityFactory entityFactory, Bodier bodier, GroupType groupType, int rawLayout) { + this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout); + // System.err.println("ID for group=" + code + " " + ident); + this.groupType = groupType; + } + + public LeafType getLeafType() { + return leafType; + } + + public boolean muteToType(LeafType newType, USymbol newSymbol) { + checkNotGroup(); + Objects.requireNonNull(newType); + if (leafType != LeafType.STILL_UNKNOWN) { + if (newType == this.leafType) + return true; + + if (leafType != LeafType.ANNOTATION && leafType != LeafType.ABSTRACT_CLASS && leafType != LeafType.CLASS + && leafType != LeafType.ENUM && leafType != LeafType.INTERFACE) { + return false; + // throw new IllegalArgumentException("type=" + leafType); + } + if (newType != LeafType.ANNOTATION && newType != LeafType.ABSTRACT_CLASS && newType != LeafType.CLASS + && newType != LeafType.ENUM && newType != LeafType.INTERFACE && newType != LeafType.OBJECT) { + return false; + // throw new IllegalArgumentException("newtype=" + newType); + } + } + if (leafType == LeafType.CLASS && newType == LeafType.OBJECT) + bodier.muteClassToObject(); + + this.leafType = newType; + this.symbol = newSymbol; + return true; + } + + public Quark getQuark() { + return quark; + } + + public String getCodeGetName() { + return getQuark().getName(); + } + + public Display getDisplay() { +// if (intricated) +// return entityFactory.getIntricatedDisplay(ident); + return display; + } + + public void setDisplay(Display display) { + this.display = display; + } + + public String getUid() { + return uid; + } + + public Stereotype getStereotype() { + return stereotype; + } + + public final void setStereotype(Stereotype stereotype) { + this.stereotype = stereotype; + } + +// public final IGroup getParentContainer() { +// return entityFactory.getParentContainer(ident, parentContainer); +// // Objects.requireNonNull(parentContainer); +// // return parentContainer; +// } + + @Override + public String toString() { + return quark.toString() + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid(); + } + + public final Url getUrl99() { + return url; + } + + public boolean hasUrl() { + if (Display.isNull(display) == false && display.hasUrl()) + return true; + + if (bodier.hasUrl()) + return true; + + return url != null; + } + + public final void addUrl(Url url) { + this.url = url; + } + + public final Margins getMargins() { + checkNotGroup(); + return margins; + } + + public final void ensureMargins(Margins newMargins) { + // checkNotGroup(); + this.margins = this.margins.merge(newMargins); + } + + public int getXposition() { + checkNotGroup(); + return xposition; + } + + public void setXposition(int pos) { + checkNotGroup(); + xposition = pos; + } + + public final IEntityImage getSvekImage() { + checkNotGroup(); + return svekImage; + } + + public final void setSvekImage(IEntityImage svekImage) { + checkNotGroup(); + this.svekImage = svekImage; + } + + public final void setGeneric(String generic) { + checkNotGroup(); + this.generic = generic; + } + + public final String getGeneric() { + checkNotGroup(); + return generic; + } + + public Bodier getBodier() { + return bodier; + } + + public EntityPosition getEntityPosition() { +// if (leafType == LeafType.PORT) +// return EntityPosition.PORT; + + if (leafType == LeafType.PORTIN) + return EntityPosition.PORTIN; + + if (leafType == LeafType.PORTOUT) + return EntityPosition.PORTOUT; + + if (leafType != LeafType.STATE) + return EntityPosition.NORMAL; + + if (quark.isRoot()) + return EntityPosition.NORMAL; + + final Stereotype stereotype = getStereotype(); + if (stereotype == null) + return EntityPosition.NORMAL; + + return EntityPosition.fromStereotype(stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR)); + + } + + // ---------- + + private void checkGroup() { + if (isGroup() == false) + throw new UnsupportedOperationException(); + + } + + private void checkNotGroup() { + if (isGroup()) + throw new UnsupportedOperationException(); + + } + +// public boolean containsLeafRecurse(ILeaf leaf) { +// if (Objects.requireNonNull(leaf).isGroup()) +// throw new IllegalArgumentException(); +// +// checkGroup(); +// if (leaf.getParentContainer() == this) +// return true; +// +// for (IGroup child : getChildren()) +// if (child.containsLeafRecurse(leaf)) +// return true; +// +// return false; +// } + +// public Collection getLeafsDirect() { +// checkGroup(); +// final List result = new ArrayList<>(); +// for (ILeaf ent : entityFactory.leafs()) { +// if (ent.isGroup()) +// throw new IllegalStateException(); +// +// if (ent.getParentContainer() == this) +// result.add(ent); +// +// } +// return Collections.unmodifiableCollection(result); +// } + +// public Collection getChildren() { +// checkGroup(); +// final Collection result = new ArrayList<>(); +// for (IGroup g : entityFactory.groups()) +// if (g != this && g.getParentContainer() == this) +// result.add(g); +// +// return Collections.unmodifiableCollection(result); +// } + +// public void moveEntitiesTo(IGroup dest) { +// if (entityFactory.namespaceSeparator.V1972()) { +// moveEntitiesTo1972(dest); +// return; +// } +// checkGroup(); +// if (dest.isGroup() == false) +// throw new UnsupportedOperationException(); +// +// for (ILeaf ent : getLeafsDirect()) +// ((ZEntityImpl) ent).parentContainer = dest; +// +// for (IGroup g : dest.getChildren()) +// // ((EntityImpl) g).parentContainer = dest; +// throw new IllegalStateException(); +// +// for (IGroup g : getChildren()) { +// if (g == dest) +// continue; +// +// ((ZEntityImpl) g).parentContainer = dest; +// } +// +// } + +// private void moveEntitiesTo1972(IGroup dest) { +// checkGroup(); +// if (dest.isGroup() == false) +// throw new UnsupportedOperationException(); +// +// // System.err.println("moveEntitiesTo1972::before1::groups2=" + +// // entityFactory.groups2()); +// final Ident firstIdent = getIdent(); +// final Ident destIdent = dest.getIdent(); +// // System.err.println("moveEntitiesTo1972::this=" + firstIdent); +// // System.err.println("moveEntitiesTo1972::dest=" + destIdent); +// if (destIdent.startsWith(firstIdent) == false) +// throw new UnsupportedOperationException(); +// +// // System.err.println("moveEntitiesTo1972::before2::groups2=" + +// // entityFactory.groups2()); +// for (ILeaf ent : new ArrayList<>(entityFactory.leafs2())) { +// Ident ident = ent.getIdent(); +// if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent) +// && ident.startsWith(destIdent) == false) { +// // System.err.print("moving leaf ident1=" + ident); +// entityFactory.leafs2.remove(ident); +// ident = ident.move(firstIdent, destIdent); +// // System.err.println(" to ident2=" + ident); +// ((ZEntityImpl) ent).ident = ident; +// ((ZEntityImpl) ent).code = ident; +// entityFactory.leafs2.put(ident, ent); +// } +// } +// // System.err.println("moveEntitiesTo1972::before3::groups2=" + +// // entityFactory.groups2()); +// for (IGroup ent : new ArrayList<>(entityFactory.groups2())) { +// Ident ident = ent.getIdent(); +// // System.err.println("found=" + ident + " " + ident.startsWith(firstIdent) + " +// // " +// // + ident.startsWith(destIdent)); +// if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent) +// && ident.startsWith(destIdent) == false) { +// // System.err.print("moving gr ident1=" + ident); +// entityFactory.groups2.remove(ident); +// ident = ident.move(firstIdent, destIdent); +// // System.err.println(" to ident2=" + ident); +// ((ZEntityImpl) ent).ident = ident; +// ((ZEntityImpl) ent).code = ident; +// entityFactory.groups2.put(ident, ent); +// // System.err.println("-->groups2=" + entityFactory.groups2()); +// } +// } +// // System.err.println("moveEntitiesTo1972::after::groups2=" + +// // entityFactory.groups2()); +// // for (IGroup g : dest.getChildren()) { +// // // ((EntityImpl) g).parentContainer = dest; +// // throw new IllegalStateException(); +// // } +// // +// // for (IGroup g : getChildren()) { +// // if (g == dest) { +// // continue; +// // } +// // ((EntityImpl) g).parentContainer = dest; +// // } +// +// } + +// public int size() { +// checkGroup(); +// return getLeafsDirect().size(); +// } + + public GroupType getGroupType() { + checkGroup(); + return groupType; + } + +// public Code getNamespace() { +// checkGroup(); +// return namespace; +// } + + public PackageStyle getPackageStyle() { + checkGroup(); + if (stereotype == null) + return null; + + return stereotype.getPackageStyle(); + } + + public boolean isGroup() { + if (groupType != null && leafType != null) + throw new IllegalStateException(); + + assert groupType == null || leafType == null; + if (groupType != null) + return true; + + if (leafType != null) + return false; + + throw new IllegalStateException(); + } + + // ---- other + + public void overrideImage(IEntityImage img, LeafType leafType) { + checkGroup(); + this.svekImage = img; + this.url = null; + + for (final Link link : new ArrayList<>(entityFactory.getLinks())) + if (EntityUtils.isPureInnerLink12(this, link)) + entityFactory.removeLink(link); + +// if (entityFactory.namespaceSeparator.V1972()) { +// entityFactory.removeGroup(getIdent()); +// for (ILeaf ent : new ArrayList<>(entityFactory.leafs())) +// if (this != ent && getIdent().equals(ent.getIdent().parent())) +// entityFactory.removeLeaf(ent.getIdent()); +// +// } else { +// entityFactory.removeGroup(getCodeGetName()); +// for (ILeaf ent : new ArrayList<>(entityFactory.leafs())) +// if (this != ent && this == ent.getParentContainer()) +// entityFactory.removeLeaf(ent.getCodeGetName()); +// } +// +// entityFactory.addLeaf(this); +// this.groupType = null; +// this.leafType = leafType; + throw new UnsupportedOperationException("to be finished"); + } + +// void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { +// checkNotGroup(); +// if (parentContainer.isGroup() == false) +// throw new IllegalArgumentException(); +// +// this.namespace = namespaceNew; +// this.groupType = groupType; +// this.leafType = null; +// this.parentContainer = parentContainer; +// } + + public USymbol getUSymbol() { + if (getLeafType() == LeafType.CIRCLE) + return USymbols.INTERFACE; + + // if (symbol != null && stereotype != null && stereotype.getSprite() != null) { + // return symbol.withStereoAlignment(HorizontalAlignment.RIGHT); + // } + return symbol; + } + + public void setUSymbol(USymbol symbol) { + this.symbol = symbol; + } + + public SingleStrategy getSingleStrategy() { + return SingleStrategy.SQUARE; + } + + public boolean isHidden() { + return false; +// if (parentContainer != null && parentContainer.isHidden()) +// return true; +// +// return isHiddenInternal(); + } + +// private boolean isHiddenInternal() { +// if (isGroup()) { +// if (entityFactory.isHidden(this)) +// return true; +// +// if (getLeafsDirect().size() == 0) +// return false; +// +// for (ILeaf leaf : getLeafsDirect()) +// if (((ZEntityImpl) leaf).isHiddenInternal() == false) +// return false; +// +// for (IGroup g : getChildren()) +// if (((ZEntityImpl) g).isHiddenInternal() == false) +// return false; +// +// return true; +// } +// return entityFactory.isHidden(this); +// } + + public boolean isRemoved() { + return false; +// if (parentContainer != null && parentContainer.isRemoved()) +// return true; +// +// return isRemovedInternal(); + } + +// private boolean isRemovedInternal() { +// if (isGroup()) { +// if (entityFactory.isRemoved(this)) +// return true; +// +// if (getLeafsDirect().size() == 0 && getChildren().size() == 0) +// return false; +// +// for (ILeaf leaf : getLeafsDirect()) +// if (((ZEntityImpl) leaf).isRemovedInternal() == false) +// return false; +// +// for (IGroup g : getChildren()) +// if (((ZEntityImpl) g).isRemovedInternal() == false) +// return false; +// +// return true; +// } +// return entityFactory.isRemoved(this); +// } + + public boolean isAloneAndUnlinked() { + return false; +// if (isGroup()) +// return false; +// +// for (Link link : entityFactory.getLinks()) +// if (link.contains(this)) { +// final ILeaf other = (ILeaf) link.getOther(this); +// final boolean removed = entityFactory.isRemovedIgnoreUnlinked(other); +// if (removed == false && link.getType().isInvisible() == false) +// return false; +// } +// +// return true; + } + + private FontParam getTitleFontParam() { + return getGroupType() == GroupType.STATE ? FontParam.STATE : FontParam.PACKAGE; + } + + public FontConfiguration getFontConfigurationForTitle(final ISkinParam skinParam) { + final FontParam fontParam = getTitleFontParam(); + final HColor fontHtmlColor = skinParam.getFontHtmlColor(getStereotype(), fontParam, FontParam.PACKAGE); + final UFont font = skinParam.getFont(getStereotype(), true, fontParam, FontParam.PACKAGE); + final FontConfiguration fontConfiguration = FontConfiguration.create(font, fontHtmlColor, + skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink(), skinParam.getTabSize()); + return fontConfiguration; + } + + public final int getRawLayout() { + return rawLayout; + } + + public char getConcurrentSeparator() { + return concurrentSeparator; + } + + public void setConcurrentSeparator(char separator) { + this.concurrentSeparator = separator; + } + + private Neighborhood neighborhood; + + public void setNeighborhood(Neighborhood neighborhood) { + this.neighborhood = neighborhood; + } + + public Neighborhood getNeighborhood() { + return neighborhood; + } + + private final Map tips = new LinkedHashMap(); + + public void putTip(String member, Display display) { + tips.put(member, display); + } + + public Map getTips() { + return Collections.unmodifiableMap(tips); + } + + private Colors colors = Colors.empty(); + + public Colors getColors() { + return colors; + } + + public void setColors(Colors colors) { + this.colors = colors; + } + + public void setSpecificColorTOBEREMOVED(ColorType type, HColor color) { + if (color != null) + this.colors = colors.add(type, color); + + } + + public Collection getPortShortNames() { + checkNotGroup(); + return Collections.unmodifiableCollection(portShortNames); + } + + public void addPortShortName(String portShortName) { + portShortNames.add(portShortName); + } + + private VisibilityModifier visibility; + + public void setVisibilityModifier(VisibilityModifier visibility) { + this.visibility = visibility; + + } + + public VisibilityModifier getVisibilityModifier() { + return visibility; + } + + public void setLegend(DisplayPositioned legend) { + checkGroup(); + this.legend = legend; + } + + public DisplayPositioned getLegend() { + return legend; + } + +// private boolean intricated; +// +// public void setIntricated(boolean intricated) { +// this.intricated = intricated; +// } + +// private IGroup originalGroup; +// +// public void setOriginalGroup(IGroup originalGroup) { +// this.originalGroup = originalGroup; +// this.legend = originalGroup.getLegend(); +// } + + public IGroup getOriginalGroup() { + throw new UnsupportedOperationException(); + // return originalGroup; + } + + private boolean together; + + public void setThisIsTogether() { + this.together = true; + } + + public String getCodeLine() { + if (this.codeLine == null) + return null; + + return "" + this.codeLine.getPosition(); + } + + public void setCodeLine(LineLocation codeLine) { + this.codeLine = codeLine; + } + + // @Override + public void setStereostyle(String stereo) { + this.stereostyles = Stereostyles.build(stereo); + } + + // @Override + public Stereostyles getStereostyles() { + return stereostyles; + } + + private final Map> kals = new EnumMap<>(Direction.class); + + public void addKal(Kal kal) { + final Direction position = kal.getPosition(); + List list = kals.get(position); + if (list == null) { + list = new ArrayList<>(); + kals.put(position, list); + } + list.add(kal); + } + + public List getKals(Direction position) { + final List result = kals.get(position); + if (result == null) + return Collections.emptyList(); + return Collections.unmodifiableList(result); + } + + public ICucaDiagram getDiagram() { + return entityFactory.getDiagram(); + } + + private boolean isStatic; + + // @Override + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + + // @Override + public boolean isStatic() { + return isStatic; + } + + // For group + + public TextBlock getStateHeader(ISkinParam skinParam) { + checkGroup(); + final Style style = EntityImageStateCommon.getStyleStateHeader(this, skinParam); + final List details = getBodier().getRawBody(); + + if (details.size() == 0) + return new TextBlockEmpty(); + + if (style == null) + throw new IllegalArgumentException(); + final FontConfiguration fontConfiguration = FontConfiguration.create(skinParam, style); + + Display display = null; + for (CharSequence s : details) + if (display == null) + display = Display.getWithNewlines(s.toString()); + else + display = display.addAll(Display.getWithNewlines(s.toString())); + + return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); + + } + + @Override + public Code getCode() { + return quark; + } + + @Override + public Ident getIdent() { + throw new UnsupportedOperationException(); + } + + @Override + public IGroup getParentContainer() { + return (IGroup) quark.getParent().getData(); + } + + @Override + public void setContainer(IGroup container) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean containsLeafRecurse(ILeaf entity) { + throw new UnsupportedOperationException(); + } + + @Override + public Collection getLeafsDirect() { + throw new UnsupportedOperationException(); + } + + @Override + public Collection getChildren() { + throw new UnsupportedOperationException(); + } + + @Override + public void moveEntitiesTo(IGroup dest) { + throw new UnsupportedOperationException(); + } + + @Override + public int size() { + throw new UnsupportedOperationException(); + } + + @Override + public Code getNamespace() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/baraye/b/IEntity.java b/src/net/sourceforge/plantuml/baraye/b/IEntity.java new file mode 100644 index 000000000..8009455ee --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/IEntity.java @@ -0,0 +1,126 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * Contribution: Miguel Esteves + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.Hideable; +import net.sourceforge.plantuml.LineConfigurable; +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.Removeable; +import net.sourceforge.plantuml.SpecificBackcolorable; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Bodier; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.CucaNote; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Stereostyles; +import net.sourceforge.plantuml.cucadiagram.Stereotag; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.graphic.color.Colors; + +public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, LineConfigurable { + + public Code getCode(); + + public String getCodeGetName(); + + public Ident getIdent(); + + public USymbol getUSymbol(); + + public void setUSymbol(USymbol symbol); + + public LeafType getLeafType(); + + public Display getDisplay(); + + public IGroup getParentContainer(); + + public void setDisplay(Display display); + + public String getUid(); + + public Url getUrl99(); + + public Stereotype getStereotype(); + + public void setStereotype(Stereotype stereotype); + + public Bodier getBodier(); + + public void addUrl(Url url); + + public boolean isGroup(); + + public boolean hasUrl(); + + public int getRawLayout(); + + public void putTip(String member, Display display); + + public Map getTips(); + + public void addStereotag(Stereotag tag); + + public Set stereotags(); + + public boolean isAloneAndUnlinked(); + + public void setThisIsTogether(); + + public String getCodeLine(); + + public void setCodeLine(LineLocation codeLine); + + public void setStereostyle(String stereo); + + public Stereostyles getStereostyles(); + + public void addNote(Display note, Position position, Colors colors); + + public EntityPosition getEntityPosition(); + + public List getNotes(Position position); + +} diff --git a/src/net/sourceforge/plantuml/baraye/b/IGroup.java b/src/net/sourceforge/plantuml/baraye/b/IGroup.java new file mode 100644 index 000000000..39b4a115f --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/IGroup.java @@ -0,0 +1,82 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.util.Collection; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.svek.IEntityImage; +import net.sourceforge.plantuml.svek.PackageStyle; +import net.sourceforge.plantuml.svek.SingleStrategy; + +public interface IGroup extends IEntity { + + public boolean containsLeafRecurse(ILeaf entity); + + public Collection getLeafsDirect(); + + public Collection getChildren(); + + public void moveEntitiesTo(IGroup dest); + + public int size(); + + public GroupType getGroupType(); + + public Code getNamespace(); + + public PackageStyle getPackageStyle(); + + public void overrideImage(IEntityImage img, LeafType state); + + public SingleStrategy getSingleStrategy(); + + public FontConfiguration getFontConfigurationForTitle(ISkinParam skinParam); + + public char getConcurrentSeparator(); + + public void setConcurrentSeparator(char separator); + + public void setLegend(DisplayPositioned legend); + + public DisplayPositioned getLegend(); + +} diff --git a/src/net/sourceforge/plantuml/baraye/b/ILeaf.java b/src/net/sourceforge/plantuml/baraye/b/ILeaf.java new file mode 100644 index 000000000..8432802dd --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/ILeaf.java @@ -0,0 +1,83 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.util.Collection; + +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood; +import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.svek.IEntityImage; +import net.sourceforge.plantuml.svek.Margins; + +public interface ILeaf extends IEntity { + + public void setContainer(IGroup container); + + public Margins getMargins(); + + public int getXposition(); + + public void setXposition(int pos); + + public IEntityImage getSvekImage(); + + public String getGeneric(); + + public boolean muteToType(LeafType newType, USymbol newSymbol); + + public void setGeneric(String generic); + + public void setSvekImage(IEntityImage svekImage); + + public void setNeighborhood(Neighborhood neighborhood); + + public Neighborhood getNeighborhood(); + + public Collection getPortShortNames(); + + public void addPortShortName(String portShortName); + + public void setVisibilityModifier(VisibilityModifier visibility); + + public VisibilityModifier getVisibilityModifier(); + + public void setStatic(boolean isStatic); + + public boolean isStatic(); + +} diff --git a/src/net/sourceforge/plantuml/baraye/b/ZEntityFactory.java b/src/net/sourceforge/plantuml/baraye/b/ZEntityFactory.java new file mode 100644 index 000000000..1c39b52d1 --- /dev/null +++ b/src/net/sourceforge/plantuml/baraye/b/ZEntityFactory.java @@ -0,0 +1,501 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.baraye.b; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.baraye.Plasma; +import net.sourceforge.plantuml.baraye.Quark; +import net.sourceforge.plantuml.baraye.a.ILeaf; +import net.sourceforge.plantuml.cucadiagram.Bodier; +import net.sourceforge.plantuml.cucadiagram.BodierJSon; +import net.sourceforge.plantuml.cucadiagram.BodierMap; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.GroupType; +import net.sourceforge.plantuml.cucadiagram.HideOrShow2; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; +import net.sourceforge.plantuml.skin.VisibilityModifier; + +public final class ZEntityFactory implements IEntityFactory { + + private final List links = new ArrayList<>(); + + private int rawLayout; + + private final Plasma plasma; + + private final List hides2; + private final List removed; + /* private */ final public ICucaDiagram namespaceSeparator; + // private final boolean mergeIntricated; + // private Map emptyGroupsAsNode = new HashMap(); + + public ILeaf getLeafForEmptyGroup(IGroup g) { +// return emptyGroupsAsNode.get(g); + throw new UnsupportedOperationException(); + } + + public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) { + throw new UnsupportedOperationException(); +// final ILeaf folder = this.createLeaf(g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, +// g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator()); +// ((ZEntityImpl) folder).setOriginalGroup(g); +// final USymbol symbol = g.getUSymbol(); +// folder.setUSymbol(symbol); +// folder.setStereotype(g.getStereotype()); +// folder.setColors(g.getColors()); +// if (g.getUrl99() != null) +// folder.addUrl(g.getUrl99()); +// for (Stereotag tag : g.stereotags()) +// folder.addStereotag(tag); +// +// emptyGroupsAsNode.put(g, folder); +// return folder; + } +// +// public Display getIntricatedDisplay(Ident ident) { +// final Set known = new HashSet<>(groups2.keySet()); +// known.removeAll(hiddenBecauseOfIntrication); +// String sep = namespaceSeparator.getNamespaceSeparator(); +// if (sep == null) +// sep = "."; +// +// for (int check = ident.size() - 1; check > 0; check--) +// if (known.contains(ident.getPrefix(check))) +// // if (hiddenBecauseOfIntrication.contains(ident.getPrefix(check)) == false) +// return Display.getWithNewlines(ident.getSuffix(check).toString(sep)) +// .withCreoleMode(CreoleMode.SIMPLE_LINE); +// +// return Display.getWithNewlines(ident.toString(sep)).withCreoleMode(CreoleMode.SIMPLE_LINE); +// } +// +// private final Collection hiddenBecauseOfIntrication = new ArrayList<>(); +// + public IGroup isIntricated(IGroup parent) { +// final int leafs = parent.getLeafsDirect().size(); +// final Collection children = parent.getChildren(); +// if (leafs == 0 && children.size() == 1) { +// final IGroup g = children.iterator().next(); +// if (g.getLeafsDirect().size() == 0 && g.getChildren().size() == 0 && g.getGroupType() == GroupType.PACKAGE) +// return null; +// +// for (Link link : this.getLinks()) +// if (link.contains(parent)) +// return null; +// +// ((ZEntityImpl) g).setIntricated(true); +// hiddenBecauseOfIntrication.add(parent.getIdent()); +// return g; +// } +// return null; + throw new UnsupportedOperationException(); + } + + public ZEntityFactory(List hides2, List removed, ICucaDiagram namespaceSeparator) { + this.hides2 = hides2; + this.removed = removed; + this.namespaceSeparator = namespaceSeparator; + // this.plasma = new Plasma(namespaceSeparator.getNamespaceSeparator()); + this.plasma = new Plasma("."); + } + + public boolean isHidden(EntityImp leaf) { + return false; +// final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); +// if (other instanceof ILeaf) +// return isHidden((ILeaf) other); +// +// boolean hidden = false; +// for (HideOrShow2 hide : hides2) +// hidden = hide.apply(hidden, leaf); +// +// return hidden; + } + + public boolean isRemoved(Stereotype stereotype) { + boolean result = false; + for (HideOrShow2 hide : removed) + result = hide.apply(result, stereotype); + + return result; + } + + public boolean isRemoved(EntityImp leaf) { + return false; +// final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); +// if (other instanceof ILeaf) +// return isRemoved((ILeaf) other); +// +// boolean result = false; +// for (HideOrShow2 hide : removed) +// result = hide.apply(result, leaf); +// +// return result; + } + +// private IEntity isNoteWithSingleLinkAttachedTo(ILeaf leaf) { +// if (leaf.getLeafType() != LeafType.NOTE) +// return null; +// IEntity result = null; +// for (Link link : this.getLinks()) { +// if (link.getType().isInvisible()) +// continue; +// if (link.contains(leaf)) { +// if (result != null) +// return result; +// result = link.getOther(leaf); +// } +// } +// return result; +// +// } + +// public boolean isRemovedIgnoreUnlinked(ILeaf leaf) { +// boolean result = false; +// for (HideOrShow2 hide : removed) +// if (hide.isAboutUnlinked() == false) +// result = hide.apply(result, leaf); +// +// return result; +// } + + public EntityImp createLeaf(Quark quark, Display display, LeafType entityType, Set hides, + String namespaceSeparator) { + final Bodier bodier; + if (Objects.requireNonNull(entityType) == LeafType.MAP) + bodier = new BodierMap(); + else if (Objects.requireNonNull(entityType) == LeafType.JSON) + bodier = new BodierJSon(); + else + bodier = BodyFactory.createLeaf(entityType, hides); + + final EntityImp result = new EntityImp(quark, this, bodier, entityType, rawLayout); + // bodier.setLeaf(result); + result.setDisplay(display); + return result; + } + + public EntityImp createGroup(Quark quark, Display display, GroupType groupType, Set hides, + String namespaceSeparator) { + Objects.requireNonNull(groupType); + if (quark.getData() != null) + return (EntityImp) quark.getData(); +// for (Entry ent : groups2.entrySet()) +// if (ent.getKey().equals(ident)) +// return ent.getValue(); + + final Bodier bodier = BodyFactory.createGroup(hides); + final EntityImp result = new EntityImp(quark, this, bodier, groupType, rawLayout); + if (Display.isNull(display) == false) + result.setDisplay(display); + + return result; + } + + public void addLeaf(ILeaf entity) { +// if (namespaceSeparator.V1972() == false) +// leafsByCode.put(entity.getCodeGetName(), entity); +// leafs2.put(entity.getIdent(), entity); +// if (namespaceSeparator.V1972()) +// ensureParentIsCreated(entity.getIdent()); + throw new UnsupportedOperationException(); + } +// +// public void addGroup(IGroup group) { +// if (namespaceSeparator.V1972() == false) +// groupsByCode.put(group.getCodeGetName(), group); +// groups2.put(group.getIdent(), group); +// if (namespaceSeparator.V1972()) +// ensureParentIsCreated(group.getIdent()); +// } +// +// private void ensureParentIsCreated(Ident ident) { +// if (groups2.get(ident.parent()) != null) +// return; +// getParentContainer(ident, null); +// } + +// void removeGroup(String name) { +// if (namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final IEntity removed = Objects.requireNonNull(groupsByCode.remove(name)); +// final IEntity removed2 = groups2.remove(removed.getIdent()); +// if (removed != removed2) { +// bigError(); +// } +// } +// +// void removeGroup(Ident ident) { +// Objects.requireNonNull(groups2.remove(Objects.requireNonNull(ident))); +// } +// + public static void bigError() { + // Thread.dumpStack(); + // System.exit(0); + throw new IllegalArgumentException(); + } + +// void removeLeaf(String name) { +// if (namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final IEntity removed = Objects.requireNonNull(leafsByCode.remove(Objects.requireNonNull(name))); +// final IEntity removed2 = leafs2.remove(removed.getIdent()); +// if (removed != removed2) { +// bigError(); +// } +// } +// +// void removeLeaf(Ident ident) { +// final IEntity removed = leafs2.remove(Objects.requireNonNull(ident)); +// if (removed == null) { +// System.err.println("leafs2=" + leafs2.keySet()); +// throw new IllegalArgumentException(ident.toString()); +// } +// } +// +// private void removeLeaf1972(ILeaf leaf) { +// final boolean removed = leafs2.values().remove(leaf); +// if (removed == false) { +// System.err.println("leafs2=" + leafs2.keySet()); +// throw new IllegalArgumentException(leaf.toString()); +// } +// } +// +// public IGroup muteToGroup(String name, Code namespace, GroupType type, IGroup parent) { +// if (namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final ILeaf leaf = leafsByCode.get(name); +// ((ZEntityImpl) leaf).muteToGroup(namespace, type, parent); +// final IGroup result = (IGroup) leaf; +// removeLeaf(name); +// return result; +// } + +// public IGroup muteToGroup1972(Ident ident, Code namespace, GroupType type, IGroup parent) { +// if (!namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final ILeaf leaf; +// if (namespaceSeparator.getNamespaceSeparator() == null) +// leaf = getLeafVerySmart(ident); +// else +// leaf = leafs2.get(ident); +// ((ZEntityImpl) leaf).muteToGroup(namespace, type, parent); +// final IGroup result = (IGroup) leaf; +// removeLeaf1972(leaf); +// return result; +// } + + public IGroup getRootGroup() { + throw new UnsupportedOperationException(); +// return rootGroup; + } + + public final ILeaf getLeafStrict(Ident ident) { + throw new UnsupportedOperationException(); +// return leafs2.get(ident); + } +// +// public final ILeaf getLeafSmart(Ident ident) { +// if (!namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final ILeaf result = leafs2.get(ident); +// if (result == null && ident.size() == 1) +// for (Entry ent : leafs2.entrySet()) +// if (ent.getKey().getLast().equals(ident.getLast())) +// return ent.getValue(); +// +// return result; +// } +// +// public final ILeaf getLeafVerySmart(Ident ident) { +// if (!namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final ILeaf result = leafs2.get(ident); +// if (result == null) +// for (Entry ent : leafs2.entrySet()) +// if (ent.getKey().getLast().equals(ident.getLast())) +// return ent.getValue(); +// +// return result; +// } +// +// public Ident buildFullyQualified(Ident currentPath, Ident id) { +// if (currentPath.equals(id) == false) +// if (leafs2.containsKey(id) || groups2.containsKey(id)) +// return id; +// +// if (id.size() > 1) +// return id; +// +// return currentPath.add(id); +// } +// +// public final IGroup getGroupStrict(Ident ident) { +// if (namespaceSeparator.getNamespaceSeparator() == null) +// return getGroupVerySmart(ident); +// +// final IGroup result = groups2.get(ident); +// return result; +// } +// +// public final IGroup getGroupVerySmart(Ident ident) { +// final IGroup result = groups2.get(ident); +// if (result == null) +// for (Entry ent : groups2.entrySet()) +// if (ent.getKey().getLast().equals(ident.getLast())) +// return ent.getValue(); +// +// return result; +// } +// +// public final ILeaf getLeaf(Code code) { +// if (namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final ILeaf result = leafsByCode.get(code.getName()); +// if (result != null && result != leafs2.get(result.getIdent())) +// bigError(); +// +// return result; +// } +// +// public final IGroup getGroup(Code code) { +// if (namespaceSeparator.V1972()) +// throw new UnsupportedOperationException(); +// final IGroup result = groupsByCode.get(code.getName()); +// if (result != null && result != groups2.get(result.getIdent())) +// bigError(); +// +// return result; +// } + + public final Collection leafs() { +// if (namespaceSeparator.V1972()) +// return leafs2(); +// final Collection result = Collections.unmodifiableCollection(leafsByCode.values()); +// if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false) +// bigError(); +// +// return result; + throw new UnsupportedOperationException(); + } + + public final Collection groups() { +// if (namespaceSeparator.V1972()) +// return groups2(); +// final Collection result = Collections.unmodifiableCollection(groupsByCode.values()); +// if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false) +// bigError(); +// +// return result; + throw new UnsupportedOperationException(); + } +// +// public final Collection groups2() { +// final Collection result = Collections.unmodifiableCollection(groups2.values()); +// return Collections.unmodifiableCollection(result); +// } +// +// public final Collection leafs2() { +// final Collection result = Collections.unmodifiableCollection(leafs2.values()); +// return Collections.unmodifiableCollection(result); +// } + + public void incRawLayout() { + rawLayout++; + } + + public final List getLinks() { + return Collections.unmodifiableList(links); + } + + public void addLink(Link link) { + if (link.isSingle() && containsSimilarLink(link)) + return; + + links.add(link); + } + + private boolean containsSimilarLink(Link other) { + for (Link link : links) + if (other.sameConnections(link)) + return true; + + return false; + } + + public void removeLink(Link link) { + final boolean ok = links.remove(link); + if (ok == false) + throw new IllegalArgumentException(); + + } + +// public IGroup getParentContainer(Ident ident, IGroup parentContainer) { +// if (namespaceSeparator.V1972()) { +// final Ident parent = ident.parent(); +// if (parent.isRoot()) +// return this.rootGroup; +// +// IGroup result = getGroupStrict(parent); +// if (result != null) +// return result; +// +// final Display display = Display.getWithNewlines(parent.getName()); +// result = createGroup(parent, parent, display, null, GroupType.PACKAGE, null, +// Collections.emptySet(), namespaceSeparator.getNamespaceSeparator()); +// addGroup(result); +// return result; +// } +// return Objects.requireNonNull(parentContainer); +// } + + public ICucaDiagram getDiagram() { + return namespaceSeparator; + } + +} diff --git a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java index 65c4a063f..bd9cd8799 100644 --- a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java @@ -42,9 +42,9 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; public abstract class AbstractEntityDiagram extends CucaDiagram { diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 1cc520119..8ba2175c1 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -42,6 +42,8 @@ import java.util.Objects; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.creole.CreoleMode; @@ -49,8 +51,6 @@ import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java index fbd0bec56..1f169f5a2 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -44,7 +45,6 @@ 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.cucadiagram.Ident; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index e52cffc37..f080c3fce 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -52,7 +53,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index d2ffdb75c..f515dbe2c 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -41,6 +41,8 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -55,8 +57,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -128,9 +128,11 @@ public class CommandCreateClassMultilines extends CommandMultilines2 { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java index 9ba7319f5..4b2f2f9a1 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -50,7 +51,6 @@ import net.sourceforge.plantuml.cucadiagram.EntityGender; import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityUtils; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java index 18f85eb33..16cf80cc1 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; 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; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; public class CommandHideShowSpecificClass extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index d35e29668..13aa06b48 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -52,7 +53,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; @@ -240,7 +240,8 @@ final public class CommandLinkClass extends SingleLineCommand2 0); - final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQuantifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), - diagram.getLabelangle())); + final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, + cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel) + .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); diagram.resetPragmaLabel(); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java new file mode 100644 index 000000000..fe3133803 --- /dev/null +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java @@ -0,0 +1,765 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * Contribution : Hisashi Miyashita + * + * + */ +package net.sourceforge.plantuml.classdiagram.command; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; +import net.sourceforge.plantuml.command.regex.RegexOr; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.cucadiagram.Code; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArg; +import net.sourceforge.plantuml.cucadiagram.LinkDecor; +import net.sourceforge.plantuml.cucadiagram.LinkType; +import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; +import net.sourceforge.plantuml.descdiagram.command.Labels; +import net.sourceforge.plantuml.graphic.color.ColorParser; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; + +final public class CommandLinkClass2 extends SingleLineCommand2 { + + private static final String SINGLE = "[.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*"; + private static final String SINGLE_GUILLEMENT = "[%g][.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*[%g]"; + private static final String SINGLE2 = "(?:" + SINGLE + "|" + SINGLE_GUILLEMENT + ")"; + private static final String COUPLE = "\\([%s]*(" + SINGLE2 + ")[%s]*,[%s]*(" + SINGLE2 + ")[%s]*\\)"; + + public CommandLinkClass2(UmlDiagramType umlDiagramType) { + super(getRegexConcat(umlDiagramType)); + } + + static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) { + return RegexConcat.build(CommandLinkClass2.class.getName() + umlDiagramType, RegexLeaf.start(), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("HEADER", "@([\\d.]+)"), // + RegexLeaf.spaceOneOrMore() // + )), new RegexOr( // + new RegexLeaf("ENT1", getClassIdentifier()), // + new RegexLeaf("COUPLE1", COUPLE)), // + + RegexLeaf.spaceZeroOrMore(), // + + new RegexOptional(new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("[\\[]"), // + new RegexLeaf("QUALIFIER1", "([^\\[\\]]+)"), // + new RegexLeaf("[\\]]"), // + RegexLeaf.spaceOneOrMore() // + )), // + new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), // + + RegexLeaf.spaceZeroOrMore(), // + + new RegexConcat( + // + new RegexLeaf("ARROW_HEAD1", + "((?<=[%s])+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), // + new RegexLeaf("ARROW_BODY1", "([-=.]+)"), // + new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // + new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), // + new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), // + new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // + new RegexLeaf("ARROW_BODY2", "([-=.]*)"), // + new RegexLeaf("ARROW_HEAD2", + "([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // + + RegexLeaf.spaceZeroOrMore(), // + + new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // + new RegexOptional(new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("[\\[]"), // + new RegexLeaf("QUALIFIER2", "([^\\[\\]]+)"), // + new RegexLeaf("[\\]]"), // + RegexLeaf.spaceOneOrMore() // + )), // + + RegexLeaf.spaceZeroOrMore(), // + + new RegexOr( // + new RegexLeaf("ENT2", getClassIdentifier()), // + new RegexLeaf("COUPLE2", COUPLE)), // + RegexLeaf.spaceZeroOrMore(), // + color().getRegex(), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf(":"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("LABEL_LINK", "(.+)") // + )), RegexLeaf.end()); + } + + private static ColorParser color() { + return ColorParser.simpleColor(ColorType.LINE); + } + + private static String getClassIdentifier() { + return "(" + getSeparator() + "?[%pLN_$]+(?:" + getSeparator() + "[%pLN_$]+)*|[%g][^%g]+[%g])"; + } + + public static String getSeparator() { + return "(?:\\.|::|\\\\|\\\\\\\\)"; + } + + @Override + protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, + RegexResult arg) throws NoSuchColorException { + + final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); + final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); + if (ent1String == null && ent2String == null) + return executeArgSpecial3(diagram, arg); + + if (ent1String == null) + return executeArgSpecial1(diagram, arg); + + if (ent2String == null) + return executeArgSpecial2(diagram, arg); + + Ident ident1 = diagram.buildLeafIdentSpecial(ent1String); + Ident ident2 = diagram.buildLeafIdentSpecial(ent2String); + Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator()); + Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator()); + Code code1 = diagram.V1972() ? ident1 : diagram.buildCode(ent1String); + Code code2 = diagram.V1972() ? ident2 : diagram.buildCode(ent2String); + if (isGroupButNotTheCurrentGroup(diagram, code1, ident1) + && isGroupButNotTheCurrentGroup(diagram, code2, ident2)) { + return executePackageLink(diagram, arg); + } + + String port1 = null; + String port2 = null; + + if (diagram.V1972()) { + if ("::".equals(diagram.getNamespaceSeparator())) { + if (removeMemberPartIdentSpecial(diagram, ident1) != null) { + port1 = ident1.getLast(); + ident1 = removeMemberPartIdentSpecial(diagram, ident1); + code1 = ident1; + } + if (removeMemberPartIdentSpecial(diagram, ident2) != null) { + port2 = ident2.getLast(); + ident2 = removeMemberPartIdentSpecial(diagram, ident2); + code2 = ident1; + } + } else { + if (removeMemberPartIdent(diagram, ident1) != null) { + port1 = ident1.getPortMember(); + ident1 = removeMemberPartIdent(diagram, ident1); + code1 = ident1; + } + if (removeMemberPartIdent(diagram, ident2) != null) { + port2 = ident2.getPortMember(); + ident2 = removeMemberPartIdent(diagram, ident2); + code2 = ident2; + } + } + } else { + if (removeMemberPartLegacy1972(diagram, ident1) != null) { + port1 = ident1.getPortMember(); + code1 = removeMemberPartLegacy1972(diagram, ident1); + ident1 = ident1.removeMemberPart(); + } + if (removeMemberPartLegacy1972(diagram, ident2) != null) { + port2 = ident2.getPortMember(); + code2 = removeMemberPartLegacy1972(diagram, ident2); + ident2 = ident2.removeMemberPart(); + } + } + + final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure); + final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure); + + final LinkType linkType = getLinkType(arg); + final Direction dir = getDirection(arg); + final int queue; + if (dir == Direction.LEFT || dir == Direction.RIGHT) + queue = 1; + else + queue = getQueueLength(arg); + + final Labels labels = new Labels(arg); + + final String kal1 = arg.get("QUALIFIER1", 0); + final String kal2 = arg.get("QUALIFIER2", 0); + + final LinkArg linkArg = LinkArg + .build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0) + .withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) + .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2); + + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, + linkType, linkArg); + if (arg.get("URL", 0) != null) { + final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); + final Url url = urlBuilder.getUrl(arg.get("URL", 0)); + link.setUrl(url); + } + link.setPortMembers(port1, port2); + + if (dir == Direction.LEFT || dir == Direction.UP) + link = link.getInv(); + + link.setLinkArrow(labels.getLinkArrow()); + link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); + link.applyStyle(arg.getLazzy("ARROW_STYLE", 0)); + link.setCodeLine(location); + + addLink(diagram, link, arg.get("HEADER", 0)); + + return CommandExecutionResult.ok(); + } + + private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident, Ident pure) { + if (isGroupButNotTheCurrentGroup(diagram, code, ident)) { + if (diagram.V1972()) + return diagram.getGroupVerySmart(ident); + +// final Code tap = ident.toCode(diagram); +// return diagram.getGroupStrict(ident); + return diagram.getGroupVerySmart(ident); + } + if (diagram.V1972()) { + final IEntity result = pure.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident); + if (result != null) + return result; + + } + return diagram.getOrCreateLeaf(ident, code, null, null); + } + + private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code, Ident ident) { + if (diagram.V1972()) { + if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName())) + return false; + + return diagram.isGroupVerySmart(ident); + } else { + if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName())) + return false; + + if (diagram.isGroupStrict(ident)) + return true; + + return diagram.isGroup(code); + } + } + + private Ident removeMemberPartIdentSpecial(AbstractClassOrObjectDiagram diagram, Ident ident) { + if (diagram.leafExistSmart(ident)) + return null; + + final Ident before = ident.parent(); + if (before == null) + return null; + + if (diagram.leafExistSmart(before) == false) + return null; + + return before; + } + + private Ident removeMemberPartIdent(AbstractClassOrObjectDiagram diagram, Ident ident) { + if (diagram.leafExistSmart(ident)) + return null; + + final Ident before = ident.removeMemberPart(); + if (before == null) + return null; + + if (diagram.leafExistSmart(before) == false) + return null; + + return before; + } + + private Code removeMemberPartLegacy1972(AbstractClassOrObjectDiagram diagram, Ident ident) { + if (diagram.leafExist(ident)) + return null; + + final Ident before = ident.removeMemberPart(); + if (before == null) + return null; + + final Code code = before.toCode(diagram); + if (diagram.leafExist(code) == false) + return null; + + return code; + } + + private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) { + diagram.addLink(link); + if (weight == null) { + // final LinkType type = link.getType(); + // --|> highest + // --*, -->, --o normal + // ..*, ..>, ..o lowest + // if (type.isDashed() == false) { + // if (type.contains(LinkDecor.EXTENDS)) { + // link.setWeight(3); + // } + // if (type.contains(LinkDecor.ARROW) || + // type.contains(LinkDecor.COMPOSITION) + // || type.contains(LinkDecor.AGREGATION)) { + // link.setWeight(2); + // } + // } + } else { + link.setWeight(Double.parseDouble(weight)); + } + } + + private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) + throws NoSuchColorException { + final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); + final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); + + Ident ident1 = diagram.buildLeafIdentSpecial(ent1String); + Ident ident2 = diagram.buildLeafIdentSpecial(ent2String); + Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator()); + Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator()); + Code code1 = diagram.V1972() ? ident1 : diagram.buildCode(ent1String); + Code code2 = diagram.V1972() ? ident2 : diagram.buildCode(ent2String); + + if (diagram.V1972()) { + throw new UnsupportedOperationException("to be finished..."); + } else { + if (removeMemberPartLegacy1972(diagram, ident1) != null) { + code1 = removeMemberPartLegacy1972(diagram, ident1); + ident1 = ident1.removeMemberPart(); + } + if (removeMemberPartLegacy1972(diagram, ident2) != null) { + code2 = removeMemberPartLegacy1972(diagram, ident2); + ident2 = ident2.removeMemberPart(); + } + } + + final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure); + final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure); + +// final IEntity cl1 = diagram.V1972() ? diagram.getGroupVerySmart(diagram.buildLeafIdent(ent1String)) +// : diagram.getGroup(diagram.buildCode(ent1String)); +// final IEntity cl2 = diagram.V1972() ? diagram.getGroupVerySmart(diagram.buildLeafIdent(ent2String)) +// : diagram.getGroup(diagram.buildCode(ent2String)); + + final LinkType linkType = getLinkType(arg); + final Direction dir = getDirection(arg); + final int queue; + if (dir == Direction.LEFT || dir == Direction.RIGHT) + queue = 1; + else + queue = getQueueLength(arg); + + final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + final String firstLabel = arg.get("FIRST_LABEL", 0); + final String secondLabel = arg.get("SECOND_LABEL", 0); + final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0); + final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, + cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel) + .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); + link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); + + diagram.resetPragmaLabel(); + + link.applyStyle(arg.getLazzy("ARROW_STYLE", 0)); + + addLink(diagram, link, arg.get("HEADER", 0)); + return CommandExecutionResult.ok(); + } + + private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + if (diagram.V1972()) + return executeArgSpecial1972Ident1(diagram, arg); + final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0)); + final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1)); + final Code clName1A = diagram.buildCode(name1A); + final Code clName1B = diagram.buildCode(name1B); + if (diagram.leafExist(clName1A) == false) + return CommandExecutionResult.error("No class " + clName1A); + + if (diagram.leafExist(clName1B) == false) + return CommandExecutionResult.error("No class " + clName1B); + + final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); + final Code ent2 = diagram.buildCode(idShort); + final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent2, null, null); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + final boolean result = diagram.associationClass(1, name1A, name1B, cl2, linkType, label); + if (result == false) + return CommandExecutionResult.error("Cannot have more than 2 assocications"); + + return CommandExecutionResult.ok(); + } + + private CommandExecutionResult executeArgSpecial1972Ident1(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + final String name1A = arg.get("COUPLE1", 0); + final String name1B = arg.get("COUPLE1", 1); + final Ident ident1A = diagram.buildLeafIdent(name1A); + final Ident ident1B = diagram.buildLeafIdent(name1B); + if (diagram.leafExistSmart(ident1A) == false) + return CommandExecutionResult.error("No class " + ident1A.getName()); + + if (diagram.leafExistSmart(ident1B) == false) + return CommandExecutionResult.error("No class " + ident1B.getName()); + + final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); + final Ident ident2 = diagram.buildLeafIdent(idShort); + final IEntity cl2 = diagram.getOrCreateLeaf(ident2, ident2, null, null); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + final boolean result = diagram.associationClass(1, name1A, name1B, cl2, linkType, label); + if (result == false) + return CommandExecutionResult.error("Cannot have more than 2 assocications"); + + return CommandExecutionResult.ok(); + } + + private CommandExecutionResult executeArgSpecial1972Ident2(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + final String name2A = arg.get("COUPLE2", 0); + final String name2B = arg.get("COUPLE2", 1); + final Ident ident2A = diagram.buildLeafIdent(name2A); + final Ident ident2B = diagram.buildLeafIdent(name2B); + if (diagram.leafExistSmart(ident2A) == false) + return CommandExecutionResult.error("No class " + ident2A.getName()); + + if (diagram.leafExistSmart(ident2B) == false) + return CommandExecutionResult.error("No class " + ident2B.getName()); + + final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); + final Ident ident1 = diagram.buildLeafIdent(idShort); + final IEntity cl1 = diagram.getOrCreateLeaf(ident1, ident1, null, null); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + final boolean result = diagram.associationClass(2, name2A, name2B, cl1, linkType, label); + if (result == false) + return CommandExecutionResult.error("Cannot have more than 2 assocications"); + + return CommandExecutionResult.ok(); + } + + private CommandExecutionResult executeArgSpecial1972Ident3(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + final String name1A = arg.get("COUPLE1", 0); + final String name1B = arg.get("COUPLE1", 1); + final String name2A = arg.get("COUPLE2", 0); + final String name2B = arg.get("COUPLE2", 1); + final Ident ident1A = diagram.buildLeafIdent(name1A); + final Ident ident1B = diagram.buildLeafIdent(name1B); + final Ident ident2A = diagram.buildLeafIdent(name2A); + final Ident ident2B = diagram.buildLeafIdent(name2B); + if (diagram.leafExistSmart(ident1A) == false) + return CommandExecutionResult.error("No class " + ident1A.getName()); + + if (diagram.leafExistSmart(ident1B) == false) + return CommandExecutionResult.error("No class " + ident1B.getName()); + + if (diagram.leafExistSmart(ident2A) == false) + return CommandExecutionResult.error("No class " + ident2A.getName()); + + if (diagram.leafExistSmart(ident2B) == false) + return CommandExecutionResult.error("No class " + ident2B.getName()); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + return diagram.associationClass(name1A, name1B, name2A, name2B, linkType, label); + } + + private CommandExecutionResult executeArgSpecial3(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + if (diagram.V1972()) + return executeArgSpecial1972Ident3(diagram, arg); + final String name1A = arg.get("COUPLE1", 0); + final String name1B = arg.get("COUPLE1", 1); + final String name2A = arg.get("COUPLE2", 0); + final String name2B = arg.get("COUPLE2", 1); + final Code clName1A = diagram.buildCode(name1A); + final Code clName1B = diagram.buildCode(name1B); + final Code clName2A = diagram.buildCode(name2A); + final Code clName2B = diagram.buildCode(name2B); + if (diagram.leafExist(clName1A) == false) + return CommandExecutionResult.error("No class " + clName1A); + + if (diagram.leafExist(clName1B) == false) + return CommandExecutionResult.error("No class " + clName1B); + + if (diagram.leafExist(clName2A) == false) + return CommandExecutionResult.error("No class " + clName2A); + + if (diagram.leafExist(clName2B) == false) + return CommandExecutionResult.error("No class " + clName2B); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + return diagram.associationClass(name1A, name1B, name2A, name2B, linkType, label); + } + + private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) { + if (diagram.V1972()) + return executeArgSpecial1972Ident2(diagram, arg); + final String name2A = arg.get("COUPLE2", 0); + final String name2B = arg.get("COUPLE2", 1); + final Code clName2A = diagram.buildCode(name2A); + final Code clName2B = diagram.buildCode(name2B); + if (diagram.leafExist(clName2A) == false) + return CommandExecutionResult.error("No class " + clName2A); + + if (diagram.leafExist(clName2B) == false) + return CommandExecutionResult.error("No class " + clName2B); + + final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); + final Code ent1 = diagram.buildCode(idShort); + final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent1, null, null); + + final LinkType linkType = getLinkType(arg); + final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); + + final boolean result = diagram.associationClass(2, name2A, name2B, cl1, linkType, label); + if (result == false) + return CommandExecutionResult.error("Cannot have more than 2 assocications"); + + return CommandExecutionResult.ok(); + } + + private LinkDecor getDecors1(String s) { + if (s == null) { + return LinkDecor.NONE; + } + s = StringUtils.trin(s); + if ("<|".equals(s)) + return LinkDecor.EXTENDS; + + if ("<|:".equals(s)) + return LinkDecor.DEFINEDBY; + + if ("<||".equals(s)) + return LinkDecor.REDEFINES; + + if ("}".equals(s)) + return LinkDecor.CROWFOOT; + + if ("}o".equals(s)) + return LinkDecor.CIRCLE_CROWFOOT; + + if ("}|".equals(s)) + return LinkDecor.LINE_CROWFOOT; + + if ("|o".equals(s)) + return LinkDecor.CIRCLE_LINE; + + if ("||".equals(s)) + return LinkDecor.DOUBLE_LINE; + + if ("<".equals(s)) + return LinkDecor.ARROW; + + if ("^".equals(s)) + return LinkDecor.EXTENDS; + + if ("+".equals(s)) + return LinkDecor.PLUS; + + if ("o".equals(s)) + return LinkDecor.AGREGATION; + + if ("x".equals(s)) + return LinkDecor.NOT_NAVIGABLE; + + if ("*".equals(s)) + return LinkDecor.COMPOSITION; + + if ("#".equals(s)) + return LinkDecor.SQUARE; + + if (")".equals(s)) + return LinkDecor.PARENTHESIS; + + return LinkDecor.NONE; + } + + private LinkDecor getDecors2(String s) { + if (s == null) + return LinkDecor.NONE; + + s = StringUtils.trin(s); + if ("|>".equals(s)) + return LinkDecor.EXTENDS; + + if (":|>".equals(s)) + return LinkDecor.DEFINEDBY; + + if ("||>".equals(s)) + return LinkDecor.REDEFINES; + + if (">".equals(s)) + return LinkDecor.ARROW; + + if ("{".equals(s)) + return LinkDecor.CROWFOOT; + + if ("o{".equals(s)) + return LinkDecor.CIRCLE_CROWFOOT; + + if ("|{".equals(s)) + return LinkDecor.LINE_CROWFOOT; + + if ("o|".equals(s)) + return LinkDecor.CIRCLE_LINE; + + if ("||".equals(s)) + return LinkDecor.DOUBLE_LINE; + + if ("^".equals(s)) + return LinkDecor.EXTENDS; + + if ("+".equals(s)) + return LinkDecor.PLUS; + + if ("o".equals(s)) + return LinkDecor.AGREGATION; + + if ("x".equals(s)) + return LinkDecor.NOT_NAVIGABLE; + + if ("*".equals(s)) + return LinkDecor.COMPOSITION; + + if ("#".equals(s)) + return LinkDecor.SQUARE; + + if ("(".equals(s)) + return LinkDecor.PARENTHESIS; + + return LinkDecor.NONE; + } + + private LinkType getLinkType(RegexResult arg) { + final LinkDecor decors1 = getDecors1(getArrowHead1(arg)); + final LinkDecor decors2 = getDecors2(getArrowHead2(arg)); + + LinkType result = new LinkType(decors2, decors1); + if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains(".")) + result = result.goDashed(); + + final String middle = arg.get("INSIDE", 0); + if ("0".equals(middle)) + result = result.withMiddleCircle(); + else if ("0)".equals(middle)) + result = result.withMiddleCircleCircled1(); + else if ("(0".equals(middle)) + result = result.withMiddleCircleCircled2(); + else if ("(0)".equals(middle)) + result = result.withMiddleCircleCircled(); + + return result; + } + + private int getQueueLength(RegexResult arg) { + String s = getFullArrow(arg); + s = s.replaceAll("[^-.=]", ""); + return s.length(); + } + + private Direction getDirection(RegexResult arg) { +// final LinkDecor decors1 = getDecors1(getArrowHead1(arg)); +// final LinkDecor decors2 = getDecors2(getArrowHead2(arg)); + + String s = getFullArrow(arg); + s = s.replaceAll("[^-.=\\w]", ""); + if (s.startsWith("o")) + s = s.substring(1); + + if (s.endsWith("o")) + s = s.substring(0, s.length() - 1); + + Direction result = StringUtils.getQueueDirection(s); +// if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) { + // result = result.getInv(); +// } + + return result; + } + + private String getArrowHead1(RegexResult arg) { + return getArrowHead(arg, "ARROW_HEAD1"); + } + + private String getArrowHead2(RegexResult arg) { + return getArrowHead(arg, "ARROW_HEAD2"); + } + + private String getArrowHead(RegexResult arg, final String key) { + return notNull(arg.get(key, 0)); + } + + private String getFullArrow(RegexResult arg) { + return getArrowHead1(arg) + notNull(arg.get("ARROW_BODY1", 0)) + notNull(arg.get("ARROW_DIRECTION", 0)) + + notNull(arg.get("ARROW_BODY2", 0)) + getArrowHead2(arg); + } + + public static String notNull(String s) { + if (s == null) + return ""; + return s; + } + +} diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java index f0f88ea31..5be099eac 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.Matcher2; @@ -50,7 +51,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -189,9 +189,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2 0); - final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQuantifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), - diagram.getLabelangle())); + final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, + cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel) + .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); diagram.resetPragmaLabel(); addLink(diagram, link, arg.get("HEADER", 0)); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java index 1e5313ad7..1264d2e17 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -43,7 +44,6 @@ 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.CucaDiagram; public class CommandNamespaceSeparator extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandRemoveRestore.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandRemoveRestore.java index 301eeffaa..1fb41adf6 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandRemoveRestore.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandRemoveRestore.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; 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; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; public class CommandRemoveRestore extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java index 879367f7c..7b6dacc14 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -45,7 +46,6 @@ 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.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java index 41da766a9..d4d94b444 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -48,7 +49,6 @@ 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.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; public class CommandUrl extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/command/CommandEndPackage.java b/src/net/sourceforge/plantuml/command/CommandEndPackage.java index 6a07d8877..085ba94c2 100644 --- a/src/net/sourceforge/plantuml/command/CommandEndPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandEndPackage.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; 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; -import net.sourceforge.plantuml.cucadiagram.IGroup; public class CommandEndPackage extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 2a4ac80f2..caf01b1e6 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -39,6 +39,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -47,8 +49,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java index 5cd46cfb7..d8ee3435d 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace2.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -39,6 +39,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -47,8 +49,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java index ab148f935..575217c04 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java @@ -39,6 +39,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -47,8 +49,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index cc6fa6da6..44661729c 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -40,6 +40,8 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.regex.IRegex; @@ -50,8 +52,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java index b75c1639e..d983c4456 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java @@ -37,6 +37,8 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -46,8 +48,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.graphic.color.ColorType; diff --git a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java index 0fe65a6f5..33e1a59ef 100644 --- a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.ErrorUmlType; import net.sourceforge.plantuml.LineLocation; @@ -190,18 +191,25 @@ public abstract class PSystemCommandFactory extends PSystemAbstractFactory { return null; } - private BlocLines addOneSingleLineManageEmbedded2(IteratorCounter2 it, BlocLines lines) { + private static BlocLines addOneSingleLineManageEmbedded2(IteratorCounter2 it, BlocLines lines) { final StringLocated linetoBeAdded = it.next(); lines = lines.add(linetoBeAdded); - if (linetoBeAdded.getTrimmed().getString().equals("{{")) { + if (EmbeddedDiagram.getEmbeddedType(linetoBeAdded.getTrimmed().getString()) != null) { + int nested = 1; while (it.hasNext()) { final StringLocated s = it.next(); lines = lines.add(s); - if (s.getTrimmed().getString().equals("}}")) - return lines; - + if (EmbeddedDiagram.getEmbeddedType(s.getTrimmed().getString()) != null) + // if (s.getTrimmed().getString().startsWith(EmbeddedDiagram.EMBEDDED_START)) + nested++; + else if (s.getTrimmed().getString().equals(EmbeddedDiagram.EMBEDDED_END)) { + nested--; + if (nested == 0) + return lines; + } } } + return lines; } diff --git a/src/net/sourceforge/plantuml/command/note/CommandConstraintOnLinks.java b/src/net/sourceforge/plantuml/command/note/CommandConstraintOnLinks.java index 13840849e..62aafacf7 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandConstraintOnLinks.java +++ b/src/net/sourceforge/plantuml/command/note/CommandConstraintOnLinks.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.command.note; import java.util.List; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -45,7 +46,6 @@ 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.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java index a99e0e690..5d4ad4923 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command.note; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.BlocLines; @@ -50,7 +51,6 @@ 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.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java index 23481b2a8..142df2748 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -55,7 +56,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -152,8 +152,8 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma throws NoSuchColorException { final String s = arg.get("COLOR", 0); - note.setSpecificColorTOBEREMOVED(ColorType.BACK, s == null ? null - : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + note.setSpecificColorTOBEREMOVED(ColorType.BACK, + s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); IEntity activity = diagram.getLastEntityConsulted(); if (activity == null) { @@ -168,17 +168,17 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); if (position == Position.RIGHT) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, - LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, + type, LinkArg.noDisplay(1)); } else if (position == Position.LEFT) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, - LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, + type, LinkArg.noDisplay(1)); } else if (position == Position.BOTTOM) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, - LinkArg.noDisplay(2)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, + type, LinkArg.noDisplay(2)); } else if (position == Position.TOP) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, - LinkArg.noDisplay(2)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, + type, LinkArg.noDisplay(2)); } else { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java index 636e42325..fa0670232 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.BlocLines; @@ -57,7 +58,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -272,15 +272,19 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); if (position == Position.RIGHT) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, + type, LinkArg.noDisplay(1)); link.setHorizontalSolitary(true); } else if (position == Position.LEFT) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, + type, LinkArg.noDisplay(1)); link.setHorizontalSolitary(true); } else if (position == Position.BOTTOM) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, LinkArg.noDisplay(2)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, + type, LinkArg.noDisplay(2)); } else if (position == Position.TOP) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, LinkArg.noDisplay(2)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, + type, LinkArg.noDisplay(2)); } else { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java index df3e149d0..b9004c6d1 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -52,7 +53,6 @@ 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.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.graphic.color.ColorParser; diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java index 3f085f665..b1a2f4a38 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.Command; @@ -52,7 +53,6 @@ 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.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -166,11 +166,11 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); final Link link; if (position == Position.RIGHT) { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, (IEntity) tips, type, - LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, + (IEntity) tips, type, LinkArg.noDisplay(1)); } else { - link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), (IEntity) tips, cl1, type, - LinkArg.noDisplay(1)); + link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + (IEntity) tips, cl1, type, LinkArg.noDisplay(1)); } diagram.addLink(link); } diff --git a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java index b885db3dd..fbe892ffc 100644 --- a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java +++ b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java @@ -39,10 +39,10 @@ import java.util.Map; import java.util.Objects; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.USymbol; diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java index 2ffb89460..d09ea41ba 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.compositediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -46,7 +47,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.compositediagram.CompositeDiagram; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; public class CommandCreateBlock extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java index eaeb8b904..b434f5c85 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.compositediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -47,7 +48,6 @@ import net.sourceforge.plantuml.compositediagram.CompositeDiagram; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java index 445149012..5719e265b 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.compositediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -43,7 +44,6 @@ 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.compositediagram.CompositeDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; public class CommandEndPackageBlock extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java index 03f4bee40..466d397c6 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java @@ -35,6 +35,7 @@ package net.sourceforge.plantuml.compositediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -44,7 +45,6 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.compositediagram.CompositeDiagram; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; @@ -95,7 +95,8 @@ public class CommandLinkBlock extends SingleLineCommand2 { final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(), diagram.getSkinParam().classAttributeIconSize() > 0); - final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg); + final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, + cl2, linkType, linkArg); diagram.addLink(link); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java index 163a177ec..d1289a130 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java +++ b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java @@ -83,8 +83,7 @@ public class CreoleHorizontalLine extends AbstractAtom implements Atom { if (line.length() == 0) { return TextBlockUtils.empty(0, 0); } - final SheetBuilder parser = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, skinParam, - CreoleMode.FULL); + final SheetBuilder parser = skinParam.sheet(fontConfiguration, HorizontalAlignment.LEFT, CreoleMode.FULL); final Sheet sheet = parser.createSheet(Display.getWithNewlines(line)); final TextBlock tb = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); return tb; diff --git a/src/net/sourceforge/plantuml/creole/Parser.java b/src/net/sourceforge/plantuml/creole/Parser.java index 04c4f50ad..3ecb29ea3 100644 --- a/src/net/sourceforge/plantuml/creole/Parser.java +++ b/src/net/sourceforge/plantuml/creole/Parser.java @@ -47,17 +47,6 @@ public class Parser { public static final String MONOSPACED = "monospaced"; - public static SheetBuilder build(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple skinParam, CreoleMode creoleMode) { - final FontConfiguration stereotype = fontConfiguration.forceFont(null, null); - return new CreoleParser(fontConfiguration, horizontalAlignment, skinParam, creoleMode, stereotype); - } - - public static SheetBuilder build(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, - ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotype) { - return new CreoleParser(fontConfiguration, horizontalAlignment, skinParam, creoleMode, stereotype); - } - public static boolean isLatexStart(String line) { return line.equals(""); } @@ -79,26 +68,26 @@ public class Parser { } public static double getScale(String s, double def) { - if (s == null) { + if (s == null) return def; - } + final Pattern p = Pattern.compile("(?:scale=|\\*)([0-9.]+)"); final Matcher m = p.matcher(s); - if (m.find()) { + if (m.find()) return Double.parseDouble(m.group(1)); - } + return def; } public static String getColor(String s) { - if (s == null) { + if (s == null) return null; - } + final Pattern p = Pattern.compile("color[= :](#[0-9a-fA-F]{6}|\\w+)"); final Matcher m = p.matcher(s); - if (m.find()) { + if (m.find()) return m.group(1); - } + return null; } diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java index 51cae98d9..587306714 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock1.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java @@ -73,6 +73,7 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S private final ClockwiseTopRightBottomLeft padding; private final double marginX1; private final double marginX2; + private Class lastCaller; @HaxeIgnored public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, double padding) { @@ -113,9 +114,10 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S } private void initMap(StringBounder stringBounder) { - if (positions != null) + final Class currentCaller = stringBounder.getClass(); + if (lastCaller == currentCaller) return; - + this.lastCaller = currentCaller; stripes = new ArrayList<>(); for (Stripe stripe : sheet) stripes.addAll(new Fission(stripe, maxWidth).getSplitted(stringBounder)); @@ -175,7 +177,7 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S public XDimension2D calculateDimension(StringBounder stringBounder) { initMap(stringBounder); - return XDimension2D.delta(minMax.getDimension(), padding.getBottom() + padding.getTop()); + return minMax.getDimension().delta(padding.getBottom() + padding.getTop()); } @Override diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomWithMargin.java b/src/net/sourceforge/plantuml/creole/atom/AtomWithMargin.java index 6a941247f..6510e04e4 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomWithMargin.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomWithMargin.java @@ -75,7 +75,7 @@ public class AtomWithMargin extends AbstractAtom implements Atom { } public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(atom.calculateDimension(stringBounder), 0, marginY1 + marginY2); + return atom.calculateDimension(stringBounder).delta(0, marginY1 + marginY2); } public double getStartingAltitude(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java index 1fedae4ce..500b4ae2e 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java @@ -36,7 +36,10 @@ package net.sourceforge.plantuml.creole.legacy; import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Objects; import net.sourceforge.plantuml.EmbeddedDiagram; @@ -116,23 +119,41 @@ public class CreoleParser implements SheetBuilder { return line.matches("^\\=?\\s*(\\<#\\w+(,#?\\w+)?\\>).*"); } + private final Map cache = new HashMap<>(); + public Sheet createSheet(Display display) { + Sheet result = cache.get(display); + if (result == null) { + result = createSheetSlow(display, false); + cache.put(display, result); + } + return result; + } + + private Sheet createSheetSlow(Display display, boolean checkColor) { final Sheet sheet = new Sheet(horizontalAlignment); if (Display.isNull(display) == false) { final CreoleContext context = new CreoleContext(); - for (CharSequence cs : display) { + final Iterator it = display.iterator(); + while (it.hasNext()) { + final CharSequence cs = it.next(); final Stripe stripe; - if (cs instanceof EmbeddedDiagram) { - final Atom atom = ((EmbeddedDiagram) cs).asDraw(skinParam); - stripe = new Stripe() { - public Atom getLHeader() { - return null; - } + final String type = EmbeddedDiagram.getEmbeddedType(StringUtils.trinNoTrace(cs)); + if (type != null) { + final Atom embeddedDiagram = EmbeddedDiagram.createAndSkip(type, it, skinParam); + if (checkColor) + stripe = null; + else { + stripe = new Stripe() { + public Atom getLHeader() { + return null; + } - public List getAtoms() { - return Arrays.asList(atom); - } - }; + public List getAtoms() { + return Arrays.asList(embeddedDiagram); + } + }; + } } else if (cs instanceof Stereotype) { if (display.showStereotype()) for (String st : ((Stereotype) cs).getLabels(skinParam.guillemet())) @@ -140,7 +161,8 @@ public class CreoleParser implements SheetBuilder { continue; } else { - stripe = createStripe(cs.toString(), context, sheet.getLastStripe(), fontConfiguration); + stripe = createStripe(skinParam.guillemet().manageGuillemet(cs.toString()), context, + sheet.getLastStripe(), fontConfiguration); } if (stripe != null) @@ -155,7 +177,7 @@ public class CreoleParser implements SheetBuilder { FontConfiguration fc = FontConfiguration.blackBlueTrue(UFont.byDefault(10)); try { new CreoleParser(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty(), CreoleMode.FULL, fc) - .createSheet(result); + .createSheetSlow(result, true); } catch (NoSuchColorRuntimeException e) { throw new NoSuchColorException(); } diff --git a/src/net/sourceforge/plantuml/creole/legacy/PSystemCreole.java b/src/net/sourceforge/plantuml/creole/legacy/PSystemCreole.java index 66ac9f4a6..9007379c3 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/PSystemCreole.java +++ b/src/net/sourceforge/plantuml/creole/legacy/PSystemCreole.java @@ -46,7 +46,6 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.cucadiagram.Display; @@ -76,8 +75,9 @@ public class PSystemCreole extends PlainDiagram { final Display display = Display.create(lines); final UFont font = UFont.serif(14); final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); - final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, - SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL).createSheet(display); + final SkinParam skinParam = SkinParam.create(UmlDiagramType.SEQUENCE); + final Sheet sheet = skinParam.sheet(fontConfiguration, HorizontalAlignment.LEFT, CreoleMode.FULL) + .createSheet(display); return new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); // final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 55111b6d9..9eea99ca5 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.List; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java index 823f78f69..7df73e953 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Objects; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.json.JsonValue; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java index 56a56c60a..197a0960e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java @@ -44,6 +44,7 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.graphic.FontConfiguration; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java index 96e583ba3..51fa841d6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java @@ -46,6 +46,7 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java index ff8055c63..84f108b49 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Objects; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java index 1aab3ddfe..1551b9890 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java @@ -42,11 +42,11 @@ import java.util.ListIterator; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.legacy.CreoleParser; @@ -131,52 +131,50 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi Display display = null; for (ListIterator it = rawBody2.iterator(); it.hasNext();) { final CharSequence cs = it.next(); - if (cs instanceof EmbeddedDiagram) { +// if (cs instanceof EmbeddedDiagram) { +// if (display == null) +// display = Display.empty(); +// if (display.size() > 0 || separator != 0) { +// blocks.add(buildTextBlock(display, separator, title, stringBounder)); +// separator = 0; +// title = null; +// display = null; +// } +// blocks.add(TextBlockUtils.withMargin(((EmbeddedDiagram) cs).asDraw(), 2, 2)); +// } else { + final String s = cs.toString(); + if (isBlockSeparator(s)) { if (display == null) display = Display.empty(); - if (display.size() > 0 || separator != 0) { - blocks.add(buildTextBlock(display, separator, title, stringBounder)); - separator = 0; - title = null; - display = null; - } - blocks.add(TextBlockUtils.withMargin(((EmbeddedDiagram) cs).asDraw(skinParam), 2, 2)); + blocks.add(buildTextBlock(display, separator, title, stringBounder)); + separator = s.charAt(0); + title = getTitle(s, skinParam); + display = null; + } else if (isTreeOrTable(s)) { + final boolean isTable = CreoleParser.isTableLine(s); + if (display == null) + display = Display.empty(); + blocks.add(buildTextBlock(display, separator, title, stringBounder)); + + separator = 0; + title = null; + display = null; + final List allTree = buildTreeOrTable(s, it); + final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getIHtmlColorSet()); + TextBlock bloc = Display.create(allTree).create7(fontConfiguration, align, skinParam, CreoleMode.FULL); + if (isTable) + bloc = TextBlockUtils.withMargin(bloc, 10, 10, 0, 5); + + blocks.add(bloc); } else { - final String s = cs.toString(); - if (isBlockSeparator(s)) { - if (display == null) - display = Display.empty(); - blocks.add(buildTextBlock(display, separator, title, stringBounder)); - separator = s.charAt(0); - title = getTitle(s, skinParam); - display = null; - } else if (isTreeOrTable(s)) { - final boolean isTable = CreoleParser.isTableLine(s); - if (display == null) - display = Display.empty(); - blocks.add(buildTextBlock(display, separator, title, stringBounder)); + if (display == null) + display = Display.empty(); + display = display.add(cs); + if (cs instanceof Member && ((Member) cs).getUrl() != null) + urls.add(((Member) cs).getUrl()); - separator = 0; - title = null; - display = null; - final List allTree = buildTreeOrTable(s, it); - final FontConfiguration fontConfiguration = style - .getFontConfiguration(skinParam.getIHtmlColorSet()); - TextBlock bloc = Display.create(allTree).create7(fontConfiguration, align, skinParam, - CreoleMode.FULL); - if (isTable) - bloc = TextBlockUtils.withMargin(bloc, 10, 10, 0, 5); - - blocks.add(bloc); - } else { - if (display == null) - display = Display.empty(); - display = display.add(cs); - if (cs instanceof Member && ((Member) cs).getUrl() != null) - urls.add(((Member) cs).getUrl()); - - } } +// } } if (display == null) diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java index 009ced769..f6a6f22a4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java @@ -82,19 +82,18 @@ public class BodyEnhanced2 extends BodyEnhancedAbstract { char separator = 0; TextBlock title = null; Display display = Display.empty(); - for (CharSequence s : rawBody) { + for (CharSequence s : rawBody) if (isBlockSeparator(s.toString())) { blocks.add(decorate(getTextBlock(display), separator, title, stringBounder)); separator = s.charAt(0); title = getTitle(s.toString(), skinParam); display = Display.empty(); } else { - if (s instanceof String) - s = Guillemet.GUILLEMET.manageGuillemet(s.toString()); - + // if (s instanceof String) + // s = Guillemet.GUILLEMET.manageGuillemet(s.toString()); display = display.add(s); } - } + blocks.add(decorate(getTextBlock(display), separator, title, stringBounder)); if (blocks.size() == 1) diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java index 04f32ed10..5735b319c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java @@ -41,6 +41,7 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java b/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java index 1009bc58d..45c220baf 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.Objects; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; +import net.sourceforge.plantuml.baraye.a.EntityFactory; public class CodeImpl implements Code { @@ -49,9 +49,9 @@ public class CodeImpl implements Code { } public static Code of(String code) { - if (code == null) { + if (code == null) EntityFactory.bigError(); - } + return new CodeImpl(code); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index 0eedfc44d..5facddcc6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Objects; @@ -47,14 +46,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sourceforge.plantuml.BackSlash; -import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.LineLocationImpl; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.StringLocated; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.command.regex.Matcher2; @@ -94,6 +90,22 @@ public class Display implements Iterable { public final static Display NULL = new Display(true, null, null, true, CreoleMode.FULL); +// @Override +// public int hashCode() { +// if (isNull) +// return 42; +// return displayData.hashCode(); +// } +// +// @Override +// public boolean equals(Object other) { +// return this.displayData.equals(((Display) other).displayData); +// } + + public boolean equalsLike(Display other) { + return this.displayData.equals(other.displayData); + } + public boolean showStereotype() { return showStereotype; } @@ -163,6 +175,25 @@ public class Display implements Iterable { return result; } +// private static List skip(String type, Iterator it) { +// final List result = new ArrayList(); +// result.add("@start" + type); +// int nested = 1; +// while (it.hasNext()) { +// final StringLocated s2 = it.next(); +// result.add(s2.getString()); +// if (s2.getTrimmed().getString().startsWith(EmbeddedDiagram.EMBEDDED_START)) +// nested++; +// else if (s2.getTrimmed().getString().equals(EmbeddedDiagram.EMBEDDED_END)) { +// nested--; +// if (nested == 0) +// break; +// } +// } +// result.add("@end" + type); +// return result; +// } + public static Display create(Collection other) { return new Display(true, other, null, false, CreoleMode.FULL); } @@ -241,48 +272,55 @@ public class Display implements Iterable { HorizontalAlignment naturalHorizontalAlignment, boolean isNull, CreoleMode defaultCreoleMode) { this(showStereotype, naturalHorizontalAlignment, isNull, defaultCreoleMode); if (isNull == false) - this.displayData.addAll(manageEmbeddedDiagrams(other)); + // this.displayData.addAll(manageEmbeddedDiagrams(other)); + this.displayData.addAll(other); } - private static List manageEmbeddedDiagrams(final Collection strings) { - final List result = new ArrayList<>(); - final Iterator it = strings.iterator(); - while (it.hasNext()) { - CharSequence s = it.next(); - final String type = EmbeddedDiagram.getEmbeddedType(s); - if (type != null) { - final List other = new ArrayList<>(); - other.add("@start" + type); - while (it.hasNext()) { - final CharSequence s2 = it.next(); - if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) - break; - - other.add(s2); - } - other.add("@end" + type); - s = new EmbeddedDiagram(Display.create(other)); - } - result.add(s); - } - return result; - } +// private static List manageEmbeddedDiagrams(final Collection strings) { +// System.err.println("tata=" + strings); +// final List result = new ArrayList<>(); +// final Iterator it = strings.iterator(); +// while (it.hasNext()) { +// CharSequence s = it.next(); +// if (s instanceof String == false) +// System.err.println("s=" + s.getClass()); +// final String type = EmbeddedDiagram.getEmbeddedType(s); +// if (type != null) { +// final List other = new ArrayList<>(); +// other.add("@start" + type); +// int nested = 1; +// while (it.hasNext()) { +// final CharSequence s2 = it.next(); +// if (StringUtils.trin(s2.toString()).equals(EmbeddedDiagram.EMBEDDED_END)) { +// nested--; +// if (nested == 0) +// break; +// } +// if (StringUtils.trin(s2.toString()).startsWith(EmbeddedDiagram.EMBEDDED_START)) +// nested++; +// +// other.add(s2); +// } +// other.add("@end" + type); +// s = new EmbeddedDiagram(Display.create(other)); +// } +// result.add(s); +// } +// return result; +// } public Display manageGuillemet(boolean manageVisibilityModifier) { final List result = new ArrayList<>(); boolean first = true; for (CharSequence line : displayData) { - if (line instanceof EmbeddedDiagram) { - result.add(line); - } else { - String lineString = line.toString(); - if (manageVisibilityModifier && first && VisibilityModifier.isVisibilityCharacter(line)) - lineString = lineString.substring(1).trim(); + String lineString = line.toString(); + if (manageVisibilityModifier && first && VisibilityModifier.isVisibilityCharacter(line)) + lineString = lineString.substring(1).trim(); + + final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString); + result.add(withGuillement); - final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString); - result.add(withGuillement); - } first = false; } return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, @@ -366,16 +404,6 @@ public class Display implements Iterable { return displayData.toString(); } - @Override - public int hashCode() { - return displayData.hashCode(); - } - - @Override - public boolean equals(Object other) { - return this.displayData.equals(((Display) other).displayData); - } - public Display addAll(Display other) { final Display result = new Display(this.showStereotype, this, this.defaultCreoleMode); result.displayData.addAll(other.displayData); @@ -429,15 +457,15 @@ public class Display implements Iterable { return Collections.unmodifiableList(displayData); } - public List as2() { - final List result = new ArrayList<>(); - LineLocationImpl location = new LineLocationImpl("inner", null); - for (CharSequence cs : displayData) { - location = location.oneLineRead(); - result.add(new StringLocated(cs.toString(), location)); - } - return Collections.unmodifiableList(result); - } +// public List as2() { +// final List result = new ArrayList<>(); +// LineLocationImpl location = new LineLocationImpl("inner", null); +// for (CharSequence cs : displayData) { +// location = location.oneLineRead(); +// result.add(new StringLocated(cs.toString(), location)); +// } +// return Collections.unmodifiableList(result); +// } public boolean hasUrl() { final UrlBuilder urlBuilder = new UrlBuilder(null, UrlMode.ANYWHERE); @@ -567,9 +595,8 @@ public class Display implements Iterable { private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode creoleMode, FontConfiguration stereotypeConfiguration, double marginX1, double marginX2) { - final Sheet sheet = Parser - .build(fontConfiguration, horizontalAlignment, spriteContainer, creoleMode, stereotypeConfiguration) - .createSheet(this); + final Sheet sheet = spriteContainer + .sheet(fontConfiguration, horizontalAlignment, creoleMode, stereotypeConfiguration).createSheet(this); final double padding = spriteContainer == null ? 0 : spriteContainer.getPadding(); final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, padding, marginX1, marginX2); return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5)); @@ -617,4 +644,23 @@ public class Display implements Iterable { return false; } +// private Object data; +// private boolean mayHaveEmbedded; +// +// public final Object getCachedDataForPerf() { +// return data; +// } +// +// public final void setCachedDataForPerf(Object data) { +// this.data = data; +// } +// +// public final void setMayHaveEmbedded() { +// this.mayHaveEmbedded = true; +// } +// +// public final boolean mayHaveEmbedded() { +// return mayHaveEmbedded; +// } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java index f3547fab1..a46b85c9c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.cucadiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; + public interface EntityGender { public boolean contains(IEntity test); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java index 7d9112156..2132cf472 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java @@ -36,6 +36,8 @@ package net.sourceforge.plantuml.cucadiagram; import net.sourceforge.plantuml.Guillemet; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; public class EntityGenderUtils { diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java index c81c0a2e8..3e46c76af 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java @@ -35,60 +35,81 @@ */ package net.sourceforge.plantuml.cucadiagram; +import net.sourceforge.plantuml.baraye.Quark; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.b.EntityImp; + public abstract class EntityUtils { public static boolean groupRoot(IGroup g) { - if (g == null) { + if (g == null) throw new IllegalStateException(); - } + return g instanceof GroupRoot; } private static boolean isParent(IGroup groupToBeTested, IGroup parentGroup) { - if (groupToBeTested.isGroup() == false) { + if (groupToBeTested.isGroup() == false) // Very strange! return false; - } - if (groupToBeTested.isGroup() == false) { + + if (groupToBeTested.isGroup() == false) throw new IllegalArgumentException(); - } + while (EntityUtils.groupRoot(groupToBeTested) == false) { - if (groupToBeTested == parentGroup) { + if (groupToBeTested == parentGroup) return true; - } + groupToBeTested = groupToBeTested.getParentContainer(); - if (groupToBeTested.isGroup() == false) { + if (groupToBeTested.isGroup() == false) throw new IllegalStateException(); - } + } return false; } + public static boolean isPureInnerLink12(EntityImp group, Link link) { + if (group.isGroup() == false) + throw new IllegalArgumentException(); + + final EntityImp e1 = (EntityImp) link.getZEntity1(); + final EntityImp e2 = (EntityImp) link.getZEntity2(); + final Quark group1 = e1.getQuark().getParent(); + final Quark group2 = e2.getQuark().getParent(); + if (group.getQuark().containsLarge(group1) && group.getQuark().containsLarge(group2)) + return true; +// if (isParent(group1, group) && isParent(group2, group)) +// return true; + + return false; + } + public static boolean isPureInnerLink12(IGroup group, Link link) { - if (group.isGroup() == false) { + if (group.isGroup() == false) throw new IllegalArgumentException(); - } + final IEntity e1 = link.getEntity1(); final IEntity e2 = link.getEntity2(); final IGroup group1 = e1.getParentContainer(); final IGroup group2 = e2.getParentContainer(); - if (isParent(group1, group) && isParent(group2, group)) { + if (isParent(group1, group) && isParent(group2, group)) return true; - } + return false; } public static boolean isPureInnerLink3(IGroup group, Link link) { - if (group.isGroup() == false) { + if (group.isGroup() == false) throw new IllegalArgumentException(); - } + final IEntity e1 = link.getEntity1(); final IEntity e2 = link.getEntity2(); final IGroup group1 = e1.getParentContainer(); final IGroup group2 = e2.getParentContainer(); - if (isParent(group2, group) == isParent(group1, group)) { + if (isParent(group2, group) == isParent(group1, group)) return true; - } + return false; } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java index 2cc3a3372..fce403f80 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java @@ -36,17 +36,14 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.Collection; -import java.util.Set; + +import net.sourceforge.plantuml.baraye.a.IGroup; public interface GroupHierarchy { public IGroup getRootGroup(); - public SuperGroup getRootSuperGroup(); - public Collection getChildrenGroups(IGroup parent); - public Set getAllSuperGroups(); - public boolean isEmpty(IGroup g); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java index 7ae662fa2..ec376ce62 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java @@ -38,6 +38,8 @@ package net.sourceforge.plantuml.cucadiagram; import java.io.IOException; import java.io.PrintWriter; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java index 1262136e6..687e2628a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java @@ -45,8 +45,10 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.command.Position; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorType; diff --git a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java index db9c091d4..56b466304 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.cucadiagram; +import net.sourceforge.plantuml.baraye.a.ILeaf; + public class HideOrShow2 { private final String what; @@ -50,7 +52,7 @@ public class HideOrShow2 { return isApplyableTag(leaf, what.substring(1)); if (what.startsWith("<<") && what.endsWith(">>")) - return isApplyableStereotype(leaf, what.substring(2, what.length() - 2).trim()); + return isApplyableStereotype(leaf.getStereotype(), what.substring(2, what.length() - 2).trim()); if (isAboutUnlinked()) return isApplyableUnlinked(leaf); @@ -60,6 +62,12 @@ public class HideOrShow2 { return match(fullName, what); } + private boolean isApplyable(Stereotype stereotype) { + if (what.startsWith("<<") && what.endsWith(">>")) + return isApplyableStereotype(stereotype, what.substring(2, what.length() - 2).trim()); + return false; + } + public boolean isAboutUnlinked() { return what.equalsIgnoreCase("@unlinked"); } @@ -71,8 +79,7 @@ public class HideOrShow2 { return false; } - private boolean isApplyableStereotype(ILeaf leaf, String pattern) { - final Stereotype stereotype = leaf.getStereotype(); + private boolean isApplyableStereotype(Stereotype stereotype, String pattern) { if (stereotype == null) return false; @@ -115,4 +122,11 @@ public class HideOrShow2 { return hidden; } + public boolean apply(boolean hidden, Stereotype stereotype) { + if (isApplyable(stereotype)) + return !show; + + return hidden; + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java new file mode 100644 index 000000000..969de1bf4 --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java @@ -0,0 +1,95 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.io.IOException; +import java.util.Collection; + +import net.sourceforge.plantuml.Annotated; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.Pragma; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; +import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; + +public interface ICucaDiagram extends GroupHierarchy, PortionShower, Annotated { + + boolean V1972(); + + ISkinParam getSkinParam(); + + UmlDiagramType getUmlDiagramType(); + + EntityFactory getEntityFactory(); + + StyleBuilder getCurrentStyleBuilder(); + + boolean isHideEmptyDescriptionForState(); + + Collection getLinks(); + + Pragma getPragma(); + + long seed(); + + String getMetadata(); + + String getFlashData(); + + Collection getLeafsvalues(); + + ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException; + + String getNamespaceSeparator(); + + boolean mergeIntricated(); + + Collection getGroups(boolean b); + + UmlSource getSource(); + + String[] getDotStringSkek(); + + boolean isAutarkic(IGroup g); + + int getUniqueSequence(); + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Ident.java b/src/net/sourceforge/plantuml/cucadiagram/Ident.java index 38cf9c3c5..dea085f92 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Ident.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Ident.java @@ -40,7 +40,8 @@ import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.EntityFactory; public class Ident implements Code { @@ -56,23 +57,22 @@ public class Ident implements Code { } public boolean startsWith(Ident other) { - if (other.parts.size() > this.parts.size()) { + if (other.parts.size() > this.parts.size()) return false; - } - for (int i = 0; i < other.parts.size(); i++) { - if (other.parts.get(i).equals(this.parts.get(i)) == false) { + + for (int i = 0; i < other.parts.size(); i++) + if (other.parts.get(i).equals(this.parts.get(i)) == false) return false; - } - } + return true; } public String forXmi() { final StringBuilder sb = new StringBuilder(); for (String s : parts) { - if (sb.length() > 0) { + if (sb.length() > 0) sb.append("."); - } + sb.append(s); } return sb.toString(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index f174aa48f..380ca440d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -42,10 +42,15 @@ import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Removeable; +import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; +import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -87,6 +92,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { private String sametail; private final StyleBuilder styleBuilder; private Stereotype stereotype; + private final IEntityFactory entityFactory; private Url url; @@ -108,16 +114,18 @@ public class Link extends WithLinkType implements Hideable, Removeable { return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName()); } - public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, LinkArg linkArg) { + public Link(IEntityFactory entityFactory, StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, + LinkArg linkArg) { if (linkArg.getLength() < 1) throw new IllegalArgumentException(); + this.entityFactory = entityFactory; this.styleBuilder = styleBuilder; this.cl1 = Objects.requireNonNull(cl1); this.cl2 = Objects.requireNonNull(cl2); this.type = type; - final CucaDiagram diagram = ((EntityImpl) cl1).getDiagram(); + final ICucaDiagram diagram = ((EntityImp) cl1).getDiagram(); this.uid = "LNK" + diagram.getUniqueSequence(); this.linkArg = linkArg; @@ -129,7 +137,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { } public Link getInv() { - final Link result = new Link(styleBuilder, cl2, cl1, getType().getInversed(), linkArg.getInv()); + final Link result = new Link(entityFactory, styleBuilder, cl2, cl1, getType().getInversed(), linkArg.getInv()); result.inverted = !this.inverted; result.port1 = this.port2; result.port2 = this.port1; @@ -185,6 +193,14 @@ public class Link extends WithLinkType implements Hideable, Removeable { return super.toString() + " {" + linkArg.getLength() + "} " + cl1 + "-->" + cl2; } + public SpecificBackcolorable getZEntity1() { + return cl1; + } + + public SpecificBackcolorable getZEntity2() { + return cl2; + } + public IEntity getEntity1() { return cl1; } @@ -339,9 +355,9 @@ public class Link extends WithLinkType implements Hideable, Removeable { static private boolean isSame(IEntity a, IEntity b) { if (a == b) return true; - if (((EntityImpl) a).getOriginalGroup() == b) + if (((EntityImp) a).getOriginalGroup() == b) return true; - if (((EntityImpl) b).getOriginalGroup() == a) + if (((EntityImp) b).getOriginalGroup() == a) return true; return false; } @@ -469,6 +485,10 @@ public class Link extends WithLinkType implements Hideable, Removeable { } public boolean isRemoved() { + final Stereotype stereotype = getStereotype(); + if (stereotype != null && entityFactory.isRemoved(stereotype)) + return true; + return cl1.isRemoved() || cl2.isRemoved(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Magma.java b/src/net/sourceforge/plantuml/cucadiagram/Magma.java index 1f41831ab..0c61366ad 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Magma.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Magma.java @@ -37,7 +37,11 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.List; -class Magma { +import net.sourceforge.plantuml.baraye.a.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; + +public class Magma { private final CucaDiagram diagram; private final List standalones; @@ -51,13 +55,13 @@ class Magma { public void putInSquare() { final SquareLinker linker = new SquareLinker() { public void topDown(ILeaf top, ILeaf down) { - diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), top, down, linkType, - LinkArg.noDisplay(2))); + diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + top, down, linkType, LinkArg.noDisplay(2))); } public void leftRight(ILeaf left, ILeaf right) { - diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), left, right, linkType, - LinkArg.noDisplay(1))); + diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + left, right, linkType, LinkArg.noDisplay(1))); } }; new SquareMaker().putInSquare(standalones, linker); @@ -103,14 +107,14 @@ class Magma { } public void linkToDown(Magma down) { - diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(), - down.getTopLeft(), linkType, LinkArg.noDisplay(2))); + diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + this.getBottomLeft(), down.getTopLeft(), linkType, LinkArg.noDisplay(2))); } public void linkToRight(Magma right) { - diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), this.getTopRight(), - right.getTopLeft(), linkType, LinkArg.noDisplay(1))); + diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + this.getTopRight(), right.getTopLeft(), linkType, LinkArg.noDisplay(1))); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java index 0e7aad87c..36eaee6a0 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java @@ -38,7 +38,9 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.ArrayList; import java.util.List; -class MagmaList { +import net.sourceforge.plantuml.baraye.a.IGroup; + +public class MagmaList { private final List all = new ArrayList<>(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index 5a51fa7c0..789efb004 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -39,13 +39,17 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Iterator; import java.util.List; import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -68,6 +72,7 @@ import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Left; import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Right; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULayoutGroup; +import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.utils.CharHidder; @@ -82,6 +87,7 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, private final Display members; private final HorizontalAlignment align; + private final List embeddeds = new ArrayList<>(); private final ILeaf leaf; private final Style style; @@ -97,7 +103,21 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, this.align = align; this.skinParam = skinParam; - this.members = members; + + final List result = new ArrayList<>(); + final Iterator it = members.iterator(); + + while (it.hasNext()) { + final CharSequence cs = it.next(); + final String type = EmbeddedDiagram.getEmbeddedType(StringUtils.trinNoTrace(cs)); + if (type != null) + embeddeds.add(EmbeddedDiagram.createAndSkip(type, it, skinParam)); + else + result.add(cs); + + } + + this.members = Display.create(result); } private boolean hasSmallIcon() { @@ -115,7 +135,21 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, return false; } + @Override public XDimension2D calculateDimension(StringBounder stringBounder) { + final XDimension2D dim1 = calculateDimensionOnlyMembers(stringBounder); + double x = dim1.getWidth(); + double y = dim1.getHeight(); + for (EmbeddedDiagram embedded : embeddeds) { + final XDimension2D dim = embedded.calculateDimension(stringBounder); + x = Math.max(dim.getWidth(), x); + y += dim.getHeight(); + } + + return new XDimension2D(x, y); + } + + private XDimension2D calculateDimensionOnlyMembers(StringBounder stringBounder) { double smallIcon = 0; if (hasSmallIcon()) smallIcon = skinParam.getCircledCharacterRadius() + 3; @@ -129,6 +163,7 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, y += dim.getHeight(); } x += smallIcon; + return new XDimension2D(x, y); } @@ -213,8 +248,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, return new TextBlockTracer(m, bloc); } - if (cs instanceof EmbeddedDiagram) - return ((EmbeddedDiagram) cs).asDraw(skinParam); +// if (cs instanceof EmbeddedDiagram) +// return ((EmbeddedDiagram) cs).asDraw(skinParam); return Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE, skinParam.wrapWidth()); @@ -306,13 +341,13 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, new PlacementStrategyVisibility(stringBounder, skinParam.getCircledCharacterRadius() + 3)); for (CharSequence cs : members) { final TextBlock bloc = createTextBlock(cs); - if (cs instanceof EmbeddedDiagram) { - group.add(getUBlock(null, null)); - } else { - final Member att = (Member) cs; - final VisibilityModifier modifier = att.getVisibilityModifier(); - group.add(getUBlock(modifier, att.getUrl())); - } +// if (cs instanceof EmbeddedDiagram) { +// group.add(getUBlock(null, null)); +// } else { + final Member att = (Member) cs; + final VisibilityModifier modifier = att.getVisibilityModifier(); + group.add(getUBlock(modifier, att.getUrl())); +// } group.add(bloc); } } else { @@ -334,9 +369,16 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, } public void drawU(UGraphic ug) { - final ULayoutGroup group = getLayout(ug.getStringBounder()); - final XDimension2D dim = calculateDimension(ug.getStringBounder()); + final StringBounder stringBounder = ug.getStringBounder(); + final ULayoutGroup group = getLayout(stringBounder); + final XDimension2D dim = calculateDimensionOnlyMembers(stringBounder); group.drawU(ug, dim.getWidth(), dim.getHeight()); + ug = ug.apply(UTranslate.dy(dim.getHeight())); + + for (EmbeddedDiagram embedded : embeddeds) { + embedded.drawU(ug); + ug = ug.apply(UTranslate.dy(embedded.calculateDimension(stringBounder).getHeight())); + } } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java index ebff40f2c..6e5a3200f 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java +++ b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.cucadiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; + public interface PortionShower { boolean showPortion(EntityPortion portion, IEntity entity); diff --git a/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java b/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java index e53af4180..f77db86ed 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java +++ b/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java @@ -197,7 +197,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { for (JsonValue element : array) { final TextBlock tb = getTextBlockValue(element, arrayTotalWidth); final XDimension2D dim = tb.calculateDimension(stringBounder); - result = XDimension2D.mergeTB(result, dim); + result = result.mergeTB(dim); } return result; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java index b129d30c5..5cd5e37cc 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java @@ -40,8 +40,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.svek.GroupPngMakerActivity; @@ -49,10 +49,10 @@ import net.sourceforge.plantuml.svek.IEntityImage; public final class CucaDiagramSimplifierActivity { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final StringBounder stringBounder; - public CucaDiagramSimplifierActivity(CucaDiagram diagram, List dotStrings, StringBounder stringBounder) + public CucaDiagramSimplifierActivity(ICucaDiagram diagram, List dotStrings, StringBounder stringBounder) throws IOException, InterruptedException { this.diagram = diagram; this.stringBounder = stringBounder; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java index 043463d80..6075fcc22 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java @@ -41,10 +41,10 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.svek.GroupPngMakerState; @@ -52,10 +52,10 @@ import net.sourceforge.plantuml.svek.IEntityImage; public final class CucaDiagramSimplifierState { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final StringBounder stringBounder; - public CucaDiagramSimplifierState(CucaDiagram diagram, List dotStrings, StringBounder stringBounder) + public CucaDiagramSimplifierState(ICucaDiagram diagram, List dotStrings, StringBounder stringBounder) throws IOException, InterruptedException { this.diagram = diagram; this.stringBounder = stringBounder; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java index 99f6c91ab..80def3296 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java @@ -50,10 +50,10 @@ import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.awt.geom.XPoint2D; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.posimo.Block; @@ -86,7 +86,7 @@ public final class CucaDiagramTxtMaker { return showMethods || showFields; } - public CucaDiagramTxtMaker(CucaDiagram diagram, FileFormat fileFormat) throws IOException { + public CucaDiagramTxtMaker(ICucaDiagram diagram, FileFormat fileFormat) throws IOException { this.fileFormat = fileFormat; this.portionShower = diagram; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java index e8c665047..57f5f0ba4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java @@ -46,14 +46,14 @@ import java.util.Objects; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Pragma; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.PortionShower; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.svek.DotMode; final public class DotData implements PortionShower { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java index f4783bb6b..b5f8f76f6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java @@ -43,7 +43,7 @@ import java.util.Set; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.SvekLine; diff --git a/src/net/sourceforge/plantuml/cucadiagram/SuperGroup.java b/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java similarity index 80% rename from src/net/sourceforge/plantuml/cucadiagram/SuperGroup.java rename to src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java index 1fa7af763..0f5e66ca4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/SuperGroup.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java @@ -33,21 +33,17 @@ * * */ -package net.sourceforge.plantuml.cucadiagram; +package net.sourceforge.plantuml.cucadiagram.entity; -import java.util.HashSet; -import java.util.Set; +import java.util.Collection; -public class SuperGroup { +import net.sourceforge.plantuml.baraye.a.ILeaf; +import net.sourceforge.plantuml.cucadiagram.Stereotype; - private final Set groups = new HashSet<>(); +public interface IEntityFactory { - public SuperGroup(IGroup g) { - this.groups.add(g); - } + public boolean isRemoved(Stereotype stereotype); - public IGroup getFirstGroup() { - return groups.iterator().next(); - } + public Collection leafs(); } diff --git a/src/net/sourceforge/plantuml/dedication/DedicationCrypted.java b/src/net/sourceforge/plantuml/dedication/DedicationCrypted.java index 95955a283..c39b3ec38 100644 --- a/src/net/sourceforge/plantuml/dedication/DedicationCrypted.java +++ b/src/net/sourceforge/plantuml/dedication/DedicationCrypted.java @@ -42,6 +42,7 @@ import java.io.ByteArrayInputStream; import java.math.BigInteger; import net.sourceforge.plantuml.log.Logme; +import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.utils.MTRandom; public class DedicationCrypted implements Dedication { @@ -110,7 +111,7 @@ public class DedicationCrypted implements Dedication { Noise.shuffle(current, rndMT); current = Noise.reverse(current, rndMT.nextInt()); - final BufferedImage img = PSystemDedication.getBufferedImage(new ByteArrayInputStream(current)); + final BufferedImage img = SFile.getBufferedImageFromWebpButHeader(new ByteArrayInputStream(current)); this.solution = line; return img; } catch (Throwable t) { diff --git a/src/net/sourceforge/plantuml/dedication/DedicationSimple.java b/src/net/sourceforge/plantuml/dedication/DedicationSimple.java index f787a9cd9..96c5b5fe4 100644 --- a/src/net/sourceforge/plantuml/dedication/DedicationSimple.java +++ b/src/net/sourceforge/plantuml/dedication/DedicationSimple.java @@ -39,6 +39,7 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import net.sourceforge.plantuml.log.Logme; +import net.sourceforge.plantuml.security.SFile; public class DedicationSimple implements Dedication { @@ -61,7 +62,7 @@ public class DedicationSimple implements Dedication { final RBlocks init = RBlocks.readFrom(current, 513); final RBlocks decoded = init.change(E, N); current = decoded.toByteArray(512); - return PSystemDedication.getBufferedImage(new ByteArrayInputStream(current)); + return SFile.getBufferedImageFromWebpButHeader(new ByteArrayInputStream(current)); } catch (Throwable t) { Logme.error(t); return null; diff --git a/src/net/sourceforge/plantuml/dedication/PSystemDedication.java b/src/net/sourceforge/plantuml/dedication/PSystemDedication.java index 70c2078dd..f13a755c0 100644 --- a/src/net/sourceforge/plantuml/dedication/PSystemDedication.java +++ b/src/net/sourceforge/plantuml/dedication/PSystemDedication.java @@ -36,19 +36,13 @@ package net.sourceforge.plantuml.dedication; import java.awt.image.BufferedImage; -import java.io.InputStream; -import java.lang.reflect.Method; import java.util.Objects; -import javax.imageio.stream.ImageInputStream; - import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.PlainDiagram; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.log.Logme; -import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -73,26 +67,6 @@ public class PSystemDedication extends PlainDiagram { }; } - public static BufferedImage getBufferedImage(InputStream is) { - try { - final Class clVP8Decoder = Class.forName("net.sourceforge.plantuml.webp.VP8Decoder"); - final Object vp8Decoder = clVP8Decoder.getDeclaredConstructor().newInstance(); - // final VP8Decoder vp8Decoder = new VP8Decoder(); - final Method decodeFrame = clVP8Decoder.getMethod("decodeFrame", ImageInputStream.class); - final ImageInputStream iis = SImageIO.createImageInputStream(is); - decodeFrame.invoke(vp8Decoder, iis); - // vp8Decoder.decodeFrame(iis); - iis.close(); - final Object frame = clVP8Decoder.getMethod("getFrame").invoke(vp8Decoder); - return (BufferedImage) frame.getClass().getMethod("getBufferedImage").invoke(frame); - // final VP8Frame frame = vp8Decoder.getFrame(); - // return frame.getBufferedImage(); - } catch (Exception e) { - Logme.error(e); - return null; - } - } - public DiagramDescription getDescription() { return new DiagramDescription("(Dedication)"); } diff --git a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java index 63a20ee37..4f16188e0 100644 --- a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java @@ -40,6 +40,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.command.GenericRegexProducer; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -50,8 +52,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java index 39aa82cf9..4ceb2424c 100644 --- a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java @@ -40,10 +40,10 @@ import java.util.Objects; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.USymbol; diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java index 71b00a142..5d18b93da 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java @@ -43,8 +43,8 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java index 5df82f112..844d17135 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java @@ -43,8 +43,8 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java index 4734f87d8..f0d8e6f09 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java @@ -43,8 +43,8 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java index 9854756b6..54e2f4d05 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java @@ -43,10 +43,10 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java index 84d9a48b6..a0eb4034f 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -48,7 +49,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java index b78cdb601..6b0421d9e 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -51,7 +52,6 @@ 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.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java index 87d58ccc9..98c183a21 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java @@ -42,6 +42,8 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -55,8 +57,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java index 9f869c710..93faa9a7d 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -54,7 +55,6 @@ 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.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementParenthesis.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementParenthesis.java index 6816b5343..a788090f9 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementParenthesis.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementParenthesis.java @@ -41,6 +41,8 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -53,8 +55,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index 887d0ade0..63846d1a2 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -38,6 +38,8 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -47,8 +49,6 @@ 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.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -85,7 +85,7 @@ public class CommandLinkElement extends SingleLineCommand2 { new RegexLeaf("HEAD2", "(0\\)|<<|<_|[<^*+#0@)]|<\\|[\\|\\:]?|[%s]+o)?"), // new RegexLeaf("BODY1", "([-=.~]+)"), // new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + LINE_STYLE_MUTILPLES + ")\\])?"), // - new RegexOptional(new RegexLeaf("DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)(?=[-=.~0()])")), // + new RegexOptional(new RegexLeaf("DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)(?=[-=.~0()\\[])")), // new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), // new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + LINE_STYLE + ")\\])?"), // new RegexLeaf("BODY2", "([-=.~]*)"), // @@ -274,8 +274,8 @@ public class CommandLinkElement extends SingleLineCommand2 { } final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(), diagram.getSkinParam().classAttributeIconSize() > 0); - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, + linkType, linkArg.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setLinkArrow(labels.getLinkArrow()); if (dir == Direction.LEFT || dir == Direction.UP) diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index e790de9db..e7e7550f0 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -40,6 +40,8 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -53,8 +55,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/ebnf/ETileBox.java b/src/net/sourceforge/plantuml/ebnf/ETileBox.java index 38937f00e..4d4405301 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileBox.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileBox.java @@ -121,7 +121,7 @@ public class ETileBox extends ETile { } private XDimension2D getBoxDim(StringBounder stringBounder) { - return XDimension2D.delta(getTextDim(stringBounder), 10); + return getTextDim(stringBounder).delta(10); } @Override @@ -153,6 +153,11 @@ public class ETileBox extends ETile { if (symbol == Symbol.TERMINAL_STRING1 || symbol == Symbol.TERMINAL_STRING2) { final URectangle rect = new URectangle(dimBox); ug.apply(new UTranslate(posxBox, posy)).apply(lineColor).apply(new UStroke(0.5)).draw(rect); + } else if (symbol == Symbol.SPECIAL_SEQUENCE) { + final URectangle rect1 = new URectangle(dimBox.delta(2)).rounded(12); + final URectangle rect2 = new URectangle(dimBox.delta(-2)).rounded(8); + ug.apply(new UTranslate(posxBox - 1, posy - 1)).apply(lineColor).apply(new UStroke(1.0)).draw(rect1); + ug.apply(new UTranslate(posxBox + 1, posy + 1)).apply(lineColor).apply(new UStroke(1.0)).draw(rect2); } else { final URectangle rect = new URectangle(dimBox).rounded(10); ug.apply(new UTranslate(posxBox, posy)).apply(lineColor).apply(backgroundColor.bg()).apply(new UStroke(1.5)) diff --git a/src/net/sourceforge/plantuml/ebnf/EbnfExpression.java b/src/net/sourceforge/plantuml/ebnf/EbnfExpression.java index 94e9e2af7..842916d4f 100644 --- a/src/net/sourceforge/plantuml/ebnf/EbnfExpression.java +++ b/src/net/sourceforge/plantuml/ebnf/EbnfExpression.java @@ -110,10 +110,13 @@ public class EbnfExpression implements TextBlockable { break; } else if (ch == '\"') { final String litteral = readString(it); - tokens.add(new Token(Symbol.TERMINAL_STRING1, litteral)); + tokens.add(new Token(Symbol.TERMINAL_STRING1, protect(litteral))); } else if (ch == '\'') { final String litteral = readString(it); - tokens.add(new Token(Symbol.TERMINAL_STRING2, litteral)); + tokens.add(new Token(Symbol.TERMINAL_STRING2, protect(litteral))); + } else if (ch == '?') { + final String litteral = readString(it); + tokens.add(new Token(Symbol.SPECIAL_SEQUENCE, protect(litteral))); } else { tokens.clear(); return; @@ -123,6 +126,10 @@ public class EbnfExpression implements TextBlockable { } } + private static String protect(final String litteral) { + return litteral.length() == 0 ? " " : litteral; + } + public TextBlock getUDrawable(ISkinParam skinParam) { final Style style = ETile.getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); final FontConfiguration fc = style.getFontConfiguration(skinParam.getIHtmlColorSet()); @@ -182,7 +189,7 @@ public class EbnfExpression implements TextBlockable { while (it.hasNext()) { final Token element = it.next(); if (element.getSymbol() == Symbol.TERMINAL_STRING1 || element.getSymbol() == Symbol.TERMINAL_STRING2 - || element.getSymbol() == Symbol.LITTERAL) + || element.getSymbol() == Symbol.LITTERAL || element.getSymbol() == Symbol.SPECIAL_SEQUENCE) engine.push(element); else if (element.getSymbol() == Symbol.COMMENT_ABOVE) engine.commentAbove(element.getData()); diff --git a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java index 28f3f66f3..efb1e1b10 100644 --- a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java @@ -54,7 +54,7 @@ public class ShuntingYard { // System.err.println("ouputQueue=" + ouputQueue); // System.err.println("operatorStack=" + operatorStack); if (token.getSymbol() == Symbol.LITTERAL || token.getSymbol() == Symbol.TERMINAL_STRING1 - || token.getSymbol() == Symbol.TERMINAL_STRING2) { + || token.getSymbol() == Symbol.TERMINAL_STRING2 || token.getSymbol() == Symbol.SPECIAL_SEQUENCE) { ouputQueue.add(token); while (thereIsAnCommentOnTopOfTheOperatorStack()) ouputQueue.add(operatorStack_removeFirstAbove()); diff --git a/src/net/sourceforge/plantuml/eggs/GraphicsPath.java b/src/net/sourceforge/plantuml/eggs/GraphicsPath.java index af1ba8f1d..3a45b9985 100644 --- a/src/net/sourceforge/plantuml/eggs/GraphicsPath.java +++ b/src/net/sourceforge/plantuml/eggs/GraphicsPath.java @@ -65,7 +65,7 @@ public class GraphicsPath { public ImageData writeImage(OutputStream os) throws IOException { final BufferedImage im = createImage(); - PngIO.write(im, os, 96); + PngIO.write(im, colorMapper, os, null, 96); return new ImageDataSimple(im.getWidth(), im.getHeight()); } diff --git a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java index d12ed66b9..b1b108d56 100644 --- a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java +++ b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java @@ -55,15 +55,15 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; /* * You can choose between real "org.eclipse.elk..." classes or proxied "net.sourceforge.plantuml.elk.proxy..." @@ -147,7 +147,7 @@ https://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/thw-bt.pdf */ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final StringBounder stringBounder; private final DotStringFactory dotStringFactory; @@ -155,7 +155,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { private final Map clusters = new LinkedHashMap(); private final Map edges = new LinkedHashMap(); - public CucaDiagramFileMakerElk(CucaDiagram diagram, StringBounder stringBounder) { + public CucaDiagramFileMakerElk(ICucaDiagram diagram, StringBounder stringBounder) { this.diagram = diagram; this.stringBounder = stringBounder; this.dotStringFactory = new DotStringFactory(stringBounder, diagram); diff --git a/src/net/sourceforge/plantuml/elk/ElkPath.java b/src/net/sourceforge/plantuml/elk/ElkPath.java index a34ac1419..08429414e 100644 --- a/src/net/sourceforge/plantuml/elk/ElkPath.java +++ b/src/net/sourceforge/plantuml/elk/ElkPath.java @@ -41,7 +41,7 @@ import java.util.List; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.awt.geom.XPoint2D; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; @@ -89,7 +89,7 @@ public class ElkPath implements UDrawable { private final Link link; private final ElkEdge edge; - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final TextBlock centerLabel; private final TextBlock headLabel; private final TextBlock tailLabel; @@ -98,7 +98,7 @@ public class ElkPath implements UDrawable { private final double magicY2; - public ElkPath(CucaDiagram diagram, SName styleName, Link link, ElkEdge edge, TextBlock centerLabel, + public ElkPath(ICucaDiagram diagram, SName styleName, Link link, ElkEdge edge, TextBlock centerLabel, TextBlock tailLabel, TextBlock headLabel, double magicY2) { this.link = link; this.edge = edge; diff --git a/src/net/sourceforge/plantuml/emoji/Emoji.java b/src/net/sourceforge/plantuml/emoji/Emoji.java index 55f4432df..85060064e 100644 --- a/src/net/sourceforge/plantuml/emoji/Emoji.java +++ b/src/net/sourceforge/plantuml/emoji/Emoji.java @@ -1,3 +1,38 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ package net.sourceforge.plantuml.emoji; import java.io.BufferedReader; diff --git a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java index 7c7851f9f..d36fe8451 100644 --- a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java +++ b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java @@ -1,3 +1,38 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ package net.sourceforge.plantuml.emoji; import java.awt.Color; diff --git a/src/net/sourceforge/plantuml/emoji/UGraphicWithScale.java b/src/net/sourceforge/plantuml/emoji/UGraphicWithScale.java index 69102b76a..d9274269e 100644 --- a/src/net/sourceforge/plantuml/emoji/UGraphicWithScale.java +++ b/src/net/sourceforge/plantuml/emoji/UGraphicWithScale.java @@ -1,3 +1,38 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ package net.sourceforge.plantuml.emoji; import java.awt.geom.AffineTransform; diff --git a/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java index 9a81c0584..73f30b1eb 100644 --- a/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java +++ b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java @@ -100,7 +100,7 @@ public class ActivityBox extends AbstractTextBlock { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = tb.calculateDimension(stringBounder); - return XDimension2D.delta(dim, 2 * MARGIN, 2 * MARGIN); + return dim.delta((2 * MARGIN), (2 * MARGIN)); } } diff --git a/src/net/sourceforge/plantuml/gitlog/MagicBox.java b/src/net/sourceforge/plantuml/gitlog/MagicBox.java index 10b2a6abf..a93a623db 100644 --- a/src/net/sourceforge/plantuml/gitlog/MagicBox.java +++ b/src/net/sourceforge/plantuml/gitlog/MagicBox.java @@ -84,8 +84,8 @@ public class MagicBox { public XDimension2D getBigDim(StringBounder stringBounder) { final XDimension2D dimComment = getCommentBlock().calculateDimension(stringBounder); final XDimension2D dimSmall = getSmallBlock().calculateDimension(stringBounder); - final XDimension2D mergeTB = XDimension2D.mergeTB(dimComment, dimSmall); - return XDimension2D.delta(mergeTB, 8, 2); + final XDimension2D mergeTB = dimComment.mergeTB(dimSmall); + return mergeTB.delta(8, 2); } public void drawBorder(UGraphic ug, XDimension2D sizeInDot) { diff --git a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java index b91363106..e38d454b8 100644 --- a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java +++ b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java @@ -70,6 +70,44 @@ public class FontConfiguration { public String toStringDebug() { return getFont().toStringDebug() + " " + styles.toString(); +// return "" + currentFont + " " + styles.toString() + currentColor + extendedColor + hyperlinkColor +// + hyperlinkUnderlineStroke + fontPosition + tabSize; + } + + @Override + public int hashCode() { + return currentFont.hashCode()// + + styles.hashCode() // + + currentColor.hashCode()// + + hashCode(extendedColor)// + + hyperlinkColor.hashCode()// + + hashCode(hyperlinkUnderlineStroke)// + + fontPosition.hashCode() // + + tabSize; + } + + private int hashCode(Object obj) { + if (obj == null) + return 43; + return obj.hashCode(); + } + + private boolean same(Object obj1, Object obj2) { + if (obj1 == null && obj2 == null) + return true; + if (obj1 != null && obj2 != null) + return obj1.equals(obj2); + return false; + } + + @Override + public boolean equals(Object obj) { + final FontConfiguration other = (FontConfiguration) obj; + return currentFont.equals(other.currentFont) && styles.equals(other.styles) + && currentColor.equals(other.currentColor) && same(extendedColor, other.extendedColor) + && hyperlinkColor.equals(other.hyperlinkColor) + && same(hyperlinkUnderlineStroke, other.hyperlinkUnderlineStroke) + && fontPosition.equals(other.fontPosition) && tabSize == other.tabSize; } public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor, diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java index 7a016c635..f574b1190 100644 --- a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java +++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java @@ -168,7 +168,7 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { } public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(calculateDimensionInternal(stringBounder), 2 * margin); + return calculateDimensionInternal(stringBounder).delta(2 * margin); } private XDimension2D calculateDimensionInternal(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java index b99fb20ce..40d8aafe6 100644 --- a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java +++ b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java @@ -47,28 +47,28 @@ public enum HorizontalAlignment { LEFT, CENTER, RIGHT; public static HorizontalAlignment fromString(String s) { - if (LEFT.name().equalsIgnoreCase(s)) { + if (LEFT.name().equalsIgnoreCase(s)) return LEFT; - } - if (CENTER.name().equalsIgnoreCase(s)) { + + if (CENTER.name().equalsIgnoreCase(s)) return CENTER; - } - if (RIGHT.name().equalsIgnoreCase(s)) { + + if (RIGHT.name().equalsIgnoreCase(s)) return RIGHT; - } + return null; } public static HorizontalAlignment fromString(String s, HorizontalAlignment defaultValue) { Objects.requireNonNull(defaultValue); - if (s == null) { + if (s == null) return defaultValue; - } + s = StringUtils.goUpperCase(s); final HorizontalAlignment result = fromString(s); - if (result == null) { + if (result == null) return defaultValue; - } + return result; } diff --git a/src/net/sourceforge/plantuml/graphic/SimpleTextBlockBordered.java b/src/net/sourceforge/plantuml/graphic/SimpleTextBlockBordered.java index f7327195d..8f2141127 100644 --- a/src/net/sourceforge/plantuml/graphic/SimpleTextBlockBordered.java +++ b/src/net/sourceforge/plantuml/graphic/SimpleTextBlockBordered.java @@ -53,7 +53,7 @@ class SimpleTextBlockBordered extends AbstractTextBlock implements TextBlock { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = textBlock.calculateDimension(stringBounder); - return XDimension2D.delta(dim, 1, 1); + return dim.delta(1, 1); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java index 7777a3d95..736cfb544 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java @@ -116,18 +116,23 @@ public class TextBlockBordered extends AbstractTextBlock implements TextBlock { if (withShadow) polygon.setDeltaShadow(4); - if (backgroundColor == null) - ug = ug.apply(HColors.none().bg()); + final HColor back; + if (backgroundColor == null || backgroundColor.isTransparent() + || backgroundColor.equals(ug.getDefaultBackground())) + back = HColors.none(); else - ug = ug.apply(backgroundColor.bg()); + back = backgroundColor; - HColor color = noBorder() ? backgroundColor : borderColor; + HColor color = noBorder() ? back : borderColor; if (color == null) color = HColors.none(); - ug = ug.apply(color); - ug = applyStroke(ug); - ug.draw(polygon); + if (back.isTransparent() == false || color.isTransparent() == false) { + ug = ug.apply(back.bg()); + ug = ug.apply(color); + ug = applyStroke(ug); + ug.draw(polygon); + } TextBlock toDraw = textBlock; if (textBlock instanceof SheetBlock2) toDraw = ((SheetBlock2) textBlock).enlargeMe(left, right); diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java index c6edc2e6e..58129ebec 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java @@ -64,7 +64,7 @@ public class TextBlockHorizontal extends AbstractTextBlock implements TextBlock public XDimension2D calculateDimension(StringBounder stringBounder) { XDimension2D dim = blocks.get(0).calculateDimension(stringBounder); for (int i = 1; i < blocks.size(); i++) { - dim = XDimension2D.mergeLR(dim, blocks.get(i).calculateDimension(stringBounder)); + dim = dim.mergeLR(blocks.get(i).calculateDimension(stringBounder)); } return dim; } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java index a401546bb..577ee0fd3 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java @@ -70,7 +70,7 @@ public class TextBlockLineBefore extends AbstractTextBlock implements TextBlock, final XDimension2D dim = textBlock.calculateDimension(stringBounder); if (title != null) { final XDimension2D dimTitle = title.calculateDimension(stringBounder); - return XDimension2D.atLeast(dim, dimTitle.getWidth() + 8, dimTitle.getHeight()); + return dim.atLeast(dimTitle.getWidth() + 8, dimTitle.getHeight()); } return dim; } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java index 5ef528a27..e07822dda 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java @@ -70,7 +70,7 @@ class TextBlockMarged extends AbstractTextBlock implements TextBlock, WithPorts public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = textBlock.calculateDimension(stringBounder); - return XDimension2D.delta(dim, left + right, top + bottom); + return dim.delta(left + right, top + bottom); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java index 9577b5578..ec8ae4ce1 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java @@ -53,7 +53,7 @@ class TextBlockMinWidth extends AbstractTextBlock implements TextBlock { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = textBlock.calculateDimension(stringBounder); - return XDimension2D.atLeast(dim, minWidth, 0); + return dim.atLeast(minWidth, 0); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java index 76cab10c5..8daa5a4e7 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.command.regex.MyPattern; @@ -68,17 +67,13 @@ public final class TextBlockSimple extends AbstractTextBlock implements TextBloc private List getLines(StringBounder stringBounder) { if (lines == null) { - if (stringBounder == null) { + if (stringBounder == null) throw new IllegalStateException(); - } + this.lines = new ArrayList<>(); - for (CharSequence s : texts) { - if (s instanceof EmbeddedDiagram) { - lines.add(((EmbeddedDiagram) s).asDraw(null)); - } else { - addInLines(stringBounder, s.toString()); - } - } + for (CharSequence s : texts) + addInLines(stringBounder, s.toString()); + } return lines; } @@ -95,12 +90,11 @@ public final class TextBlockSimple extends AbstractTextBlock implements TextBloc if (w > maxMessageSize) { addSingleLineNoSpace(currentLine.toString()); currentLine.setLength(0); - if (token.startsWith(" ") == false) { + if (token.startsWith(" ") == false) currentLine.append(token); - } - } else { + } else currentLine.append(token); - } + } addSingleLineNoSpace(currentLine.toString()); } else if (maxMessageSize < 0) { @@ -111,9 +105,9 @@ public final class TextBlockSimple extends AbstractTextBlock implements TextBloc if (w > -maxMessageSize) { addSingleLineNoSpace(currentLine.toString()); currentLine.setLength(0); - if (c != ' ') { + if (c != ' ') currentLine.append(c); - } + } else { currentLine.append(c); } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java index 258dc2d75..9f042cd7f 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java @@ -88,7 +88,7 @@ public class TextBlockVertical2 extends AbstractTextBlock implements TextBlock, public XDimension2D calculateDimension(StringBounder stringBounder) { XDimension2D dim = blocks.get(0).calculateDimension(stringBounder); for (int i = 1; i < blocks.size(); i++) - dim = XDimension2D.mergeTB(dim, blocks.get(i).calculateDimension(stringBounder)); + dim = dim.mergeTB(blocks.get(i).calculateDimension(stringBounder)); return dim; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java index f192d9047..347c597a0 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java @@ -105,7 +105,7 @@ class USymbolArtifact extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java index 16f6adf80..4bc3336e8 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCard.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java @@ -83,7 +83,7 @@ class USymbolCard extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java index 712f9ece0..424dca5a8 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java @@ -234,7 +234,7 @@ class USymbolCloud extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCollections.java b/src/net/sourceforge/plantuml/graphic/USymbolCollections.java index dc698080c..7b2f0a2c4 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCollections.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCollections.java @@ -87,7 +87,7 @@ class USymbolCollections extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java index 6f28f04bd..d9f6cd55b 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java @@ -89,7 +89,7 @@ class USymbolComponent1 extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java index 4bd28e0a7..621ce722a 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java @@ -93,7 +93,7 @@ class USymbolComponent2 extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java index 15019c1cc..4f8ab85e0 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java @@ -129,7 +129,7 @@ class USymbolDatabase extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFile.java b/src/net/sourceforge/plantuml/graphic/USymbolFile.java index 947d770d2..4807c82ee 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFile.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFile.java @@ -118,7 +118,7 @@ class USymbolFile extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java index 33d2d0771..cdb7ff025 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java @@ -165,7 +165,7 @@ public class USymbolFolder extends USymbol { final XDimension2D dimName = getDimName(stringBounder); final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimName, dimStereo, dimLabel)); + return getMargin().addDimension(dimName.mergeTB(dimStereo, dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index 3e9086760..91fe5fa99 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -119,7 +119,7 @@ class USymbolFrame extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java b/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java index 675d3d580..14aa5b086 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java @@ -67,7 +67,7 @@ public class USymbolHexagon extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - final XDimension2D full = XDimension2D.mergeTB(dimStereo, dimLabel); + final XDimension2D full = dimStereo.mergeTB(dimLabel); return new XDimension2D(full.getWidth() * 2, full.getHeight() + 2 * marginY); } }; diff --git a/src/net/sourceforge/plantuml/graphic/USymbolLabel.java b/src/net/sourceforge/plantuml/graphic/USymbolLabel.java index 61be98dc1..7eeeff1a4 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolLabel.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolLabel.java @@ -69,7 +69,7 @@ class USymbolLabel extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolNode.java b/src/net/sourceforge/plantuml/graphic/USymbolNode.java index 746ee6294..2e8e805a2 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolNode.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolNode.java @@ -139,7 +139,7 @@ class USymbolNode extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolPerson.java b/src/net/sourceforge/plantuml/graphic/USymbolPerson.java index 120f8d1a3..c2e0a3634 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolPerson.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolPerson.java @@ -90,13 +90,13 @@ class USymbolPerson extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D body = bodyDimension(stringBounder); - return XDimension2D.delta(body, 0, headSize(body)); + return body.delta(0, headSize(body)); } private XDimension2D bodyDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java index 4ce02e597..715221406 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java @@ -144,7 +144,7 @@ class USymbolQueue extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java index b2c326a07..aa00f3995 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java @@ -87,7 +87,7 @@ class USymbolRectangle extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStack.java b/src/net/sourceforge/plantuml/graphic/USymbolStack.java index 921976eb9..8fc40f085 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolStack.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolStack.java @@ -105,7 +105,7 @@ class USymbolStack extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java index 3c148b641..9f9e7e976 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java @@ -78,7 +78,7 @@ class USymbolStorage extends USymbol { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dimLabel = label.calculateDimension(stringBounder); final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); - return getMargin().addDimension(XDimension2D.mergeTB(dimStereo, dimLabel)); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); } }; } diff --git a/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java b/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java index f6d29f132..15f4e9d5d 100644 --- a/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java +++ b/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java @@ -43,16 +43,16 @@ import javax.xml.transform.TransformerException; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.UmlDiagram; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.xmi.XmlDiagramTransformer; public final class CucaDiagramGraphmlMaker { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; - public CucaDiagramGraphmlMaker(CucaDiagram diagram) throws IOException { + public CucaDiagramGraphmlMaker(ICucaDiagram diagram) throws IOException { this.diagram = diagram; } diff --git a/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java b/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java index a1d8ac677..211fa8685 100644 --- a/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java @@ -52,8 +52,8 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.xmi.XmlDiagramTransformer; import net.sourceforge.plantuml.xml.XmlFactories; diff --git a/src/net/sourceforge/plantuml/help/Help.java b/src/net/sourceforge/plantuml/help/Help.java index 4694b57de..2c9dc3dff 100644 --- a/src/net/sourceforge/plantuml/help/Help.java +++ b/src/net/sourceforge/plantuml/help/Help.java @@ -47,7 +47,6 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.cucadiagram.Display; @@ -80,7 +79,7 @@ public class Help extends UmlDiagram { final Display display = Display.create(lines); final UFont font = UFont.serif(16); final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); - final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL) + final Sheet sheet = getSkinParam().sheet(fontConfiguration, HorizontalAlignment.LEFT, CreoleMode.FULL) .createSheet(display); final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); return createImageBuilder(fileFormat).drawable(sheetBlock).write(os); diff --git a/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java index d714b9090..cc3824c35 100644 --- a/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java +++ b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java @@ -45,8 +45,8 @@ import java.util.List; import net.sourceforge.plantuml.FileImageData; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.baraye.a.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java index b3b581953..fd4fea19d 100644 --- a/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java +++ b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.html; import java.io.PrintWriter; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; diff --git a/src/net/sourceforge/plantuml/logo/PSystemLogo.java b/src/net/sourceforge/plantuml/logo/PSystemLogo.java index 68bc89055..5d96bf6d7 100644 --- a/src/net/sourceforge/plantuml/logo/PSystemLogo.java +++ b/src/net/sourceforge/plantuml/logo/PSystemLogo.java @@ -71,9 +71,11 @@ public class PSystemLogo extends AbstractPSystem { final int width = 640; final int height = 480; final StringBounder stringBounder = FileFormat.PNG.getDefaultStringBounder(); - final EmptyImageBuilder builder = new EmptyImageBuilder(fileFormat.getWatermark(), width, height, Color.WHITE, stringBounder); + final EmptyImageBuilder builder = new EmptyImageBuilder(fileFormat.getWatermark(), width, height, Color.WHITE, + stringBounder); final BufferedImage im = builder.getBufferedImage(); - final UGraphic ug = new UGraphicG2d(HColors.WHITE, ColorMapper.IDENTITY, stringBounder, builder.getGraphics2D(), 1.0); + final UGraphic ug = new UGraphicG2d(HColors.WHITE, ColorMapper.IDENTITY, stringBounder, builder.getGraphics2D(), + 1.0); ((UGraphicG2d) ug).setBufferedImage(im); final TurtleGraphicsPane turtleGraphicsPane = new TurtleGraphicsPane(width, height); @@ -82,7 +84,7 @@ public class PSystemLogo extends AbstractPSystem { tinyJavaLogo.doCommandLine(line); } turtleGraphicsPane.paint(ug); - PngIO.write(im, os, 96); + PngIO.write(im, ColorMapper.IDENTITY, os, null, 96); return new ImageDataSimple(im.getWidth(), im.getHeight()); } diff --git a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java index bcee20bfd..e8a3aa370 100644 --- a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java +++ b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java @@ -44,10 +44,10 @@ import net.sourceforge.plantuml.BlockUml; import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.api.mda.option2.MDADiagram; import net.sourceforge.plantuml.api.mda.option2.MDAPackage; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.core.Diagram; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; public class MDADiagramImpl implements MDADiagram { diff --git a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java index 86202c7dd..54704026d 100644 --- a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java +++ b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.mda; import net.sourceforge.plantuml.api.mda.option2.MDAEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; public class MDAEntityImpl implements MDAEntity { diff --git a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java index e92092768..5cb6ebdcf 100644 --- a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java +++ b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java @@ -41,9 +41,9 @@ import java.util.Collections; import net.sourceforge.plantuml.api.mda.option2.MDAEntity; import net.sourceforge.plantuml.api.mda.option2.MDAPackage; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; public class MDAPackageImpl implements MDAPackage { diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index b120b34c0..ea901ad31 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -40,6 +40,8 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.UmlSource; @@ -47,8 +49,6 @@ import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -77,11 +77,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram if (link == null) { return false; } - final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), + final Link l1 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, node, + link.getType(), LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) .withQuantifier(link.getQuantifier1(), null) .withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); - final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), + final Link l2 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), node, entity2, + link.getType(), LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) .withQuantifier(null, link.getQuantifier2()) .withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); @@ -149,8 +151,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram insertPointBetween(entity2A, entity2B, point2); final int length = 1; - final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType, - LinkArg.build(label, length)); + final Link point1ToPoint2 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point1, + point2, linkType, LinkArg.build(label, length)); addLink(point1ToPoint2); return CommandExecutionResult.ok(); @@ -161,7 +163,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) { Link existingLink1 = foundLink(entity1A, entity1B); if (existingLink1 == null) { - existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, + existingLink1 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); } else { removeLink(existingLink1); @@ -172,16 +174,15 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final IEntity entity2real = existingLink1.isInverted() ? existingLink1.getEntity1() : existingLink1.getEntity2(); - final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1, - existingLink1.getType().getPart2(), + final Link entity1ToPoint = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1real, + point1, existingLink1.getType().getPart2(), LinkArg.build(existingLink1.getLabel(), existingLink1.getLength()) .withQuantifier(existingLink1.getQuantifier1(), null) .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); - final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, - existingLink1.getType().getPart1(), - LinkArg.noDisplay(existingLink1.getLength()) - .withQuantifier(null, existingLink1.getQuantifier2()) + final Link pointToEntity2 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point1, + entity2real, existingLink1.getType().getPart1(), + LinkArg.noDisplay(existingLink1.getLength()).withQuantifier(null, existingLink1.getQuantifier2()) .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); // int length = 1; @@ -273,7 +274,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createNew(int mode, LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, + existingLink = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); } else { removeLink(existingLink); @@ -284,16 +285,15 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink.getEntity2(); - entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, + entity1ToPoint = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(), LinkArg.build(existingLink.getLabel(), existingLink.getLength()) .withQuantifier(existingLink.getQuantifier1(), null) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); - pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, + pointToEntity2 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(), - LinkArg.noDisplay(existingLink.getLength()) - .withQuantifier(null, existingLink.getQuantifier2()) + LinkArg.noDisplay(existingLink.getLength()).withQuantifier(null, existingLink.getQuantifier2()) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); int length = 1; @@ -313,11 +313,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram addLink(pointToEntity2); if (mode == 1) { - pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, - LinkArg.build(label, length)); + pointToAssocied = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point, associed, + linkType, LinkArg.build(label, length)); } else { - pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, - LinkArg.build(label, length)); + pointToAssocied = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), associed, point, + linkType, LinkArg.build(label, length)); } addLink(pointToAssocied); } @@ -325,17 +325,17 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createInSecond(LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, + existingLink = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); } else { removeLink(existingLink); } - entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, + entity1ToPoint = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), LinkArg.build(existingLink.getLabel(), 2).withQuantifier(existingLink.getQuantifier1(), null) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); - pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, + pointToEntity2 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), LinkArg.noDisplay(2).withQuantifier(null, existingLink.getQuantifier2()) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); @@ -350,12 +350,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram other.pointToAssocied = other.pointToAssocied.getInv(); addLink(other.pointToAssocied); } - pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, - LinkArg.build(label, 1)); + pointToAssocied = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point, associed, + linkType, LinkArg.build(label, 1)); addLink(pointToAssocied); - final Link lnode = new Link(getSkinParam().getCurrentStyleBuilder(), other.point, this.point, - new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(1)); + final Link lnode = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), other.point, + this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(1)); lnode.setInvis(true); addLink(lnode); diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java index fa76572dd..e00b19582 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.objectdiagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; 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; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java index 47f65b612..2c2c58573 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -48,7 +49,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java index 8d1483e9f..5c11b186d 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.objectdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; @@ -49,7 +50,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java index e0e2e2a60..9141bb509 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.objectdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -51,7 +52,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.BodierJSon; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java index 080b0654c..f1bfa556d 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.objectdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -47,7 +48,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.BodierJSon; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java index 3e166990c..95be84c3d 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java @@ -38,6 +38,8 @@ package net.sourceforge.plantuml.objectdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -52,8 +54,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.BodierMap; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -130,8 +130,8 @@ public class CommandCreateMap extends CommandMultilines2 final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); final int length = linkStr.length() - 2; - final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType, - LinkArg.noDisplay(length)); + final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + entity1, entity2, linkType, LinkArg.noDisplay(length)); link.setPortMembers(key, null); diagram.addLink(link); } @@ -158,8 +158,7 @@ public class CommandCreateMap extends CommandMultilines2 Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); final String s = line0.get("LINECOLOR", 1); - final HColor lineColor = s == null ? null - : diagram.getSkinParam().getIHtmlColorSet().getColor(s); + final HColor lineColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (lineColor != null) colors = colors.add(ColorType.LINE, lineColor); diff --git a/src/net/sourceforge/plantuml/openiconic/Movement.java b/src/net/sourceforge/plantuml/openiconic/Movement.java index b7efb84b3..8393dbb01 100644 --- a/src/net/sourceforge/plantuml/openiconic/Movement.java +++ b/src/net/sourceforge/plantuml/openiconic/Movement.java @@ -150,6 +150,9 @@ public class Movement { if (letter.is('l')) return new Movement(new SvgCommandLetter("L"), delta.add(getSvgPosition(0))); + if (letter.is('t')) + return new Movement(new SvgCommandLetter("T"), delta.add(getSvgPosition(0))); + if (letter.is('z')) return new Movement(new SvgCommandLetter("Z")); @@ -157,6 +160,9 @@ public class Movement { return new Movement(new SvgCommandLetter("C"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2)), delta.add(getSvgPosition(4))); + if (letter.is('q')) + return new Movement(new SvgCommandLetter("Q"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2))); + if (letter.is('s')) return new Movement(new SvgCommandLetter("S"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2))); diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java index 8b36dde66..69e321cad 100644 --- a/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java +++ b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java @@ -42,9 +42,9 @@ public class SvgCommandLetter implements SvgCommand { final private char letter; public SvgCommandLetter(String letter) { - if (letter.matches("[mlhvzsacMLHVZSAC]") == false) { + if (letter.matches("[mlhvzsacqtMLHVZSACQT]") == false) throw new IllegalArgumentException(letter); - } + this.letter = letter.charAt(0); } @@ -61,6 +61,7 @@ public class SvgCommandLetter implements SvgCommand { switch (StringUtils.goLowerCase(letter)) { case 'm': case 'l': + case 't': return 2; case 'h': case 'v': @@ -69,6 +70,7 @@ public class SvgCommandLetter implements SvgCommand { return 0; case 'c': return 6; + case 'q': case 's': return 4; case 'a': diff --git a/src/net/sourceforge/plantuml/openiconic/SvgPath.java b/src/net/sourceforge/plantuml/openiconic/SvgPath.java index 97388094b..a8341825e 100644 --- a/src/net/sourceforge/plantuml/openiconic/SvgPath.java +++ b/src/net/sourceforge/plantuml/openiconic/SvgPath.java @@ -50,6 +50,7 @@ public class SvgPath { // http://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths // http://tutorials.jenkov.com/svg/path-element.html + // https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands private List movements = new ArrayList<>(); private List commands = new ArrayList<>(); @@ -145,19 +146,32 @@ public class SvgPath { private UPath toUPath(double factorx, double factory) { final UPath result = new UPath(); + Movement previous = null; for (Movement move : movements) { final char letter = move.getLetter(); - final SvgPosition lastPosition = move.lastPosition(); + final SvgPosition position = move.lastPosition(); if (letter == 'M') { - result.moveTo(lastPosition.getXDouble() * factorx, lastPosition.getYDouble() * factory); + result.moveTo(position.getXDouble() * factorx, position.getYDouble() * factory); } else if (letter == 'C') { final SvgPosition ctl1 = move.getSvgPosition(0); final SvgPosition ctl2 = move.getSvgPosition(2); result.cubicTo(ctl1.getXDouble() * factorx, ctl1.getYDouble() * factory, ctl2.getXDouble() * factorx, - ctl2.getYDouble() * factory, lastPosition.getXDouble() * factorx, - lastPosition.getYDouble() * factory); + ctl2.getYDouble() * factory, position.getXDouble() * factorx, position.getYDouble() * factory); + } else if (letter == 'Q') { + final SvgPosition ctl = move.getSvgPosition(0); + result.cubicTo(ctl.getXDouble() * factorx, ctl.getYDouble() * factory, ctl.getXDouble() * factorx, + ctl.getYDouble() * factory, position.getXDouble() * factorx, position.getYDouble() * factory); + } else if (letter == 'T') { + if (previous.getLetter() != 'Q') + throw new IllegalArgumentException(); + // https://stackoverflow.com/questions/5287559/calculating-control-points-for-a-shorthand-smooth-svg-path-bezier-curve + final SvgPosition lastCtl = previous.getSvgPosition(0); + final SvgPosition lastP = previous.lastPosition(); + final SvgPosition ctl = lastP.getMirror(lastCtl); + result.cubicTo(ctl.getXDouble() * factorx, ctl.getYDouble() * factory, ctl.getXDouble() * factorx, + ctl.getYDouble() * factory, position.getXDouble() * factorx, position.getYDouble() * factory); } else if (letter == 'L') { - result.lineTo(lastPosition.getXDouble() * factorx, lastPosition.getYDouble() * factory); + result.lineTo(position.getXDouble() * factorx, position.getYDouble() * factory); } else if (letter == 'A') { final double rx = move.getArgument(0); final double ry = move.getArgument(1); @@ -165,7 +179,7 @@ public class SvgPath { final double large_arc_flag = move.getArgument(3); final double sweep_flag = move.getArgument(4); result.arcTo(rx * factorx, ry * factory, x_axis_rotation, large_arc_flag, sweep_flag, - lastPosition.getXDouble() * factorx, lastPosition.getYDouble() * factory); + position.getXDouble() * factorx, position.getYDouble() * factory); } else if (letter == 'Z') { result.closePath(); } else { @@ -178,24 +192,36 @@ public class SvgPath { private UPath toUPath(AffineTransform at) { final UPath result = new UPath(); + Movement previous = null; for (Movement move : movements) { final char letter = move.getLetter(); - final SvgPosition lastPosition = move.lastPosition(); + final SvgPosition position = move.lastPosition(); if (letter == 'M') { - result.moveTo(lastPosition.affine(at)); + result.moveTo(position.affine(at)); } else if (letter == 'C') { final SvgPosition ctl1 = move.getSvgPosition(0); final SvgPosition ctl2 = move.getSvgPosition(2); - result.cubicTo(ctl1.affine(at), ctl2.affine(at), lastPosition.affine(at)); + result.cubicTo(ctl1.affine(at), ctl2.affine(at), position.affine(at)); + } else if (letter == 'Q') { + final SvgPosition ctl = move.getSvgPosition(0); + result.cubicTo(ctl.affine(at), ctl.affine(at), position.affine(at)); + } else if (letter == 'T') { + if (previous.getLetter() != 'Q') + throw new IllegalArgumentException(); + // https://stackoverflow.com/questions/5287559/calculating-control-points-for-a-shorthand-smooth-svg-path-bezier-curve + final SvgPosition lastCtl = previous.getSvgPosition(0); + final SvgPosition lastP = previous.lastPosition(); + final SvgPosition ctl = lastP.getMirror(lastCtl); + result.cubicTo(ctl.affine(at), ctl.affine(at), position.affine(at)); } else if (letter == 'L') { - result.lineTo(lastPosition.affine(at)); + result.lineTo(position.affine(at)); } else if (letter == 'A') { final double rx = move.getArgument(0); final double ry = move.getArgument(1); final double x_axis_rotation = move.getArgument(2); final double large_arc_flag = move.getArgument(3); final double sweep_flag = move.getArgument(4); - final XPoint2D tmp = lastPosition.affine(at); + final XPoint2D tmp = position.affine(at); result.arcTo(rx * at.getScaleX(), ry * at.getScaleY(), x_axis_rotation, large_arc_flag, sweep_flag, tmp.getX(), tmp.getY()); } else if (letter == 'Z') { @@ -203,6 +229,7 @@ public class SvgPath { } else { throw new UnsupportedOperationException("letter " + letter); } + previous = move; } result.setOpenIconic(true); return result; diff --git a/src/net/sourceforge/plantuml/png/PngIO.java b/src/net/sourceforge/plantuml/png/PngIO.java index c47ba1bf8..bbea9fac6 100644 --- a/src/net/sourceforge/plantuml/png/PngIO.java +++ b/src/net/sourceforge/plantuml/png/PngIO.java @@ -35,29 +35,26 @@ */ package net.sourceforge.plantuml.png; +import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; import java.io.IOException; import java.io.OutputStream; import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.quantization.Quantizer; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SImageIO; +import net.sourceforge.plantuml.ugraphic.color.ColorMapper; public class PngIO { private static final String copyleft = "Generated by http://plantuml.com"; + public static boolean USE_QUANTIZATION = false; - public static void write(RenderedImage image, SFile file, int dpi) throws IOException { - write(image, file, null, dpi); - } - - public static void write(RenderedImage image, OutputStream os, int dpi) throws IOException { - write(image, os, null, dpi); - } - - public static void write(RenderedImage image, SFile file, String metadata, int dpi) throws IOException { + public static void write(RenderedImage image, ColorMapper mapper, SFile file, String metadata, int dpi) + throws IOException { try (OutputStream os = file.createBufferedOutputStream()) { - write(image, os, metadata, dpi); + write(image, mapper, os, metadata, dpi); } Log.debug("File is " + file); Log.debug("File size " + file.length()); @@ -67,17 +64,22 @@ public class PngIO { } } - public static void write(RenderedImage image, OutputStream os, String metadata, int dpi) throws IOException { - write(image, os, metadata, dpi, null); + public static void write(RenderedImage image, ColorMapper mapper, OutputStream os, String metadata, int dpi) + throws IOException { + write(image, mapper, os, metadata, dpi, null); } - public static void write(RenderedImage image, OutputStream os, String metadata, int dpi, String debugData) - throws IOException { - if (metadata == null) { + private static void write(RenderedImage image, ColorMapper mapper, OutputStream os, String metadata, int dpi, + String debugData) throws IOException { + + if (USE_QUANTIZATION) + image = Quantizer.quantizeNow(mapper, (BufferedImage) image); + + if (metadata == null) SImageIO.write(image, "png", os); - } else { + else PngIOMetadata.writeWithMetadata(image, os, metadata, dpi, debugData); - } + } // /** writes a BufferedImage of type TYPE_INT_ARGB to PNG using PNGJ */ diff --git a/src/net/sourceforge/plantuml/png/PngSplitter.java b/src/net/sourceforge/plantuml/png/PngSplitter.java index b05a763cb..a83586599 100644 --- a/src/net/sourceforge/plantuml/png/PngSplitter.java +++ b/src/net/sourceforge/plantuml/png/PngSplitter.java @@ -47,20 +47,22 @@ import net.sourceforge.plantuml.SplitParam; import net.sourceforge.plantuml.SuggestedFile; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SImageIO; +import net.sourceforge.plantuml.ugraphic.color.ColorMapper; public class PngSplitter { private final List files = new ArrayList<>(); - public PngSplitter(SuggestedFile pngFile, int horizontalPages, int verticalPages, String metadata, int dpi, - SplitParam splitParam) throws IOException { + public PngSplitter(ColorMapper colorMapper, SuggestedFile pngFile, int horizontalPages, int verticalPages, + String metadata, int dpi, SplitParam splitParam) throws IOException { if (horizontalPages == 1 && verticalPages == 1) { this.files.add(pngFile.getFile(0)); return; } Log.info("Splitting " + horizontalPages + " x " + verticalPages); - final SFile full = pngFile.getTmpFile(); // SecurityUtils.File(pngFile.getParentFile(), pngFile.getName() + ".tmp"); + final SFile full = pngFile.getTmpFile(); // SecurityUtils.File(pngFile.getParentFile(), pngFile.getName() + + // ".tmp"); // Thread.yield(); full.delete(); // Thread.yield(); @@ -86,8 +88,8 @@ public class PngSplitter { BufferedImage piece = im.getSubimage(horizontalSegment.getStart(i), verticalSegment.getStart(j), width, height); if (splitParam.isSet()) { - BufferedImage withMargin = new BufferedImage(width + 2 * splitParam.getExternalMargin(), height + 2 - * splitParam.getExternalMargin(), BufferedImage.TYPE_INT_ARGB); + BufferedImage withMargin = new BufferedImage(width + 2 * splitParam.getExternalMargin(), + height + 2 * splitParam.getExternalMargin(), BufferedImage.TYPE_INT_ARGB); final Graphics2D g2d = withMargin.createGraphics(); if (splitParam.getExternalColor() != null) { g2d.setColor(splitParam.getExternalColor()); @@ -106,7 +108,7 @@ public class PngSplitter { g2d.dispose(); } // Thread.yield(); - PngIO.write(piece, f, metadata, dpi); + PngIO.write(piece, colorMapper, f, metadata, dpi); // Thread.yield(); } } diff --git a/src/net/sourceforge/plantuml/posimo/PositionableUtils.java b/src/net/sourceforge/plantuml/posimo/PositionableUtils.java index 8612ed771..7201835d9 100644 --- a/src/net/sourceforge/plantuml/posimo/PositionableUtils.java +++ b/src/net/sourceforge/plantuml/posimo/PositionableUtils.java @@ -62,7 +62,7 @@ public class PositionableUtils { } public XDimension2D getSize() { - return XDimension2D.delta(pos.getSize(), 2 * widthMargin, 2 * heightMargin); + return pos.getSize().delta(2 * widthMargin, 2 * heightMargin); } public void moveSvek(double deltaX, double deltaY) { diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index bfd9a8028..d35babaff 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.cucadiagram.Display; @@ -204,7 +203,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { final FontConfiguration fc = style.getFontConfiguration(getColorSet()); final HorizontalAlignment horizontalAlignment = style.value(PName.HorizontalAlignment).asHorizontalAlignment(); - final Sheet sheet = Parser.build(fc, horizontalAlignment, skinParam, CreoleMode.FULL).createSheet(note); + final Sheet sheet = skinParam.sheet(fc, horizontalAlignment, CreoleMode.FULL).createSheet(note); final double padding = style.value(PName.Padding).asDouble(); final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, padding); @@ -281,8 +280,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { } final HColor backUndone = StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.undone) - .getMergedStyle(getStyleBuilder()).value(PName.BackGroundColor) - .asColor(getColorSet()); + .getMergedStyle(getStyleBuilder()).value(PName.BackGroundColor).asColor(getColorSet()); final RectangleTask rectangleTask = new RectangleTask(startPos, endPos, round, getCompletion(), off); diff --git a/src/net/sourceforge/plantuml/quantization/ArbitraryComparator.java b/src/net/sourceforge/plantuml/quantization/ArbitraryComparator.java new file mode 100644 index 000000000..b7105c3d4 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/ArbitraryComparator.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sourceforge.plantuml.quantization; + +import java.util.Comparator; +import java.util.WeakHashMap; + +/** + * Provides a stable ordering of objects, such that: + * + *
    + *
  • compare(a, b) == 0 iff a == b
  • + *
  • sign(compare(a, b)) == -sign(compare(b, a))
  • + *
+ * + *

+ * Similar to Guava's {code Ordering.arbitrary()}. + */ +final class ArbitraryComparator implements Comparator { + public static final ArbitraryComparator INSTANCE = new ArbitraryComparator(); + + /** + * If we have no other way to order two objects in a stable manner, we will + * register both in this map and order them according to their associated + * values. The map's values are just integers corresponding to the order in + * which objects were added. + */ + private static final WeakHashMap objectIds = new WeakHashMap<>(); + + private ArbitraryComparator() { + } + + @Override + public int compare(Object a, Object b) { + if (a == b) + return 0; + if (a == null) + return -1; + if (b == null) + return 1; + + int identityHashCodeDifference = System.identityHashCode(a) - System.identityHashCode(b); + if (identityHashCodeDifference != 0) { + return identityHashCodeDifference; + } + + // We have an identityHashCode collision. + return getObjectId(a) - getObjectId(b); + } + + /** + * Get the ID of an object, adding it to the ID map if it isn't already + * registered. + */ + private static int getObjectId(Object object) { + synchronized (objectIds) { + Integer id = objectIds.get(object); + if (id == null) { + id = objectIds.size(); + objectIds.put(object, id); + } + return id; + } + } +} diff --git a/src/net/sourceforge/plantuml/quantization/ColorQuantizer.java b/src/net/sourceforge/plantuml/quantization/ColorQuantizer.java new file mode 100644 index 000000000..79fb426e4 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/ColorQuantizer.java @@ -0,0 +1,19 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.Set; + +public interface ColorQuantizer { + /** + * Quantize the given set of colors, returning a set no larger than + * {@code maxColors}. + * + *

+ * The intent is to pick a set of colors which are representative of the + * original color set, but no specific guarantees are made. + * + * @param originalColors the colors in the original image + * @param maxColorCount the maximum number of colors to allow + * @return a quantized collection of colors no larger than {@code maxColors} + */ + public Set quantize(Multiset originalColors, int maxColorCount); +} diff --git a/src/net/sourceforge/plantuml/quantization/Ditherer.java b/src/net/sourceforge/plantuml/quantization/Ditherer.java new file mode 100644 index 000000000..5868b2c6c --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/Ditherer.java @@ -0,0 +1,15 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.Set; + +public interface Ditherer { + /** + * Dither the given image, producing a new image which only contains colors from + * the given color set. + * + * @param image the original, unquantized image + * @param newColors the quantized set of colors to be used in the new image + * @return a new image containing only of colors from {@code newColors} + */ + public QImage dither(QImage image, Set newColors); +} diff --git a/src/net/sourceforge/plantuml/quantization/FloydSteinbergDitherer.java b/src/net/sourceforge/plantuml/quantization/FloydSteinbergDitherer.java new file mode 100644 index 000000000..4d9bae246 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/FloydSteinbergDitherer.java @@ -0,0 +1,53 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.Set; + +public final class FloydSteinbergDitherer implements Ditherer { + public static final FloydSteinbergDitherer INSTANCE = new FloydSteinbergDitherer(); + + private static final ErrorComponent[] ERROR_DISTRIBUTION = { new ErrorComponent(1, 0, 7.0 / 16.0), + new ErrorComponent(-1, 1, 3.0 / 16.0), new ErrorComponent(0, 1, 5.0 / 16.0), + new ErrorComponent(1, 1, 1.0 / 16.0) }; + + private FloydSteinbergDitherer() { + } + + @Override + public QImage dither(QImage image, Set newColors) { + final int width = image.getWidth(); + final int height = image.getHeight(); + QColor[][] colors = new QColor[height][width]; + for (int y = 0; y < height; ++y) + for (int x = 0; x < width; ++x) + colors[y][x] = image.getColor(x, y); + + for (int y = 0; y < height; ++y) + for (int x = 0; x < width; ++x) { + final QColor originalColor = colors[y][x]; + final QColor replacementColor = originalColor.getNearestColor(newColors); + colors[y][x] = replacementColor; + final QColor error = originalColor.minus(replacementColor); + + for (ErrorComponent component : ERROR_DISTRIBUTION) { + int siblingX = x + component.deltaX, siblingY = y + component.deltaY; + if (siblingX >= 0 && siblingY >= 0 && siblingX < width && siblingY < height) { + QColor errorComponent = error.scaled(component.errorFraction); + colors[siblingY][siblingX] = colors[siblingY][siblingX].plus(errorComponent); + } + } + } + + return QImage.fromColors(colors); + } + + private static final class ErrorComponent { + final int deltaX, deltaY; + final double errorFraction; + + ErrorComponent(int deltaX, int deltaY, double errorFraction) { + this.deltaX = deltaX; + this.deltaY = deltaY; + this.errorFraction = errorFraction; + } + } +} diff --git a/src/net/sourceforge/plantuml/quantization/HashMultiset.java b/src/net/sourceforge/plantuml/quantization/HashMultiset.java new file mode 100644 index 000000000..9c6547aa6 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/HashMultiset.java @@ -0,0 +1,133 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +public final class HashMultiset extends AbstractCollection implements Multiset { + private final Map elementCounts = new HashMap<>(); + private int size; + + public HashMultiset() { + } + + public HashMultiset(Collection source) { + addAll(source); + } + + @Override + public void add(E element, int n) { + Count count = elementCounts.get(element); + if (count != null) + count.value += n; + else + elementCounts.put(element, new Count(n)); + + size += n; + } + + @Override + public boolean add(E element) { + add(element, 1); + return true; + } + + @Override + public int remove(Object element, int n) { + Count count = elementCounts.get(element); + if (count == null) + return 0; + + if (n < count.value) { + count.value -= n; + size -= n; + return n; + } + + elementCounts.remove(element); + size -= count.value; + return count.value; + } + + @Override + public boolean remove(Object element) { + return remove(element, 1) > 0; + } + + @Override + public Iterator iterator() { + return new HashMultisetIterator(); + } + + @Override + public int size() { + return size; + } + + @Override + public int count(Object element) { + Count countOrNull = elementCounts.get(element); + return countOrNull != null ? countOrNull.value : 0; + } + + @Override + public Set getDistinctElements() { + return elementCounts.keySet(); + } + + private final class HashMultisetIterator implements Iterator { + final private Iterator> distinctElementIterator; + private E currentElement; + private int currentCount; + private boolean currentElementRemoved; + + HashMultisetIterator() { + this.distinctElementIterator = elementCounts.entrySet().iterator(); + this.currentCount = 0; + } + + @Override + public boolean hasNext() { + return currentCount > 0 || distinctElementIterator.hasNext(); + } + + @Override + public E next() { + if (hasNext() == false) + throw new NoSuchElementException("iterator has been exhausted"); + + if (currentCount == 0) { + Map.Entry next = distinctElementIterator.next(); + currentElement = next.getKey(); + currentCount = next.getValue().value; + } + + currentCount--; + currentElementRemoved = false; + return currentElement; + } + + @Override + public void remove() { + if (currentElement == null) + throw new IllegalStateException("next() has not been called"); + + if (currentElementRemoved) + throw new IllegalStateException("remove() already called for current element"); + + HashMultiset.this.remove(currentElement); + } + } + + private static final class Count { + private int value; + + Count(int value) { + this.value = value; + } + } +} diff --git a/src/net/sourceforge/plantuml/quantization/KMeansQuantizer.java b/src/net/sourceforge/plantuml/quantization/KMeansQuantizer.java new file mode 100644 index 000000000..4997dc19c --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/KMeansQuantizer.java @@ -0,0 +1,76 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Uses k-means clustering for color quantization. This tends to yield good + * results, but convergence can be slow. It is not recommended for large images. + */ +public final class KMeansQuantizer implements ColorQuantizer { + public static final KMeansQuantizer INSTANCE = new KMeansQuantizer(); + + private KMeansQuantizer() { + } + + @Override + public Set quantize(Multiset originalColors, int maxColorCount) { + Map> clustersByCentroid = new LinkedHashMap<>(); + Set centroidsToRecompute = getInitialCentroids(originalColors, maxColorCount); + for (QColor centroid : centroidsToRecompute) + clustersByCentroid.put(centroid, new HashMultiset()); + + for (QColor color : originalColors.getDistinctElements()) { + final int count = originalColors.count(color); + clustersByCentroid.get(color.getNearestColor(centroidsToRecompute)).add(color, count); + } + + while (centroidsToRecompute.isEmpty() == false) { + recomputeCentroids(clustersByCentroid, centroidsToRecompute); + centroidsToRecompute.clear(); + + Set allCentroids = clustersByCentroid.keySet(); + for (QColor centroid : clustersByCentroid.keySet()) { + Multiset cluster = clustersByCentroid.get(centroid); + for (QColor color : new ArrayList<>(cluster.getDistinctElements())) { + QColor newCentroid = color.getNearestColor(allCentroids); + if (newCentroid != centroid) { + final int count = cluster.count(color); + final Multiset newCluster = clustersByCentroid.get(newCentroid); + + cluster.remove(color, count); + newCluster.add(color, count); + + centroidsToRecompute.add(centroid); + centroidsToRecompute.add(newCentroid); + } + } + } + } + + return clustersByCentroid.keySet(); + } + + private static void recomputeCentroids(Map> clustersByCentroid, + Set centroidsToRecompute) { + for (QColor oldCentroid : centroidsToRecompute) { + final Multiset cluster = clustersByCentroid.get(oldCentroid); + final QColor newCentroid = QColor.getCentroid(cluster); + clustersByCentroid.remove(oldCentroid); + clustersByCentroid.put(newCentroid, cluster); + } + } + + private static Set getInitialCentroids(Multiset originalColors, int maxColorCount) { + // We use the Forgy initialization method: choose random colors as initial + // cluster centroids. + final List colorList = new ArrayList<>(originalColors.getDistinctElements()); + Collections.shuffle(colorList); + return new HashSet<>(colorList.subList(0, maxColorCount)); + } +} diff --git a/src/net/sourceforge/plantuml/quantization/MedianCutQuantizer.java b/src/net/sourceforge/plantuml/quantization/MedianCutQuantizer.java new file mode 100644 index 000000000..95a0f2678 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/MedianCutQuantizer.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sourceforge.plantuml.quantization; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +/** + * Implements median cut quantization. + * + *

+ * The algorithm works as follows: + * + *

    + *
  • Begin with one cluster containing all the original colors.
  • + *
  • Find the cluster containing the greatest spread along a single color + * component (red, green or blue).
  • + *
  • Find the median of that color component among colors in the cluster.
  • + *
  • Split the cluster into two halves, using that median as a threshold.
  • + *
  • Repeat this process until the desired number of clusters is reached.
  • + *
+ */ +public final class MedianCutQuantizer implements ColorQuantizer { + public static final MedianCutQuantizer INSTANCE = new MedianCutQuantizer(); + + private MedianCutQuantizer() { + } + + @Override + public Set quantize(Multiset originalColors, int maxColorCount) { + TreeSet clusters = new TreeSet<>(new ClusterSpreadComparator()); + clusters.add(new Cluster(originalColors)); + + while (clusters.size() < maxColorCount) { + Cluster clusterWithLargestSpread = clusters.pollFirst(); + clusters.addAll(clusterWithLargestSpread.split()); + } + + Set clusterCentroids = new HashSet<>(); + for (Cluster cluster : clusters) { + clusterCentroids.add(QColor.getCentroid(cluster.colors)); + } + return clusterCentroids; + } + + private static final class Cluster { + final Multiset colors; + double largestSpread; + int componentWithLargestSpread; + + Cluster(Multiset colors) { + this.colors = colors; + this.largestSpread = -1; + for (int component = 0; component < 3; ++component) { + double componentSpread = getComponentSpread(component); + if (componentSpread > largestSpread) { + largestSpread = componentSpread; + componentWithLargestSpread = component; + } + } + } + + double getComponentSpread(int component) { + double min = Double.POSITIVE_INFINITY; + double max = Double.NEGATIVE_INFINITY; + for (QColor color : colors) { + min = Math.min(min, color.getComponent(component)); + max = Math.max(max, color.getComponent(component)); + } + return max - min; + } + + Collection split() { + List orderedColors = new ArrayList<>(colors); + Collections.sort(orderedColors, new ColorComponentComparator(componentWithLargestSpread)); + int medianIndex = orderedColors.size() / 2; + return Arrays.asList(new Cluster(new HashMultiset<>(orderedColors.subList(0, medianIndex))), + new Cluster(new HashMultiset<>(orderedColors.subList(medianIndex, orderedColors.size())))); + } + } + + /** + * Orders clusters according to their maximum spread, in descending order. + */ + static final class ClusterSpreadComparator implements Comparator { + @Override + public int compare(Cluster a, Cluster b) { + double spreadDifference = b.largestSpread - a.largestSpread; + if (spreadDifference == 0) { + return ArbitraryComparator.INSTANCE.compare(a, b); + } + return (int) Math.signum(spreadDifference); + } + } + + /** + * Orders colors according to the value of one particular component, in + * ascending order. + */ + static final class ColorComponentComparator implements Comparator { + final int component; + + ColorComponentComparator(int component) { + this.component = component; + } + + @Override + public int compare(QColor a, QColor b) { + double componentDifference = a.getComponent(component) - b.getComponent(component); + if (componentDifference == 0) { + return ArbitraryComparator.INSTANCE.compare(a, b); + } + return (int) Math.signum(componentDifference); + } + } +} diff --git a/src/net/sourceforge/plantuml/quantization/Multiset.java b/src/net/sourceforge/plantuml/quantization/Multiset.java new file mode 100644 index 000000000..469340216 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/Multiset.java @@ -0,0 +1,33 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.Collection; +import java.util.Set; + +/** + * A collection which permits duplicates, and provides methods adding/removing + * several counts of an element. + * + * @param the element type + */ +public interface Multiset extends Collection { + /** + * Add n counts of an element. + * + * @param element the element to add + * @param n how many to add + */ + public void add(E element, int n); + + /** + * Remove up to n counts of an element. + * + * @param element the element the remove + * @param n how many to remove + * @return the number of elements removed + */ + public int remove(Object element, int n); + + public int count(Object element); + + public Set getDistinctElements(); +} diff --git a/src/net/sourceforge/plantuml/quantization/QColor.java b/src/net/sourceforge/plantuml/quantization/QColor.java new file mode 100644 index 000000000..196ef221b --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/QColor.java @@ -0,0 +1,145 @@ +package net.sourceforge.plantuml.quantization; + +import java.util.Collection; + +import net.sourceforge.plantuml.ugraphic.color.ColorMapper; + +/** + * An RGB representation of a color, which stores each component as a double in + * the range [0, 1]. Values outside of [0, 1] are permitted though, as this is + * convenient e.g. for representing color deltas. + */ +public final class QColor { + public static final QColor BLACK = new QColor(0, 0, 0); + public static final QColor WHITE = new QColor(1, 1, 1); + public static final QColor RED = new QColor(1, 0, 0); + public static final QColor GREEN = new QColor(0, 1, 0); + public static final QColor BLUE = new QColor(0, 0, 1); + + private final double red; + private final double green; + private final double blue; + + public QColor(double red, double green, double blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + + public static QColor fromArgbInt(ColorMapper mapper, int rgb) { + final double alpha = (rgb >>> 24 & 0xFF) / 255.0; + double red = (rgb >>> 16 & 0xFF) / 255.0; + double green = (rgb >>> 8 & 0xFF) / 255.0; + double blue = (rgb & 0xFF) / 255.0; + + if (mapper == ColorMapper.DARK_MODE) { + red = alpha * red; + green = alpha * green; + blue = alpha * blue; + + } else { + + red = 1 - alpha * (1 - red); + green = 1 - alpha * (1 - green); + blue = 1 - alpha * (1 - blue); + } + return new QColor(red, green, blue); + } + + public static QColor fromRgbInt(int rgb) { + final double red = (rgb >>> 16 & 0xFF) / 255.0; + final double green = (rgb >>> 8 & 0xFF) / 255.0; + final double blue = (rgb & 0xFF) / 255.0; + return new QColor(red, green, blue); + } + + public static QColor getCentroid(Multiset colors) { + QColor sum = QColor.BLACK; + for (QColor color : colors.getDistinctElements()) { + int weight = colors.count(color); + sum = sum.plus(color.scaled(weight)); + } + return sum.scaled(1.0 / colors.size()); + } + + public double getComponent(int index) { + switch (index) { + case 0: + return red; + case 1: + return green; + case 2: + return blue; + default: + throw new IllegalArgumentException("Unexpected component index: " + index); + } + } + + public QColor scaled(double s) { + return new QColor(s * red, s * green, s * blue); + } + + public QColor plus(QColor that) { + return new QColor(this.red + that.red, this.green + that.green, this.blue + that.blue); + } + + public QColor minus(QColor that) { + return new QColor(this.red - that.red, this.green - that.green, this.blue - that.blue); + } + + public double getEuclideanDistanceTo(QColor that) { + final QColor d = this.minus(that); + final double sumOfSquares = d.red * d.red + d.green * d.green + d.blue * d.blue; + return Math.sqrt(sumOfSquares); + } + + /** + * Find this color's nearest neighbor, based on Euclidean distance, among some + * set of colors. + */ + public QColor getNearestColor(Collection colors) { + QColor nearestCentroid = null; + double nearestCentroidDistance = Double.POSITIVE_INFINITY; + for (QColor color : colors) { + final double distance = getEuclideanDistanceTo(color); + if (distance < nearestCentroidDistance) { + nearestCentroid = color; + nearestCentroidDistance = distance; + } + } + return nearestCentroid; + } + + public int getRgbInt() { + final int redComponent = (int) (red * 255); + final int greenComponent = (int) (green * 255); + final int blueComponent = (int) (blue * 255); + return redComponent << 16 | greenComponent << 8 | blueComponent; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof QColor)) + return false; + final QColor that = (QColor) o; + return this.red == that.red && this.green == that.green && this.blue == that.blue; + } + + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(red); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(green); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(blue); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + return String.format("Color[%f, %f, %f]", red, green, blue); + } +} diff --git a/src/net/sourceforge/plantuml/quantization/QImage.java b/src/net/sourceforge/plantuml/quantization/QImage.java new file mode 100644 index 000000000..21d27c373 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/QImage.java @@ -0,0 +1,92 @@ +package net.sourceforge.plantuml.quantization; + +import java.awt.image.BufferedImage; + +import net.sourceforge.plantuml.ugraphic.color.ColorMapper; + +/** + * An immutable grid of pixel colors. + */ +public final class QImage { + /** + * The first index corresponds to the row, while the second index corresponds + * the column. + */ + private final QColor[][] colors; + + private QImage(QColor[][] colors) { + this.colors = colors; + } + + public static QImage fromBufferedImage(ColorMapper mapper, BufferedImage img) { + final int height = img.getHeight(); + final int width = img.getWidth(); + final QColor[][] colors = new QColor[height][width]; + + if (img.getType() == BufferedImage.TYPE_INT_ARGB) { + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + colors[y][x] = QColor.fromArgbInt(mapper, img.getRGB(x, y)); + } else if (img.getType() == BufferedImage.TYPE_INT_RGB) { + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + colors[y][x] = QColor.fromRgbInt(img.getRGB(x, y)); + } else { + throw new IllegalArgumentException(); + } + + return new QImage(colors); + } + + public static QImage fromColors(QColor[][] colors) { + return new QImage(colors); + } + + public QColor getColor(int x, int y) { + return colors[y][x]; + } + + public QColor getColor(int index) { + return colors[index / getWidth()][index % getWidth()]; + } + + Multiset getColors() { + final Multiset colorCounts = new HashMultiset<>(); + for (int i = 0; i < getNumPixels(); ++i) { + final QColor color = getColor(i); + colorCounts.add(color); + } + return colorCounts; + } + + public int getWidth() { + return colors[0].length; + } + + public int getHeight() { + return colors.length; + } + + public int getNumPixels() { + return getWidth() * getHeight(); + } + + public BufferedImage toBufferedImage() { + final BufferedImage result = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); + for (int i = 0; i < result.getWidth(); i++) + for (int j = 0; j < result.getHeight(); j++) + result.setRGB(i, j, colors[j][i].getRgbInt()); + return result; + } + + public BufferedImage toBufferedImageKeepTransparency(BufferedImage orig) { + final BufferedImage result = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); + for (int i = 0; i < result.getWidth(); i++) + for (int j = 0; j < result.getHeight(); j++) { + if ((orig.getRGB(i, j)) != 0x00000000) + result.setRGB(i, j, colors[j][i].getRgbInt() | 0xFF000000); + } + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/quantization/Quantizer.java b/src/net/sourceforge/plantuml/quantization/Quantizer.java new file mode 100644 index 000000000..2a6adf114 --- /dev/null +++ b/src/net/sourceforge/plantuml/quantization/Quantizer.java @@ -0,0 +1,37 @@ +package net.sourceforge.plantuml.quantization; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Set; + +import net.sourceforge.plantuml.ugraphic.color.ColorMapper; + +public final class Quantizer { + private static final int MAX_COLOR_COUNT = 256; + + private static QImage quantizeNow(QImage image) throws IOException { + + Multiset originalColors = image.getColors(); + Set distinctColors = originalColors.getDistinctElements(); + if (distinctColors.size() > MAX_COLOR_COUNT) { + // distinctColors = KMeansQuantizer.INSTANCE.quantize(originalColors, + // MAX_COLOR_COUNT); + distinctColors = MedianCutQuantizer.INSTANCE.quantize(originalColors, MAX_COLOR_COUNT); + image = FloydSteinbergDitherer.INSTANCE.dither(image, distinctColors); + } + return image; + } + + public static BufferedImage quantizeNow(ColorMapper mapper, BufferedImage orig) throws IOException { + final QImage raw = QImage.fromBufferedImage(mapper, orig); + final QImage result = quantizeNow(raw); + + if (orig.getType() == BufferedImage.TYPE_INT_RGB) + return result.toBufferedImage(); + else if (orig.getType() == BufferedImage.TYPE_INT_ARGB) + return result.toBufferedImageKeepTransparency(orig); + else + throw new IllegalArgumentException(); + + } +} diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java index 9f2732a1b..153f1fea0 100644 --- a/src/net/sourceforge/plantuml/salt/Dictionary.java +++ b/src/net/sourceforge/plantuml/salt/Dictionary.java @@ -43,7 +43,12 @@ import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SpriteContainer; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.SheetBuilder; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.salt.element.Element; import net.sourceforge.plantuml.salt.element.WrappedElement; import net.sourceforge.plantuml.sprite.Sprite; @@ -63,34 +68,42 @@ public class Dictionary implements SpriteContainer, ISkinSimple { return new WrappedElement(result); } + @Override public Sprite getSprite(String name) { return sprites.get(name); } + @Override public String getValue(String key) { return null; } + @Override public double getPadding() { return 0; } + @Override public Guillemet guillemet() { return Guillemet.GUILLEMET; } + @Override public String getMonospacedFamily() { return Parser.MONOSPACED; } + @Override public int getTabSize() { return 8; } + @Override public HColorSet getIHtmlColorSet() { return HColorSet.instance(); } + @Override public int getDpi() { return 96; } @@ -102,14 +115,17 @@ public class Dictionary implements SpriteContainer, ISkinSimple { } + @Override public LineBreakStrategy wrapWidth() { return LineBreakStrategy.NONE; } + @Override public void copyAllFrom(Map other) { throw new UnsupportedOperationException(); } + @Override public Map values() { throw new UnsupportedOperationException(); } @@ -118,8 +134,21 @@ public class Dictionary implements SpriteContainer, ISkinSimple { return 0; } + @Override public String transformStringForSizeHack(String s) { return s; } + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode) { + throw new UnsupportedOperationException(); + } + + @Override + public SheetBuilder sheet(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment, + CreoleMode creoleMode, FontConfiguration stereo) { + return new CreoleParser(fontConfiguration, horizontalAlignment, this, creoleMode, stereo); + } + } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementButton.java b/src/net/sourceforge/plantuml/salt/element/ElementButton.java index b15fa97e0..77428e810 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementButton.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementButton.java @@ -56,8 +56,8 @@ public class ElementButton extends AbstractElementText implements Element { public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { XDimension2D dim = getTextDimensionAt(stringBounder, x + stroke + marginX); - dim = XDimension2D.delta(dim, 2 * marginX, 2 * marginY); - return XDimension2D.delta(dim, 2 * stroke); + dim = dim.delta(2 * marginX, 2 * marginY); + return dim.delta(2 * stroke); } public void drawU(UGraphic ug, int zIndex, XDimension2D dimToUse) { diff --git a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java index 44bdb8ba3..1ae756004 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java @@ -85,16 +85,15 @@ public class ElementDroplist extends AbstractElementText implements Element { public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { final XDimension2D dim = getTextDimensionAt(stringBounder, x + 2); - return XDimension2D.delta(dim, 4 + box, 4); + return dim.delta((4 + box), 4); } public void drawU(UGraphic ug, int zIndex, XDimension2D dimToUse) { final XDimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0); ug = ug.apply(getBlack()); - + if (zIndex == 0) { - ug.apply(getColorEE().bg()) - .draw(new URectangle(dim.getWidth() - 1, dim.getHeight() - 1)); + ug.apply(getColorEE().bg()).draw(new URectangle(dim.getWidth() - 1, dim.getHeight() - 1)); drawText(ug, 2, 2); final double xline = dim.getWidth() - box; ug.apply(UTranslate.dx(xline)).draw(ULine.vline(dim.getHeight() - 1)); @@ -109,11 +108,10 @@ public class ElementDroplist extends AbstractElementText implements Element { } if (openDrop != null) { - final XDimension2D dimOpen = XDimension2D.atLeast(openDrop.calculateDimension(ug.getStringBounder()), - dim.getWidth() - 1, 0); + final XDimension2D dimOpen = openDrop.calculateDimension(ug.getStringBounder()).atLeast(dim.getWidth() - 1, + 0); ug = ug.apply(UTranslate.dy(dim.getHeight() - 1)); - ug.apply(getColorEE().bg()) - .draw(new URectangle(dimOpen.getWidth() - 1, dimOpen.getHeight() - 1)); + ug.apply(getColorEE().bg()).draw(new URectangle(dimOpen.getWidth() - 1, dimOpen.getHeight() - 1)); openDrop.drawU(ug); } } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementPyramidScrolled.java b/src/net/sourceforge/plantuml/salt/element/ElementPyramidScrolled.java index 731b8afe2..6eccacc35 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementPyramidScrolled.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementPyramidScrolled.java @@ -62,12 +62,12 @@ public class ElementPyramidScrolled extends ElementPyramid { public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { final XDimension2D result = super.getPreferredDimension(stringBounder, x, y); if (scrollStrategy == ScrollStrategy.HORIZONTAL_ONLY) - return XDimension2D.delta(result, 0, 30); + return result.delta(0, 30); if (scrollStrategy == ScrollStrategy.VERTICAL_ONLY) - return XDimension2D.delta(result, 30, 0); + return result.delta(30, 0); - return XDimension2D.delta(result, 30); + return result.delta(30); } @Override diff --git a/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java index 3fcb8f862..584a388e4 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java @@ -74,7 +74,7 @@ public class ElementRadioCheckbox extends AbstractElement { public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { final XDimension2D dim = block.calculateDimension(stringBounder); - return XDimension2D.delta(dim, margin, 0); + return dim.delta(margin, 0); } public void drawU(UGraphic ug, int zIndex, XDimension2D dimToUse) { diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTextField.java b/src/net/sourceforge/plantuml/salt/element/ElementTextField.java index 1b2f38a00..d6309f535 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementTextField.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementTextField.java @@ -51,7 +51,7 @@ public class ElementTextField extends AbstractElementText implements Element { public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { final XDimension2D dim = getTextDimensionAt(stringBounder, x); - return XDimension2D.delta(dim, 6, 2); + return dim.delta(6, 2); } public void drawU(UGraphic ug, int zIndex, XDimension2D dimToUse) { diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java b/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java index 7166b8230..802ad46f0 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java @@ -60,7 +60,7 @@ public class ElementTreeEntry { } public XDimension2D getPreferredDimensionFirstCell(StringBounder stringBounder) { - return XDimension2D.delta(firstElement.getPreferredDimension(stringBounder, 0, 0), getXDelta(), 0); + return firstElement.getPreferredDimension(stringBounder, 0, 0).delta(getXDelta(), 0); } public ListWidth getPreferredDimensionOtherCell(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java index 87c6917d0..cee5cfe20 100644 --- a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java +++ b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java @@ -69,16 +69,16 @@ import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -109,7 +109,7 @@ import smetana.core.debug.SmetanaDebug; public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final StringBounder stringBounder; private final Map nodes = new LinkedHashMap(); @@ -186,7 +186,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { } - public CucaDiagramFileMakerSmetana(CucaDiagram diagram, StringBounder stringBounder) { + public CucaDiagramFileMakerSmetana(ICucaDiagram diagram, StringBounder stringBounder) { this.diagram = diagram; this.stringBounder = stringBounder; this.dotStringFactory = new DotStringFactory(stringBounder, diagram); @@ -250,7 +250,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { if (g.getGroupType() == GroupType.CONCURRENT_STATE) return; - final ClusterHeader clusterHeader = new ClusterHeader((EntityImpl) g, diagram.getSkinParam(), diagram, + final ClusterHeader clusterHeader = new ClusterHeader((EntityImp) g, diagram.getSkinParam(), diagram, stringBounder); dotStringFactory.openCluster(g, clusterHeader); this.printEntities(g.getLeafsDirect()); diff --git a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java index 82c1910ff..32d608b2b 100644 --- a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java +++ b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java @@ -43,7 +43,7 @@ import h.ST_splines; import h.ST_textlabel_t; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.awt.geom.XPoint2D; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.graphic.TextBlock; @@ -69,13 +69,13 @@ public class SmetanaPath implements UDrawable { private final Link link; private final ST_Agedge_s edge; private final YMirror ymirror; - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final TextBlock label; private final TextBlock headLabel; private final TextBlock tailLabel; private final Rose rose = new Rose(); - public SmetanaPath(Link link, ST_Agedge_s edge, YMirror ymirror, CucaDiagram diagram, TextBlock label, + public SmetanaPath(Link link, ST_Agedge_s edge, YMirror ymirror, ICucaDiagram diagram, TextBlock label, TextBlock tailLabel, TextBlock headLabel) { this.link = link; this.edge = edge; diff --git a/src/net/sourceforge/plantuml/security/SFile.java b/src/net/sourceforge/plantuml/security/SFile.java index 0a96a9208..9ad189c2d 100644 --- a/src/net/sourceforge/plantuml/security/SFile.java +++ b/src/net/sourceforge/plantuml/security/SFile.java @@ -49,6 +49,7 @@ import java.io.InputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; import java.net.URI; import java.nio.charset.Charset; import java.nio.file.Path; @@ -58,6 +59,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import javax.imageio.stream.ImageInputStream; import javax.swing.ImageIcon; import net.sourceforge.plantuml.log.Logme; @@ -84,13 +86,14 @@ public class SFile implements Comparable { @Override public String toString() { - if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) - try { - return internal.getCanonicalPath(); - } catch (IOException e) { - return internal.getAbsolutePath(); - } - return super.toString(); + if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET + || SecurityUtils.getSecurityProfile() == SecurityProfile.ALLOWLIST) + return super.toString(); + try { + return internal.getCanonicalPath(); + } catch (IOException e) { + return internal.getAbsolutePath(); + } } public SFile(String nameOrPath) { @@ -184,9 +187,9 @@ public class SFile implements Comparable { return Collections.emptyList(); final List result = new ArrayList<>(tmp.length); - for (File f : tmp) { + for (File f : tmp) result.add(new SFile(f)); - } + return Collections.unmodifiableCollection(result); } @@ -296,12 +299,11 @@ public class SFile implements Comparable { private boolean isInAllowList(List allowlist) { final String path = getCleanPathSecure(); - for (SFile allow : allowlist) { - if (path.startsWith(allow.getCleanPathSecure())) { + for (SFile allow : allowlist) + if (path.startsWith(allow.getCleanPathSecure())) // File directory is in the allowlist return true; - } - } + return false; } @@ -348,13 +350,62 @@ public class SFile implements Comparable { // https://stackoverflow.com/questions/18743790/can-java-load-images-with-transparency if (isFileOk()) try { - return SecurityUtils.readRasterImage(new ImageIcon(this.getAbsolutePath())); + if (internal.getName().endsWith(".webp")) + return readWebp(); + else + return SecurityUtils.readRasterImage(new ImageIcon(this.getAbsolutePath())); } catch (Exception e) { Logme.error(e); } return null; } + private BufferedImage readWebp() throws IOException { + try (InputStream is = openFile()) { + final int riff = read32(is); + if (riff != 0x46464952) + return null; + final int len1 = read32(is); + final int webp = read32(is); + if (webp != 0x50424557) + return null; + final int vp8_ = read32(is); + if (vp8_ != 0x20385056) + return null; + final int len2 = read32(is); + if (len1 != len2 + 12) + return null; + + return getBufferedImageFromWebpButHeader(is); + } + } + + private int read32(InputStream is) throws IOException { + return (is.read() << 0) + (is.read() << 8) + (is.read() << 16) + (is.read() << 24); + } + + public static BufferedImage getBufferedImageFromWebpButHeader(InputStream is) { + if (is == null) + return null; + try { + final Class clVP8Decoder = Class.forName("net.sourceforge.plantuml.webp.VP8Decoder"); + final Object vp8Decoder = clVP8Decoder.getDeclaredConstructor().newInstance(); + // final VP8Decoder vp8Decoder = new VP8Decoder(); + final Method decodeFrame = clVP8Decoder.getMethod("decodeFrame", ImageInputStream.class); + final ImageInputStream iis = SImageIO.createImageInputStream(is); + decodeFrame.invoke(vp8Decoder, iis); + // vp8Decoder.decodeFrame(iis); + iis.close(); + final Object frame = clVP8Decoder.getMethod("getFrame").invoke(vp8Decoder); + return (BufferedImage) frame.getClass().getMethod("getBufferedImage").invoke(frame); + // final VP8Frame frame = vp8Decoder.getFrame(); + // return frame.getBufferedImage(); + } catch (Exception e) { + Logme.error(e); + return null; + } + } + public BufferedReader openBufferedReader() { if (isFileOk()) { try { diff --git a/src/net/sourceforge/plantuml/security/SecurityProfile.java b/src/net/sourceforge/plantuml/security/SecurityProfile.java index 8ff2183d9..df40e7834 100644 --- a/src/net/sourceforge/plantuml/security/SecurityProfile.java +++ b/src/net/sourceforge/plantuml/security/SecurityProfile.java @@ -106,15 +106,15 @@ public enum SecurityProfile { */ static SecurityProfile init() { final String env = SecurityUtils.getenv("PLANTUML_SECURITY_PROFILE"); - if ("SANDBOX".equalsIgnoreCase(env)) { + if ("SANDBOX".equalsIgnoreCase(env)) return SANDBOX; - } else if ("ALLOWLIST".equalsIgnoreCase(env)) { + else if ("ALLOWLIST".equalsIgnoreCase(env)) return ALLOWLIST; - } else if ("INTERNET".equalsIgnoreCase(env)) { + else if ("INTERNET".equalsIgnoreCase(env)) return INTERNET; - } else if ("UNSECURE".equalsIgnoreCase(env)) { + else if ("UNSECURE".equalsIgnoreCase(env)) return UNSECURE; - } + return LEGACY; } diff --git a/src/net/sourceforge/plantuml/skin/CircleInterface.java b/src/net/sourceforge/plantuml/skin/CircleInterface.java index b8a9c5019..d984c7869 100644 --- a/src/net/sourceforge/plantuml/skin/CircleInterface.java +++ b/src/net/sourceforge/plantuml/skin/CircleInterface.java @@ -61,7 +61,7 @@ public class CircleInterface implements UDrawable { final UEllipse head = new UEllipse(headDiam, headDiam); ug.apply(new UStroke(thickness)).apply(backgroundColor.bg()) - .apply(foregroundColor).apply(new UTranslate((double) thickness, (double) thickness)).draw(head); + .apply(foregroundColor).apply(new UTranslate(thickness, thickness)).draw(head); } public double getPreferredWidth(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/skin/Padder.java b/src/net/sourceforge/plantuml/skin/Padder.java index 9e144aa8c..2ce4b77be 100644 --- a/src/net/sourceforge/plantuml/skin/Padder.java +++ b/src/net/sourceforge/plantuml/skin/Padder.java @@ -110,7 +110,7 @@ public class Padder { } return new AbstractTextBlock() { public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * (margin + padding)); + return orig.calculateDimension(stringBounder).delta(2 * (margin + padding)); } public void drawU(UGraphic ug) { @@ -127,8 +127,7 @@ public class Padder { ug2 = ug2.apply(backgroundColor.bg()); } final XDimension2D originalDim = orig.calculateDimension(ug.getStringBounder()); - final URectangle rect = new URectangle(XDimension2D.delta(originalDim, 2 * padding)) - .rounded(roundCorner); + final URectangle rect = new URectangle(originalDim.delta(2 * padding)).rounded(roundCorner); ug2.draw(rect); orig.drawU(ug.apply(new UTranslate(padding, padding))); } diff --git a/src/net/sourceforge/plantuml/sprite/SpriteImage.java b/src/net/sourceforge/plantuml/sprite/SpriteImage.java index f0908ebda..753b437dc 100644 --- a/src/net/sourceforge/plantuml/sprite/SpriteImage.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteImage.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Objects; +import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; @@ -99,6 +100,7 @@ public class SpriteImage implements Sprite { public static InputStream getInternalSprite(final String inner) { final String path = "/sprites/" + inner; + Log.info("Triying " + path); final InputStream is = SpriteImage.class.getResourceAsStream(path); return is; } diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java index 975fcf511..c83ecba97 100644 --- a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java +++ b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java @@ -39,15 +39,15 @@ import java.util.Map; import java.util.Objects; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java index 9964bf970..fc0fc37f8 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.statediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -44,7 +45,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java index d956f5cef..db05db7ca 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java @@ -39,6 +39,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -50,8 +52,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java index 4886009eb..206e7f5e1 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java @@ -39,6 +39,8 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -51,8 +53,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java index 2f5c8b112..3fa302263 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -50,7 +51,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotag; diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java index 3c79b3bff..6a7d4bf29 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.statediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.a.IEntity; 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; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.statediagram.StateDiagram; public class CommandEndState extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java index b257e3eae..ed6268e15 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -47,7 +48,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; @@ -91,16 +91,14 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2 { if (arg.get("ENT1", 2) != null) { final String s = arg.get("ENT1", 2); - cl1.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + cl1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } if (arg.get("ENT2", 1) != null) { cl2.setStereotype(Stereotype.build(arg.get("ENT2", 1))); } if (arg.get("ENT2", 2) != null) { final String s = arg.get("ENT2", 2); - cl2.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(s)); + cl2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0); @@ -118,7 +116,8 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2 { final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); final LinkArg linkArg = LinkArg.build(label, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg); + Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, + linkType, linkArg); if (dir == Direction.LEFT || dir == Direction.UP) link = link.getInv(); diff --git a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java index dd348aa3a..db68324f3 100644 --- a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java +++ b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java @@ -87,17 +87,17 @@ public class GraphicsSudoku { } public ImageData writeImageSvg(OutputStream os) throws IOException { - final UGraphicSvg ug = new UGraphicSvg(HColors.WHITE, true, new XDimension2D(0, 0), - ColorMapper.IDENTITY, false, 1.0, null, null, 0, "none", FileFormat.SVG.getDefaultStringBounder(), - LengthAdjust.defaultValue(), false); + final UGraphicSvg ug = new UGraphicSvg(HColors.WHITE, true, new XDimension2D(0, 0), ColorMapper.IDENTITY, false, + 1.0, null, null, 0, "none", FileFormat.SVG.getDefaultStringBounder(), LengthAdjust.defaultValue(), + false); drawInternal(ug); ug.writeToStream(os, null, -1); // dpi param is not used return ImageDataSimple.ok(); } public ImageData writeImageLatex(OutputStream os, FileFormat fileFormat) throws IOException { - final UGraphicTikz ug = new UGraphicTikz(HColors.WHITE, ColorMapper.IDENTITY, FileFormat.LATEX.getDefaultStringBounder(), 1, - fileFormat == FileFormat.LATEX); + final UGraphicTikz ug = new UGraphicTikz(HColors.WHITE, ColorMapper.IDENTITY, + FileFormat.LATEX.getDefaultStringBounder(), 1, fileFormat == FileFormat.LATEX); drawInternal(ug); ug.writeToStream(os, null, -1); // dpi param is not used return ImageDataSimple.ok(); @@ -114,7 +114,7 @@ public class GraphicsSudoku { drawInternal(ug); g3d.dispose(); - PngIO.write(im, os, 96); + PngIO.write(im, ColorMapper.IDENTITY, os, null, 96); return new ImageDataSimple(im.getWidth(), im.getHeight()); } diff --git a/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java index e666ae103..d98d33ee8 100644 --- a/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java +++ b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.svek; import java.util.Objects; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; diff --git a/src/net/sourceforge/plantuml/svek/Bibliotekon.java b/src/net/sourceforge/plantuml/svek/Bibliotekon.java index 92e2804bd..62a846403 100644 --- a/src/net/sourceforge/plantuml/svek/Bibliotekon.java +++ b/src/net/sourceforge/plantuml/svek/Bibliotekon.java @@ -43,9 +43,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.graphic.StringBounder; diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index 661df12b0..44092e501 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -54,16 +54,16 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.Position; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityUtils; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.USymbol; @@ -105,7 +105,7 @@ public class Cluster implements Moveable { private final int colorNoteTop; private final int colorNoteBottom; private final ISkinParam skinParam; - protected final CucaDiagram diagram; + protected final ICucaDiagram diagram; private ClusterHeader clusterHeader; @@ -137,11 +137,11 @@ public class Cluster implements Moveable { return Collections.unmodifiableSet(result); } - public Cluster(CucaDiagram diagram, ColorSequence colorSequence, ISkinParam skinParam, IGroup root) { + public Cluster(ICucaDiagram diagram, ColorSequence colorSequence, ISkinParam skinParam, IGroup root) { this(diagram, null, colorSequence, skinParam, root); } - private Cluster(CucaDiagram diagram, Cluster parentCluster, ColorSequence colorSequence, ISkinParam skinParam, + private Cluster(ICucaDiagram diagram, Cluster parentCluster, ColorSequence colorSequence, ISkinParam skinParam, IGroup group) { if (group == null) throw new IllegalStateException(); @@ -422,7 +422,7 @@ public class Cluster implements Moveable { final HColor imgBackcolor = EntityImageStateCommon.getStyleStateBody(group, skinParam) .value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); - final TextBlock attribute = ((EntityImpl) group).getStateHeader(skinParam); + final TextBlock attribute = ((EntityImp) group).getStateHeader(skinParam); final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight(); if (total.getWidth() == 0) { System.err.println("Cluster::drawUState issue"); diff --git a/src/net/sourceforge/plantuml/svek/ClusterHeader.java b/src/net/sourceforge/plantuml/svek/ClusterHeader.java index 20cbb9741..a79bdd3b2 100644 --- a/src/net/sourceforge/plantuml/svek/ClusterHeader.java +++ b/src/net/sourceforge/plantuml/svek/ClusterHeader.java @@ -42,13 +42,13 @@ import java.util.List; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -66,14 +66,14 @@ public final class ClusterHeader { final private TextBlock title; final private TextBlock stereo; - public ClusterHeader(EntityImpl g, ISkinParam skinParam, PortionShower portionShower, StringBounder stringBounder) { + public ClusterHeader(EntityImp g, ISkinParam skinParam, PortionShower portionShower, StringBounder stringBounder) { this.title = getTitleBlock(g, skinParam); this.stereo = getStereoBlock(g, skinParam, portionShower); final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER); final XDimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder); if (dimLabel.getWidth() > 0) { - final XDimension2D dimAttribute = ((EntityImpl) g).getStateHeader(skinParam) + final XDimension2D dimAttribute = ((EntityImp) g).getStateHeader(skinParam) .calculateDimension(stringBounder); final double attributeHeight = dimAttribute.getHeight(); final double attributeWidth = dimAttribute.getWidth(); @@ -105,7 +105,7 @@ public final class ClusterHeader { return stereo; } - private TextBlock getTitleBlock(EntityImpl g, ISkinParam skinParam) { + private TextBlock getTitleBlock(EntityImp g, ISkinParam skinParam) { final Display label = g.getDisplay(); if (label == null) return TextBlockUtils.empty(0, 0); @@ -134,7 +134,7 @@ public final class ClusterHeader { return label.create(fontConfiguration, alignment, skinParam); } - private TextBlock getStereoBlock(EntityImpl g, ISkinParam skinParam, PortionShower portionShower) { + private TextBlock getStereoBlock(EntityImp g, ISkinParam skinParam, PortionShower portionShower) { final TextBlock stereo = getStereoBlockWithoutLegend(g, portionShower, skinParam); final DisplayPositioned legend = g.getLegend(); if (legend == null || legend.isNull()) @@ -145,7 +145,7 @@ public final class ClusterHeader { legend.getVerticalAlignment()); } - private TextBlock getStereoBlockWithoutLegend(EntityImpl g, PortionShower portionShower, ISkinParam skinParam) { + private TextBlock getStereoBlockWithoutLegend(EntityImp g, PortionShower portionShower, ISkinParam skinParam) { final Stereotype stereotype = g.getStereotype(); // final DisplayPositionned legend = g.getLegend(); if (stereotype == null) diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index f4d9b586a..85012429c 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.NamedOutputStream; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierActivity; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState; @@ -57,9 +57,9 @@ import net.sourceforge.plantuml.log.Logme; public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; - public CucaDiagramFileMakerSvek(CucaDiagram diagram) throws IOException { + public CucaDiagramFileMakerSvek(ICucaDiagram diagram) throws IOException { this.diagram = diagram; } diff --git a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java index 756aa8aaa..1d7e96219 100644 --- a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java +++ b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java @@ -144,8 +144,8 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB final XDimension2D dimOriginal = original.calculateDimension(stringBounder); final XDimension2D dim1 = getTextDim(text1, stringBounder); final XDimension2D dim2 = getTextDim(text2, stringBounder); - final XDimension2D dimText = XDimension2D.mergeTB(dim1, dim2); - return XDimension2D.mergeTB(dimOriginal, dimText); + final XDimension2D dimText = dim1.mergeTB(dim2); + return dimOriginal.mergeTB(dimText); } @Override diff --git a/src/net/sourceforge/plantuml/svek/DotStringFactory.java b/src/net/sourceforge/plantuml/svek/DotStringFactory.java index 4c8641501..665a2fcfb 100644 --- a/src/net/sourceforge/plantuml/svek/DotStringFactory.java +++ b/src/net/sourceforge/plantuml/svek/DotStringFactory.java @@ -50,9 +50,10 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.Position; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.dot.DotData; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; @@ -61,7 +62,6 @@ import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersions; import net.sourceforge.plantuml.cucadiagram.dot.ProcessState; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.Moveable; import net.sourceforge.plantuml.security.SFile; @@ -95,7 +95,7 @@ public class DotStringFactory implements Moveable { this.current = root; } - public DotStringFactory(StringBounder stringBounder, CucaDiagram diagram) { + public DotStringFactory(StringBounder stringBounder, ICucaDiagram diagram) { this.skinParam = diagram.getSkinParam(); this.umlDiagramType = diagram.getUmlDiagramType(); this.dotMode = DotMode.NORMAL; diff --git a/src/net/sourceforge/plantuml/svek/EntityImageDegenerated.java b/src/net/sourceforge/plantuml/svek/EntityImageDegenerated.java index 1b77c19b3..1d1146070 100644 --- a/src/net/sourceforge/plantuml/svek/EntityImageDegenerated.java +++ b/src/net/sourceforge/plantuml/svek/EntityImageDegenerated.java @@ -66,7 +66,7 @@ public class EntityImageDegenerated implements IEntityImage { } public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), delta * 2, delta * 2); + return orig.calculateDimension(stringBounder).delta(delta * 2, delta * 2); } public MinMax getMinMax(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/EntityImageProtected.java b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java index 325b1db54..2eb42556e 100644 --- a/src/net/sourceforge/plantuml/svek/EntityImageProtected.java +++ b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java @@ -74,7 +74,7 @@ public class EntityImageProtected extends AbstractTextBlock implements IEntityIm } public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * border); + return orig.calculateDimension(stringBounder).delta(2 * border); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 818110bf7..ce8ae9e67 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -58,13 +58,15 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.EntityFactory; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.PortionShower; @@ -75,8 +77,6 @@ import net.sourceforge.plantuml.cucadiagram.dot.ExeState; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.descdiagram.EntityImageDesignedDomain; import net.sourceforge.plantuml.descdiagram.EntityImageDomain; import net.sourceforge.plantuml.descdiagram.EntityImageMachine; @@ -606,7 +606,7 @@ public final class GeneralImageBuilder { } } - final ClusterHeader clusterHeader = new ClusterHeader((EntityImpl) g, dotData.getSkinParam(), dotData, + final ClusterHeader clusterHeader = new ClusterHeader((EntityImp) g, dotData.getSkinParam(), dotData, stringBounder); dotStringFactory.openCluster(g, clusterHeader); this.printEntities(dotStringFactory, g.getLeafsDirect()); diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java index 66f4991e8..9211e9bd6 100644 --- a/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java +++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java @@ -39,19 +39,17 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Set; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.cucadiagram.SuperGroup; import net.sourceforge.plantuml.cucadiagram.dot.DotData; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -65,24 +63,16 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public final class GroupPngMakerActivity { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final IGroup group; private final StringBounder stringBounder; class InnerGroupHierarchy implements GroupHierarchy { - public Set getAllSuperGroups() { - throw new UnsupportedOperationException(); - } - public IGroup getRootGroup() { throw new UnsupportedOperationException(); } - public SuperGroup getRootSuperGroup() { - throw new UnsupportedOperationException(); - } - public Collection getChildrenGroups(IGroup parent) { if (EntityUtils.groupRoot(parent)) { return diagram.getChildrenGroups(group); @@ -96,7 +86,7 @@ public final class GroupPngMakerActivity { } - public GroupPngMakerActivity(CucaDiagram diagram, IGroup group, StringBounder stringBounder) { + public GroupPngMakerActivity(ICucaDiagram diagram, IGroup group, StringBounder stringBounder) { this.diagram = diagram; this.group = group; this.stringBounder = stringBounder; diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java index 1799eb0b1..e0e0cc232 100644 --- a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java +++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java @@ -38,22 +38,20 @@ package net.sourceforge.plantuml.svek; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Set; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; import net.sourceforge.plantuml.cucadiagram.GroupType; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.cucadiagram.SuperGroup; import net.sourceforge.plantuml.cucadiagram.dot.DotData; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -69,24 +67,16 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public final class GroupPngMakerState { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final IGroup group; private final StringBounder stringBounder; class InnerGroupHierarchy implements GroupHierarchy { - public Set getAllSuperGroups() { - throw new UnsupportedOperationException(); - } - public IGroup getRootGroup() { throw new UnsupportedOperationException(); } - public SuperGroup getRootSuperGroup() { - throw new UnsupportedOperationException(); - } - public Collection getChildrenGroups(IGroup parent) { if (EntityUtils.groupRoot(parent)) return diagram.getChildrenGroups(group); @@ -100,7 +90,7 @@ public final class GroupPngMakerState { } - public GroupPngMakerState(CucaDiagram diagram, IGroup group, StringBounder stringBounder) { + public GroupPngMakerState(ICucaDiagram diagram, IGroup group, StringBounder stringBounder) { this.diagram = diagram; this.stringBounder = stringBounder; this.group = group; @@ -166,7 +156,7 @@ public final class GroupPngMakerState { if (stroke == null) stroke = style.getStroke(); - final TextBlock attribute = ((EntityImpl) group).getStateHeader(skinParam); + final TextBlock attribute = ((EntityImp) group).getStateHeader(skinParam); final Stereotype stereotype = group.getStereotype(); final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol(); diff --git a/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java index 5a00d03d3..22b06f708 100644 --- a/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java +++ b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java @@ -124,11 +124,10 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit final XDimension2D text = title.calculateDimension(stringBounder); final XDimension2D attr = attribute.calculateDimension(stringBounder); - final XDimension2D dim = XDimension2D.mergeTB(text, attr, img); + final XDimension2D dim = text.mergeTB(attr, img); final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0; - final XDimension2D result = XDimension2D.delta(dim, - IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE + marginForFields); + final XDimension2D result = dim.delta(IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE + marginForFields); return result; } diff --git a/src/net/sourceforge/plantuml/svek/Kal.java b/src/net/sourceforge/plantuml/svek/Kal.java index 6c23ff7b1..ea9ae4178 100644 --- a/src/net/sourceforge/plantuml/svek/Kal.java +++ b/src/net/sourceforge/plantuml/svek/Kal.java @@ -38,10 +38,10 @@ package net.sourceforge.plantuml.svek; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -61,17 +61,17 @@ public class Kal implements UDrawable { private XDimension2D dim; private UTranslate translate; private final SvekLine svekLine; - private final EntityImpl entity; + private final EntityImp entity; private final Link link; - public Kal(SvekLine svekLine, String text, FontConfiguration font, ISkinParam skinParam, EntityImpl entity, + public Kal(SvekLine svekLine, String text, FontConfiguration font, ISkinParam skinParam, EntityImp entity, Link link, StringBounder stringBounder) { this.svekLine = svekLine; this.entity = entity; this.link = link; this.textBlock = Display.getWithNewlines(text).create7(font, HorizontalAlignment.LEFT, skinParam, CreoleMode.SIMPLE_LINE); - this.dim = XDimension2D.delta(this.textBlock.calculateDimension(stringBounder), 4, 2); + this.dim = this.textBlock.calculateDimension(stringBounder).delta(4, 2); if (link.getLength() == 1 && link.getEntity1() == entity) { this.position = Direction.RIGHT; diff --git a/src/net/sourceforge/plantuml/svek/SvekLine.java b/src/net/sourceforge/plantuml/svek/SvekLine.java index 6e8e36eff..95e721dfb 100644 --- a/src/net/sourceforge/plantuml/svek/SvekLine.java +++ b/src/net/sourceforge/plantuml/svek/SvekLine.java @@ -56,13 +56,14 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPort; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArrow; @@ -73,7 +74,6 @@ import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.descdiagram.command.StringWithArrow; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -216,17 +216,17 @@ public class SvekLine implements Moveable, Hideable, GuideLine { FontConfiguration font, Bibliotekon bibliotekon, Pragma pragma, GraphvizVersion graphvizVersion) { if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQuantifier1() != null) - ((EntityImpl) link.getEntity1()).ensureMargins(Margins.uniform(16)); + ((EntityImp) link.getEntity1()).ensureMargins(Margins.uniform(16)); if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQuantifier2() != null) - ((EntityImpl) link.getEntity2()).ensureMargins(Margins.uniform(16)); + ((EntityImp) link.getEntity2()).ensureMargins(Margins.uniform(16)); if (link.getLinkArg().getKal1() != null) - this.kal1 = new Kal(this, link.getLinkArg().getKal1(), font, skinParam, (EntityImpl) link.getEntity1(), + this.kal1 = new Kal(this, link.getLinkArg().getKal1(), font, skinParam, (EntityImp) link.getEntity1(), link, stringBounder); if (link.getLinkArg().getKal2() != null) - this.kal2 = new Kal(this, link.getLinkArg().getKal2(), font, skinParam, (EntityImpl) link.getEntity2(), + this.kal2 = new Kal(this, link.getLinkArg().getKal2(), font, skinParam, (EntityImp) link.getEntity2(), link, stringBounder); this.link = Objects.requireNonNull(link); @@ -402,7 +402,7 @@ public class SvekLine implements Moveable, Hideable, GuideLine { sb.append("label=<"); } XDimension2D dimNote = hasNoteLabelText() ? labelText.calculateDimension(stringBounder) : CONSTRAINT_SPOT; - dimNote = XDimension2D.delta(dimNote, 2 * labelShield); + dimNote = dimNote.delta(2 * labelShield); appendTable(sb, eventuallyDivideByTwo(dimNote), noteLabelColor, graphvizVersion); sb.append(">"); diff --git a/src/net/sourceforge/plantuml/svek/SvekNode.java b/src/net/sourceforge/plantuml/svek/SvekNode.java index 271bf8a0b..366572dfe 100644 --- a/src/net/sourceforge/plantuml/svek/SvekNode.java +++ b/src/net/sourceforge/plantuml/svek/SvekNode.java @@ -42,10 +42,10 @@ import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.Positionable; import net.sourceforge.plantuml.svek.image.EntityImageDescription; @@ -103,11 +103,11 @@ public class SvekNode implements Positionable, Hideable { this.color = colorSequence.getValue(); this.uid = String.format("sh%04d", color); - if (((EntityImpl) ent).getOriginalGroup() == null) { + if (((EntityImp) ent).getOriginalGroup() == null) { this.group = null; this.leaf = ent; } else { - this.group = ((EntityImpl) ent).getOriginalGroup(); + this.group = ((EntityImp) ent).getOriginalGroup(); this.leaf = null; } } @@ -426,22 +426,22 @@ public class SvekNode implements Positionable, Hideable { } public void drawKals(UGraphic ug) { - if (leaf instanceof EntityImpl == false) + if (leaf instanceof EntityImp == false) return; - drawList(ug, ((EntityImpl) leaf).getKals(Direction.DOWN)); - drawList(ug, ((EntityImpl) leaf).getKals(Direction.UP)); - drawList(ug, ((EntityImpl) leaf).getKals(Direction.LEFT)); - drawList(ug, ((EntityImpl) leaf).getKals(Direction.RIGHT)); + drawList(ug, ((EntityImp) leaf).getKals(Direction.DOWN)); + drawList(ug, ((EntityImp) leaf).getKals(Direction.UP)); + drawList(ug, ((EntityImp) leaf).getKals(Direction.LEFT)); + drawList(ug, ((EntityImp) leaf).getKals(Direction.RIGHT)); } public void fixOverlap() { - if (leaf instanceof EntityImpl == false) + if (leaf instanceof EntityImp == false) return; - fixHoverlap(((EntityImpl) leaf).getKals(Direction.DOWN)); - fixHoverlap(((EntityImpl) leaf).getKals(Direction.UP)); + fixHoverlap(((EntityImp) leaf).getKals(Direction.DOWN)); + fixHoverlap(((EntityImp) leaf).getKals(Direction.UP)); } private void fixHoverlap(final List list) { diff --git a/src/net/sourceforge/plantuml/svek/SvekResult.java b/src/net/sourceforge/plantuml/svek/SvekResult.java index a26d770c6..6dc953d9f 100644 --- a/src/net/sourceforge/plantuml/svek/SvekResult.java +++ b/src/net/sourceforge/plantuml/svek/SvekResult.java @@ -138,7 +138,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage minMax = TextBlockUtils.getMinMax(this, stringBounder, false); dotStringFactory.moveSvek(6 - minMax.getMinX(), 6 - minMax.getMinY()); } - return XDimension2D.delta(minMax.getDimension(), 0, 12); + return minMax.getDimension().delta(0, 12); } public ShapeType getShapeType() { diff --git a/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java b/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java index 29339b33f..28f8cc620 100644 --- a/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java @@ -39,8 +39,8 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java index 1af2fe2f2..40e6ee441 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -85,7 +85,7 @@ public class EntityImageActivity extends AbstractEntityImage { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = desc.calculateDimension(stringBounder); - return XDimension2D.delta(dim, MARGIN * 2); + return dim.delta(MARGIN * 2); } final public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java index 6d0c0bde1..c18d361da 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java @@ -39,8 +39,8 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -80,7 +80,7 @@ public class EntityImageArcCircle extends AbstractEntityImage { final XDimension2D dimName = name.calculateDimension(stringBounder); final XDimension2D dimStereo = getStereoDimension(stringBounder); // final Dimension2D circle = new Dimension2DDouble(SIZE, SIZE); - return XDimension2D.mergeTB(dimStereo, dimName); + return dimStereo.mergeTB(dimName); } private XDimension2D getStereoDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java index bb242f6f0..b58629217 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java index 0e55bc052..151bcc686 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java b/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java index 870db30d8..5e0933dcc 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java @@ -40,7 +40,7 @@ import java.util.Map; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java index 2c5b9a3b6..1514e4b3d 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java index 6fd2d1dfa..972510908 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java index 697c146ed..2c2f46f01 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java @@ -44,12 +44,12 @@ import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -122,10 +122,10 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi private double getKalWidth() { double widthUp = 0; double widthDown = 0; - for (Kal kal : ((EntityImpl) getEntity()).getKals(Direction.UP)) + for (Kal kal : ((EntityImp) getEntity()).getKals(Direction.UP)) widthUp += kal.getDimension().getWidth(); - for (Kal kal : ((EntityImpl) getEntity()).getKals(Direction.DOWN)) + for (Kal kal : ((EntityImp) getEntity()).getKals(Direction.DOWN)) widthDown += kal.getDimension().getWidth(); return Math.max(widthUp, widthDown); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader.java index 43e2e759d..8ddf0963a 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader.java @@ -40,9 +40,9 @@ import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java index 179f42f5b..bcf3f7b11 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.style.SName; public class EntityImageDeepHistory extends EntityImagePseudoState { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index 2442ad42f..8074cc998 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -47,11 +47,11 @@ import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -162,7 +162,7 @@ public class EntityImageDescription extends AbstractEntityImage { diagonalCorner); final Display codeDisplay = Display.getWithNewlines(entity.getCodeGetName()); - if ((entity.getDisplay().equals(codeDisplay) && symbol.getSName() == SName.package_) + if ((entity.getDisplay().equalsLike(codeDisplay) && symbol.getSName() == SName.package_) || entity.getDisplay().isWhite()) desc = TextBlockUtils.empty(style.value(PName.MinimumWidth).asDouble(), 0); else diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java index 1f66b55df..df6b77e06 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java @@ -42,13 +42,13 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.EntityImp; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -115,7 +115,7 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { this.desc = entity.getDisplay().create(titleFontConfiguration, titleHorizontalAlignment, skinParam); - final DisplayPositioned legend = ((EntityImpl) entity).getLegend(); + final DisplayPositioned legend = ((EntityImp) entity).getLegend(); if (legend != null) { final TextBlock legendBlock = EntityImageLegend.create(legend.getDisplay(), skinParam); stereoBlock = legendBlock; @@ -136,8 +136,8 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { final XDimension2D dimDesc = desc.calculateDimension(stringBounder); XDimension2D dim = TextBlockUtils.mergeTB(desc, stereoBlock, HorizontalAlignment.LEFT) .calculateDimension(stringBounder); - dim = XDimension2D.atLeast(dim, 0, 2 * dimDesc.getHeight()); - return XDimension2D.delta(dim, MARGIN * 2, MARGIN * 2); + dim = dim.atLeast(0, 2 * dimDesc.getHeight()); + return dim.delta(MARGIN * 2, MARGIN * 2); } final public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java index 554a8cc30..61b548883 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java b/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java index 46e3d42af..96c80d948 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java @@ -42,10 +42,10 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java index 1c2a3afa7..21a98698b 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java @@ -41,7 +41,7 @@ import java.util.Map; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java index 06b941e7d..e34b30e19 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java @@ -44,7 +44,7 @@ import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java index dea392654..c2b453bd8 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java @@ -40,9 +40,9 @@ import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java index c27f5b781..05cd46a55 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java @@ -45,10 +45,10 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java index 09e29717b..172f66e7f 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java @@ -49,11 +49,11 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XLine2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java index e196d97e6..cfae9727c 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java @@ -46,10 +46,10 @@ import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java index 4ef28af2c..d6f82ad96 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java @@ -40,8 +40,8 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java index 66681ef66..a532ba900 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java @@ -38,8 +38,8 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java index 00613d415..ad1de2181 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java @@ -39,9 +39,9 @@ import java.util.Collections; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -85,14 +85,13 @@ public class EntityImageState extends EntityImageStateCommon { } public XDimension2D calculateDimension(StringBounder stringBounder) { - final XDimension2D dim = XDimension2D.mergeTB(title.calculateDimension(stringBounder), - fields.calculateDimension(stringBounder)); + final XDimension2D dim = title.calculateDimension(stringBounder).mergeTB(fields.calculateDimension(stringBounder)); double heightSymbol = 0; if (withSymbol) heightSymbol += 2 * smallRadius + smallMarginY; - final XDimension2D result = XDimension2D.delta(dim, MARGIN * 2 + 2 * MARGIN_LINE + heightSymbol); - return XDimension2D.atLeast(result, MIN_WIDTH, MIN_HEIGHT); + final XDimension2D result = dim.delta(MARGIN * 2 + 2 * MARGIN_LINE + heightSymbol); + return result.atLeast(MIN_WIDTH, MIN_HEIGHT); } final public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java index 07e577a83..431321a2f 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java @@ -38,8 +38,8 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.BodyFactory; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java index aabcbcbe5..dc2ea1c05 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java @@ -39,8 +39,8 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java index c299c6355..b129c3b3b 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java @@ -39,8 +39,9 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.b.EntityImp; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; @@ -86,6 +87,11 @@ public abstract class EntityImageStateCommon extends AbstractEntityImage { .withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder()); } + public static Style getStyleStateHeader(EntityImp group, ISkinParam skinParam) { + return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.header) + .withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder()); + } + public static Style getStyleState(IEntity group, ISkinParam skinParam) { return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state) .withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder()); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java index 4644870fd..036def3ec 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -55,8 +55,8 @@ public class EntityImageStateEmptyDescription extends EntityImageStateCommon { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = title.calculateDimension(stringBounder); - final XDimension2D result = XDimension2D.delta(dim, MARGIN * 2); - return XDimension2D.atLeast(result, MIN_WIDTH, MIN_HEIGHT); + final XDimension2D result = dim.delta(MARGIN * 2); + return result.atLeast(MIN_WIDTH, MIN_HEIGHT); } final public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java index b926c6223..d39c4050c 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.svek.image; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.PName; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index b60d44a81..9a1fcdc37 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -43,11 +43,11 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.InnerStrategy; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index 0721210e4..010576367 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -44,11 +44,11 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/svg/SvgGraphics.java b/src/net/sourceforge/plantuml/svg/SvgGraphics.java index 9990b994c..13dbc9f95 100644 --- a/src/net/sourceforge/plantuml/svg/SvgGraphics.java +++ b/src/net/sourceforge/plantuml/svg/SvgGraphics.java @@ -81,6 +81,7 @@ import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.USegment; import net.sourceforge.plantuml.ugraphic.USegmentType; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; +import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorGradient; import net.sourceforge.plantuml.xml.XmlFactories; @@ -114,7 +115,7 @@ public class SvgGraphics { private String strokeWidth; private String strokeDasharray = null; - private final String backcolor; + private final String backcolorString; private int maxX = 10; private int maxY = 10; @@ -130,6 +131,8 @@ public class SvgGraphics { private final boolean interactive; + private Element pendingBackground; + final protected void ensureVisible(double x, double y) { if (x > maxX) { maxX = (int) (x + 1); @@ -139,14 +142,15 @@ public class SvgGraphics { } } - public SvgGraphics(String backcolor, boolean svgDimensionStyle, XDimension2D minDim, double scale, String hover, - long seed, String preserveAspectRatio, LengthAdjust lengthAdjust, boolean interactive) { + public SvgGraphics(ColorMapper mapper, HColor backcolor, boolean svgDimensionStyle, XDimension2D minDim, + double scale, String hover, long seed, String preserveAspectRatio, LengthAdjust lengthAdjust, + boolean interactive) { try { this.lengthAdjust = lengthAdjust; this.svgDimensionStyle = svgDimensionStyle; this.scale = scale; this.document = getDocument(); - this.backcolor = backcolor; + this.preserveAspectRatio = preserveAspectRatio; this.interactive = interactive; ensureVisible(minDim.getWidth(), minDim.getHeight()); @@ -173,12 +177,36 @@ public class SvgGraphics { if (script != null) defs.appendChild(script); } + + if (backcolor instanceof HColorGradient) { + this.backcolorString = null; + HColorGradient gr = (HColorGradient) backcolor; + final String id = this.createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper), + gr.getPolicy()); + this.paintBackcolor("url(#" + id + ")"); + } else if (backcolor == null) { + this.backcolorString = null; + } else { + this.backcolorString = backcolor.toSvg(mapper); + final String color = backcolor.toSvg(mapper); + if (color.equals("#00000000") == false && color.equals("#000000") == false + && color.equals("#FFFFFF") == false) + this.paintBackcolor(color); + } + } catch (ParserConfigurationException e) { Logme.error(e); throw new IllegalStateException(e); } } + private void paintBackcolor(String back) { + setFillColor(back); + setStrokeColor(null); + pendingBackground = createRectangleInternal(0, 0, 0, 0); + getG().appendChild(pendingBackground); + } + private Element getStylesForInteractiveMode() { final Element style = simpleElement("style"); final String text = getData("default.css"); @@ -251,16 +279,6 @@ public class SvgGraphics { return Long.toString(Math.abs(seed), 36); } - private Element pendingBackground; - - public void paintBackcolorGradient(ColorMapper mapper, HColorGradient gr) { - final String id = createSvgGradient(gr.getColor1().toRGB(mapper), gr.getColor2().toRGB(mapper), gr.getPolicy()); - setFillColor("url(#" + id + ")"); - setStrokeColor(null); - pendingBackground = createRectangleInternal(0, 0, 0, 0); - getG().appendChild(pendingBackground); - } - // This method returns a reference to a simple XML // element node that has no attributes. private Element simpleElement(String type) { @@ -644,8 +662,9 @@ public class SvgGraphics { final int maxXscaled = (int) (maxX * scale); final int maxYscaled = (int) (maxY * scale); String style = "width:" + maxXscaled + "px;height:" + maxYscaled + "px;"; - if (backcolor != null && "#00000000".equals(backcolor) == false) - style += "background:" + backcolor + ";"; + + if (backcolorString != null && "#00000000".equals(backcolorString) == false) + style += "background:" + backcolorString + ";"; if (svgDimensionStyle) { root.setAttribute("style", style); diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java index 569e2e4ac..8580afba4 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java @@ -88,9 +88,6 @@ public class PlayerAnalog extends Player { for (Double val : values.values()) min = Math.min(min, val); - if (min == 0) - return 10; - return min; } @@ -190,7 +187,7 @@ public class PlayerAnalog extends Player { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = getTitle().calculateDimension(stringBounder); - return XDimension2D.delta(dim, 5 + getMaxWidthForTicks(stringBounder), 0); + return dim.delta(5 + getMaxWidthForTicks(stringBounder), 0); } }; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java index 396869e79..520979813 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java @@ -160,7 +160,7 @@ public class PlayerBinary extends Player { public XDimension2D calculateDimension(StringBounder stringBounder) { final XDimension2D dim = getTitle().calculateDimension(stringBounder); - return XDimension2D.delta(dim, 5, 0); + return dim.delta(5, 0); } }; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingNote.java b/src/net/sourceforge/plantuml/timingdiagram/TimingNote.java index c34c487e2..76f4a7c5c 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingNote.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingNote.java @@ -38,7 +38,6 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.cucadiagram.Display; @@ -88,8 +87,8 @@ public class TimingNote { final HColor noteBackgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); final UStroke stroke = style.getStroke(); - final Sheet sheet = Parser - .build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL) + final Sheet sheet = skinParam + .sheet(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL) .createSheet(note); final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); final Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, sheet1, false, stroke); diff --git a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java index 01d822d16..52625a4dd 100644 --- a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java +++ b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java @@ -156,7 +156,7 @@ public class FontChecker { } private String getSvgImage(char c) throws IOException, TransformerException { - final SvgGraphics svg = new SvgGraphics(null, true, new XDimension2D(0, 0), 1.0, null, 42, "none", + final SvgGraphics svg = new SvgGraphics(null, null, true, new XDimension2D(0, 0), 1.0, null, 42, "none", LengthAdjust.defaultValue(), false); svg.setStrokeColor("black"); svg.svgImage(getBufferedImage(c), 0, 0); diff --git a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java index cc4b988c4..c30a17ffd 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java @@ -104,12 +104,6 @@ public class UImageSvg implements UShape { } public int getData(String name) { - final Pattern p = Pattern.compile("(?i)]+" + name + "\\W+(\\d+)"); - final Matcher m = p.matcher(svg); - if (m.find()) { - final String s = m.group(1); - return Integer.parseInt(s); - } final Pattern p2 = Pattern.compile("viewBox[= \"\']+([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)"); final Matcher m2 = p2.matcher(svg); if (m2.find()) { @@ -124,6 +118,12 @@ public class UImageSvg implements UShape { return result; } } + final Pattern p = Pattern.compile("(?i)]+" + name + "\\W+(\\d+)"); + final Matcher m = p.matcher(svg); + if (m.find()) { + final String s = m.group(1); + return Integer.parseInt(s); + } throw new IllegalStateException("Cannot find " + name); } diff --git a/src/net/sourceforge/plantuml/ugraphic/UStroke.java b/src/net/sourceforge/plantuml/ugraphic/UStroke.java index c058a49f8..0844f219c 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UStroke.java +++ b/src/net/sourceforge/plantuml/ugraphic/UStroke.java @@ -41,6 +41,18 @@ public class UStroke implements UChange { private final double dashSpace; private final double thickness; + @Override + public int hashCode() { + return Double.hashCode(dashVisible) + Double.hashCode(dashSpace) + Double.hashCode(thickness); + } + + @Override + public boolean equals(Object obj) { + final UStroke other = (UStroke) obj; + return this.dashVisible == other.dashVisible && this.dashSpace == other.dashSpace + && this.thickness == other.thickness; + } + @Override public String toString() { return "" + dashVisible + "-" + dashSpace + "-" + thickness; diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java index fae5d1241..73d9c090b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java @@ -216,7 +216,7 @@ public class UGraphicG2d extends AbstractUGraphic implements EnsureV @Override public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException { final BufferedImage im = getBufferedImage(); - PngIO.write(im, os, metadata, dpi); + PngIO.write(im, getColorMapper(), os, metadata, dpi); } @Override diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java index d29967c41..9833cb643 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java @@ -92,13 +92,9 @@ public class UGraphicSvg extends AbstractUGraphic implements ClipCo ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover, long seed, String preserveAspectRatio, StringBounder stringBounder, LengthAdjust lengthAdjust, boolean interactive) { this(defaultBackground, minDim, colorMapper, - new SvgGraphics(defaultBackground.toSvg(colorMapper), svgDimensionStyle, minDim, scale, hover, seed, + new SvgGraphics(colorMapper, defaultBackground, svgDimensionStyle, minDim, scale, hover, seed, preserveAspectRatio, lengthAdjust, interactive), textAsPath, linkTarget, stringBounder, interactive); - if (defaultBackground instanceof HColorGradient) { - final SvgGraphics svg = getGraphicObject(); - svg.paintBackcolorGradient(colorMapper, (HColorGradient) defaultBackground); - } } @Override diff --git a/src/net/sourceforge/plantuml/version/PSystemVersion.java b/src/net/sourceforge/plantuml/version/PSystemVersion.java index 65ab85665..913754122 100644 --- a/src/net/sourceforge/plantuml/version/PSystemVersion.java +++ b/src/net/sourceforge/plantuml/version/PSystemVersion.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.Run; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; -import net.sourceforge.plantuml.dedication.PSystemDedication; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.preproc2.PreprocessorUtils; @@ -128,7 +127,7 @@ public class PSystemVersion extends PlainStringsDiagram { private static BufferedImage getImageWebp(final String name) { try (InputStream is = PSystemVersion.class.getResourceAsStream(name)) { - return PSystemDedication.getBufferedImage(is); + return SFile.getBufferedImageFromWebpButHeader(is); } catch (IOException e) { Logme.error(e); } @@ -186,7 +185,7 @@ public class PSystemVersion extends PlainStringsDiagram { for (String v : OptionPrint.interestingValues()) { strings.add(v); } - + return new PSystemVersion(source, true, strings); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 13fdd040d..c46120bd9 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 1; + final int beta = 5; return beta; } diff --git a/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java index af2cf6e04..b7ec47ccb 100644 --- a/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java +++ b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java @@ -45,17 +45,17 @@ import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.statediagram.StateDiagram; public final class CucaDiagramXmiMaker { - private final CucaDiagram diagram; + private final ICucaDiagram diagram; private final FileFormat fileFormat; - public CucaDiagramXmiMaker(CucaDiagram diagram, FileFormat fileFormat) throws IOException { + public CucaDiagramXmiMaker(ICucaDiagram diagram, FileFormat fileFormat) throws IOException { this.diagram = diagram; this.fileFormat = fileFormat; } diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java index d2792f0cd..da438c404 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java @@ -54,10 +54,10 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.Stereotype; diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java index e3184bba0..7e49cb4cd 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java @@ -39,8 +39,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.ClassDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; public class XmiClassDiagramArgo extends XmiClassDiagramAbstract implements XmlDiagramTransformer { diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java index 52b4a26a3..7ba308ec0 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java @@ -39,8 +39,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.ClassDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; public class XmiClassDiagramStandard extends XmiClassDiagramAbstract implements XmlDiagramTransformer { diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java index c6a087036..2f34decd0 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java @@ -39,9 +39,9 @@ import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; diff --git a/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java index 3df9420a7..bcadef6dc 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java @@ -52,10 +52,10 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; diff --git a/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java b/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java index 86a3cb36c..108026476 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java +++ b/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java @@ -52,10 +52,10 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.statediagram.StateDiagram; diff --git a/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java b/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java index 3fea315d5..4f58cb8f7 100644 --- a/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java +++ b/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java @@ -54,11 +54,11 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import net.sourceforge.plantuml.Guillemet; +import net.sourceforge.plantuml.baraye.a.IEntity; +import net.sourceforge.plantuml.baraye.a.IGroup; +import net.sourceforge.plantuml.baraye.a.ILeaf; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityUtils; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype;