Skip to content

Commit

Permalink
Split API and internal packages
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskn committed Jun 21, 2024
1 parent 9e2a58b commit 0579a0a
Show file tree
Hide file tree
Showing 49 changed files with 578 additions and 626 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "io.github.chriskn"
version = "0.11.0"
version = "0.11.1"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.chriskn.structurizrextension
package com.github.chriskn.structurizrextension.api

import com.github.chriskn.structurizrextension.export.ExtendedC4PlantUMLExporter
import com.github.chriskn.structurizrextension.internal.export.ExtendedC4PlantUMLExporter
import com.structurizr.Workspace
import com.structurizr.export.Diagram
import java.io.BufferedWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

private const val MAX_ROW_SIZE = 4

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.export.plantuml.C4PlantUMLExporter
import com.structurizr.model.Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Component
import com.structurizr.model.Container
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Element
import com.structurizr.model.InteractionStyle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Container
import com.structurizr.model.DeploymentElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Container
import com.structurizr.model.Location
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Container
import com.structurizr.model.DeploymentElement
Expand All @@ -9,6 +9,17 @@ import com.structurizr.model.Person
import com.structurizr.model.SoftwareSystem
import com.structurizr.model.StaticStructureElement

private const val ENTERPRISE_NAME_PROPERTY = "enterprise:name"

/**
* Stores the name of the enterprise this model belongs to if set
*/
var Model.enterpriseName: String?
set(name) {
this.addProperty(ENTERPRISE_NAME_PROPERTY, name)
}
get() = this.properties[ENTERPRISE_NAME_PROPERTY]

/**
* Adds a person.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.ModelItem

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.Container
import com.structurizr.model.Location
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chriskn.structurizrextension.model
package com.github.chriskn.structurizrextension.api.model

import com.structurizr.model.InteractionStyle
import com.structurizr.model.Person
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.chriskn.structurizrextension.api.view

import com.structurizr.view.ComponentView
import com.structurizr.view.ContainerView
import com.structurizr.view.DynamicView
import com.structurizr.view.SystemContextView
import com.structurizr.view.SystemLandscapeView

private const val SHOW_BOUNDARY_PROPERTY = "SHOW_BOUNDARY"

var DynamicView.showExternalBoundaries: Boolean
get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean()
set(value) {
this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString())
}

var ContainerView.showExternalSoftwareSystemBoundaries: Boolean
get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean()
set(value) {
this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString())
}

var ComponentView.showExternalContainerBoundaries: Boolean
get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean()
set(value) {
this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString())
}

var SystemLandscapeView.showEnterpriseBoundary: Boolean
get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean()
set(value) {
this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString())
}

var SystemContextView.showEnterpriseBoundary: Boolean
get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean()
set(value) {
this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString())
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.chriskn.structurizrextension.view
package com.github.chriskn.structurizrextension.api.view

import com.github.chriskn.structurizrextension.plantuml.C4PlantUmlLayout
import com.github.chriskn.structurizrextension.api.view.layout.C4PlantUmlLayout
import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.structurizr.model.Container
import com.structurizr.model.SoftwareSystem
import com.structurizr.view.ComponentView
Expand All @@ -10,7 +11,6 @@ import com.structurizr.view.DynamicView
import com.structurizr.view.SystemContextView
import com.structurizr.view.SystemLandscapeView
import com.structurizr.view.ViewSet
import com.structurizr.view.showEnterpriseBoundary

/**
* Creates a system landscape view.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.chriskn.structurizrextension.view
package com.github.chriskn.structurizrextension.api.view.dynamic

import com.structurizr.model.StaticStructureElement
import com.structurizr.view.DynamicView
import com.structurizr.view.RelationshipView
import com.structurizr.view.publicOrder
import com.structurizr.view.orderInternal

private const val NUMBER_OF_ENDED_PARALLEL_FLOWS = "NUMBER_OF_PARALLEL_ROOT_SEQUENCES"
private const val AS_SEQUENCE_DIAGRAM = "plantuml.sequenceDiagram"
Expand All @@ -27,7 +27,7 @@ fun DynamicView.add(
technology: String? = null,
): RelationshipView {
val relationshipView = this.add(source, description, technology, destination)
relationshipView.publicOrder = (relationshipView.order.toInt() + this.numberOfEndedParallelFlows).toString()
relationshipView.orderInternal = (relationshipView.order.toInt() + this.numberOfEndedParallelFlows).toString()
return relationshipView
}

Expand All @@ -46,10 +46,10 @@ fun DynamicView.startNestedParallelSequence(): NestedParallelSequenceContext {

var DynamicView.numberOfEndedParallelFlows: Int
get() {
return this.properties.getOrDefault(NUMBER_OF_ENDED_PARALLEL_FLOWS, "0").toInt()
return properties.getOrDefault(NUMBER_OF_ENDED_PARALLEL_FLOWS, "0").toInt()
}
set(value) {
this.addProperty(NUMBER_OF_ENDED_PARALLEL_FLOWS, value.toString())
addProperty(NUMBER_OF_ENDED_PARALLEL_FLOWS, value.toString())
}

var DynamicView.renderAsSequenceDiagram: Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.chriskn.structurizrextension.view
package com.github.chriskn.structurizrextension.api.view.dynamic

import com.structurizr.model.StaticStructureElement
import com.structurizr.view.DynamicView
import com.structurizr.view.RelationshipView
import com.structurizr.view.publicOrder
import com.structurizr.view.orderInternal

/**
* Wrapper around [DynamicView] to manage nested numbering for parallel sequences.
Expand Down Expand Up @@ -45,12 +45,12 @@ data class NestedParallelSequenceContext(
description = description,
technology = technology
)
view.publicOrder = getNextOder()
view.orderInternal = getNextOrder()

return view
}

private fun getNextOder(): String {
private fun getNextOrder(): String {
latestOrder = "$startOrder.${++parallelCounter}"
return latestOrder
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
package com.github.chriskn.structurizrextension.plantuml
package com.github.chriskn.structurizrextension.api.view.layout

import com.github.chriskn.structurizrextension.plantuml.Direction.Down
import com.github.chriskn.structurizrextension.plantuml.Direction.Left
import com.github.chriskn.structurizrextension.plantuml.Direction.Right
import com.github.chriskn.structurizrextension.plantuml.Direction.Up
import com.github.chriskn.structurizrextension.plantuml.Layout.Landscape
import com.github.chriskn.structurizrextension.plantuml.Layout.LeftToRight
import com.github.chriskn.structurizrextension.plantuml.Layout.TopDown
import com.github.chriskn.structurizrextension.plantuml.Legend.None
import com.github.chriskn.structurizrextension.plantuml.Legend.ShowFloatingLegend
import com.github.chriskn.structurizrextension.plantuml.Legend.ShowLegend
import com.github.chriskn.structurizrextension.plantuml.Legend.ShowStaticLegend
import com.github.chriskn.structurizrextension.plantuml.LineType.Ortho
import com.github.chriskn.structurizrextension.plantuml.LineType.Polyline
import com.github.chriskn.structurizrextension.plantuml.Mode.Back
import com.github.chriskn.structurizrextension.plantuml.Mode.BackNeighbor
import com.github.chriskn.structurizrextension.plantuml.Mode.Neighbor
import com.github.chriskn.structurizrextension.plantuml.Mode.Rel
import com.github.chriskn.structurizrextension.plantuml.Mode.RelIndex
import com.github.chriskn.structurizrextension.api.view.layout.Layout.TopDown
import com.github.chriskn.structurizrextension.api.view.layout.Legend.None
import com.github.chriskn.structurizrextension.api.view.layout.Legend.ShowLegend
import com.structurizr.model.Relationship

/**
* Allows the configuration of the layout for generated C4-PlantUML diagram.
*
* @param nodeSep the PlantUML nodesep skinparam in order to control the distance between nodes
* @param rankSep the PlantUML ranksep skinparam in order to control the distance between ranks
* @param lineType the PlantUML [LineType] skinparam
* @param layout the C4PlantUML [Layout]. [TopDown] is default
* @param layout the C4PlantUML [Legend]. [ShowLegend] is default
* @param showPersonOutline activates person outline instead of a rectangle (default is true)
* @param hideStereotypes hides stereotypes when rendering elements (default is true)
* @param dependencyConfigurations list of [DependencyConfiguration]
*/
data class C4PlantUmlLayout(
val nodeSep: Int? = null,
val rankSep: Int? = null,
val lineType: LineType? = null,
val layout: Layout = TopDown,
val legend: Legend = ShowLegend,
val showPersonOutline: Boolean = true,
val hideStereotypes: Boolean = true,
val dependencyConfigurations: List<DependencyConfiguration> = listOf()
) {
internal fun hasPostamble(): Boolean = nodeSep != null || rankSep != null || lineType != null || legend != None
}

/**
* Options for the PlanUML skinparam linetype.
*
Expand Down Expand Up @@ -112,28 +122,3 @@ data class DependencyConfiguration(
val mode: Mode? = null,
val direction: Direction? = null
)

/**
* Allows the configuration of the layout for generated C4-PlantUML diagram.
*
* @param nodeSep the PlantUML nodesep skinparam in order to control the distance between nodes
* @param rankSep the PlantUML ranksep skinparam in order to control the distance between ranks
* @param lineType the PlantUML [LineType] skinparam
* @param layout the C4PlantUML [Layout]. [TopDown] is default
* @param layout the C4PlantUML [Legend]. [ShowLegend] is default
* @param showPersonOutline activates person outline instead of a rectangle (default is true)
* @param hideStereotypes hides stereotypes when rendering elements (default is true)
* @param dependencyConfigurations list of [DependencyConfiguration]
*/
data class C4PlantUmlLayout(
val nodeSep: Int? = null,
val rankSep: Int? = null,
val lineType: LineType? = null,
val layout: Layout = TopDown,
val legend: Legend = ShowLegend,
val showPersonOutline: Boolean = true,
val hideStereotypes: Boolean = true,
val dependencyConfigurations: List<DependencyConfiguration> = listOf()
) {
fun hasPostamble(): Boolean = nodeSep != null || rankSep != null || lineType != null || legend != None
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package com.github.chriskn.structurizrextension.view

import com.github.chriskn.structurizrextension.plantuml.C4PlantUmlLayout
package com.github.chriskn.structurizrextension.api.view.layout

object LayoutRegistry {

Expand Down

This file was deleted.

Loading

0 comments on commit 0579a0a

Please sign in to comment.