I am trying to create UML diagram with plantuml, this is my diagram:
@startuml
'https://plantuml.com/component-diagram
together {
class Rice {
}
class Egg extends IIngredient{
}
class Avocado extends IIngredient{
}
IIngredient <|-- Rice
}
abstract class IIngredient {
@protected
List<String>? allergens;
@protected
String? name;
@protected
int? price;
String? getAllergens()
String? getName()
int? getPrice()
}
class Salmon {
}
class Tuna {
}
IIngredient <|-- Salmon
IIngredient <|-- Tuna
class Sesame extends IIngredient{
}
class Crisp extends IIngredient {
}
@enduml
the result is :
I want to IIngredient is center and other classes around it like this:
something like this:
Here's my take.
implements
or extends
means vertical alignment for inheritance. Using -r-|>
forces the inheritance link in a direction (l, r, u, d) as mentioned by @Christophe.r
and l
relationship, as more than one will result in links that curve around. The multiple u
or d
flow nicely.u
or d
on the links.interface IIngredient ...
and you should change your relationships to be .r.|>
to show dashed lines (for implements).@startuml
hide empty members
abstract class IIngredient {
' # means protected visibility
' UML syntax name : type for attributes
' no "optional" like "?" in typescript
#allergens:List<String>
#name:String
#price:int
getAllergens():String
getName():String
getPrice():int
}
Egg -d-|> IIngredient
Avocado -d-|> IIngredient
Rice -d-|> IIngredient
Salmon -u-|> IIngredient
Tuna -u-|> IIngredient
Sesame -l-|> IIngredient
Crisp -r-|> IIngredient
@enduml