Saturday, 15 July 2023

PlantUML: hide and show members in class diagram

diagram1.txt

@startuml

class Employee{
	int id
	String name
	int age

	String aboutMe()
}

class Manager{
	int noOfReportees
}

Employee <|-- Manager

@enduml

Above snippet generate below diagram.

 


How to hide members (fields, methods) in the class diagram?

Using the keyword ‘hide members’, we can hide the members of class diagram.

 

hideMembers.txt

@startuml

hide members

class Employee{
	int id
	String name
	int age

	String aboutMe()
}

class Manager{
	int noOfReportees
}

Employee <|-- Manager

@enduml

Above snippet generate below diagram.


 


 

How to show specific entity members, fields?

show Class methods

show Class fields

 

For example, below snippet show Manager class fields and Employee class methods

 

show Manager fields

show Employee methods

 

 

showMembers.txt

@startuml

hide members

class Employee{
	int id
	String name
	int age

	String aboutMe()
}

class Manager{
	int noOfReportees
}

Employee <|-- Manager

' Show Manager field and Employee methods
show Manager fields
show Employee methods

@enduml

 

Above snippet generate below diagram.

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment