Multilingual Wiki Documentation

You are currently using syntax.
In an attempt to improve PlantUML documentation...
Please do not use this website for your own diagrams.
You can click here and use the online server here for your own documentation.

Wiki Toc    View page history    Add new chapter    Reorder page    Raw


オブジェクト図

Object Diagram

オブジェクト図とは、特定の時点でのオブジェクトとその関係を示すグラフィカルな 表現です。

PlantUMLは、プレーンテキストを使用してオブジェクトダイアグラムを 作成する、シンプルで直感的な方法を提供します。そのユーザフレンドリな構文は、複雑な GUI ツールを必要とすることなく、迅速なダイアグラムの作成を可能にします。さらに、PlantUML フォーラムは、ユーザが議論し、共有し、支援を求めるための プラットフォームを提供し、協力的なコミュニティを育成します。PlantUML を選択することで、ユーザはマークダウンベースのダイアグラム作成の効率性と、活発なコミュニティのサポートの両方から恩恵を受けることができます。

An object diagram is a graphical representation that showcases objects and their relationships at a specific moment in time. It provides a snapshot of the system's structure, capturing the static view of the instances present and their associations.

PlantUML offers a simple and intuitive way to create object diagrams using plain text. Its user-friendly syntax allows for quick diagram creation without the need for complex GUI tools. Moreover, the PlantUML forum provides a platform for users to discuss, share, and seek assistance, fostering a collaborative community. By choosing PlantUML, users benefit from both the efficiency of markdown-based diagramming and the support of an active community.

オブジェクトの定義

Definition of objects

オブジェクトのインスタンスを、キーワード object を使用して定義します。

@startuml
object firstObject
object "My Second Object" as o2
@enduml

You define instances of objects using the object keyword.

@startuml
object firstObject
object "My Second Object" as o2
@enduml

オブジェクト間の関係

Relations between objects

オブジェクト間の関係は次の記号を用いて定義します:

Type Symbol Image
Extension <|--
Composition *--
Aggregation o--

--.. に置き換えることで点線を示すことができます。

これらのルールを知ることで、以下の図を描くことができます。

関係にラベルをつけることができ、: を用い、ラベルの文字列を続けます。

関係の各側のスペースを含む文字列を引用符 "" で囲むことができます。

@startuml
object Object01
object Object02
object Object03
object Object04
object Object05
object Object06
object Object07
object Object08

Object01 <|-- Object02
Object03 *-- Object04
Object05 o-- "4" Object06
Object07 .. Object08 : some labels
@enduml

Relations between objects are defined using the following symbols :

Type Symbol Image
Extension <|--
Composition *--
Aggregation o--

It is possible to replace -- by .. to have a dotted line.

Knowing those rules, it is possible to draw the following drawings.

It is possible a add a label on the relation, using : followed by the text of the label.

For cardinality, you can use double-quotes "" on each side of the relation.

@startuml
object Object01
object Object02
object Object03
object Object04
object Object05
object Object06
object Object07
object Object08

Object01 <|-- Object02
Object03 *-- Object04
Object05 o-- "4" Object06
Object07 .. Object08 : some labels
@enduml

n-項関連

Associations objects

@startuml
object o1
object o2
diamond dia
object o3

o1  --> dia
o2  --> dia
dia --> o3
@enduml

@startuml
object o1
object o2
diamond dia
object o3

o1  --> dia
o2  --> dia
dia --> o3
@enduml

フィールドの追加

Adding fields

フィールドを宣言するには、シンボル : にフィールド名を続けます。

@startuml

object user

user : name = "Dummy"
user : id = 123

@enduml

全てのフィールドを括弧 {} で括って範囲を示すことも可能です。

@startuml

object user {
  name = "Dummy"
  id = 123
}

@enduml

To declare fields, you can use the symbol : followed by the field's name.

@startuml

object user

user : name = "Dummy"
user : id = 123

@enduml

It is also possible to group all fields between brackets {}.

@startuml

object user {
  name = "Dummy"
  id = 123
}

@enduml

クラス図と共通の機能

Common features with class diagrams

マップテーブル(連想配列)

Map table or associative array

mapキーワードとセパレータ=>を使って、マップテーブル(連想配列)を定義することができます。

@startuml
map CapitalCity {
 UK => London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
map "Map **Contry => CapitalCity**" as CC {
 UK => London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
map "map: Map<Integer, String>" as users {
 1 => Alice
 2 => Bob
 3 => Charlie
}
@enduml

オブジェクトにリンクを追加します。

@startuml
object London

map CapitalCity {
 UK *-> London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
object London
object Washington
object Berlin
object NewYork

map CapitalCity {
 UK *-> London
 USA *--> Washington
 Germany *---> Berlin
}

NewYork --> CapitalCity::USA
@enduml

[Ref. #307]

@startuml
package foo {
    object baz
}

package bar {
    map A {
        b *-> foo.baz
        c =>
    }
}

A::c --> foo
@enduml

[Ref. QA-12934]

@startuml
object Foo
map Bar {
  abc=>
  def=>
}
object Baz

Bar::abc --> Baz : Label one
Foo --> Bar::def : Label two
@enduml

[Ref. #307]

You can define a map table or associative array, with map keyword and => separator.

@startuml
map CapitalCity {
 UK => London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
map "Map **Contry => CapitalCity**" as CC {
 UK => London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
map "map: Map<Integer, String>" as users {
 1 => Alice
 2 => Bob
 3 => Charlie
}
@enduml

And add link with object.

@startuml
object London

map CapitalCity {
 UK *-> London
 USA => Washington
 Germany => Berlin
}
@enduml

@startuml
object London
object Washington
object Berlin
object NewYork

map CapitalCity {
 UK *-> London
 USA *--> Washington
 Germany *---> Berlin
}

NewYork --> CapitalCity::USA
@enduml

[Ref. #307]

@startuml
package foo {
    object baz
}

package bar {
    map A {
        b *-> foo.baz
        c =>
    }
}

A::c --> foo
@enduml

[Ref. QA-12934]

@startuml
object Foo
map Bar {
  abc=>
  def=>
}
object Baz

Bar::abc --> Baz : Label one
Foo --> Bar::def : Label two
@enduml

[Ref. #307]

mapを利用してPERT(Program Evaluation and Review Technique)図を作成する

Program (or project) evaluation and review technique (PERT) with map

map tableを利用してPERT(Program (or Project) Evaluation and Review Technique)図を作成できます。

@startuml PERT
left to right direction
' Horizontal lines: -->, <--, <-->
' Vertical lines: ->, <-, <->
title PERT: Project Name

map Kick.Off {
}
map task.1 {
    Start => End
}
map task.2 {
    Start => End
}
map task.3 {
    Start => End
}
map task.4 {
    Start => End
}
map task.5 {
    Start => End
}
Kick.Off --> task.1 : Label 1
Kick.Off --> task.2 : Label 2
Kick.Off --> task.3 : Label 3
task.1 --> task.4
task.2 --> task.4
task.3 --> task.4
task.4 --> task.5 : Label 4
@enduml

[Ref. QA-12337]

You can use map table in order to make Program (or project) evaluation and review technique (PERT) diagram.

@startuml PERT
left to right direction
' Horizontal lines: -->, <--, <-->
' Vertical lines: ->, <-, <->
title PERT: Project Name

map Kick.Off {
}
map task.1 {
    Start => End
}
map task.2 {
    Start => End
}
map task.3 {
    Start => End
}
map task.4 {
    Start => End
}
map task.5 {
    Start => End
}
Kick.Off --> task.1 : Label 1
Kick.Off --> task.2 : Label 2
Kick.Off --> task.3 : Label 3
task.1 --> task.4
task.2 --> task.4
task.3 --> task.4
task.4 --> task.5 : Label 4
@enduml

[Ref. QA-12337]

Display JSON Data on Class or Object diagram

Simple example

@startuml
class Class
object Object
json JSON {
   "fruit":"Apple",
   "size":"Large",
   "color": ["Red", "Green"]
}
@enduml

[Ref. QA-15481]

For another example, see on JSON page.


Please report any bugs to plantuml@gmail.com or here.
This website is still in beta testing.