Is it possible to specialize the class type in blueclass and redclass and then define skinparam for both?

0 votes
asked Jan 8, 2023 in Question / help by Avi Sfez
Hello,
To render some classes in blue, and some other in red, I can write the following:
    class Foo #blue {}
    class Bar #pink {}
But what's the simplest way to define style for such a style (without using stereotypes)?
Is it possible to specialize the class type in blueclass and redclass and then define skinparam for both?

1 Answer

0 votes
answered Jan 9, 2023 by Todd Musheno (2,680 points)
What do you mean by "specialize"?
commented Jan 9, 2023 by Avi Sfez
Something like being able to write the following:

blueclass extends class ' define a new `blueclass` type extending the `class`type
redclass extends class
skinparam blueclass { backgroundColor white }  ' define skin for `blueclass` type, not `class` type
skinparam redclass { backgroundColor white }
package {
    blueclass Foo { name: String }
    redclass Bar << Singleton >> { name: String }
    redclass Baz << Facade >> { name: String }
}

That way, all skinparam are define once an my package can create several specialized class.
What I want is to be able to define some skinparam that will apply to some classes but not all classes, and without relying on the UML stereotype which have a different meaning for me.

Any help would be greatly appreciated?

Maybe there is a different way to achieve what I want
commented Jan 10, 2023 by Todd Musheno (2,680 points)

I would like to recommend something like the following...

could actually refactor existing stuff to this (abstract -> #abstract, annotation -> #annotation) such that one can override existing "types" easily as well (the predefined names just become synonyms for the same skinning). But its just my 2 cents. (in my example, I am re-styling all abstract classes)

<style>
    classDiagram {
        types {
            blueclass {
                backgroundColor blue
            }
            redclass {
                backgroundColor red
            }
            abstract {
                backgroundColor green
            }
        }
    }
</style>

package {
    #blueclass Foo { name: String }
    #redclass Bar << Singleton >> { name: String }
    #redclass Baz << Facade >> { name: String }
    abstract Biz { name: String }
}
...