Applying Diagram Properties

Diagram Properties control the way the GraphElements are displayed in MagicDraw.

Create a Boolean Diagram Property

A Boolean Diagram Property, allows, for example, to control if the name of a GraphEdge will be displayed or not in a Diagram.
Here is a sample code that shows how to not display the name of a GraphEdge:
GraphEdge graphEdge = ...
DiagramProperties.createBoolean(graphEdge, "SHOW_NAME", false);
DiagramProperties.createBoolean(graphEdge, "SHOW_NAME_DESCRIPTION", false);

Create a Choice Diagram Property

A Choice Diagram Property, allows, for example, to control the way a Stereotype is displayed for a GraphNode.
Here is a sample code that shows how create a Choice Diagram Property:
List<String> STEREOTYPES_DISPLAY_MODE_CHOICES = Collections.unmodifiableList(Arrays.asList(
            "STEREOTYPE_DISPLAY_MODE_TEXT_AND_ICON", "STEREOTYPE_DISPLAY_MODE_TEXT", "STEREOTYPE_DISPLAY_MODE_ICON",
           "STEREOTYPE_DISPLAY_MODE_SHAPE_IMAGE_AND_TEXT", "STEREOTYPE_DISPLAY_MODE_SHAPE_IMAGE", "STEREOTYPE_DISPLAY_MODE_DO_NOT_DISPLAY_STEREOTYPES")); 
GraphNode graphNode = ...
DiagramProperties.createChoice(graphNode, "STEREOTYPES_DISPLAY_MODE", STEREOTYPES_DISPLAY_MODE_CHOICES, 5);
or
List<String> STEREOTYPES_DISPLAY_MODE_CHOICES = Collections.unmodifiableList(Arrays.asList(
            "STEREOTYPE_DISPLAY_MODE_TEXT_AND_ICON", "STEREOTYPE_DISPLAY_MODE_TEXT", "STEREOTYPE_DISPLAY_MODE_ICON",
           "STEREOTYPE_DISPLAY_MODE_SHAPE_IMAGE_AND_TEXT", "STEREOTYPE_DISPLAY_MODE_SHAPE_IMAGE", "STEREOTYPE_DISPLAY_MODE_DO_NOT_DISPLAY_STEREOTYPES")); 
GraphNode graphNode = ...
DiagramProperties.createChoice(graphNode, "STEREOTYPES_DISPLAY_MODE", STEREOTYPES_DISPLAY_MODE_CHOICES, "STEREOTYPE_DISPLAY_MODE_ICON");

Create a Color Diagram Property

A Color Diagram Property, allows, for example, to control the color displayed for a GraphNode.
Here is a sample code that shows how to set the color for a GraphNode:
GraphNode graphNode = ...
Color color = new Color(50, 12, 78);
DiagramProperties.createColor(graphNode, "FILL_COLOR", color.getRGB());

Create a Font Diagram Property

A Font Diagram Property, allows to control the Font for a GraphElement.
Here is a sample code that shows how to set the font for a GraphNode:
GraphNode graphNode = ...
DiagramProperties.createFont(graphNode, "FONT", "Arial", 10, 0);

Related concept
Diagram Interchange

Related tasks
Managing Diagram
Reading Diagram Properties

Related reference
MDAccess for UML API Reference
MDAccess for MagicDraw API Reference
DiagramProperties