-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,493 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 0 additions & 112 deletions
112
...n/kotlin/com/github/chriskn/structurizrextension/api/view/style/ElementStyleExtensions.kt
This file was deleted.
Oops, something went wrong.
45 changes: 41 additions & 4 deletions
45
...in/kotlin/com/github/chriskn/structurizrextension/api/view/style/ViewSetStyleExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,52 @@ | ||
package com.github.chriskn.structurizrextension.api.view.style | ||
|
||
import com.structurizr.view.ElementStyle | ||
import com.github.chriskn.structurizrextension.api.view.style.styles.BoundaryStyle | ||
import com.github.chriskn.structurizrextension.api.view.style.styles.ElementStyle | ||
import com.github.chriskn.structurizrextension.api.view.style.styles.PersonStyle | ||
import com.github.chriskn.structurizrextension.internal.export.view.style.boundaryStyleFromJson | ||
import com.github.chriskn.structurizrextension.internal.export.view.style.elementStyleFromJson | ||
import com.github.chriskn.structurizrextension.internal.export.view.style.personStyleFromJson | ||
import com.github.chriskn.structurizrextension.internal.export.view.style.toJson | ||
import com.structurizr.view.ViewSet | ||
import com.structurizr.view.clearBoundaryStyles | ||
import com.structurizr.view.clearElementStyles | ||
import com.structurizr.view.clearPersonStyles | ||
|
||
fun ViewSet.addElementStyle(elementStyle: ElementStyle) { | ||
this.configuration.styles.add(elementStyle) | ||
this.configuration.addProperty("$ELEMENT_STYLE_PROPERTY_NAME_PREFIX:${elementStyle.tag}", elementStyle.toJson()) | ||
} | ||
|
||
fun ViewSet.getElementStyles(): List<ElementStyle> = | ||
this.configuration.styles.elements.toList() | ||
this.configuration.properties | ||
.filter { it.key.startsWith(ELEMENT_STYLE_PROPERTY_NAME_PREFIX) } | ||
.map { elementStyleFromJson(it.value) } | ||
|
||
internal fun ViewSet.clearElementStyles() { | ||
this.configuration.styles.elements.clear() | ||
this.configuration.clearElementStyles() | ||
} | ||
|
||
fun ViewSet.addBoundaryStyle(boundaryStyle: BoundaryStyle) { | ||
this.configuration.addProperty("$BOUNDARY_STYLE_PROPERTY_NAME_PREFIX:${boundaryStyle.tag}", boundaryStyle.toJson()) | ||
} | ||
|
||
fun ViewSet.getBoundaryStyles(): List<BoundaryStyle> = | ||
this.configuration.properties | ||
.filter { it.key.startsWith(BOUNDARY_STYLE_PROPERTY_NAME_PREFIX) } | ||
.map { boundaryStyleFromJson(it.value) } | ||
|
||
internal fun ViewSet.clearBoundaryStyles() { | ||
this.configuration.clearBoundaryStyles() | ||
} | ||
|
||
fun ViewSet.addPersonStyle(personStyle: PersonStyle) { | ||
this.configuration.addProperty("$PERSON_STYLE_PROPERTY_NAME_PREFIX:${personStyle.tag}", personStyle.toJson()) | ||
} | ||
|
||
fun ViewSet.getPersonStyles(): List<PersonStyle> = | ||
this.configuration.properties | ||
.filter { it.key.startsWith(PERSON_STYLE_PROPERTY_NAME_PREFIX) } | ||
.map { personStyleFromJson(it.value) } | ||
|
||
internal fun ViewSet.clearPersonStyles() { | ||
this.configuration.clearPersonStyles() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...ain/kotlin/com/github/chriskn/structurizrextension/api/view/style/styles/BoundaryStyle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.github.chriskn.structurizrextension.api.view.style.styles | ||
|
||
import com.github.chriskn.structurizrextension.api.view.style.C4Shape | ||
import com.github.chriskn.structurizrextension.api.view.style.sprite.Sprite | ||
import com.github.chriskn.structurizrextension.api.view.style.toValidColor | ||
import com.structurizr.view.Border | ||
|
||
// TODO doucment | ||
|
||
class BoundaryStyle : C4PumlStyle { | ||
|
||
override val tag: String | ||
override val backgroundColor: String? | ||
override val fontColor: String? | ||
override val border: Border? | ||
override val borderWith: Int? | ||
override val borderColor: String? | ||
override val shadowing: Boolean | ||
override val c4Shape: C4Shape? | ||
override val sprite: Sprite? | ||
override val legendText: String? | ||
override val legendSprite: Sprite? | ||
|
||
@Suppress("LongParameterList") | ||
constructor( | ||
tag: String, | ||
backgroundColor: String? = null, | ||
fontColor: String? = null, | ||
border: Border? = null, | ||
borderWith: Int? = null, | ||
borderColor: String? = null, | ||
shadowing: Boolean = false, | ||
c4Shape: C4Shape? = null, | ||
sprite: Sprite? = null, | ||
legendText: String? = null, | ||
legendSprite: Sprite? = null | ||
) { | ||
require(tag.isNotBlank()) { "tag cannot be blank" } | ||
this.tag = tag | ||
this.backgroundColor = toValidColor(backgroundColor) | ||
this.fontColor = toValidColor(fontColor) | ||
this.border = border | ||
this.borderWith = borderWith | ||
this.borderColor = toValidColor(borderColor) | ||
this.shadowing = shadowing | ||
this.c4Shape = c4Shape | ||
this.sprite = sprite | ||
this.legendText = legendText | ||
this.legendSprite = legendSprite | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as BoundaryStyle | ||
|
||
if (tag != other.tag) return false | ||
if (backgroundColor != other.backgroundColor) return false | ||
if (fontColor != other.fontColor) return false | ||
if (border != other.border) return false | ||
if (borderWith != other.borderWith) return false | ||
if (borderColor != other.borderColor) return false | ||
if (shadowing != other.shadowing) return false | ||
if (c4Shape != other.c4Shape) return false | ||
if (sprite != other.sprite) return false | ||
if (legendText != other.legendText) return false | ||
if (legendSprite != other.legendSprite) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = tag.hashCode() | ||
result = 31 * result + (backgroundColor?.hashCode() ?: 0) | ||
result = 31 * result + (fontColor?.hashCode() ?: 0) | ||
result = 31 * result + (border?.hashCode() ?: 0) | ||
result = 31 * result + (borderWith ?: 0) | ||
result = 31 * result + (borderColor?.hashCode() ?: 0) | ||
result = 31 * result + shadowing.hashCode() | ||
result = 31 * result + (c4Shape?.hashCode() ?: 0) | ||
result = 31 * result + (sprite?.hashCode() ?: 0) | ||
result = 31 * result + (legendText?.hashCode() ?: 0) | ||
result = 31 * result + (legendSprite?.hashCode() ?: 0) | ||
return result | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/github/chriskn/structurizrextension/api/view/style/styles/C4PumlStyle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.chriskn.structurizrextension.api.view.style.styles | ||
|
||
import com.github.chriskn.structurizrextension.api.view.style.C4Shape | ||
import com.github.chriskn.structurizrextension.api.view.style.sprite.Sprite | ||
import com.structurizr.view.Border | ||
|
||
// TODO move to internal package | ||
interface C4PumlStyle { | ||
val tag: String | ||
val backgroundColor: String? | ||
val fontColor: String? | ||
val border: Border? | ||
val borderWith: Int? | ||
val borderColor: String? | ||
val shadowing: Boolean | ||
val c4Shape: C4Shape? | ||
val sprite: Sprite? | ||
val legendText: String? | ||
val legendSprite: Sprite? | ||
} |
Oops, something went wrong.