Monday, 19 June 2023

PlantUML: Add notes to the entities in a class diagram

Notes to the entities is defined using below keywords.

a.   note left of

b.   note right of

c.    note top of

d.   note bottom of

 

Example

note top of List : An ordered collection

note left of AbstractList : implements List interface

note right of ArrayList : Resizable-array implementation \n of the List interface

note bottom of Serializable : Serializability of a class is enabled \n by the class implementing this

 

 

notes.txt

@startuml

interface List{
	
}

abstract class AbstractList implements List{
	
}

interface Serializable{
	
}

class ArrayList extends AbstractList implements Serializable{
	
}

note top of List : An ordered collection 
note left of AbstractList : implements List interface
note right of ArrayList : Resizable-array implementation \n of the List interface
note bottom of Serializable : Serializability of a class is enabled \n by the class implementing this

@enduml

Above snippet generate below diagram.



You can define notes on last defined class using below keywords.

 

a.   note left

b.    note right

c.    note top

d.   note bottom

 

notes2.txt

 

@startuml

interface List{
	
}
note top: An ordered collection 


abstract class AbstractList{
	
}
note left: implements List interface


interface Serializable{
	
}
note bottom : Serializability of a class is enabled \n by the class implementing this


class ArrayList{
	
}
note right: Resizable-array implementation \n of the List interface

List <|.. AbstractList
AbstractList <|-- ArrayList
Serializable <|.. ArrayList

@enduml

 

Above snippet generate below diagram.


 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment