Skip to main content

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

Hi Michael,

 

thanks for the input and I have to say that what you say is right and that I also find it confusing. I have already opened a bugzilla for that (actually yesterday ;-) ): https://bugs.eclipse.org/bugs/show_bug.cgi?id=352542

 

This bugzilla references 2 bugs opened by other users targeting exactly this issue and sketches a potential solution that is similar to what you proposed. I would like to discuss this with 2 of our key developers, but they are currently on vacation (until beginning resp. mid of August). Nevertheless feel free to comment on that bugzilla.

 

Until then the only workaround I see is what you described: explicitly setting the values to null (which unfortunately  requires that you know which values were set by default in the framework).

 

Michael

 

 

From: graphiti-dev-bounces@xxxxxxxxxxx [mailto:graphiti-dev-bounces@xxxxxxxxxxx] On Behalf Of Keppler Michael (ETAS/EPS2)
Sent: Donnerstag, 21. Juli 2011 07:01
To: graphiti-dev@xxxxxxxxxxx
Subject: [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