Skip to content

Commit

Permalink
only scale up PNG diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
slu-it committed Sep 25, 2024
1 parent bffa6be commit 28e1961
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ApplicationContextDiagramGenerator(
appendLine("@startuml")
appendLine("'https://plantuml.com/deployment-diagram")
appendLine()
appendLine("scale 2")
appendLine("scale 1")
appendLine()
appendLine(LEFT_TO_RIGHT)
appendLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MessagingDiagramGenerator(
appendLine("@startuml")
appendLine("'https://plantuml.com/deployment-diagram")
appendLine()
appendLine("scale 2")
appendLine("scale 1")
appendLine()
appendLine("left to right direction")
appendLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MultipleApplicationsDiagramGenerator(
appendLine("@startuml")
appendLine("'https://plantuml.com/deployment-diagram")
appendLine()
appendLine("scale 2")
appendLine("scale 1")
appendLine()
appendLine(options.direction)
appendLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ object PlantUmlDiagramGenerator {
fun generateDiagramAndSaveAsImage(diagramSource: String, outputFolder: File, fileName: String, format: FileFormat) {
val outputFile = File(outputFolder, fileName + format.fileSuffix)
val fileFormatOption = FileFormatOption(format, false)
val reader = SourceStringReader(diagramSource)
val scaledDiagramSource = scale(diagramSource, format)
val reader = SourceStringReader(scaledDiagramSource)

outputFolder.mkdirs()

Expand All @@ -26,4 +27,9 @@ object PlantUmlDiagramGenerator {
.use { fos -> fos.bufferedWriter().use { bw -> bw.write(diagramSource) } }
}
}

private fun scale(diagramSource: String, format: FileFormat) = when (format) {
FileFormat.PNG -> diagramSource.replace("scale 1", "scale 2")
else -> diagramSource
}
}

0 comments on commit 28e1961

Please sign in to comment.