See the procedures on this page for customizing the style sheet components. 

  • The procedures on this page use the example of customizing rules of the DefaultStyleSheet style sheet, however, customization of any other style sheet's rules, whether predefined or custom, is analogous.
  • For procedures on supplementing customized style sheets with your own custom rules (instead of or in addition to customizing existing ones), see the Creating style sheet components page.

Customizing style sheet components

Reusing style sheet rules

To reuse style sheet rules


  1. Reuse a style sheet (e.g., DefaultStyleSheet).
  2. Within the body of the part definition of the new style sheet, declare a part usage, specify a new name for the rule (optional), redefine the needed rule, and in its body, do any of the following as needed:
    1. Modify the style definition defining the style of a rule.
    2. Modify the style attributes locally for the style of a rule.
    3. Modify the compartment style of a rule.
  3. Synchronize modifications.
    partPortRule rule defined in the DefaultStyleSheet style sheet

    package NewStylesPackage {
       private import DS_Styles::**;
       private import CoreStylesComponents::*;
       private import Predicates::*;
       private import ColorDefinitions::*;
       private import CompartmentVisibilityDefinitions::*;
       private import KerMLStyles::*;
       private import SysMLStyles::*;

        part def NewStyleSheet :> DefaultStyleSheet {
            part customizedPartPortRule :>> partPortRule { // redefining and renaming the partPortRule rule
            // customize the redefined rule
            }
        }
    }

Modifying the style definition defining the style of a rule

To modify the style definition defining the style of a rule


  1. Reuse a style sheet rule.
  2. Declare a view usage, define it by the needed auxiliary style definition, and redefine the inherited part style.

    You can define the view by multiple style definitions, listing them in a comma-separated list.

  3. Synchronize modifications.

    part def NewStyleSheet :> DefaultStyleSheet {
       part customizedPartPortRule :>> partPortRule {
                view : AbstractCyanStyle :>> style// the AbstractGreenRule inherited from the partPortRule via the DefaultStyleSheet style sheet is replaced with the predefined style definition AbstractCyanStyle
       }
    }

Modifying the style attributes locally for the style of a rule

There are two ways you can specify a style for a rule:

To modify the style attributes locally for the style of a rule


  1. Reuse a style sheet rule.
  2. Declare a view usage, redefine the inherited part style, and in its body, redefine the needed attribute, specifying the new value.

    The attributes available to the specified style definition depend on the style definitions they subclassify. For an extensive list of the predefined style definitions and the primary style definitions they subclassify, and their available attributes, see the Symbol styles table on the Style sheet conditions and styles tables page.

  3. Synchronize modifications.

    part def NewStyleSheet :> DefaultStyleSheet
       part customizedPartPortRule :>> partPortRule {
          view :>> style 
             attribute :>> fillColor default "#D9EEDA";   // redefining the attribute fillColor available via the predefined style definition AbstractGreenRule 
          }
     
       }
    }


Modifying the compartment style of a rule

The majority of the compartments are disabled (set to false) for most of the elements in the DefaultStyleSheet style sheet via the HideAllCompartments predefined compartment style definition.

To modify the compartment style of a rule 


  1. Reuse a style sheet rule.
  2. Declare a view usage, redefine the inherited part style. In its body, declare a part for the needed compartment and define it by its definition. In its body, redefine the needed attribute, specifying the new value. 

    To determine which primary compartment style definitions (including their attributes and value types) are available for each element symbol, see the Symbol compartment styles table on the (2026x) Style sheet conditions and styles tables page.

  3. Synchronize modifications.

    part def NewStyleSheet :> DefaultStyleSheet {
       part newPartPortRule :>> partPortRule {
          view :>> style {
             part attributeCompartment : AttributesCompartmentStyle {
                :>> showCompartment default true; // the inherited attributeCompartment part's showCompartment attribute's value is changed to true
             }
          }
       }
    }