From 494c0c981e992cce8e40da536e6bf4a7fd7b0e0c Mon Sep 17 00:00:00 2001 From: Benjamin Davies Date: Mon, 15 Apr 2024 12:43:17 +1200 Subject: [PATCH] Add support for more common commands in Chen EER diagrams Fixes #1729 --- .../cheneer/ChenEerDiagramFactory.java | 5 +- test/nonreg/simple/ChenRankDir_Test.java | 38 ++++++ .../nonreg/simple/ChenRankDir_TestResult.java | 119 ++++++++++++++++++ 3 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 test/nonreg/simple/ChenRankDir_Test.java create mode 100644 test/nonreg/simple/ChenRankDir_TestResult.java diff --git a/src/net/sourceforge/plantuml/cheneer/ChenEerDiagramFactory.java b/src/net/sourceforge/plantuml/cheneer/ChenEerDiagramFactory.java index 5712b5f99..786f112ed 100644 --- a/src/net/sourceforge/plantuml/cheneer/ChenEerDiagramFactory.java +++ b/src/net/sourceforge/plantuml/cheneer/ChenEerDiagramFactory.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.cheneer.command.CommandEndGroup; import net.sourceforge.plantuml.cheneer.command.CommandMultiSubclass; import net.sourceforge.plantuml.cheneer.command.CommandSimpleSubclass; import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.CommandRankDir; import net.sourceforge.plantuml.command.CommonCommands; import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; @@ -59,8 +60,8 @@ public class ChenEerDiagramFactory extends PSystemCommandFactory { @Override protected void initCommandsList(List cmds) { - CommonCommands.addTitleCommands(cmds); - CommonCommands.addCommonCommands2(cmds); + CommonCommands.addCommonCommands1(cmds); + cmds.add(new CommandRankDir()); cmds.add(new CommandCreateEntity()); cmds.add(new CommandCreateAttribute()); diff --git a/test/nonreg/simple/ChenRankDir_Test.java b/test/nonreg/simple/ChenRankDir_Test.java new file mode 100644 index 000000000..8e2471b35 --- /dev/null +++ b/test/nonreg/simple/ChenRankDir_Test.java @@ -0,0 +1,38 @@ +package nonreg.simple; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import nonreg.BasicTest; + +/* + +Test diagram MUST be put between triple quotes + +""" +@startchen +left to right direction + +entity Person { +} +entity Location { +} +relationship Birthplace { +} + +Person -N- Birthplace +Birthplace -1- Location + +@endchen +""" + + */ +public class ChenRankDir_Test extends BasicTest { + + @Test + void testSimple() throws IOException { + checkImage("(3 entities)"); + } + +} diff --git a/test/nonreg/simple/ChenRankDir_TestResult.java b/test/nonreg/simple/ChenRankDir_TestResult.java new file mode 100644 index 000000000..75a1ebb48 --- /dev/null +++ b/test/nonreg/simple/ChenRankDir_TestResult.java @@ -0,0 +1,119 @@ +package nonreg.simple; + +public class ChenRankDir_TestResult { +} +/* +""" +DPI: 96 +dimension: [ 644.3264 ; 111.8193 ] +scaleFactor: 1.0000 +seed: -4308824771398432496 +svgLinkTarget: _top +hoverPathColorRGB: null +preserveAspectRatio: none + +RECTANGLE: + pt1: [ 6.0000 ; 42.0000 ] + pt2: [ 119.9805 ; 76.0000 ] + xCorner: 0 + yCorner: 0 + stroke: 0.0-0.0-0.5 + shadow: 0 + color: ff181818 + backcolor: fff1f1f1 + +TEXT: + text: Person + position: [ 16.0000 ; 62.8889 ] + orientation: 0 + font: SansSerif.plain/14 [] + color: ff000000 + extendedColor: NULL_COLOR + +RECTANGLE: + pt1: [ 480.0000 ; 42.0000 ] + pt2: [ 639.3264 ; 76.0000 ] + xCorner: 0 + yCorner: 0 + stroke: 0.0-0.0-0.5 + shadow: 0 + color: ff181818 + backcolor: fff1f1f1 + +TEXT: + text: Location + position: [ 490.0000 ; 62.8889 ] + orientation: 0 + font: SansSerif.plain/14 [] + color: ff000000 + extendedColor: NULL_COLOR + +POLYGON: + points: + - [ 206.0000 ; 58.9096 ] + - [ 299.8193 ; 12.0000 ] + - [ 393.6386 ; 58.9096 ] + - [ 299.8193 ; 105.8193 ] + stroke: 0.0-0.0-0.5 + shadow: 0 + color: ff181818 + backcolor: fff1f1f1 + +TEXT: + text: Birthplace + position: [ 231.1803 ; 62.7985 ] + orientation: 0 + font: SansSerif.plain/14 [] + color: ff000000 + extendedColor: NULL_COLOR + +PATH: + - type: SEG_MOVETO + pt1: [ 114.2884 ; 53.0000 ] + - type: SEG_CUBICTO + pt1: [ 139.8162 ; 53.0000 ] + pt2: [ 170.6921 ; 53.0000 ] + pt3: [ 199.5468 ; 53.0000 ] + stroke: 0.0-0.0-1.0 + shadow: 0 + color: ff181818 + backcolor: NULL_COLOR + +EMPTY: + pt1: [ 157.0000 ; 46.0000 ] + pt2: [ 169.5088 ; 59.0000 ] + +TEXT: + text: N + position: [ 158.0000 ; 55.5556 ] + orientation: 0 + font: SansSerif.plain/11 [] + color: ff000000 + extendedColor: NULL_COLOR + +PATH: + - type: SEG_MOVETO + pt1: [ 388.3275 ; 53.0000 ] + - type: SEG_CUBICTO + pt1: [ 416.3938 ; 53.0000 ] + pt2: [ 446.8953 ; 53.0000 ] + pt3: [ 473.9060 ; 53.0000 ] + stroke: 0.0-0.0-1.0 + shadow: 0 + color: ff181818 + backcolor: NULL_COLOR + +EMPTY: + pt1: [ 431.0000 ; 46.0000 ] + pt2: [ 443.3969 ; 59.0000 ] + +TEXT: + text: 1 + position: [ 432.0000 ; 55.5556 ] + orientation: 0 + font: SansSerif.plain/11 [] + color: ff000000 + extendedColor: NULL_COLOR + +""" +*/ \ No newline at end of file