Class UmlClass
Represents a UML Class classifier that defines the structure and behavior of an object in a diagram.
Inherited Members
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.Diagram.dll
Syntax
public class UmlClass : DiagramObject, IDiagramObject, ICloneable
Remarks
The class is rendered with separate compartments for its name, attributes, and methods, and supports customization of section headers, styling, and grouping (including separators).
Examples
DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>();
nodes.Add(new Node()
{
ID = "classNode",
OffsetX = 250,
OffsetY = 250,
Width = 200,
Height = 200,
Style = new ShapeStyle() { Fill = "lightyellow" },
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Animal",
Attributes = new DiagramObjectCollection<UmlClassAttribute>()
{
new UmlClassAttribute() { Name = "name", Type = "string", Scope = UmlScope.Private },
new UmlClassAttribute() { Name = "age", Type = "int", Scope = UmlScope.Private }
},
Methods = new DiagramObjectCollection<UmlClassMethod>()
{
new UmlClassMethod() { Name = "eat", Type = "void", Scope = UmlScope.Public },
new UmlClassMethod()
{
Name = "move",
Type = "void",
Scope = UmlScope.Public,
Parameters = new DiagramObjectCollection<UmlTypedElement>()
{
new UmlTypedElement() { Name = "speed", Type = "int" }
}
}
}
}
}
});
Constructors
UmlClass()
Creates a new instance of the UmlClass.
Declaration
public UmlClass()
UmlClass(UmlClass)
Declaration
public UmlClass(UmlClass src)
Parameters
| Type | Name | Description |
|---|---|---|
| UmlClass | src |
UmlClass(string)
Creates a new instance of the UmlClass.
Declaration
public UmlClass(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the class. |
Properties
AttributeHeaderSettings
Gets or sets the configuration for the Attributes section header.
Declaration
[JsonPropertyName("attributeHeaderSettings")]
public UmlSectionHeaderSettings AttributeHeaderSettings { get; set; }
Property Value
| Type | Description |
|---|---|
| UmlSectionHeaderSettings | A UmlSectionHeaderSettings representing the attributes header configuration. |
Remarks
Provides customization options for the section, including:
- Header text (e.g., "Attributes")
- Text styling
- Visibility of add/remove action buttons
- Expand/collapse behavior and icon visibility
Examples
This example demonstrates customizing the attribute header in a node:
nodes.Add(new Node()
{
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Product",
AttributeHeaderSettings = new UmlSectionHeaderSettings()
{
HeaderText = "Properties",
ShowExpandCollapseIcon = true,
IsExpanded = true
}
}
}
});
Attributes
Gets or sets the collection of attributes (properties) defined in the UML class.
Declaration
[JsonPropertyName("attributes")]
public DiagramObjectCollection<UmlClassAttribute> Attributes { get; set; }
Property Value
| Type | Description |
|---|---|
| DiagramObjectCollection<UmlClassAttribute> | A DiagramObjectCollection<T> representing the class attributes. |
Remarks
Each attribute represents a structural feature with optional type, visibility scope, and custom text styling. Separator entries can also be included.
Examples
This example demonstrates adding attributes to a UML class inside a node:
nodes.Add(new Node()
{
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Person",
Attributes = new DiagramObjectCollection<UmlClassAttribute>()
{
new UmlClassAttribute() { Name = "Name", Type = "string", Scope = UmlScope.Private },
new UmlClassAttribute() { Name = "Age", Type = "int", Scope = UmlScope.Private }
}
}
}
});
MethodHeaderSettings
Gets or sets the configuration for the Methods (Operations) section header.
Declaration
[JsonPropertyName("methodHeaderSettings")]
public UmlSectionHeaderSettings MethodHeaderSettings { get; set; }
Property Value
| Type | Description |
|---|---|
| UmlSectionHeaderSettings | A UmlSectionHeaderSettings representing the methods header configuration. |
Remarks
This property allows customization of the section, including:
- Header text (e.g., "Operations")
- Text styling
- Visibility of add/remove action buttons
- Expand/collapse state and toggle icon visibility
Examples
This example demonstrates customizing the methods section header:
nodes.Add(new Node()
{
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Service",
MethodHeaderSettings = new UmlSectionHeaderSettings()
{
HeaderText = "Operations",
ShowExpandCollapseIcon = true
}
}
}
});
Methods
Gets or sets the collection of methods (operations) defined in the UML class.
Declaration
[JsonPropertyName("methods")]
public DiagramObjectCollection<UmlClassMethod> Methods { get; set; }
Property Value
| Type | Description |
|---|---|
| DiagramObjectCollection<UmlClassMethod> | A DiagramObjectCollection<T> representing the class methods. |
Remarks
Each method includes its name, return type, visibility scope, and optional parameters. Separator entries can also be included for grouping.
Examples
This example demonstrates adding methods to a UML class:
nodes.Add(new Node()
{
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Vehicle",
Methods = new DiagramObjectCollection<UmlClassMethod>()
{
new UmlClassMethod() { Name = "Start", Type = "void", Scope = UmlScope.Public },
new UmlClassMethod()
{
Name = "Move",
Type = "void",
Scope = UmlScope.Public,
Parameters = new DiagramObjectCollection<UmlTypedElement>()
{
new UmlTypedElement() { Name = "speed", Type = "int" }
}
}
}
}
}
});
Name
Gets or sets the name of the UML class, displayed in the classifier header.
Declaration
[JsonPropertyName("name")]
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A string representing the class name. The default value is |
Remarks
This property defines the identifier of the UML class displayed in the classifier header. It is typically used to represent a domain entity in a diagram.
Examples
This example demonstrates how to define a UML class with a name inside a node:
DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>();
nodes.Add(new Node()
{
Shape = new UmlClassifierShape()
{
Classifier = ClassifierShape.Class,
ClassShape = new UmlClass()
{
Name = "Animal"
}
}
});
Methods
Clone()
Creates a new object that is a copy of the current UmlClass.
Declaration
public override object Clone()
Returns
| Type | Description |
|---|---|
| object | A new UmlClass instance that is a deep copy of the current UML class. |
Overrides
Remarks
This method performs a deep copy, creating an independent UmlClass instance with identical properties, attributes, methods, and styling.