You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/05/31 15:57:59 UTC
[isis] 02/04: ISIS-2505 LayoutDiagram (preview) improved
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch ISIS-2505_Catch_Up_With_Demo_Examples
in repository https://gitbox.apache.org/repos/asf/isis.git
commit a811857dcf7eab678ccb601033d68d304f92da24
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu May 27 21:07:23 2021 +0200
ISIS-2505 LayoutDiagram (preview) improved
---
.../isis/client/kroviz/ui/diagram/LayoutDiagram.kt | 34 +++++++++-------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
index 3ca9752..6654da6 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
@@ -24,42 +24,36 @@ import org.apache.isis.client.kroviz.to.bs3.Row
object LayoutDiagram {
- @Deprecated("pass in as arg")
- val sampleCode = "@startsalt\n" +
- "{#\n" +
- ". | Column 2 | Column 3\n" +
- "Row header 1 | value 1 | value 2\n" +
- "Row header 2 | A long cell | *\n" +
- "}\n" +
- "@endsalt"
-
fun build(grid: Grid): String {
var pumlCode = "@startsalt\n{#\n"
- grid.rows.forEach {
- pumlCode += buildRow(it)
+ grid.rows.forEachIndexed() { index, it ->
+ val rLabel = "r" + index.toString()
+ pumlCode += buildRow(it, rLabel)
}
return pumlCode + "}\n@endsalt"
}
- val blue = "<color:Blue>"
- val green = "<color:Green>"
- private fun buildRow(row: Row): String {
+ private val blue = "<color:Blue>"
+ private val red = "<color:Red>"
+ private fun buildRow(row: Row, rLabel: String): String {
var s = ""
row.colList.forEachIndexed() { index, it ->
- if (index % 2 == 0)
- s += buildCol(it, blue)
- else
- s += buildCol(it, green)
+ val cLabel = rLabel + ".c" + index.toString()
+ if (index % 2 == 0) {
+ s += buildCol(it, blue, cLabel)
+ } else {
+ s += buildCol(it, red, cLabel)
+ }
}
s = s.dropLast(1)
return s + "\n"
}
- private fun buildCol(col: Col, colorCode: String): String {
+ private fun buildCol(col: Col, colorCode: String, label: String): String {
var s = ""
val span: Int = col.span
repeat(span) {
- s += "$colorCode C |"
+ s += "$colorCode $label |"
}
return s
}