diff --git a/samples/Basic/C4Sharp.Sample/C4Sharp.Sample.csproj b/samples/Basic/C4Sharp.Sample/C4Sharp.Sample.csproj index 07bbc6b..5411c6c 100644 --- a/samples/Basic/C4Sharp.Sample/C4Sharp.Sample.csproj +++ b/samples/Basic/C4Sharp.Sample/C4Sharp.Sample.csproj @@ -2,10 +2,10 @@ Exe - net6.0 10 true enable + net6.0;net7.0;net8.0 diff --git a/samples/Basic/C4Sharp.Sample/Diagrams/ComponentDiagram.cs b/samples/Basic/C4Sharp.Sample/Diagrams/ComponentDiagram.cs index 2823fc3..32bf193 100644 --- a/samples/Basic/C4Sharp.Sample/Diagrams/ComponentDiagram.cs +++ b/samples/Basic/C4Sharp.Sample/Diagrams/ComponentDiagram.cs @@ -25,7 +25,7 @@ public class ComponentDiagram: DiagramBuildRunner protected override DiagramType DiagramType => DiagramType.Component; protected override DiagramLayout FlowVisualization => DiagramLayout.LeftRight; - protected override bool LayoutAsSketch => true; + protected override bool LayoutAsSketch => false; protected override IEnumerable Structures => new Structure[] { diff --git a/samples/Basic/C4Sharp.Sample/Diagrams/ContainerDiagram.cs b/samples/Basic/C4Sharp.Sample/Diagrams/ContainerDiagram.cs index a5edaa3..abadded 100644 --- a/samples/Basic/C4Sharp.Sample/Diagrams/ContainerDiagram.cs +++ b/samples/Basic/C4Sharp.Sample/Diagrams/ContainerDiagram.cs @@ -1,9 +1,9 @@ using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; +using C4Sharp.Diagrams.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Style; using C4Sharp.Elements; using C4Sharp.Elements.Boundaries; -using C4Sharp.Elements.Plantuml; -using C4Sharp.Elements.Plantuml.Constants; using C4Sharp.Elements.Relationships; using C4Sharp.Sample.Structures; @@ -26,7 +26,7 @@ public class ContainerDiagram: DiagramBuildRunner Spa, MobileApp, SqlDatabase, - RabbitMQ, + RabbitMq, BackendApi ) }; @@ -41,7 +41,7 @@ public class ContainerDiagram: DiagramBuildRunner Spa > BackendApi | ("Uses", "async, JSON/HTTPS"), MobileApp > BackendApi | ("Uses", "async, JSON/HTTPS"), SqlDatabase < BackendApi | ("Uses", "async, JSON/HTTPS") | Position.Neighbor, - RabbitMQ < BackendApi | ("Uses", "async, JSON"), + RabbitMq < BackendApi | ("Uses", "async, JSON"), People.Customer < Systems.MailSystem | "Sends e-mails to", Systems.MailSystem < BackendApi | ("Sends e-mails using", "sync, SMTP"), diff --git a/samples/Basic/C4Sharp.Sample/Diagrams/ContextDiagram.cs b/samples/Basic/C4Sharp.Sample/Diagrams/ContextDiagram.cs index d5f99ad..4de2f5b 100644 --- a/samples/Basic/C4Sharp.Sample/Diagrams/ContextDiagram.cs +++ b/samples/Basic/C4Sharp.Sample/Diagrams/ContextDiagram.cs @@ -1,8 +1,8 @@ using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; +using C4Sharp.Diagrams.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Style; using C4Sharp.Elements; -using C4Sharp.Elements.Plantuml; -using C4Sharp.Elements.Plantuml.Constants; using C4Sharp.Elements.Relationships; using C4Sharp.Sample.Structures; diff --git a/samples/Basic/C4Sharp.Sample/Diagrams/EnterpriseDiagram.cs b/samples/Basic/C4Sharp.Sample/Diagrams/EnterpriseDiagram.cs index 3137b0e..8ed28f1 100644 --- a/samples/Basic/C4Sharp.Sample/Diagrams/EnterpriseDiagram.cs +++ b/samples/Basic/C4Sharp.Sample/Diagrams/EnterpriseDiagram.cs @@ -1,9 +1,9 @@ using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; +using C4Sharp.Diagrams.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Style; using C4Sharp.Elements; using C4Sharp.Elements.Boundaries; -using C4Sharp.Elements.Plantuml; -using C4Sharp.Elements.Plantuml.Constants; using C4Sharp.Elements.Relationships; using C4Sharp.Sample.Structures; diff --git a/samples/Basic/C4Sharp.Sample/Diagrams/SequenceDiagram.cs b/samples/Basic/C4Sharp.Sample/Diagrams/SequenceDiagram.cs new file mode 100644 index 0000000..ed642f6 --- /dev/null +++ b/samples/Basic/C4Sharp.Sample/Diagrams/SequenceDiagram.cs @@ -0,0 +1,34 @@ +using C4Sharp.Diagrams; +using C4Sharp.Elements; +using C4Sharp.Elements.Boundaries; +using C4Sharp.Elements.Relationships; + +namespace C4Sharp.Sample.Diagrams; + +public class SequenceDiagram: DiagramBuildRunner +{ + protected override string Title => "Sequence diagram for Internet Banking System"; + protected override DiagramType DiagramType => DiagramType.Sequence; + + protected override IEnumerable Structures => new Structure[] + { + new Container("cA", "Single-Page Application", ContainerType.None, "JavaScript and Angular", "Provides all of the Internet banking functionality to customers via their web browser."), + + new SequenceContainerBoundary("b", "Api Application") + { + Components = new Component[] + { + new ("cB", "Sign In Controller", ComponentType.None, "Spring MVC Rest Controller", "Allows users to sign in to the Internet Banking System."), + new ("cC", "Security Component", ComponentType.None, "Spring Bean", "Provides functionality Related to signing in, changing passwords, etc.") + } + }, + new Container("cD", "Database", ContainerType.Database ,"Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.") + }; + + protected override IEnumerable Relationships => new[] + { + It("cA") > It("cB") | ("Submits credentials to", "JSON/HTTPS"), + It("cB") > It("cC") | "Calls isAuthenticated() on", + It("cC") > It("cD") | ("select * from users where username = ?o", "JDBCS") + }; +} \ No newline at end of file diff --git a/samples/Basic/C4Sharp.Sample/Program.cs b/samples/Basic/C4Sharp.Sample/Program.cs index 68ba6ff..f91aecd 100644 --- a/samples/Basic/C4Sharp.Sample/Program.cs +++ b/samples/Basic/C4Sharp.Sample/Program.cs @@ -1,4 +1,4 @@ -using C4Sharp.Elements.Plantuml.IO; +using C4Sharp.Diagrams.Plantuml; using C4Sharp.Sample.Diagrams; namespace C4Sharp.Sample; @@ -14,14 +14,15 @@ private static void Main() new ComponentDiagram().Build(), new DeploymentDiagram().Build(), new EnterpriseDiagram().Build(), + new SequenceDiagram().Build() }; var context = new PlantumlContext(); context .UseDiagramImageBuilder() - .UseDiagramSvgImageBuilder() - .UseDiagramMermaidBuilder() + //.UseDiagramSvgImageBuilder() + //.UseDiagramMermaidBuilder() //.UseStandardLibraryBaseUrl() //load the resources from github C4plantuml repository .Export(diagrams); } diff --git a/samples/Basic/C4Sharp.Sample/Structures/Containers.cs b/samples/Basic/C4Sharp.Sample/Structures/Containers.cs index 257de7d..2a49ece 100644 --- a/samples/Basic/C4Sharp.Sample/Structures/Containers.cs +++ b/samples/Basic/C4Sharp.Sample/Structures/Containers.cs @@ -43,9 +43,9 @@ public static class Containers Technology: "SQL Database" ); - public static Queue _rabbitMQ; + private static Queue? _rabbitMq = null; - public static Queue RabbitMQ => _rabbitMQ ?? new Queue( + public static Queue RabbitMq => _rabbitMq ?? new Queue( Alias: "Queue", Label: "RabbitMQ", Description: "Stores user registration information, hashed auth credentials, access logs, etc.", diff --git a/src/C4Sharp.Tools/C4Sharp.Tools.csproj b/src/C4Sharp.Tools/C4Sharp.Tools.csproj index ba06109..9b49a44 100644 --- a/src/C4Sharp.Tools/C4Sharp.Tools.csproj +++ b/src/C4Sharp.Tools/C4Sharp.Tools.csproj @@ -4,7 +4,7 @@ Exe enable c4scli - net5.0;net6.0 + net6.0;net7.0;net8.0 true C4SCLI - Tool for C4Sharp yanjustino, albertomonteiro diff --git a/src/C4Sharp.Tools/Commands/BuildCommand.cs b/src/C4Sharp.Tools/Commands/BuildCommand.cs index bafec88..d9da8f7 100644 --- a/src/C4Sharp.Tools/Commands/BuildCommand.cs +++ b/src/C4Sharp.Tools/Commands/BuildCommand.cs @@ -2,7 +2,7 @@ using System.Reflection; using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; -using C4Sharp.Elements.Plantuml.IO; +using C4Sharp.Diagrams.Plantuml; using C4Sharp.Tools.Commands.Arguments; using C4Sharp.Tools.Commands.Options; diff --git a/src/C4Sharp/C4Sharp.csproj b/src/C4Sharp/C4Sharp.csproj index 9a6d82c..9a99534 100644 --- a/src/C4Sharp/C4Sharp.csproj +++ b/src/C4Sharp/C4Sharp.csproj @@ -1,7 +1,7 @@  - net5.0;net6.0 + net6.0;net7.0;net8.0 true C4Sharp - simple .NET superset of C4-PlantUML yanjustino, leisiamedeiros diff --git a/src/C4Sharp/Commons/FileSystem/C4FileException.cs b/src/C4Sharp/Commons/FileSystem/C4FileException.cs index 64e1259..42fe43a 100644 --- a/src/C4Sharp/Commons/FileSystem/C4FileException.cs +++ b/src/C4Sharp/Commons/FileSystem/C4FileException.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; -namespace C4Sharp.FileSystem; +namespace C4Sharp.Commons.FileSystem; /// /// C4File Exception @@ -27,6 +26,8 @@ public C4FileException(string message, Exception innerException) : base(message, { } + +#if NET6 /// /// Constructor /// @@ -35,4 +36,5 @@ public C4FileException(string message, Exception innerException) : base(message, public C4FileException([NotNull] SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } diff --git a/src/C4Sharp/Commons/FileSystem/C4SharpDirectory.cs b/src/C4Sharp/Commons/FileSystem/C4SharpDirectory.cs index aa376ac..05ef9b5 100644 --- a/src/C4Sharp/Commons/FileSystem/C4SharpDirectory.cs +++ b/src/C4Sharp/Commons/FileSystem/C4SharpDirectory.cs @@ -1,4 +1,4 @@ -namespace C4Sharp.FileSystem; +namespace C4Sharp.Commons.FileSystem; /// /// Manipulate the C4 folder and their resourcers diff --git a/src/C4Sharp/Commons/ResourceFile.cs b/src/C4Sharp/Commons/ResourceFile.cs index ab2ba59..7383e76 100644 --- a/src/C4Sharp/Commons/ResourceFile.cs +++ b/src/C4Sharp/Commons/ResourceFile.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; -using C4Sharp.Elements.Plantuml.IO; +using C4Sharp.Diagrams.Plantuml; namespace C4Sharp.Commons; diff --git a/src/C4Sharp/Diagrams/DiagramConstants.cs b/src/C4Sharp/Diagrams/DiagramConstants.cs index e46140c..087ef32 100644 --- a/src/C4Sharp/Diagrams/DiagramConstants.cs +++ b/src/C4Sharp/Diagrams/DiagramConstants.cs @@ -6,4 +6,5 @@ public static class DiagramConstants public const string Container = "C4_Container"; public const string Context = "C4_Context"; public const string Deployment = "C4_Deployment"; + public const string Sequence = "C4_Sequence"; } \ No newline at end of file diff --git a/src/C4Sharp/Diagrams/DiagramType.cs b/src/C4Sharp/Diagrams/DiagramType.cs index e15faf5..519f27c 100644 --- a/src/C4Sharp/Diagrams/DiagramType.cs +++ b/src/C4Sharp/Diagrams/DiagramType.cs @@ -6,4 +6,5 @@ public record DiagramType(string Value, string Name) public static DiagramType Container => new (DiagramConstants.Container, nameof(DiagramConstants.Container)); public static DiagramType Context => new (DiagramConstants.Context, nameof(DiagramConstants.Context)); public static DiagramType Deployment => new (DiagramConstants.Deployment, nameof(DiagramConstants.Deployment)); + public static DiagramType Sequence => new (DiagramConstants.Sequence, nameof(DiagramConstants.Sequence)); } \ No newline at end of file diff --git a/src/C4Sharp/Diagrams/Plantuml/Constants/BorderStyle.cs b/src/C4Sharp/Diagrams/Plantuml/Constants/BorderStyle.cs new file mode 100644 index 0000000..e90448d --- /dev/null +++ b/src/C4Sharp/Diagrams/Plantuml/Constants/BorderStyle.cs @@ -0,0 +1,20 @@ +namespace C4Sharp.Diagrams.Plantuml.Constants; + +public class BorderStyle +{ + /// + /// This call returns the name of the dashed line and can be used as ?lineStyle argument. + /// + public static BorderStyle SolidLine => new() { Value = "SolidLine()" }; + /// + /// This call returns the name of the dotted line and can be used as ?lineStyle argument. + /// + public static BorderStyle DashedLine => new() { Value = "DashedLine()" }; + /// + /// This call returns the name of the bold line and can be used as ?lineStyle argument. + /// + public static BorderStyle DottedLine => new() { Value = "DottedLine()" }; + public static BorderStyle BoldLine => new() { Value = "BoldLine()" }; + + public string Value { get; private init; } = string.Empty; +} \ No newline at end of file diff --git a/src/C4Sharp/Diagrams/Plantuml/Constants/ElementName.cs b/src/C4Sharp/Diagrams/Plantuml/Constants/ElementName.cs index 18e6614..6264a86 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Constants/ElementName.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Constants/ElementName.cs @@ -1,4 +1,4 @@ -namespace C4Sharp.Elements.Plantuml.Constants; +namespace C4Sharp.Diagrams.Plantuml.Constants; public record ElementName { diff --git a/src/C4Sharp/Diagrams/Plantuml/Constants/LineStyle.cs b/src/C4Sharp/Diagrams/Plantuml/Constants/LineStyle.cs index 877c37d..46b8370 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Constants/LineStyle.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Constants/LineStyle.cs @@ -1,4 +1,4 @@ -namespace C4Sharp.Elements.Plantuml.Constants; +namespace C4Sharp.Diagrams.Plantuml.Constants; public record LineStyle { diff --git a/src/C4Sharp/Diagrams/Plantuml/Constants/Shape.cs b/src/C4Sharp/Diagrams/Plantuml/Constants/Shape.cs index 09c777c..f9f3f50 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Constants/Shape.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Constants/Shape.cs @@ -1,4 +1,4 @@ -namespace C4Sharp.Elements.Plantuml.Constants; +namespace C4Sharp.Diagrams.Plantuml.Constants; public record Shape { diff --git a/src/C4Sharp/Diagrams/Plantuml/PlantumlContext.cs b/src/C4Sharp/Diagrams/Plantuml/PlantumlContext.cs index 80197a5..8bbcaf1 100644 --- a/src/C4Sharp/Diagrams/Plantuml/PlantumlContext.cs +++ b/src/C4Sharp/Diagrams/Plantuml/PlantumlContext.cs @@ -1,11 +1,8 @@ using System.Diagnostics; -using System.Runtime.InteropServices.ComTypes; using System.Text; -using C4Sharp.Diagrams; -using C4Sharp.Diagrams.Plantuml; -using C4Sharp.FileSystem; +using C4Sharp.Commons.FileSystem; -namespace C4Sharp.Elements.Plantuml.IO; +namespace C4Sharp.Diagrams.Plantuml; public partial class PlantumlContext : IDisposable { @@ -42,9 +39,10 @@ public PlantumlContext() /// use this method /// /// PlantumlSession instance + [Obsolete("Now, we are suporting just embended version")] public PlantumlContext UseStandardLibraryBaseUrl() { - StandardLibraryBaseUrl = true; + StandardLibraryBaseUrl = false; return this; } diff --git a/src/C4Sharp/Diagrams/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Diagrams/Plantuml/PlantumlDiagram.cs index 7de43af..e8ad9bd 100644 --- a/src/C4Sharp/Diagrams/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Diagrams/Plantuml/PlantumlDiagram.cs @@ -1,6 +1,6 @@ using System.Text; +using C4Sharp.Commons.FileSystem; using C4Sharp.Elements.Relationships; -using C4Sharp.FileSystem; namespace C4Sharp.Diagrams.Plantuml; @@ -49,7 +49,12 @@ private static StringBuilder BuildHeader(this StringBuilder stream, Diagram diag } stream.AppendLine("SHOW_PERSON_PORTRAIT()"); - stream.AppendLine($"{(diagram.FlowVisualization == DiagramLayout.TopDown ? "LAYOUT_TOP_DOWN()" : "LAYOUT_LEFT_RIGHT()")}"); + if (diagram.Type != DiagramType.Sequence) + { + stream.AppendLine( + $"{(diagram.FlowVisualization == DiagramLayout.TopDown ? "LAYOUT_TOP_DOWN()" : "LAYOUT_LEFT_RIGHT()")}"); + } + stream.AppendLine(); if (!string.IsNullOrWhiteSpace(diagram.Title)) @@ -163,7 +168,8 @@ private static StringBuilder BuildMermaidHeader(this StringBuilder stream, Diagr DiagramConstants.Context => "C4Context", DiagramConstants.Container => "C4Container", DiagramConstants.Component => "C4Component", - DiagramConstants.Deployment => "C4Deployment" + DiagramConstants.Deployment => "C4Deployment", + _ => throw new ArgumentOutOfRangeException() }; stream.AppendLine(diagramType); diff --git a/src/C4Sharp/Diagrams/Plantuml/PlantumlException.cs b/src/C4Sharp/Diagrams/Plantuml/PlantumlException.cs index 601cc55..ccb3084 100644 --- a/src/C4Sharp/Diagrams/Plantuml/PlantumlException.cs +++ b/src/C4Sharp/Diagrams/Plantuml/PlantumlException.cs @@ -1,4 +1,4 @@ -namespace C4Sharp.Elements.Plantuml.IO; +namespace C4Sharp.Diagrams.Plantuml; /// /// PlantumlException diff --git a/src/C4Sharp/Diagrams/Plantuml/PlantumlResources.cs b/src/C4Sharp/Diagrams/Plantuml/PlantumlResources.cs index 8ce9bc9..1f7a2d9 100644 --- a/src/C4Sharp/Diagrams/Plantuml/PlantumlResources.cs +++ b/src/C4Sharp/Diagrams/Plantuml/PlantumlResources.cs @@ -1,7 +1,7 @@ using C4Sharp.Commons; -using C4Sharp.FileSystem; +using C4Sharp.Commons.FileSystem; -namespace C4Sharp.Elements.Plantuml.IO; +namespace C4Sharp.Diagrams.Plantuml; internal static class PlantumlResources { @@ -19,6 +19,7 @@ public static void LoadResources(string path) LoadResource(local, "C4_Container.puml"); LoadResource(local, "C4_Context.puml"); LoadResource(local, "C4_Deployment.puml"); + LoadResource(local, "C4_Sequence.puml"); } /// diff --git a/src/C4Sharp/Diagrams/Plantuml/PlantumlStructure.cs b/src/C4Sharp/Diagrams/Plantuml/PlantumlStructure.cs index e2443b3..ada343d 100644 --- a/src/C4Sharp/Diagrams/Plantuml/PlantumlStructure.cs +++ b/src/C4Sharp/Diagrams/Plantuml/PlantumlStructure.cs @@ -25,6 +25,7 @@ public static string ToPumlString(this Structure structure) Container container => container.ToPumlString(), ContainerBoundary containerBoundary => containerBoundary.ToPumlString(), EnterpriseBoundary enterpriseBoundary => enterpriseBoundary.ToPumlString(), + SequenceContainerBoundary sequenceContainerBoundary => sequenceContainerBoundary.ToPumlString(), _ => string.Empty }; @@ -136,6 +137,22 @@ private static string ToPumlString(this ContainerBoundary boundary) return stream.ToString(); } + + private static string ToPumlString(this SequenceContainerBoundary boundary) + { + var stream = new StringBuilder(); + + stream.AppendLine(); + stream.AppendLine($"Container_Boundary({boundary.Alias}, \"{boundary.Label}\")"); + foreach (var component in boundary.Components) + { + stream.AppendLine($"{TabIndentation.Indent()}{component.ToPumlString()}"); + } + + stream.AppendLine("Boundary_End()"); + + return stream.ToString(); + } private static string ToPumlString(this DeploymentNode deployment, int concat = 0) { diff --git a/src/C4Sharp/Diagrams/Plantuml/Style/ElementStyle.cs b/src/C4Sharp/Diagrams/Plantuml/Style/ElementStyle.cs index 5c472f6..7122aa6 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Style/ElementStyle.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Style/ElementStyle.cs @@ -1,8 +1,7 @@ -using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; -using C4Sharp.Elements.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Constants; -namespace C4Sharp.Elements.Plantuml; +namespace C4Sharp.Diagrams.Plantuml.Style; public class ElementStyle : IElementStyle { @@ -17,18 +16,37 @@ public class ElementStyle : IElementStyle /// /// /// + /// + /// /// /// - public ElementStyle UpdateElementStyle(ElementName elementName, string bgColor, string fontColor = "#ffffff", string borderColor = "#00000000", bool shadowing = false, Shape? shape = null) + public ElementStyle UpdateElementStyle(ElementName elementName, string? bgColor = null, string? fontColor = null, string? borderColor = null , bool shadowing = false, Shape? shape = null, BorderStyle? borderStyle = null, int? borderThickness = null) { if (elementName is null) throw new ArgumentNullException(nameof(elementName), $"{nameof(elementName)} is required"); - var value = shape is null - ? $"UpdateElementStyle(\"{elementName.Name}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing}\")" - : $"UpdateElementStyle(\"{elementName.Name}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing}\", $shape={shape.Value})"; + var styles = new List(); + if (fontColor is not null) + styles.Add($"$bgColor={bgColor}"); + + if (bgColor is not null) + styles.Add($"$fontColor={fontColor}"); + + if (borderColor is not null) + styles.Add($"$borderColor={borderColor}"); + + styles.Add($"$shadowing=\"{shadowing.ToString().ToLower()}\""); + + if (shape is not null) + styles.Add($"$shape={shape.Value}"); + + if (borderStyle is not null) + styles.Add($"borderStyle={borderStyle.Value}"); - Items[elementName.Name] = value; + if (borderThickness is not null) + styles.Add($"$borderThickness={borderThickness}"); + + Items[elementName.Name] = $"UpdateElementStyle(\"{elementName.Name}\", {string.Join(",", styles)})"; return this; } } diff --git a/src/C4Sharp/Diagrams/Plantuml/Style/ElementTag.cs b/src/C4Sharp/Diagrams/Plantuml/Style/ElementTag.cs index d1a75b3..3dec87f 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Style/ElementTag.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Style/ElementTag.cs @@ -1,8 +1,7 @@ -using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; -using C4Sharp.Elements.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Constants; -namespace C4Sharp.Elements.Plantuml; +namespace C4Sharp.Diagrams.Plantuml.Style; public class ElementTag : IElementTag { @@ -30,8 +29,8 @@ public ElementTag AddElementTag(string tagStereo, string bgColor, string fontCol } var value = shape is null - ? $"AddElementTag(\"{tagStereo}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing}\")" - : $"AddElementTag(\"{tagStereo}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing}\", $shape={shape.Value})"; + ? $"AddElementTag(\"{tagStereo}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing.ToString().ToLower()}\")" + : $"AddElementTag(\"{tagStereo}\", $bgColor={bgColor}, $fontColor={fontColor}, $borderColor={borderColor}, $shadowing=\"{shadowing.ToString().ToLower()}\", $shape={shape.Value})"; Items[tagStereo] = value; return this; diff --git a/src/C4Sharp/Diagrams/Plantuml/Style/RelationshipTag.cs b/src/C4Sharp/Diagrams/Plantuml/Style/RelationshipTag.cs index 2106e8d..4114e6b 100644 --- a/src/C4Sharp/Diagrams/Plantuml/Style/RelationshipTag.cs +++ b/src/C4Sharp/Diagrams/Plantuml/Style/RelationshipTag.cs @@ -1,8 +1,7 @@ -using C4Sharp.Diagrams; using C4Sharp.Diagrams.Interfaces; -using C4Sharp.Elements.Plantuml.Constants; +using C4Sharp.Diagrams.Plantuml.Constants; -namespace C4Sharp.Elements.Plantuml; +namespace C4Sharp.Diagrams.Plantuml.Style; public class RelationshipTag : IRelationshipTag { diff --git a/src/C4Sharp/Elements/Boundaries/SequenceContainerBoundary.cs b/src/C4Sharp/Elements/Boundaries/SequenceContainerBoundary.cs new file mode 100644 index 0000000..72157fb --- /dev/null +++ b/src/C4Sharp/Elements/Boundaries/SequenceContainerBoundary.cs @@ -0,0 +1,34 @@ +using C4Sharp.Commons.Extensions; + +namespace C4Sharp.Elements.Boundaries; + +/// +/// Container Boundary +/// +public record SequenceContainerBoundary: Structure, IBoundary +{ + public SequenceContainerBoundary(string alias, string label):base(alias, label) + { + } + + public SequenceContainerBoundary(StructureIdentity alias, string label):base(alias, label) + { + } + + public IEnumerable Components { get; init; } = Array.Empty(); + public Structure[] GetBoundaryStructures() => Components.Select(x => x as Structure).ToArray(); +} + +/// +/// Container Boundary +/// +public sealed record SequenceContainerBoundary : ContainerBoundary +{ + public SequenceContainerBoundary():base(StructureIdentity.New(), typeof(T).ToNamingConvention()) + { + } + + public SequenceContainerBoundary(string label):base(StructureIdentity.New(), label) + { + } +} diff --git a/src/C4Sharp/Resources/C4.puml b/src/C4Sharp/Resources/C4.puml index ecd1d45..3d7e330 100644 --- a/src/C4Sharp/Resources/C4.puml +++ b/src/C4Sharp/Resources/C4.puml @@ -1,10 +1,19 @@ ' C4-PlantUML +' Global pre-settings +' ################################## +' ENABLE_ALL_PLANT_ELEMENTS +' If ENABLE_ALL_PLANT_ELEMENTS is set BEFORE the first C4_* file is loaded, nearly "all" PlantUML elements can be used like +' Component(StorageA, "Storage A ", $baseShape="storage") +' ENABLE_ALL_PLANT_ELEMENTS can be set via +' !ENABLE_ALL_PLANT_ELEMENTS = 1 +' or with additional command line argument -DENABLE_ALL_PLANT_ELEMENTS=1 + 'Version ' ################################## !function C4Version() ' 2 spaces and ' are used as unique marker, that the release scripts makes the correct version update - !$c4Version = "2.6.0beta1" + !$c4Version = "2.10.0beta1" !return $c4Version !end function @@ -17,65 +26,98 @@ rectangle C4VersionDetailsArea <> [ ' Colors ' ################################## +!$ELEMENT_FONT_COLOR ?= "#FFFFFF" -!global $ELEMENT_FONT_COLOR = "#FFFFFF" +!$ARROW_COLOR ?= "#666666" +!$ARROW_FONT_COLOR ?= $ARROW_COLOR -!global $ARROW_COLOR = "#666666" +!$BOUNDARY_COLOR ?= "#444444" +!$BOUNDARY_BG_COLOR ?= "transparent" +!$BOUNDARY_BORDER_STYLE ?= "dashed" -!global $BOUNDARY_COLOR = "#444444" -!global $BOUNDARY_BG_COLOR = "transparent" - -!global $LEGEND_FONT_COLOR = "#FFFFFF" -!global $LEGEND_TITLE_COLOR = "#000000" +!$LEGEND_TITLE_COLOR ?= "#000000" +!$LEGEND_FONT_COLOR ?= "#FFFFFF" +!$LEGEND_BG_COLOR ?= "transparent" +!$LEGEND_BORDER_COLOR ?= "transparent" ' %darken(darkkhaki,50), #khaki -!global $LEGEND_DARK_COLOR = "#66622E" -!global $LEGEND_LIGHT_COLOR = "#khaki" +!$LEGEND_DARK_COLOR ?= "#66622E" +!$LEGEND_LIGHT_COLOR ?= "#khaki" -!global $SKETCH_BG_COLOR = "#EEEBDC" -!global $SKETCH_FONT_COLOR = "" -!global $SKETCH_WARNING_COLOR = "red" -!global $SKETCH_FONT_NAME = "Comic Sans MS" +!$SKETCH_BG_COLOR ?= "#EEEBDC" +!$SKETCH_FONT_COLOR ?= "" +!$SKETCH_WARNING_COLOR ?= "red" +!$SKETCH_FONT_NAME ?= "Comic Sans MS" ' Labels ' ################################## -!global $LEGEND_SHADOW_TEXT = "shadow" -!global $LEGEND_NO_SHADOW_TEXT = "no shadow" -!global $LEGEND_NO_FONT_BG_TEXT = "last text and back color" -!global $LEGEND_NO_FONT_TEXT = "last text color" -!global $LEGEND_NO_BG_TEXT = "last back color" -!global $LEGEND_NO_LINE_TEXT = "last line color" -!global $LEGEND_ROUNDED_BOX = "rounded box" -!global $LEGEND_EIGHT_SIDED = "eight sided" -!global $LEGEND_DOTTED_LINE = "dotted" -!global $LEGEND_DASHED_LINE = "dashed" -!global $LEGEND_BOLD_LINE = "bold" -!global $LEGEND_BOUNDARY = "boundary" -!global $LEGEND_DASHED_BOUNDARY = "dashed" -' ignore transparent atm, that the legend is smaller -'!global $LEGEND_DASHED_TRANSPARENT_BOUNDARY = "dashed, transparent" -!global $LEGEND_DASHED_TRANSPARENT_BOUNDARY = "dashed" - -!global $SKETCH_FOOTER_WARNING = "Warning:" -!global $SKETCH_FOOTER_TEXT = "Created for discussion, needs to be validated" +!$LEGEND_SHADOW_TEXT ?= "shadow" +!$LEGEND_NO_SHADOW_TEXT ?= "no shadow" +!$LEGEND_NO_FONT_BG_TEXT ?= "last text and back color" +!$LEGEND_NO_FONT_TEXT ?= "last text color" +!$LEGEND_NO_BG_TEXT ?= "last back color" +!$LEGEND_NO_LINE_TEXT ?= "last line color" +!$LEGEND_ROUNDED_BOX ?= "rounded box" +!$LEGEND_EIGHT_SIDED ?= "eight sided" +!$LEGEND_DOTTED_LINE ?= "dotted" +!$LEGEND_DASHED_LINE ?= "dashed" +!$LEGEND_BOLD_LINE ?= "bold" +!$LEGEND_SOLID_LINE ?= "solid" + +!$LEGEND_BOUNDARY ?= "boundary" +' ignore (boundary) transparent atm, that the legend is smaller +' !$LEGEND_BOUNDARY_TRANSPARENT_INCL_COMA ?= "transparent, " +!$LEGEND_BOUNDARY_TRANSPARENT_INCL_COMA ?= "" +' (boundary) dashed should not be ignored atm +!$LEGEND_BOUNDARY_DASHED_INCL_COMA ?= "dashed, " +' !$LEGEND_BOUNDARY_DASHED_INCL_COMA ?= "" + +!$LEGEND_THICKNESS ?= "thickness" + +!$SKETCH_FOOTER_WARNING ?= "Warning:" +!$SKETCH_FOOTER_TEXT ?= "Created for discussion, needs to be validated" ' Styling ' ################################## -!global $TECHN_FONT_SIZE = 12 -!global $ROUNDED_BOX_SIZE = 25 -!global $EIGHT_SIDED_SIZE = 18 +!$STEREOTYPE_FONT_SIZE ?= 12 +!global $TRANSPARENT_STEREOTYPE_FONT_SIZE = $STEREOTYPE_FONT_SIZE/2 +!$TECHN_FONT_SIZE ?= 12 + +!$ARROW_FONT_SIZE ?= 12 -!global $LEGEND_DETAILS_SMALL_SIZE = 10 -!global $LEGEND_DETAILS_NORMAL_SIZE = 14 +!$LEGEND_DETAILS_SMALL_SIZE ?= 10 +!$LEGEND_DETAILS_NORMAL_SIZE ?= 14 !global $LEGEND_DETAILS_SIZE = $LEGEND_DETAILS_SMALL_SIZE +' element symbols typically 4 times too big in legend +!$LEGEND_IMAGE_SIZE_FACTOR ?= 0.25 + +!$ROUNDED_BOX_SIZE ?= 25 +!$EIGHT_SIDED_SIZE ?= 18 + +' Default element wrap width (of an element) +!$DEFAULT_WRAP_WIDTH ?= 200 +' Maximum size in pixels, of a message (in a sequence diagram?) +!$MAX_MESSAGE_SIZE ?= 150 +' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relationships) +' therefore Rel...() implements an automatic line break based on spaces (like in all other objects). +' If a $type contains \n then these are used (and no automatic space based line breaks are done) +' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position +!$REL_TECHN_MAX_CHAR_WIDTH ?= 35 +!$REL_DESCR_MAX_CHAR_WIDTH ?= 32 + +' internal +' ################################## + !global $ROUNDED_BOX = "roundedBox" !global $EIGHT_SIDED = "eightSided" !global $DOTTED_LINE = "dotted" !global $DASHED_LINE = "dashed" !global $BOLD_LINE = "bold" +' solid is not defined in plantUML, but works as reset of all other styles too +!global $SOLID_LINE = "solid" !global $LEGEND_DETAILS_NONE = "none" !global $LEGEND_DETAILS_NORMAL = "normal" @@ -83,63 +125,119 @@ rectangle C4VersionDetailsArea <> [ skinparam defaultTextAlignment center -skinparam wrapWidth 200 -skinparam maxMessageSize 150 +skinparam wrapWidth $DEFAULT_WRAP_WIDTH +skinparam maxMessageSize $MAX_MESSAGE_SIZE -skinparam LegendBorderColor transparent -skinparam LegendBackgroundColor transparent skinparam LegendFontColor $LEGEND_FONT_COLOR +skinparam LegendBackgroundColor $LEGEND_BG_COLOR +skinparam LegendBorderColor $LEGEND_BORDER_COLOR -skinparam shadowing<> false -' #00000000 is transparent skinparam rectangle<> { - backgroundcolor #00000000 - bordercolor #00000000 + backgroundcolor $LEGEND_BG_COLOR + bordercolor $LEGEND_BORDER_COLOR } skinparam rectangle { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam database { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam queue { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} + +skinparam participant { + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam arrow { Color $ARROW_COLOR - FontColor $ARROW_COLOR - FontSize 12 + FontColor $ARROW_FONT_COLOR + FontSize $ARROW_FONT_SIZE } skinparam person { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam actor { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE style awesome } +!if %variable_exists("ENABLE_ALL_PLANT_ELEMENTS") +skinparam agent { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam artifact { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam boundary { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam card { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam circle { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam cloud { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam collections { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam control { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam entity { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam file { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam folder { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam frame { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam hexagon { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam interface { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam label { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam stack { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam storage { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam usecase { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +skinparam person { + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} +!endif + ' Some boundary skinparams have to be set as package skinparams too (PlantUML uses internal packages) ' UpdateBoundaryStyle() called in boundary section below skinparam rectangle<> { - Shadowing false - StereotypeFontSize 6 + StereotypeFontSize $TRANSPARENT_STEREOTYPE_FONT_SIZE StereotypeFontColor $BOUNDARY_BG_COLOR - BorderStyle dashed + BorderStyle $BOUNDARY_BORDER_STYLE } skinparam package { - StereotypeFontSize 6 + StereotypeFontSize $TRANSPARENT_STEREOTYPE_FONT_SIZE StereotypeFontColor $BOUNDARY_BG_COLOR FontStyle plain BackgroundColor $BOUNDARY_BG_COLOR @@ -293,7 +391,7 @@ skinparam package { !return "" !endfunction -!function $elementTagSkinparams($element, $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) +!function $elementTagSkinparams($element, $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness) !$elementSkin = "skinparam " + $element + "<<" + $tagStereo + ">> {" + %newline() !if ($fontColor != "") !if (%strpos($tagStereo, "boundary") < 0) @@ -323,23 +421,55 @@ skinparam package { !$elementSkin = $elementSkin + " DiagonalCorner " + $EIGHT_SIDED_SIZE+ %newline() !endif !endif + !if ($borderStyle != "") + !$elementSkin = $elementSkin + " BorderStyle " + $borderStyle + %newline() + !endif + !if ($borderThickness != "") + !$elementSkin = $elementSkin + " BorderThickness " + $borderThickness + %newline() + !endif !$elementSkin = $elementSkin + "}" + %newline() !return $elementSkin !endfunction -!unquoted procedure $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) +!unquoted procedure $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness) ' only rectangle supports shape(d corners) - !$tagSkin = $elementTagSkinparams("rectangle", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) - !$tagSkin = $tagSkin + $elementTagSkinparams("database", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") - !$tagSkin = $tagSkin + $elementTagSkinparams("queue", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") + !$tagSkin = $elementTagSkinparams("rectangle", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("database", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("queue", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) ' plantuml.jar bug - actor have to be after person - !$tagSkin = $tagSkin + $elementTagSkinparams("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") + !$tagSkin = $tagSkin + $elementTagSkinparams("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) ' actor has style awesome, therefore $fontColor is ignored and text uses $bgColor too - !$tagSkin = $tagSkin + $elementTagSkinparams("actor", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "") + !$tagSkin = $tagSkin + $elementTagSkinparams("actor", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + ' sequence requires participant + !$tagSkin = $tagSkin + $elementTagSkinparams("participant", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("sequencebox", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) !if (%strpos($tagStereo, "boundary") >= 0 && $bgColor != "") !$tagSkin = $tagSkin + "skinparam package<<" + $tagStereo + ">>StereotypeFontColor " + $bgColor + %newline() !$tagSkin = $tagSkin + "skinparam rectangle<<" + $tagStereo + ">>StereotypeFontColor " + $bgColor + %newline() !endif + !if %variable_exists("ENABLE_ALL_PLANT_ELEMENTS") + !$tagSkin = $tagSkin + $elementTagSkinparams("agent", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("artifact", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("card", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("cloud", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("collections", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("file", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("folder", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("frame", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("hexagon", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("package", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("stack", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("storage", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("usecase", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + ' elements without background: font uses $bgColor + !$tagSkin = $tagSkin + $elementTagSkinparams("boundary", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("circle", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("control", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("entity", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !$tagSkin = $tagSkin + $elementTagSkinparams("interface", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + ' label uses wrong font color? (should be $bgColor too) + !$tagSkin = $tagSkin + $elementTagSkinparams("label", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness) + !endif $tagSkin !endprocedure @@ -423,7 +553,7 @@ $elementSkin !return "1" !endfunction -!function $tagLegendMask($bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite) +!function $tagLegendMask($bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $borderStyle, $borderThickness) !$mask = "" !$mask = $addMaskFlag($mask, $bgColor) !$mask = $addMaskFlag($mask, $fontColor) @@ -431,11 +561,13 @@ $elementSkin !$mask = $addMaskFlag($mask, $shadowing) !$mask = $addMaskFlag($mask, $shape) !$mask = $addMaskFlag($mask, $sprite) + !$mask = $addMaskFlag($mask, $borderStyle) + !$mask = $addMaskFlag($mask, $borderThickness) !return $mask !endfunction !function $resetMask() - !return "000000" + !return "00000000" !endfunction !function $combineMasks($mask1, $mask2) @@ -446,6 +578,8 @@ $elementSkin !$mask = $mask + $orFlags(%substr($mask1, 3, 1), %substr($mask2, 3, 1)) !$mask = $mask + $orFlags(%substr($mask1, 4, 1), %substr($mask2, 4, 1)) !$mask = $mask + $orFlags(%substr($mask1, 5, 1), %substr($mask2, 5, 1)) + !$mask = $mask + $orFlags(%substr($mask1, 6, 1), %substr($mask2, 6, 1)) + !$mask = $mask + $orFlags(%substr($mask1, 7, 1), %substr($mask2, 7, 1)) !return $mask !endfunction @@ -465,9 +599,9 @@ $elementSkin ' ,scale= ... has to be first (...,color=black,scale=0.25... is invalid too) !if (%strpos($sprite, "=") < 0) !if (%substr($sprite, 0, 4) == "img:") - !$smallSprite = $sprite + "{scale=0.25}" + !$smallSprite = $sprite + "{scale=" + $LEGEND_IMAGE_SIZE_FACTOR + "}" !else - !$smallSprite = $sprite + ",scale=0.25" + !$smallSprite = $sprite + ",scale=" + $LEGEND_IMAGE_SIZE_FACTOR !endif !else !$smallSprite = $sprite @@ -487,7 +621,7 @@ $elementSkin !return $formatted !endfunction -!function $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) +!function $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite, $borderStyle, $borderThickness) !$bg = $bgColor !$fo = $fontColor !$bo = $borderColor @@ -536,31 +670,29 @@ $elementSkin !if ($legendSprite != "") !$tagEntry = $tagEntry + $getSprite($legendSprite) + " " !endif + + !$isBoundary = 0 !if ($legendText == "") - !if ($tagStereo == "boundary") - !if ($bgColor == "#00000000" || %lower($bgColor) == "transparent") + !if (%strpos($tagStereo, "boundary") >= 0) + !if ($tagStereo == "boundary") + !$isBoundary = 1 !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " - !$tagDetails = $tagDetails + $LEGEND_DASHED_TRANSPARENT_BOUNDARY + ", " !else - !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " - !$tagDetails = $tagDetails + $LEGEND_DASHED_BOUNDARY + ", " - !endif - !elseif (%strpos($tagStereo, "boundary") >= 0) - ' if contains/ends with _boundary remove _boundary and add "boundary (dashed)" - !$pos = %strpos($tagStereo, "_boundary") - !if ($pos > 0) - !$tagEntry = $tagEntry + " " + %substr($tagStereo, 0 ,$pos) - !if ($bgColor == "#00000000" || %lower($bgColor) == "transparent") - !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " - !$tagDetails = $tagDetails + $LEGEND_DASHED_TRANSPARENT_BOUNDARY + ", " - !else - !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " - !$tagDetails = $tagDetails + $LEGEND_DASHED_BOUNDARY + ", " + ' if contains/ends with _boundary remove _boundary and add "boundary (dashed)" + !$pos = %strpos($tagStereo, "_boundary") + !if ($pos > 0) + !$isBoundary = 1 + !$tagEntry = $tagEntry + " " + %substr($tagStereo, 0 ,$pos) + " " +$LEGEND_BOUNDARY + " " !endif !endif - !else + !endif + !if ($isBoundary == 0) !$tagEntry = $tagEntry + " " + $tagStereo + " " !endif + + !if ($isBoundary == 1 && ($bgColor == "#00000000" || %lower($bgColor) == "transparent")) + !$tagDetails = $tagDetails + $LEGEND_BOUNDARY_TRANSPARENT_INCL_COMA + !endif !if ($shadowing == "true") !$tagDetails = $tagDetails + $LEGEND_SHADOW_TEXT + ", " !endif @@ -583,7 +715,27 @@ $elementSkin !$tagDetails = $tagDetails + $LEGEND_NO_BG_TEXT + ", " !endif !endif - !if ($tagDetails=="(") + !if ($borderStyle != "") + !if ($borderStyle == $DOTTED_LINE) + !$tagDetails = $tagDetails + $LEGEND_DOTTED_LINE + ", " + !elseif ($borderStyle == $DASHED_LINE) + !if ($isBoundary == 1) + !$tagDetails = $tagDetails + $LEGEND_BOUNDARY_DASHED_INCL_COMA + !else + !$tagDetails = $tagDetails + $LEGEND_DASHED_LINE + ", " + !endif + !elseif ($borderStyle == $BOLD_LINE) + !$tagDetails = $tagDetails + $LEGEND_BOLD_LINE + ", " + !elseif ($borderStyle == $SOLID_LINE) + !$tagDetails = $tagDetails + $LEGEND_SOLID_LINE + ", " + !else + !$tagDetails = $tagDetails + $lineStyle + ", " + !endif + !endif + !if ($borderThickness != "") + !$tagDetails = $tagDetails + $LEGEND_THICKNESS + " " + $borderThickness + ", " + !endif + !if ($tagDetails=="(" || $tagDetails=="(, ") !$tagDetails = "" !else !$tagDetails = %substr($tagDetails, 0, %strlen($tagDetails)-2) @@ -618,7 +770,7 @@ $elementSkin !if ($tc == "") !if ($PlantUMLSupportsDynamicLegendColor) - !$tc = $flatLegend($ARROW_COLOR) + !$tc = $flatLegend($ARROW_FONT_COLOR) !else !$tc = $LEGEND_DARK_COLOR !endif @@ -659,7 +811,7 @@ $elementSkin !endif !endif !if ($lineThickness != "") - !$tagDetails = $tagDetails + "thickness " + $lineThickness + ") " + !$tagDetails = $tagDetails + $LEGEND_THICKNESS + " " + $lineThickness + ", " !endif !if ($tagDetails=="(") !$tagDetails = "" @@ -690,14 +842,14 @@ $elementSkin !return $tagEntry !endfunction -!unquoted procedure $addTagToLegend($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $legendText="", $legendSprite="") +!unquoted procedure $addTagToLegend($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") '' if a combined element tag is defined (e.g. "v1.0&v1.1") then it is typically a merged color, '' like a new $fontColor="#fdae61" therefore it should be added to the legend '' and the & combined tags will be not removed ' !if (%strpos($tagStereo, "&") < 0) - !$dummyAlreadyVariables = $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) + !$dummyAlreadyVariables = $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite, $borderStyle, $borderThickness) !$tagCustomLegend = $tagCustomLegend + $tagStereo + "\n" - !$tagMask = $tagLegendMask( $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite) + !$tagMask = $tagLegendMask( $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $borderStyle, $borderThickness) %set_variable_value("$" + $tagStereo + "LegendMask", $tagMask) ' !endif !endprocedure @@ -763,9 +915,13 @@ $line !return $BOLD_LINE !endfunction +!function SolidLine() +!return $SOLID_LINE +!endfunction + ' used by new defined tags -!unquoted procedure AddElementTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") -$defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) +!unquoted procedure AddElementTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") +$defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness) !if ($sprite!="") %set_variable_value("$" + $tagStereo + "ElementTagSprite", $sprite) !if ($legendSprite == "") @@ -775,22 +931,24 @@ $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $s !if ($techn != "") %set_variable_value("$" + $tagStereo + "ElementTagTechn", $techn) !endif -$addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) +$addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure $addElementTagInclReuse($elementName, $tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - !$bgColor=$restoreEmpty($elementName, "bgColor", $bgColor, %true()) - !$fontColor=$restoreEmpty($elementName, "fontColor", $fontColor, %true()) - !$borderColor=$restoreEmpty($elementName, "borderColor", $borderColor, %true()) - !$shadowing=$restoreEmpty($elementName, "shadowing", $shadowing, %true()) - !$shape=$restoreEmpty($elementName, "shape", $shape, %true()) - !$sprite=$restoreEmpty($elementName, "sprite", $sprite, %true()) - !$techn=$restoreEmpty($elementName, "techn", $techn, %true()) +!unquoted procedure $addElementTagInclReuse($elementName, $tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") + !$bgColor=$restoreEmpty($elementName, "bgColor", $bgColor, %false()) + !$fontColor=$restoreEmpty($elementName, "fontColor", $fontColor, %false()) + !$borderColor=$restoreEmpty($elementName, "borderColor", $borderColor, %false()) + !$shadowing=$restoreEmpty($elementName, "shadowing", $shadowing, %false()) + !$shape=$restoreEmpty($elementName, "shape", $shape, %false()) + !$sprite=$restoreEmpty($elementName, "sprite", $sprite, %false()) + !$techn=$restoreEmpty($elementName, "techn", $techn, %false()) ' new style should has its own legend text - ' !$legendText=$restoreEmpty($elementName, "legendText", $legendText, %true()) - !$legendSprite=$restoreEmpty($elementName, "legendSprite", $legendSprite, %true()) + ' !$legendText=$restoreEmpty($elementName, "legendText", $legendText, %false()) + !$legendSprite=$restoreEmpty($elementName, "legendSprite", $legendSprite, %false()) + !$borderStyle=$restoreEmpty($elementName, "borderStyle", $borderStyle, %false()) + !$borderThickness=$restoreEmpty($elementName, "borderThickness", $borderThickness, %false()) - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) + AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure ' used by new defined rel tags @@ -810,7 +968,7 @@ $addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, !endprocedure ' update the style of existing elements like person, ... -!unquoted procedure UpdateElementStyle($elementName, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") +!unquoted procedure UpdateElementStyle($elementName, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") !$bgColor=$restoreEmpty($elementName, "bgColor", $bgColor, %true()) !$fontColor=$restoreEmpty($elementName, "fontColor", $fontColor, %true()) !$borderColor=$restoreEmpty($elementName, "borderColor", $borderColor, %true()) @@ -820,7 +978,10 @@ $addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, !$techn=$restoreEmpty($elementName, "techn", $techn, %true()) !$legendText=$restoreEmpty($elementName, "legendText", $legendText, %true()) !$legendSprite=$restoreEmpty($elementName, "legendSprite", $legendSprite, %true()) -$defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape) +!$borderStyle=$restoreEmpty($elementName, "borderStyle", $borderStyle, %true()) +!$borderThickness=$restoreEmpty($elementName, "borderThickness", $borderThickness, %true()) + +$defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness) !if ($sprite != "") %set_variable_value("$" + $elementName + "ElementTagSprite", $sprite) !if ($legendSprite == "") @@ -830,9 +991,9 @@ $defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, !if ($techn != "") %set_variable_value("$" + $elementName + "ElementTagTechn", $techn) !endif - !$dummyAlreadyVariables = $setTagLegendVariables($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) + !$dummyAlreadyVariables = $setTagLegendVariables($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite, $borderStyle, $borderThickness) ' default tags sets at least bgColor and fontColor - !$tagMask = $tagLegendMask("CHANGED", "CHANGED", $borderColor, $shadowing, $shape, $sprite) + !$tagMask = $tagLegendMask("CHANGED", "CHANGED", $borderColor, $shadowing, $shape, $sprite, $borderStyle, $borderThickness) %set_variable_value("$" + $elementName + "LegendMask", $tagMask) !endprocedure @@ -869,21 +1030,22 @@ $elementSkin ' Line breaks ' ################################## -' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relashionships) -' therefore Rel...() implements an automatic line break based on spaces (like in all other objects). -' If a $type contains \n then these are used (and no automatic space based line breaks are done) -' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position -!global $REL_TECHN_MAX_CHAR_WIDTH = 35 -!global $REL_DESCR_MAX_CHAR_WIDTH = 32 - !unquoted function $breakText($text, $usedNewLine, $widthStr="-1") !$width = %intval($widthStr) !$multiLine = "" !if (%strpos($text, "\n") >= 0) !while (%strpos($text, "\n") >= 0) !$brPos = %strpos($text, "\n") - !$multiLine = $multiLine + %substr($text, 0, $brPos) + $usedNewLine + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $usedNewLine + !else + ' non breaking change that newLine breaks with formats can be used with \n\n + !$multiLine = $multiLine + "" + $usedNewLine + !endif !$text = %substr($text, $brPos+2) + !if (%strlen($text) == 0) + !$text = "" + !endif !endwhile !else !while ($width>0 && %strlen($text) > $width) @@ -929,6 +1091,42 @@ $elementSkin !return $breakText($text, $usedNewLine, $widthStr) !endfunction +' Element base layout +' ################################## + +!function $getElementBase($label, $techn, $descr, $sprite) + !$element = "" + !if ($sprite != "") + !$element = $element + $getSprite($sprite) + !if ($label != "") + !$element = $element + '\n' + !endif + !endif + !if ($label != "") + !$element = $element + '== ' + $breakLabel($label) + !else + !$element = $element + '.' + !endif + !if ($techn != "") + !$element = $element + '\n//[' + $breakTechn($techn, '-1') + ']//' + !endif + !if ($descr != "") + !$element = $element + '\n\n' + $descr + !endif + !return $element +!endfunction + +!function $getElementLine($umlShape, $elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link) + !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", $elementType) + !$techn=$toElementArg($techn, $tags, "ElementTagTechn", $elementType) + !$baseProp = $getElementBase($label, $techn, $descr, $sprite) + $getProps() + !$stereo = $toStereos($elementType,$tags) + !$calcLink = $getLink($link) + + !$line = $umlShape + " " + %chr(34) + $baseProp + %chr(34) +" " + $stereo + " as " + $alias + $calcLink + !return $line +!endfunction + ' Element properties ' ################################## @@ -1014,7 +1212,7 @@ hide stereotype !procedure $getLegendTable($detailsFormat) !global $LEGEND_DETAILS_SIZE = $getLegendDetailsSize($detailsFormat) -<#00000000,#00000000>|**Legend** | +<$colorWithHash(transparent),$colorWithHash(transparent)>|**Legend** | $showActiveLegendEntries($tagDefaultLegend) $showActiveLegendEntries($tagCustomLegend) !endprocedure @@ -1062,9 +1260,10 @@ hide stereotype } !if $ARROW_COLOR == "#666666" !global $ARROW_COLOR = $SKETCH_FONT_COLOR + !global $ARROW_FONT_COLOR = $SKETCH_FONT_COLOR skinparam arrow { Color $ARROW_COLOR - FontColor $ARROW_COLOR + FontColor $ARROW_FONT_COLOR } !endif !if $BOUNDARY_COLOR == "#444444" @@ -1167,29 +1366,29 @@ SHOW_LEGEND($hideStereotype) !endfunction ' enables that legend can be located in drawing area of the diagram. It has to be last call in diagram followed by Lay_Distance() -!unquoted procedure SHOW_FLOATING_LEGEND($alias=LEGEND(), $hideStereotype="true", $details=Normal()) +!unquoted procedure SHOW_FLOATING_LEGEND($alias=LEGEND(), $hideStereotype="true", $details=Small()) $getLegendArea($alias, $hideStereotype, $details) !endprocedure ' Boundaries ' ################################## -!unquoted procedure UpdateBoundaryStyle($elementName="", $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="") +!unquoted procedure UpdateBoundaryStyle($elementName="", $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="") !if ($elementName != "") !$elementBoundary = $elementName + '_boundary' - UpdateElementStyle($elementBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") + UpdateElementStyle($elementBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness) !else - UpdateElementStyle("boundary", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") + UpdateElementStyle("boundary", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness) ' simulate color inheritance - UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Enterprise", "") - UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "System", "") - UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Container", "") + UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Enterprise", "", $borderStyle, $borderThickness) + UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "System", "", $borderStyle, $borderThickness) + UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Container", "", $borderStyle, $borderThickness) !endif !endprocedure -!unquoted procedure AddBoundaryTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="") +!unquoted procedure AddBoundaryTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="") !$tagBoundary = $tagStereo + '_boundary' - AddElementTag($tagBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") + AddElementTag($tagBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness) !endprocedure ' add _boundary to all tags that short tag version can be used @@ -1228,7 +1427,58 @@ rectangle "$getBoundary($label, $type)" $toStereos("boundary", $boundaryTags) as !endprocedure ' Boundary Styling -UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR) +UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $borderStyle=DashedLine()) + +' Index +' ################################## + +' Dynamic/Sequence diagram supports (automatically) numbered interactions: +' preferred function calls +' (Uppercase) LastIndex(): return the last used index (function which can be used as argument) +' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) +' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) + +' old procedures calls +' (lowercase) increment($offset=1): increase current index (procedure which has no direct output) +' (lowercase) setIndex($new_index): set the new index (procedure which has no direct output) + +!$lastIndex = 0 +!$index = 1 + +!procedure increment($offset=1) + !$lastIndex = $index + !$index = $index + $offset +!endprocedure + +!procedure setIndex($new_index) + !$lastIndex = $index + !$index = $new_index +!endprocedure + +!function Index($offset=1) + !$lastIndex = $index + !$index = $lastIndex + $offset + !return $lastIndex +!endfunction + +!function LastIndex() + !return $lastIndex +!endfunction + +!function SetIndex($new_index, $offset=1) + !$lastIndex = $new_index + !$index = $new_index + $offset + !return $lastIndex +!endfunction + +!unquoted function $getPrefix($index) + !if ($index == "") + !$pre = Index() + ": " + !else + !$pre = $index + ": " + !endif + !return $pre +!endfunction ' Relationship ' ################################## @@ -1241,15 +1491,26 @@ UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, !$rel = $rel + ' ' + $toStereos($tags) !endif !$rel = $rel + ' : ' + !if ($link != "") + !$rel = $rel + '**[[' + $link + ' ' + !endif !if ($sprite != "") - !$rel = $rel + $getSprite($sprite) + ' ' + !$rel = $rel + $getSprite($sprite) + !if ($label != "") + !$rel = $rel + ' ' + !endif !endif !if ($link != "") !$usedNewLine = ']]**\n**[[' + $link + ' ' - !$rel = $rel + '**[[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]**' + ' if sprite and label is empty than the link url is shown (otherwise link cannot be activated at all) + !$rel = $rel + $breakText($label, $usedNewLine) + ']]**' !else - !$usedNewLine = '**\n**' - !$rel = $rel + '**' + $breakText($label, $usedNewLine) + '**' + !if ($label != "") + !$usedNewLine = '**\n**' + !$rel = $rel + '**' + $breakText($label, $usedNewLine) + '**' + !else + !$rel = $rel + '.' + !endif !endif !if ($techn != "") ' line break is not deterministic, calculate it @@ -1390,8 +1651,8 @@ $from -[hidden]L- $to !endprocedure ' PlantUML bug: lines which does "not match" with the orientation/direction of the diagram -' uses the same length therefore the method offers no direction at all. +' use the same length therefore the method offers no direction at all. ' If a direction is required the Lay_...() methods can be used !unquoted procedure Lay_Distance($from, $to, $distance="0") $from $getHiddenLine($distance) $to -!endprocedure \ No newline at end of file +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Component.puml b/src/C4Sharp/Resources/C4_Component.puml index 8a83386..a4137d6 100644 --- a/src/C4Sharp/Resources/C4_Component.puml +++ b/src/C4Sharp/Resources/C4_Component.puml @@ -13,25 +13,26 @@ ' Colors ' ################################## -!global $COMPONENT_FONT_COLOR = "#000000" +!$COMPONENT_FONT_COLOR ?= "#000000" +!$COMPONENT_BG_COLOR ?= "#85BBF0" +!$COMPONENT_BORDER_COLOR ?= "#78A8D8" -!global $COMPONENT_BG_COLOR = "#85BBF0" -!global $COMPONENT_BORDER_COLOR = "#78A8D8" -!global $EXTERNAL_COMPONENT_BG_COLOR = "#CCCCCC" -!global $EXTERNAL_COMPONENT_BORDER_COLOR = "#BFBFBF" +!$EXTERNAL_COMPONENT_FONT_COLOR ?= $COMPONENT_FONT_COLOR +!$EXTERNAL_COMPONENT_BG_COLOR ?= "#CCCCCC" +!$EXTERNAL_COMPONENT_BORDER_COLOR ?= "#BFBFBF" ' Styling ' ################################## -UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR) -UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR) +UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR, false) +UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $EXTERNAL_COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR, false) ' shortcuts with default colors -!unquoted procedure AddComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - $addElementTagInclReuse("component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure AddExternalComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - $addElementTagInclReuse("external_component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddExternalComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("external_component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure ' Layout @@ -57,53 +58,26 @@ endlegend ' Elements ' ################################## -!function $getComponent($label, $techn, $descr, $sprite) - !$component = "" - !if ($sprite != "") - !$component = $component + $getSprite($sprite) + '\n' - !endif - !$component = $component + '== ' + $breakLabel($label) - !if ($techn != "") - !$component = $component + '\n//[' + $breakTechn($techn, '-1') + ']//' - !endif - !if ($descr != "") - !$component = $component + '\n\n' + $descr - !endif - !return $component -!endfunction - -!unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) +!unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getElementLine($baseShape, "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) + $getElementLine("database", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) + $getElementLine("queue", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) +!unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getElementLine($baseShape, "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) + $getElementLine("database", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) -!endprocedure \ No newline at end of file + $getElementLine("queue", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Container.puml b/src/C4Sharp/Resources/C4_Container.puml index 6a9543f..bccd6fd 100644 --- a/src/C4Sharp/Resources/C4_Container.puml +++ b/src/C4Sharp/Resources/C4_Container.puml @@ -13,28 +13,35 @@ ' Colors ' ################################## -!global $CONTAINER_BG_COLOR = "#438DD5" -!global $CONTAINER_BORDER_COLOR = "#3C7FC0" -!global $EXTERNAL_CONTAINER_BG_COLOR = "#B3B3B3" -!global $EXTERNAL_CONTAINER_BORDER_COLOR = "#A6A6A6" +!$CONTAINER_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$CONTAINER_BG_COLOR ?= "#438DD5" +!$CONTAINER_BORDER_COLOR ?= "#3C7FC0" + +!$CONTAINER_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$CONTAINER_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$CONTAINER_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE + +!$EXTERNAL_CONTAINER_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_CONTAINER_BG_COLOR ?= "#B3B3B3" +!$EXTERNAL_CONTAINER_BORDER_COLOR ?= "#A6A6A6" ' Styling ' ################################## -UpdateElementStyle("container", $CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $CONTAINER_BORDER_COLOR) -UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR) +UpdateElementStyle("container", $CONTAINER_BG_COLOR, $CONTAINER_FONT_COLOR, $CONTAINER_BORDER_COLOR, false) +UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $EXTERNAL_CONTAINER_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR, false) -UpdateBoundaryStyle("container", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $type="Container") +UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container", $shadowing="false") ' shortcuts with default colors -!unquoted procedure AddContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - $addElementTagInclReuse("container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure AddExternalContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - $addElementTagInclReuse("external_container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddExternalContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("external_container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure UpdateContainerBoundaryStyle($bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $shadowing="", $shape="", $type="Container", $legendText="") - UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) +!unquoted procedure UpdateContainerBoundaryStyle($bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Container", $legendText="", $borderStyle="", $borderThickness="") + UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness) !endprocedure ' Layout @@ -58,55 +65,28 @@ endlegend ' Elements ' ################################## -!function $getContainer($label, $techn, $descr, $sprite) - !$container = "" - !if ($sprite != "") - !$container = $container + $getSprite($sprite) + '\n' - !endif - !$container = $container + '== ' + $breakLabel($label) - !if ($techn != "") - !$container = $container + '\n//[' + $breakTechn($techn, '-1') + ']//' - !endif - !if ($descr != "") - !$container = $container + '\n\n' + $descr - !endif - !return $container -!endfunction - -!unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) +!unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getElementLine($baseShape , "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) + $getElementLine("database", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) + $getElementLine("queue", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) +!unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getElementLine($baseShape , "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) + $getElementLine("database", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) + $getElementLine("queue", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure ' Boundaries @@ -120,4 +100,4 @@ queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("ex !endif ' $type defined via $tag style Boundary($alias, $label, "", $allTags, $link) -!endprocedure \ No newline at end of file +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Context.puml b/src/C4Sharp/Resources/C4_Context.puml index ff7de8d..71b2574 100644 --- a/src/C4Sharp/Resources/C4_Context.puml +++ b/src/C4Sharp/Resources/C4_Context.puml @@ -13,45 +13,60 @@ ' Colors ' ################################## -!global $PERSON_BG_COLOR = "#08427B" -!global $PERSON_BORDER_COLOR = "#073B6F" -!global $EXTERNAL_PERSON_BG_COLOR = "#686868" -!global $EXTERNAL_PERSON_BORDER_COLOR = "#8A8A8A" -!global $SYSTEM_BG_COLOR = "#1168BD" -!global $SYSTEM_BORDER_COLOR = "#3C7FC0" -!global $EXTERNAL_SYSTEM_BG_COLOR = "#999999" -!global $EXTERNAL_SYSTEM_BORDER_COLOR = "#8A8A8A" +!$PERSON_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$PERSON_BG_COLOR ?= "#08427B" +!$PERSON_BORDER_COLOR ?= "#073B6F" + +!$EXTERNAL_PERSON_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_PERSON_BG_COLOR ?= "#686868" +!$EXTERNAL_PERSON_BORDER_COLOR ?= "#8A8A8A" + +!$SYSTEM_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$SYSTEM_BG_COLOR ?= "#1168BD" +!$SYSTEM_BORDER_COLOR ?= "#3C7FC0" + +!$SYSTEM_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$SYSTEM_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$SYSTEM_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE + +!$EXTERNAL_SYSTEM_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_SYSTEM_BG_COLOR ?= "#999999" +!$EXTERNAL_SYSTEM_BORDER_COLOR ?= "#8A8A8A" + +!$ENTERPRISE_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$ENTERPRISE_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$ENTERPRISE_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE ' Styling ' ################################## -UpdateElementStyle("person", $PERSON_BG_COLOR, $ELEMENT_FONT_COLOR, $PERSON_BORDER_COLOR) -UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR) -UpdateElementStyle("system", $SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $SYSTEM_BORDER_COLOR) -UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR) +UpdateElementStyle("person", $PERSON_BG_COLOR, $PERSON_FONT_COLOR, $PERSON_BORDER_COLOR, false) +UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $EXTERNAL_PERSON_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR, false) +UpdateElementStyle("system", $SYSTEM_BG_COLOR, $SYSTEM_FONT_COLOR, $SYSTEM_BORDER_COLOR, false) +UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $EXTERNAL_SYSTEM_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR, false) -UpdateBoundaryStyle("enterprise", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $type="Enterprise") -UpdateBoundaryStyle("system", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $type="System") +UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System", $shadowing="false") +UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise", $shadowing="false") ' shortcuts with default colors -!unquoted procedure AddPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - $addElementTagInclReuse("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure AddExternalPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - $addElementTagInclReuse("external_person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddExternalPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("external_person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure AddSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - $addElementTagInclReuse("system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure AddExternalSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - $addElementTagInclReuse("external_system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddExternalSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="", $borderStyle="", $borderThickness="") + $addElementTagInclReuse("external_system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure UpdateEnterpriseBoundaryStyle($bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $shadowing="", $shape="", $type="Enterprise", $legendText="") - UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) +!unquoted procedure UpdateEnterpriseBoundaryStyle($bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Enterprise", $legendText="", $borderStyle="", $borderThickness="") + UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness) !endprocedure -!unquoted procedure UpdateSystemBoundaryStyle($bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $shadowing="", $shape="", $type="System", $legendText="") - UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) +!unquoted procedure UpdateSystemBoundaryStyle($bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $shadowing="", $shape="", $type="System", $legendText="", $borderStyle="", $borderThickness="") + UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness) !endprocedure ' Sprites @@ -332,89 +347,67 @@ UpdateElementStyle("external_person") ' Elements ' ################################## -!function $getPerson($label, $descr, $sprite) -!if ($sprite == "") && ($defaultPersonSprite != "") - !$sprite = $defaultPersonSprite -!endif -!if ($descr == "") && ($sprite == "") - !return '== '+$breakLabel($label) -!endif -!if ($descr == "") && ($sprite != "") - !return $getSprite($sprite)+'\n== '+$breakLabel($label) -!endif -!if ($descr != "") && ($sprite == "") - !return '== '+$breakLabel($label)+'\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") - !return $getSprite($sprite)+'\n== '+$breakLabel($label)+'\n\n '+$descr -!endif -!endfunction - -!function $getSystem($label, $descr, $sprite) -!if ($descr == "") && ($sprite == "") -!return '== '+$breakLabel($label) -!endif -!if ($descr == "") && ($sprite != "") -!return $getSprite($sprite)+'\n== '+$breakLabel($label) -!endif -!if ($descr != "") && ($sprite == "") -!return '== '+$breakLabel($label)+'\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") -!return $getSprite($sprite)+'\n== '+$breakLabel($label)+'\n\n '+$descr -!endif +!function $getPerson($label, $type, $descr, $sprite) + !if ($sprite == "") && ($defaultPersonSprite != "") + !$sprite = $defaultPersonSprite + !endif + !return $getElementBase($label, $type, $descr, $sprite) !endfunction -!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="") +!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "person") +' $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "person") !if ($portraitPerson == "portrait") && ($sprite == "") -actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +actor "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !elseif ($portraitPerson == "outline") && ($sprite == "") -person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +person "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !else -rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !endif !endprocedure -!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") +!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_person") +' $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "external_person") !if ($portraitPerson == "portrait") && ($sprite == "") -actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +actor "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !elseif ($portraitPerson == "outline") && ($sprite == "") -person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +person "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !else -rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !endif !endprocedure -!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="", $baseShape="rectangle") + ' $type reuses $techn definition of $tags + $getElementLine($baseShape, "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("database", "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("queue", "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="", $baseShape="rectangle") + ' $type reuses $techn definition of $tags + $getElementLine($baseShape , "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("database", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("queue", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure ' Boundaries @@ -438,4 +431,4 @@ queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_syst !endif ' $type defined via $tag style Boundary($alias, $label, "", $allTags, $link) -!endprocedure \ No newline at end of file +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Deployment.puml b/src/C4Sharp/Resources/C4_Deployment.puml index eda6ee7..afc9945 100644 --- a/src/C4Sharp/Resources/C4_Deployment.puml +++ b/src/C4Sharp/Resources/C4_Deployment.puml @@ -8,22 +8,30 @@ ' Colors ' ################################## -!global $NODE_FONT_COLOR = "#000000" -!global $NODE_BG_COLOR = "#FFFFFF" -!global $NODE_BORDER_COLOR = "#A2A2A2" +!$NODE_FONT_COLOR ?= "#000000" +!$NODE_BG_COLOR ?= "#FFFFFF" +!$NODE_BORDER_COLOR ?= "#A2A2A2" ' Styling ' ################################## -UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR) +' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container") +' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects). +' If a $type contains \n then these are used (and no automatic space based line breaks are done) +' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position +!$NODE_TYPE_MAX_CHAR_WIDTH ?= 35 +!$NODE_DESCR_MAX_CHAR_WIDTH ?= 32 + +UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR, false) skinparam rectangle<> { FontStyle normal } ' shortcuts with default colors -' node specific: $type reuses $techn definition of $tags -!unquoted procedure AddNodeTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - $addElementTagInclReuse("node", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +' node specific: $techn is only used in old scripts, new scripts uses $type ($techn has to remain, it could be called via named argument) +!unquoted procedure AddNodeTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $type="", $legendText="", $legendSprite="", $techn="", $borderStyle="", $borderThickness="") + !$type=$type+$techn + $addElementTagInclReuse("node", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness) !endprocedure ' Layout @@ -35,13 +43,6 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy ' Line breaks ' ################################## -' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container") -' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects). -' If a $type contains \n then these are used (and no automatic space based line breaks are done) -' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position -!global $NODE_TYPE_MAX_CHAR_WIDTH = 35 -!global $NODE_DESCR_MAX_CHAR_WIDTH = 32 - ' $breakTechn() in C4 supports //...//; $breakNode() in C4_Deployment supports no //....// !unquoted function $breakNode($text, $widthStr) !$usedNewLine = '\n' @@ -136,4 +137,4 @@ rectangle "$getNode_L($label, $type, $descr, $sprite)$getProps_L()" $toStereos(" ' nodes $type reuses $techn definition of $tags !$type=$toElementArg($type, $tags, "ElementTagTechn", "node") rectangle "$getNode_R($label, $type, $descr, $sprite)$getProps_R()" $toStereos("node",$tags) as $alias $getLink($link) -!endprocedure \ No newline at end of file +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Dynamic.puml b/src/C4Sharp/Resources/C4_Dynamic.puml index e4a4108..f12cb86 100644 --- a/src/C4Sharp/Resources/C4_Dynamic.puml +++ b/src/C4Sharp/Resources/C4_Dynamic.puml @@ -20,38 +20,6 @@ ' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) ' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) -' Index -' ################################## - -!$lastIndex = 0 -!$index = 1 - -!procedure increment($offset=1) - !$lastIndex = $index - !$index = $index + $offset -!endprocedure - -!procedure setIndex($new_index) - !$lastIndex = $index - !$index = $new_index -!endprocedure - -!function Index($offset=1) - !$lastIndex = $index - !$index = $lastIndex + $offset - !return $lastIndex -!endfunction - -!function LastIndex() - !return $lastIndex -!endfunction - -!function SetIndex($new_index, $offset=1) - !$lastIndex = $new_index - !$index = $new_index + $offset - !return $lastIndex -!endfunction - ' Relationship override ' ################################## @@ -65,39 +33,66 @@ $getRel($direction, $alias1, $alias2, $e_index + ": " + $label, "", "", "", "", $getRel($direction, $alias1, $alias2, $e_index + ": " + $label, $techn, "", "", "", "") !endprocedure +' all RelIndex... calls are outdated, Rel(..., $index=...) calls should be used !!!! + +' first Rel() supports the $index argument too; second Rel() overwrites C4.puml definition +!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel("-->>", $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("-->>", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel("-->>", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_Back($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel("<<--", $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_Back($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<--", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Back($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_Back($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel("<<--", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel("->>", $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("->>", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Neighbor($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_Neighbor($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel("->>", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel("<<-", $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<-", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Back_Neighbor($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_Back_Neighbor($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel("<<-", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($down("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_D($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") +!endprocedure +!unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($down("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Down($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_D($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) @@ -106,11 +101,19 @@ $getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($up("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_U($from, $to, $label, $techn, $descr, $sprite, $tags, $link=, "") +!endprocedure +!unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($up("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Up($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_U($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) @@ -119,11 +122,19 @@ $getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $s $getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($left("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_L($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") +!endprocedure +!unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($left("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Left($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_L($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) @@ -132,15 +143,23 @@ $getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure +!unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($right("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure !unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_R($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") +!endprocedure +!unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="") +!$pre = $getPrefix($index) +$getRel($right("-","->>"), $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) +Rel_Right($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "") !endprocedure !unquoted procedure RelIndex_R($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel($right("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure RelIndex_Right($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") $getRel($right("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure \ No newline at end of file +!endprocedure diff --git a/src/C4Sharp/Resources/C4_Sequence.puml b/src/C4Sharp/Resources/C4_Sequence.puml new file mode 100644 index 0000000..ee40694 --- /dev/null +++ b/src/C4Sharp/Resources/C4_Sequence.puml @@ -0,0 +1,398 @@ +' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./C4_Component.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml +!endif + +' Scope: Interactions in an enterprise, software system or container. +' Primary and supporting elements: Depends on the diagram scope - +' enterprise - people and software systems Related to the enterprise in scope +' software system - see system context or container diagrams, +' container - see component diagram. +' Intended audience: Technical and non-technical people, inside and outside of the software development team. + +' Sequence diagram introduces (automatically) numbered interactions: +' (lowercase) increment($offset=1): increase current index (procedure which has no direct output) +' (lowercase) setIndex($new_index): set the new index (procedure which has no direct output) +' +' (Uppercase) LastIndex(): return the last used index (function which can be used as argument) +' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) +' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) + +' enables multi-level boxes +!pragma teoz true + + +' Legend redefintion +' ################################## +' sequence has no dashed boxes +!if ($LEGEND_DASHED_BOUNDARY == "dashed") + !$LEGEND_DASHED_BOUNDARY = "" +!endif +!if ($LEGEND_DASHED_TRANSPARENT_BOUNDARY == "dashed") + !$LEGEND_DASHED_TRANSPARENT_BOUNDARY = "" +!endif +UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR) +UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise") +UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System") +UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container") + +' Styling and Layout +' ################################## + +!global $display_element_description = %false() + +' typically the element/participant descriptions are not displayed in a sequence diagram, but it can be activated with this call +!unquoted procedure SHOW_ELEMENT_DESCRIPTIONS($show="true") +!if ($show == "true") + !global $display_element_description = %true() +!else + !global $display_element_description = %false() +!endif +!endprocedure + +' typically the foot boxes descriptions are not displayed in a sequence diagram, but it can be activated with this call +!unquoted procedure SHOW_FOOT_BOXES($show="true") +!if ($show == "true") + show footbox +!else + hide footbox +!endif +!endprocedure + +!global $show_index = %false() +' All relation specific (default) ordinary index numbers can be shown with this call +!unquoted procedure SHOW_INDEX($show="true") +!if ($show == "true") + !global $show_index = %true() +!else + !global $show_index = %false() +!endif +!endprocedure + +' ======= if no theme is defined hide foot box and activate C4_blue styles +!if (%variable_exists("$THEME")) +!else +' $BOUNDARY_BG_COLOR... have to be defined in theme itself that it can be used in styles,... +' (no default values which are defined in C4.puml) +' If skinparams and styles are defined with concrete values no variables are required +!$BOUNDARY_BG_COLOR ?= "transparent" +!$BOUNDARY_COLOR ?= "#444444" +!$ARROW_COLOR ?= "#666666" + +' replace transparent with concrete background that it can be used as font color too +!if ($BOUNDARY_BG_COLOR == "transparent") + !$SEQUENCE_BG_COLOR = white +!else + !$SEQUENCE_BG_COLOR = $BOUNDARY_BG_COLOR +!endif + +' "C4 styled" default is no foot boxes +hide footbox +' "C4 styled" default is that lifeline is arrow color +skinparam SequenceLifelineBorderColor $ARROW_COLOR + +skinparam SequenceGroupBodyBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceGroupFontColor $BOUNDARY_COLOR +skinparam SequenceGroupBackgroundColor $BOUNDARY_COLOR +skinparam SequenceGroupHeaderFontColor $SEQUENCE_BG_COLOR +skinparam SequenceGroupBorderColor $BOUNDARY_COLOR + +skinparam SequenceReferenceBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceReferenceFontColor $BOUNDARY_COLOR +skinparam SequenceReferenceHeaderBackgroundColor $BOUNDARY_COLOR +' VIA STYLE +' skinparam SequenceReferenceHeaderFontColor $SEQUENCE_BG_COLOR + +skinparam SequenceReferenceBorderColor $BOUNDARY_COLOR + +skinparam SequenceDividerBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceDividerFontColor $BOUNDARY_COLOR +skinparam SequenceDividerBorderColor $BOUNDARY_COLOR + +' VIA STYLE +' skinparam SequenceDelayFontColor green + +!endif +' ======= if no theme is defined hide foot box and activate C4_blue styles + +' Elements redefinition +' ################################## + +' all elements have to be displayed as participant +' participants requires ` %newline()` instead of `\n` + +!unquoted function $breakWithNewline($text, $lineEnd, $lineStart, $widthStr="-1") +!$width = %intval($widthStr) +!$multiLine = "" +!if (%strpos($text, "\n") >= 0) + !while (%strpos($text, "\n") >= 0) + !$brPos = %strpos($text, "\n") + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $lineEnd + %newline() + $lineStart + !else + ' non breaking change that newLine breaks with formats can be used with \n\n + !$multiLine = $multiLine + "" + $lineEnd + %newline() + $lineStart + !endif + !$text = %substr($text, $brPos+2) + !if (%strlen($text) == 0) + !$text = "" + !endif + !endwhile +!else + !while ($width>0 && %strlen($text) > $width) + !$brPos = $width + !while ($brPos > 0 && %substr($text, $brPos, 1) != ' ') + !$brPos = $brPos - 1 + !endwhile + + !if ($brPos < 1) + !$brPos = %strpos($text, " ") + !else + !endif + + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $lineEnd + %newline() + $lineStart + !$text = %substr($text, $brPos + 1) + !else + !$multiLine = $multiLine+ $text + !$text = "" + !endif + !endwhile +!endif +!if (%strlen($text) > 0) + !$multiLine = $multiLine + $text +!endif +!return $multiLine +!endfunction + +!unquoted function $breakNewLineLabel($text) +!$multiLine = $breakWithNewline($text, "", "==") +!return $multiLine +!endfunction + +!unquoted function $breakNewLineDescr($text) + !return $breakWithNewline($text, "", "", $REL_DESCR_MAX_CHAR_WIDTH) +!endfunction + +!unquoted function $breakNewLineTechn($text) + !$lineStart = "//" + !$lineEnd = '//' + !return $breakWithNewline($text, $lineStart, $lineEnd, $REL_TECHN_MAX_CHAR_WIDTH) +!endfunction + +' description is not displayed (size too big, line breaks not supported) +' properties are not displayed in sequence diagram (size would be too big) +' $breakLabel() not required by participant +!procedure $getParticipant($elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link) + !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", $elementType) + !$techn=$toElementArg($techn, $tags, "ElementTagTechn", $elementType) + !$stereo = $toStereos($elementType,$tags) + !$calcLabel = "== " + $breakNewLineLabel($label) + !$calcTech = "//[" + $breakNewLineTechn($techn) + "]//" + !$calcDescr = $breakNewLineDescr($descr) + !$calcLink = $getLink($link) + +participant $alias $stereo $calcLink [ +!if ($sprite != "") +$getSprite($sprite) +!endif +!if ($label != "") +$calcLabel +!endif +!if ($techn != "") +$calcTech +!endif +!if ($display_element_description == %true() && $descr != "") + +$calcDescr +!endif +] +!endprocedure + + +!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("person", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_person", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="", $baseShape="rectangle") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="", $baseShape="rectangle") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + + + +!unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + + + +!unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + + +' Boundary redefinition +' ################################## + +' all boundaries have to be displayed as box and +' !!! important changes: without { at the end; and boundary ends with Boundary_End() instead of } + +' alias ignored +' $breakLabel() not required by participant + +!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="") +!$boundaryTags = $addBoundaryPostfix($tags) +' nodes $type reuses $techn definition of $boundaryTags +!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary") +!if ($link != "") + !$usedNewLine = ']]\n== [[' + $link + ' ' + !$labelType = '== [[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]' +!else + !$usedNewLine = '\n== ' + !$labelType = $breakText($label, $usedNewLine) +!endif +!if (type != "") + !$labelType = $labelType + '\n[' + $type + ']' +!endif +box "$labelType" $toStereos("boundary", $boundaryTags) +!endprocedure + +!procedure Boundary_End() +end box +!endprocedure + +!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+enterprise' + !else + !$allTags = 'enterprise' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +!unquoted procedure System_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+system' + !else + !$allTags = 'system' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+container' + !else + !$allTags = 'container' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +' Relationship (redefinition) +' ################################## + +' only Rel is supported in sequence diagram + +' first Rel() supports the $index and $rel argument too; second Rel() overwrites C4.puml definition +' don't add empty lines in procedure otherwise & calls are not working anymore '& a -> b: call' are not working anymore +!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="", $rel="") + !if ($show_index == %true()) + !$pre = $getPrefix($index) + !else + !$pre = "" + !endif + !if ($rel == "") + !$rel = "->" + !endif +$getRel($rel, $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure +!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") +Rel($from, $to, $label, $techn, $descr, $sprite, $tags, $link, "", "") +!endprocedure \ No newline at end of file diff --git a/src/C4Sharp/Resources/plantuml.jar b/src/C4Sharp/Resources/plantuml.jar index 65b4894..b387226 100644 Binary files a/src/C4Sharp/Resources/plantuml.jar and b/src/C4Sharp/Resources/plantuml.jar differ diff --git a/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs b/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs index c2dec08..a9324fe 100644 --- a/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs +++ b/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs @@ -1,5 +1,5 @@ using C4Sharp.Diagrams; -using C4Sharp.Elements.Plantuml.IO; +using C4Sharp.Diagrams.Plantuml; using Xunit; using ComponentDiagram = C4Sharp.Sample.Diagrams.ComponentDiagram; using ContainerDiagram = C4Sharp.Sample.Diagrams.ContainerDiagram;