The Astah Legend Plug-in enhances your modeling tool experience by seamlessly incorporating legend capabilities. The plugin enables coloring of diagram elements based on rules described in Groovy language.
- Reset, load, and save legend in YAML format
- Visual attributes for legends and legend items
- Add, remove, modify, and change order of legend items
- Scripting capability in Groovy
- Edit on double click
- Auto assign color for new legend items
- Enter Legend name
- Modify legend style by pressing the Configure button
- Add new legend items by pressing the add button on the Legend items tab
- Edit the legend item, set name, colors, and script
- Press
Apply on diagram
button in the toolbar
- The script should be written in Groovy.
- It is required to output a boolean value (true or false).
- A true result signifies that the legend item will be applied, while false indicates that the legend item will not be applied.
- If the Elements only checkbox is selected, the script will not be executed for presentation elements lacking a corresponding model element (e.g., line, rectangle, image).
- The script receives two variables:
presentation
: represents the presentation element (of typeIPresentation
).element
: represents a model element referenced by the presentation element (of typeIElement
).
- Example usage: "Test".equals(element.name). This condition will color each element on the diagram whose name equals "Test".
If we want to color a single element with a certain name, use he following script:
"Error".equals(element.name)
This will result in the following coloring:
A more realistic example is when certain rules are defined for the structure of names. An example is that a name cannot end with a certain characters, like data. So, let's use the following script:
element.name.toLowerCase().endsWith("data")
This will result in the following coloring:
To color the diagram based on a stereotype, for example if an element has an associated stereotype with the name Stakeholder
, use the following script:
element.hasStereotype("Stakeholder")
This will result in the following coloring: