Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[graphiti-dev] Style versus setDefaultGraphicsAlgorithmValues

Hi graphiti developers!

 

I know that the intention of the current style implementation is that you can have “hierarchical nesting” of style attributes (e.g. defining and using a style for a lot of pictogram elements, but also overwriting some specific attributes for selected pictogram elements). And that sounds like a good idea to me. Nevertheless there is one detail, which I find very confusing and which is at least partly caused by that order of style attribute lookups: The default graphics algorithm values (like lineWidth=1) “overrule” style definitions.

 

Example code (inspired by tutorial):

style = gaService.createStyle(diagram, styleId);

style.setForeground(gaService.manageColor(diagram, NETWORK_DEVICE_FOREGROUND));

style.setLineWidth(2);

roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 5, 5);

roundedRectangle.setStyle(style);

 

The surprising result is that the foreground color has been used, but the line width has not been used for painting the rounded rectangle (The effect can also be seen in the final tutorial code, where the class shapes no longer have lineWidth=2). To make the code work fine, you have to explicitly add the line

roundedRectangle.setLineWidth(null);

 

That way you “reset” the default value from the creation service and the style attribute is finally used. After debugging the style attributes I now understand that it literally works as specified and documented in the help system, but nevertheless I find it very confusing (and looking like a bug for most Graphiti users) that you have to “reset” an attribute like that if you use a style definition.

 

Do other users have a work around for this issue, do they create the shapes in a different way (without the default values)? The Graphiti framework itself could help by changing the style implementation a bit. If it were possible to distinguish between the automatically set default values and values set by “Graphiti user code”, then we might change the order of style attribute lookups to ignore default values if a style is set.

 

Any comments on that?

 

Ciao, Michael

 

BTW: I use 0.8, if that’s important.


Back to the top