Monday 5 June 2023

PlantUML: Specify the visibility of members in a class

Below table summarizes the visibility levels supported by PlantUML.

 

Symbol

Description

-

private

#

protected

~

package private

+

public

 

 

specifyVisibilityOfMembers.txt

@startuml

class MyClass{
	-field1
	#field2
	~field3
	+field4

	-method1()
	#method2()
	~method3()
	+method4()
}

@enduml

 


 

From the above diagram, you can notice that different icons are used for various visibility levels. You can turn off these icons using below command.

 

skinparam classAttributeIconSize 0

 

specifyVisibilityOfMembers2.txt

@startuml

skinparam classAttributeIconSize 0

class MyClass{
	-field1
	#field2
	~field3
	+field4

	-method1()
	#method2()
	~method3()
	+method4()
}

@enduml

Above snippet generate below diagram.




Previous                                                    Next                                                    Home

No comments:

Post a Comment