Using DPO With Font Styles

With Dynamic Property Overriders, it is possible to override the static font styles of the diagram labels.

The font styles belong to an Enumeration of the graphdesc meta-model.

Let's imagine in the school sample that we want to associate the font styles of the classrooms header label with their student count. For example, if the students count is > 0, we want a bold and underlined font style, and in other cases, we want an italic font.

To get this result, we have to :

  1. Add a Dynamic Property Overrider to the Classroom ClassFigure
  2. Select the labelStyle in the Property To Override entry
  3. Enter the following expression in the Overriding Expression entry (comments may be ommited) :
    -- if the classroom has at least one student
    if (students->size() > 0)
    then
    	-- the header label is bold and underlined
    	-- (we musn't forget to put the styles in a Collection, here
    	-- we choose a Set)
    	Set{ graphdesc::FontStyle::bold, graphdesc::FontStyle::underline }
    else
    	-- else it is italic (in a Set like before)
    	Set { graphdesc::FontStyle::italic }
    endif
    

You should get the following result (without the DPO on the left, and with the DPO on the right ; we can see the font styles that become dynamic on the right diagram) :