Sunday, 5 November 2023

Enriching Swimlanes with Colors in PlantUML Activity Diagrams

A swimlane diagram is a type of flowchart that delineates who does what in a process. We can define swimlanes using pipe | symbol.

 

Example

|swimlane1|

 

Using #color notation, we can add colors to the lane.

 

Example

|#gold|lane1|

 

Above statement add gold color to the lane1.

 

addColorLane.txt

@startuml

|#gold|lane1|
	start
	:activity1;
|#palegreen|lane2|
	:activtiy3;
	:activtiy4;
|#aqua|lane3|
	:activtiy5;
|lane1|
:activtiy6;
:activtiy7;
|lane3|
	:activtiy8;
|lane2|
	:activtiy9;
	:activtiy10;

stop
@enduml

 

Above snippet generate below diagram.



You can use, conditional statements (if, if else if ladder), loops (while, repeat) inside swimlanes.

 

Find the below example.

 

swimLane2.txt

@startuml

|#gold|Customer|
	start
	:Insert card;
	:Enter pin;
|#palegreen|ATM|
|#aqua|Bank|
	if (pin is correct) then (yes)
		|Customer|
		:Enter amount;

		|Bank|
		:Check account balance;

		if (entered amount > balance) then (yes)
			|Customer|
			:Insuffecient funds in the account;
		else (suffecient balance)
			|ATM|
			:Give the money to customer;
			:Show home page screen;
		endif
	else (no)
    	|Customer|
		:Invalid pin;
	endif
stop
@enduml

 

Above snippet generate below diagram.

 


  


  

Previous                                                    Next                                                    Home

No comments:

Post a Comment