Sunday, 16 July 2023

PlantUML: Hide and show stereotype in a class diagram

Following commands used to hide, show stereotypes.

 

Example1: Hide stereotype for all the members

hide stereotype

 

Example 2: Show stereotype for all the members. This is the default behavior.

 

show stereotype

 

Example 3: Hide stereotype for all the members except for Employee class.

 

hide stereotype

show Employee stereotype

 

Example 4: Show stereotype for all the members, except for Employee class.

 

hide Employee stereotype

 

defaultStereotype.txt

@startuml

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

 

Above snippet generate below diagram.

 

 


Hide stereotype for all the members

 

hideStereotypeForAll.txt

@startuml

hide stereotype

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

Above snippet generate below diagram.


 


Hide stereotype for all the members except for Employee class.

 

showStereotypeForEmployeeOnly.txt

@startuml

hide stereotype
show Employee stereotype

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

 

Above snippet generate below diagram.

 

 


Show stereotype for all the members, except for Employee class.

 

hideStereotypeForEmployeeClassOnly.txt

@startuml

hide Employee stereotype

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

Above snippet generate below diagram.





Previous                                                    Next                                                    Home

No comments:

Post a Comment