Most of presentation elements can have properties (for example Autosize for shapes or Path Style for paths):

  • To check if an element has some properties (or uses properties from its parent), use the method com.nomagic.magicdraw.uml.symbols.PresentationElement.useParentProperties().
  • To get all properties of this element, use the method PresentationElement.getPropertyManager().
  • To get a property of this element with a given ID, use the method com.nomagic.magicdraw.uml.symbols.PresentationElement.getProperty(java.lang.String).
  • To change element properties, use the method com.nomagic.magicdraw.openapi.uml.PresentationElementsManager.setPresentationElementProperties(PresentationElement, PropertyManager). The given com.nomagic.magicdraw.properties.PropertyManager can have only few element’s properties (for example, just properties you want to change).

The Ids of all used properties are defined in the class com.nomagic.magicdraw.properties.PropertyID.

Look at Properties page for more details about properties structure.

There is no information about what exactly properties every presentation element has. Use java debugger and analyze PresentationElement.getPropertyManager() object. You can also guess property ID from the Symbol Properties name.

If you want to change a value of existing property, recommendation would be clone that property, change value for a clone and set it. Don't use constructor if possible.

The following code example shows how to change element properties:

    ShapeElement element = ...;
    Property property = element.getProperty(PropertyID.AUTOSIZE);
    if (property instanceof BooleanProperty)
    {
        BooleanProperty autoSize = (BooleanProperty) property.clone();
        autoSize.setValue(true);

        PropertyManager properties = new PropertyManager();
        properties.addProperty(autoSize);

        SessionManager.getInstance().createSession(project, "Test");
        PresentationElementsManager.getInstance().setPresentationElementProperties(element, properties);
        SessionManager.getInstance().closeSession(project);
}

The properties must be new instances. You cannot do something like this: 

    ShapeElement element = ...;
    PropertyManager properties = element.getPropertyManager();
    properties.getProperty(PropertyID.AUTOSIZE).setValue(new Boolean(true));
    SessionManager.getInstance().createSession(project, "Test");
    PresentationElementsManager.getInstance().setPresentationElementProperties(element, properties);
    SessionManager.getInstance().closeSession(project);