Book a Demo

Author Topic: Multiple stereotypes and apperance(s)  (Read 8170 times)

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Multiple stereotypes and apperance(s)
« on: September 20, 2013, 01:21:57 am »
To an element more than one stereotype can be assigned. A stereotype can be used to influence the apperance of an element on a diagram.

Is it possible to show the same element on different diagrams with a different appearance, based on one of the assigned stereotypes?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #1 on: September 20, 2013, 04:35:44 am »
AFAIK you can't do that. I'm not sure whether you could call an add-in from within a shape script. If so you would be able to determine the diagram type and/or location and influence the appearance. But I'm not sure whether that's possible.

[edit] I could not find such an add-in exit for shape script. The only thing you could query is border color, size, and fill color. So that could be used to control the shape individually. But that looks like a bad hack.

q.
« Last Edit: September 20, 2013, 04:40:19 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #2 on: September 20, 2013, 09:05:30 am »
Only one element shape script will be used to render a diagram, so having multiple stereotypes won't help too much.

However, within a shape script you can access the diagram type for conditional processing. You can also detect what other stereotypes are defined with HasProperty("stereotype", "otherstereotype").

Finally, there is an example script that shows getting a value from an add-in. However it's not recommended because any access to the model is going to significantly slow down diagram rendering.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #3 on: September 20, 2013, 08:38:50 pm »
Simon,
can you give a pointer where to find that example script? I did not find it first hand.

q.

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #4 on: September 25, 2013, 05:22:53 pm »
@Simon: thank you for this answer. Same question as qwerty: where to find the example script?

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #5 on: September 25, 2013, 05:24:54 pm »
@Simon:

Well, still a question. Quote from your answer: "Only one element shape script will be used to render a diagram".

The question is: if there are more stereotypes linked to an element and all those stereotypes have a shape script linked, what's the rules for selecting the shape script?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #6 on: September 25, 2013, 07:37:33 pm »
Not an answer but a guess: the stereotypes are stored in a comma separated list from which the first one is displayed in the properties (the rest is only available via the ellipsis button). So most likely that prominent first one is taken.

q.

[edit] My assumption was wrong. I defined <<a>> and <<b>> with <<b>> being the first and EA rendered <<a>>. So it looks like they take it alphabetically :o
The question stays open (like that for the script).
« Last Edit: September 25, 2013, 07:45:22 pm by qwerty »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #7 on: September 26, 2013, 08:42:22 am »
On the Example Scripts page there is this:
Code: [Select]
// GET A VALUE RETURNED BY AN ADD-IN
shape main
{
       //Draw a simple rectangle
       Rectangle(0,0,100,100);
 
       //Print string value returned from Add-In "MyAddin",
       //Function "MyExample" with two string parameters
       Print("#ADDIN:MyAddin, MyExample, param1, param2#");
}
 
// METHOD SIGNATURE FOR ADD-IN FUNCTION:
// Public Function MyExample(Repository As EA.Repository,
// eaGuid As String, args As Variant) As Variant
I have never used it so can't offer any more help than that.
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #8 on: September 26, 2013, 08:50:44 am »
Thanks for that pointer, Neil. However, there's the unanswered question from Jacob about the order of evaluation. Can you answer that too?

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #9 on: September 26, 2013, 09:11:24 am »
I'm sorry, I don't know
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #10 on: September 26, 2013, 06:08:16 pm »
In that case: back to Simon. And would Roy document that in the help, please?

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #11 on: September 30, 2013, 02:01:29 pm »
It will prioritize getting the shape script from stereotypes with a metatype. Otherwise it looks like it will get the last stereotype.

In general it's probably not a good idea to get in this situation because as soon as you do, you can't determine from the shape what the thing is.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #12 on: September 30, 2013, 03:04:52 pm »
I would have said that the only time you would apply multiple stereotypes to an element is when you want to use the stereotype as a simple label. For example, Class: Dog might have stereotypes <canine>, <animal>, <mammal>, <carnivore>.

You shouldn't need to use multiple stereotypes that each affect appearance. As Neil and Simon have pointed out, you can use conditional statements within a single Shape Script (on a single stereotype) to produce a different image for each condition.
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #13 on: September 30, 2013, 08:03:46 pm »
Myself I actually don't care much. IIRC the maximum I ever used were two stereotypes. But there seem to be users which make excessive use of multi-stereotypes. So it would be nice to find Simon's assumption "it looks like it will get the last stereotype" written as a definite statement in the help. Just for the records.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Multiple stereotypes and apperance(s)
« Reply #14 on: October 01, 2013, 08:34:26 am »
Personally, if it was to be documented I would prefer it says that you will get "undefined results". Meaning don't do it (and if you do it anyway, don't expect the way your diagram is rendered to be stable across versions)