PlantUML Examples

Class Diagram

Diagram
@startuml
class "Class A" as a
class "Class B" as b
class "Class C" as c
class "Class D" as d
class "Class E" as e
a -- b
a o- c
a *-up- d
a -left-> e
@enduml

Class Diagram: Associations

Diagram
@startuml
class "Class A" as a
class "Class B" as b

a "role a" - "role b" b : "Association Name"
@enduml

Object Diagram

Diagram
@startuml
object "<u>a:Class A" as a {
    name = "object a"
}
object "<u>b:Class B" as b {
    id = "object b"
}

a --> b
@enduml

Package Diagram

Diagram
@startuml
package "neoemf-commons" as commons {}
package "neoemf-core" as core {}
package "neoemf-data" as data {
    package berkeleydb {}
    package blueprints {}
    package hbase {}
    package mapdb {}
    package mongodb {}

    mongodb .[hidden]. hbase 
    mapdb .[hidden]. blueprints
}
package "neoemf-io" as io {}

core ..> commons : << import >>
data ..> commons : << import >>
io ..> commons : << import >>

core <. data : << access >>
core <. io : << access >>
data <. io: << access >>

note left of commons
Responsible for logging,
checking preconditions,
generic operations, etc.
end note

note top of core
Main component,
specifies main interfaces
end note
@enduml

Use Case Diagram

Diagram
@startuml
left to right direction

actor Client as client
actor "Cash Provider" as provider
actor Engineer as engineer

rectangle "Cash Dispenser" as atm {
usecase Withdraw as withdraw
usecase "Browse last operations" as browse
usecase "Insert Cash" as insert
usecase "Extract broken cards" as extract
usecase "Perform maintenance" as maintenance
}

client "[1]" -- "[1]" withdraw 
client -- browse

provider -- insert

extract -- engineer
maintenance -- engineer
@enduml

Sequence Diagram

Diagram
@startuml

box "UI Layer" #LightBlue
    actor Cashier
    boundary SaleJFrame
end box

box "Domain Layer" #LightGrey
    participant Unknown
end box

Cashier -> SaleJFrame : actionPerformed(actionEvent)
SaleJFrame -> Unknown : enterItem(itemID, qty)

center footer
From [Larman 2004]
endfooter
@enduml

System Sequence Diagram (Scenarios)

Diagram
@startuml

actor "__Paul : Client__" as paul
participant "__:ATM__" as ATM

paul -> ATM : Insert Card
ATM -> ATM  : Check Card
ATM -> paul : Request Code
paul -> ATM : '1234'
ATM -> ATM  : Check Code
ATM -> paul : Wrong Code
ATM -> paul : Request Code
paul -> ATM : '2528'

@enduml

Entity-control-boundary (ECB)

Diagram
@startuml

participant Participant as Foo
actor       Actor       as Foo1
boundary    Boundary    as Foo2
control     Control     as Foo3
entity      Entity      as Foo4
database    Database    as Foo5
collections Collections as Foo6
queue       Queue       as Foo7
Foo -> Foo1 : To actor 
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue

@enduml

Enumeration and Datatypes

Diagram
@startuml
class Date  <<Datatype>> {
    day   : Integer
    month : Integer
    year  : Integer
}

enum Temperature <<enumeration>> {
    Cold
    Hot
}
@enduml

Interfaces

Diagram
@startuml
interface "Serializable" as seri <<interface>> {
    read()
    write()
}

class "Exporter" as exp {
    write()
}

class "HTMLPage" as page {
    title : String
    size : Integer
    render()
    save()
}
seri <|.. page 
seri <..right.. exp : <<uses>>

() Serializable
HTMLPage - Serializable : "\t\t"
Serializable )- Exporter : "\t\t"

page -[hidden]- HTMLPage
@enduml

Components

Diagram
@startuml
left to right direction 

component Server {
    portout "WebSockets" as sws
}

interface Play

component Client {
    portin "WebSockets" as cws
}

sws --() Play
Play  )-- cws
@enduml

PlantUML Configuration File

Configuration File for this Presentation
skinparam {
 
	' use the strictuml style - no circles, no footboxes, no drop shadows, and proper arrows
	' Style strictuml
 
	BackgroundColor transparent
 
	TitleFontName Helvetica
	TitleFontStyle Bold
	TitleFontSize 12
	sequenceParticipant underline
	Guillemet true
	
	Default {
		TextAlignment center
		FontName Helvetica
	}
	
	Sequence {
		LifeLine {
			BackgroundColor LightGrey
			BorderColor DarkBlue
		}
		
		Arrow {
			Color DarkBlue
			Thickness 0.5
		}
		
		' FontColor #FF0000
		' FontName Helvetica Neue
		' FontStyle Light
		
		
		Actor {
			BorderThickness 0.5
			FontSize 5
			BackgroundColor #F2F2F2
			BorderColor DarkBlue
		}
		
		Participant {
			BorderThickness 0.5
			BackgroundColor White
			BorderColor DarkBlue
			Font {
				Style Light
				Size 10
				Name Helvetica Neue
			}
		}

		Box {
			BackgroundColor #F2F2F2
			BorderColor Black
			FontSize 10
		}
 
		Message {
			Align center
		}
		
		Stereotype {
			Font {
				Size 8
				Style Plain
				Color #515151
			}
		}
	}
	
	Boundary {
		BackgroundColor #F2F2F2
		BorderColor DarkBlue
		FontSize 10			
	}

	Class {
		FontSize 10
		FontName Helvetica Neue
		FontStyle Plain
		BackgroundColor White
		BorderColor Black
		BorderThickness 0.2
		FontColor Black

		Attribute {
			IconSize 0
			FontSize 8
			FontName Helvetica Neue
			FontColor Black
			FontStyle Light
		}

		Stereotype {
			Font {
				Size 8
				Style plain
				Color #515151
			}
		}
	}

	Object {
		FontSize 10
		FontName Helvetica Neue
		FontStyle Underline
		BorderColor DarkBlue
		BorderThickness 0.2
		FontColor DarkBlue
		BackgroundColor White
	}
	
	Note {
		FontSize 8
		FontColor White
		BorderThickness 0.1
		BorderColor DarkBlue
		BackgroundColor #99CCFF
		Shadowing true
	}
	
	Component {
		FontSize 10
		FontName Helvetica Neue
		FontStyle Bold
		BackgroundColor White
		BorderColor Black
		BorderThickness 0.2
		FontColor Black
	}
	
	Interface {
		IconSize 8
		BackgroundColor White
		BorderColor Black
		BorderThickness 0.2
		Font {
			Color Black
			Name Helvetica Neue
			Size 10
			Style Plain
		}
	}
	
	Stereotype {
		IBackgroundColor White
		IBorderColor DarkBlue
	}
	
	CircledCharacter {
		FontSize 10
		FontStyle Plain
	}
	
	Arrow  {
		Font {
			Size 8
			Name Helvetica Neue
			Style Light
		}
		Thickness 0.2
	}

	Activity {
		ArrowThickness 0.2
		BackgroundColor transparent
		Border {
			Color DarkBlue
			Thickness 0.2
		}

		Diamond {
			BackgroundColor #99CCFF
			BorderColor DarkBlue
			BorderThickness 0.2
			FontColor White
		}

		BarColor DarkBlue
	}

	Usecase {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}

	Entity {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}

	Database {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}

	Control {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}

	Collections {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}

	Queue {
		BackgroundColor White
		BorderColor DarkBlue
		FontSize 10
	}
}

hide circle
hide footbox
scale 1024 width
scale 800 height

Useful Links