Creating reusable styles
You can create custom styles that you can later use when specifying styles for a style sheet rule. Unlike local attribute specification, creating custom style definitions and/or attribute values allows you to reuse them for the style specification of multiple rules.
Currently, reusable styles can only be created via the Textual Editor.
Creating reusable styles
To create reusable style definitions and attribute values
- Open a style sheet in the Textual Editor.
- Create reusable style attribute values grouped within a custom style class:
- Within the body of the part definition of a style sheet, declare a part usage and specify its name.
- Within the body of the part usage, declare an attribute, specify its name, then define it by the needed value type, and specify its value.
- Create a custom style definition:
- Within the body of the part definition of a style sheet, declare a part definition, specify its name, and subclassify a primary style definition from the DS_Styles::CoreStylesComponents::KerMLStyles package.
You can create custom style definitions specifying the needed attributes and their values. Custom style definitions must subclassify primary style definitions (such as ShapeStyle, ShapeOnBorderStyle, etc.), inheriting their attributes, which you can modify. However, you can only add attributes that are available to the primary style definition that the custom style definition subclassifies.
For an extensive list of primary style definitions and their available attributes, see the Symbol styles table. - Within the body of the part definition, declare an attribute usage, redefine the needed attribute, and specify the attribute's value.
- Within the body of the part definition of a style sheet, declare a part definition, specify its name, and subclassify a primary style definition from the DS_Styles::CoreStylesComponents::KerMLStyles package.
- Reuse the style definitions and/or attribute values when specifying styles for a style sheet rule. Use feature chaining for attributes nested within custom style classes.
- Synchronize modifications and assess layout-sensitive changes.
part def NewStyleSheet :> DS_Styles::CoreStylesComponents::StyleSheet {
// reusable style attribute values grouped within a custom style class:
part customColorPalette {
attribute customDarkGreen : DS_Styles::CoreStylesComponents::KerMLStyles::Color default "#357F35";
attribute customLightGreen : DS_Styles::CoreStylesComponents::KerMLStyles::Color default "#BFF7AA";
}
// a custom style definition PartTextStyleRule reuses the color specified in the custom style class customColorPalette:
part def PartTextStyleRule :> DS_Styles::CoreStylesComponents::KerMLStyles::ShapeStyle {
attribute :>> penColor default customColorPalette.customDarkGreen;
}
// using the custom style definition PartTextStyleRule for a rule:
part partRule :> rule {
part :>> condition : DS_Styles::CoreStylesComponents::Predicates::ByElementMetaclassCondition {
ref item :>> elementMetaclass = SysML::Systems::PartUsage.metadata;
}
part :>> style : PartTextStyleRule; // the custom style is passed to the rule's style
}
}