Sparx Systems Forum

Enterprise Architect => Uml Process => Topic started by: Philipp91 on October 16, 2020, 04:29:00 am

Title: Stereotype and Icons
Post by: Philipp91 on October 16, 2020, 04:29:00 am
Hello again,

I would like to add some icons to my stereotypes.
I wanted to ask if I am able to do that just by creating profile diagrams or it can be done only by creating MDG stereotypes?

Kind Regards
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 16, 2020, 04:55:02 am
Philipp,

You can't do anything with profile diagram, except exporting them to a profile xml.
From that point on you can either import the profile xml directly, or package it in an MDG file.
I think icons can be used in both situations

You shouldn't be afraid of MDG's, it's really a simple process to create an MDG file.

Geert
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 16, 2020, 05:53:08 am
I am not sure if I explained myself correctly. So I want to add a new icon on my stereotypes and not to use the icons
provided by EA. So for example if I create a stereotype on a class called "Computer" I would like to add a computer icon with it. Until now I found
that documentation :https://sparxsystems.com/enterprise_architect_user_guide/14.0/modeling_tools/usingtheshapescript.html

About the MDG's, actually I am quite satisfied with being able to create my profiles and profile defined classes and being able to export them for further use. If I will be able to add also icons in this way it could be that this will be all I needed. So as long we discuss about it what is the benefits of making a MDG file?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 16, 2020, 07:41:36 am
Hard to tell in a few sentences (except that you need MDGs for the real stuff). You might read a bit here: http://samples.leanpub.com/EA-MDG-Profiles-sample.pdf (http://samples.leanpub.com/EA-MDG-Profiles-sample.pdf)

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 16, 2020, 11:51:00 pm
Just a bit I looked by scrolling the chapter that talks about Icons is unfortunately omitted but I will have a more detailed look to
get the points of MDGs.
However, my basic question is if I can add my own icons on stereotypes without MDG technology, is that possible?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 17, 2020, 12:16:58 am
However, my basic question is if I can add my own icons on stereotypes without MDG technology, is that possible?
Yes, I believe you can.

Geert
Title: Re: Stereotype and Icons
Post by: qwerty on October 17, 2020, 12:48:20 am
For sure. The icons are part of the profiles. You need to add the icon property in the stereotype pointing to the 16 square pix bit image.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 17, 2020, 05:05:57 am
Thanks for the answers, I will give it a try! :)
Is there any link guiding you for this?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 17, 2020, 06:31:02 am
Well, no. Ask a consultant to do it for you (Geert is recommended) would be the easiest. If you're on the trial and error track: good luck.

q.
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 17, 2020, 08:24:18 am
This might be a good place to start: https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/mdgtechnologies_2.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/mdgtechnologies_2.html)

Geert
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 21, 2020, 07:01:25 am
Hello again,

so in the end I followed the path of creating a MDG file. I followed the tutorials, I was able to create my stereotypes/profiles, customized
toolbox profile and a custom diagram profile. So I deployed the MDG file and tested it on another project and it worked as expected ( I could create the custom diagram, my toolbox existed and so on).

So we go back to the icon issue. What I want to achieve is the same as in this post : https://stackoverflow.com/questions/37611486/how-to-use-a-custom-icon-for-a-stereotype-in-enterprise-architect. The only different thing is that I want to add icons to other element( i.e Action from activity diagram). So after trying for a long time to add an icon on an action it was not working. However, then I had the idea to test the same shape script and image on another stereotype that extend the metaclass "class". Unfortunately it worked...

So is it not possible to add an icon on some particular UML elements?? And if so is there any type of "hack" to be able to do something like that?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 21, 2020, 03:01:09 pm
Do yo mean you created your own stereotype that extends action, and that doesn't want to take the icon and shapescript?

That should work; I don't thinks there are any restrictions in term of which metaclasses you can extend.

I'm not sure if I ever extended Action though, so I can't say for sure that it's possible.

Geert
Title: Re: Stereotype and Icons
Post by: qwerty on October 21, 2020, 07:28:51 pm
No problem with Action. Probably the issue itself is not explained correctly?

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 22, 2020, 03:31:05 am
Thanks for the answers. In the end you were both right.
For some wired reason to show the icon on an activity I had to manually import the profile from the MDG file, while to display the icon on a class
element there was no need to do that.

I am trying now to add more than one icon on a stereotype and was not able to achieve it. Is something like that possible?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 22, 2020, 04:04:35 am
No. How should EA determine which to show? The open folder is something made in EA's guts.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 22, 2020, 04:46:30 am
Sorry I did not get what you meant with "The open folder is something made in EA's guts."
To show to images cannot be done by any command via shape script?? Otherwise as a cheap solution I though i create only icons
as a stereotype and minimize them as much I can and add them inside the metaclass "action", any other way to achieve something like that?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 22, 2020, 05:53:59 am
I thought you were talking about the icons in the tree view. Obviously not :-/

You can show images with shapescripts. Use Image(imageName,left,top,right,bottom) to do that. The image then needs to be in the images table in EA.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 22, 2020, 06:12:03 am
Yes I was able to add some images to my stereotypes.
So to make my question more clear in the following link you can see a screenshot : https://paste.pics/5a8094cfde52d46e8bd36bd1d5125055 .

So as you see I added in the Migratable stereotype an icon of a laptop, and in restartable an icon of a smartphone. So actually my question is can i create a stereotype were it will has both icons next to each other in the right-top corner via shapescript or so?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 22, 2020, 07:08:39 am
You can draw as many icons up there as you like. (The question is whether you will still be able to recognize any details.)

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 22, 2020, 10:07:49 pm
Any example/tip of how something like this can be achieved?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 22, 2020, 11:51:14 pm
Well, you have your shape script, don't you? Just add the other icons.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 23, 2020, 12:43:41 am
Yes, I tried.
My script is the simple cause of an image

decoration icon
{
    orientation="NE";
    image("laptop.png",0, 0, 100, 100);
}

So I tried things like

{
    orientation="NE";
    image("laptop.png",0, 0, 100, 100);
    image("computer.png",0,0,100,100);
}

Or 

decoration icon
{
    orientation="NE";
    image("laptop.png",0, 0, 100, 100);
}
decoration anothericon
{
    orientation="NE";
    image("computer.png",0, 0, 100, 100);
}

and so but I was not able to show 2 icons together

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 23, 2020, 12:46:06 am
Showing both icons NorthEast, in the same location will make your second icon overwrite the first one.
You can either show them in a different corner, or show them next to each other by playing with the coordinates

Geert
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 23, 2020, 01:42:21 am
Thanks, good idea. Dump of me that I did not though it.


Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 23, 2020, 03:13:22 am
Ah, I was just thinking/talking of the coordinate variant and though it were obvious :-/

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 24, 2020, 10:31:28 pm
No problem, the discussion in general is already helpful enough :).
Still was not able to get what I want but I am close to it.

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 28, 2020, 02:27:48 am
Hello again,

I was thinking to open  a new topic but its related with this one so i thought to continue here.
So  I am still struggling with the icon thing..

What I want to achieve is to apply 2-3 stereotypes on a metaclass element and these stereotypes have also icons and I want all the icon to be displayed. As you can see in the screenshot: https://paste.pics/3544ce347a9dfb911be159af71c583c8, in the action search routes there are applied two stereotypes and both icons are displayed. However, I achieved this by making cheats and not by creating an official stereotype.

So when I create officially the stereotypes with their icons and I apply both on them on the same element they override each other even if they are have not the same coordinates. For example in :https://paste.pics/a640a6b23c44211a2cbfe6dd42133896 you can see that in Action6 there are applied 2 stereotypes but only one icon is displayed, where in https://paste.pics/871bd930b61572d4c22d45d94cc89f20 we have again the same stereotypes but the other icon is shown.

As I understood its just takes one( depends on which you choose first i think) and just shows these...And as you can see in the screenshots the two icons are not in the same spot.

Any suggestion of how to achieve that? It's the last thing I need to do with icons...

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 28, 2020, 02:38:24 am
Stereotypes and shapescripts don't work like that.
There will only be one shapescript that will be executed.

Geert

PS. It looks like you are using activities instead of actions.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 28, 2020, 03:33:06 am
No its atomic actions, activities cannot have control flow between them.
So even if the shapescripts are on different stereotypes only the one will be executed?

So to display two icons my only option is to have both in the same shape script, right? If thats the only case
then can you give me any hint for the coordinates of how to add in one shape script 3 icons with a proper size?
I am trying so long I am really confused with this coordinates..

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 28, 2020, 05:33:56 am
It doesn't seem possible to add multiple subshapes, or to escape the the designated corner when using decorations.

Alternative is something like this

Code: [Select]
shape main
{
layouttype = "leftright";
DrawNativeShape();
AddSubShape("EALogo",20,20,60,0);
AddSubShape("Favorites",20,20,60,0);
shape EALogo
{
Image("EA Logo",0,0,100,100);
}
shape Favorites
{
Image("Favorites",0,0,100,100);
}
}

Geert
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 28, 2020, 06:18:02 am
It's sad that I cannot add two different stereotype with different images and show both of them because in the UML extensions mechanism
we should be able to do something like that..

Unfortunately your code did not worked. It didn't displayed any image, did it worked for you?

The way I achieved to add three images next to each other is :


decoration mail

{

     orientation= "NE";
   
     image ("tablet.png",100, 0, 0, 100);
     image ("smartphone.png", 0, 0, -100, 100);
          image("laptop.png", -100, 0, -300,100);
}

However if I have 3 different stereotypes with different images then there will be scenarios that a will apply the two of them, three of them and so..so in the end to cover of the cases I have to create 8 different "stereotypes" to be able to do something like that..and it will not be user-friendly..

Any hack or something to do it differently?

Kind Regards,
Philipp

 
Title: Re: Stereotype and Icons
Post by: Geert Bellekens on October 28, 2020, 08:38:42 am
Yes, it worked for me, but you might need to change the names of the images as they might not exist in your model.

You should be able to add the images conditonally based on the stereotypes (of it not that, based on tagged values that you can define in your stereotype)
That way all of your stereotypes could have the same shapescript.

Geert
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 28, 2020, 10:48:30 am
Thanks!! It worked for me also. So in the end I was able to add conditionally the images  based on tagged values of  a stereotype and it worked.
However, you mentioned "add the images conditonally based on the stereotypes" how can that be achieved? I tried things like hasStereotype and so but I did not found something in the documentation.

Also, is there a way to add in the method "HasTag" something like  if (HasTag ("Example", "*")) where example is a char type attribute
and the start means "whatever text"?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 28, 2020, 10:56:46 am
Well, yes. It's in the documentation and even the picker when typing the operation in the script editor suggests that.

q.
Title: Re: Stereotype and Icons
Post by: Paolo F Cantoni on October 28, 2020, 11:29:27 am
Hi Philipp,

I'm interested in why you need multiple stereotypes.  I suspect there may be a conceptual modelling issue "in play" here.  We have (after more than a decade of EA use) not used more than a single stereotype to define an item.  This, in turn, defines a single metatype.

It seems to me that you may be trying to use stereotypes as properties.  We have many properties which we can assign to various metatypes and our shapescripts react to them in a consistent way.  We can also suppress the rendering of the various types of properties on a per-diagram basis - to make simplified diagrams for various user communities/perspectives.

We can have upwards of half a dozen "widgets" on a given diagram item (in various corners) if required.

Can you say why you need more than one stereotype and why that need couldn't be satisfied by the use of properties?

Just a thought,
Paolo
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 29, 2020, 01:46:12 am
qwerty, I will have a look. To add in the property of the hasTag a star or something that represents any character can be done?

Paolo,

actually what I want to achieve is to create a stereotype called for instance "migratable" extending the metaclass "action". Furthermore, I would
like to show between which devices that action is "migratable" and I had the idea to add the devices as Icons which can be more than 1.
So this is the scenario.

So for now the way I did it is I created the stereotype migratable with its properties and another stereotype called "devices" which has as tagged values the devices that are included and I added both stereotypes on an action . Then I created a shapescript depending on which devices the user added in the properties and the icons are shown.  However, the thing I still want to achieve is to have a "random" image for
general devices which i will not have a standard icon ( that's actually related to my question I did in the last post and to qwerty on this one.)

You think if I do something like this I will have consistency problems? And how I understood your point, you mean I should better skip the second stereotype "devices" and add it as a property(tagged value) in the stereotype "migratable"?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 29, 2020, 03:18:18 am
Not really (your question was not clear). There is no wild card. You'd need an add-in to do that. You only have a) exact match ignoring case when specifying a string and b) testing the mere existence of a TV by leaving away the 2nd string.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 29, 2020, 05:51:10 am
Sorry for not making my question clear. I also got confused by your answer. Let me ask it differently on an example

For instance, when I have the command if( hasTag("device","tablet")) --> i show the icon for tablet
if(hasTag("device","")) --> i show no icon and so on..
So what I want is for all the other cases that the attribute is not blank("") or I don't have a predefined icon to show a particular icon.
So when the user adds device = "adadasfaa" or device = "blahblah" or whatever I show this particular icon.

Can something like that be achieved?
Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: qwerty on October 29, 2020, 06:00:52 am
Unfortunately Shapescript is a very, very poor language. Its parents did not give him any string operations. Even no operations at all. Means: no boolean operations. So if you have a complex construct you have to copy/paste.

if (A and B) <stmt> -> if (A) { if (B) { <stmt> }}
if (A or B) <stmt> -> if (A)  { <stmt>}; if (B) { <stmt> }

where <stmt> is any (complex) block of statements.

q.
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 29, 2020, 06:33:31 am
Its parents did not took good care of him :P j/k

Thanks for your help I will give it a try :)

Kind Regards,
Philipp

Title: Re: Stereotype and Icons
Post by: KP on October 29, 2020, 07:51:37 am
For instance, when I have the command if( hasTag("device","tablet")) --> i show the icon for tablet
if(hasTag("device","")) --> i show no icon and so on..
So what I want is for all the other cases that the attribute is not blank("") or I don't have a predefined icon to show a particular icon.
So when the user adds device = "adadasfaa" or device = "blahblah" or whatever I show this particular icon.

Can something like that be achieved?

if()
{
}
else if()
{
}
else
{
}
Title: Re: Stereotype and Icons
Post by: Paolo F Cantoni on October 29, 2020, 10:56:17 am
[SNIP]

Do you think if I do something like this I will have consistency problems? And how I understood your point, you mean I should better skip the second stereotype "devices" and add it as a property(tagged value) in the stereotype "migratable"?

Kind Regards,
Philipp
Hi Philipp,

Having read your response, I'm not really sure what you are trying to do.  As I understand UML (I assume you are using UML):
16. Actions
An Action is the fundamental unit of behavior specification in UML. An Action may take a set of inputs and produce a
set of outputs, though either or both of these sets may be empty. Some Actions may modify the state of the system in
which the Action executes.


Thus, "migratable" is not an action, it is a property of something.

Not sure I can help further.

Paolo
Title: Re: Stereotype and Icons
Post by: Philipp91 on October 29, 2020, 11:16:53 pm
KP,

Thanks, I got that it can be done only by nested if's.

Paolo,

Well actually I am creating a "new" language to cover characteristics of Cross-device applications which UML does not consider.
So I choose to not create a whole new language but to extend UML with profiles and not change the metamodel to keep the consistency.
So in the end in CDA we can migrate from one device to another while an action is executed. So I am showing that this action is Migratable
while its running and want to show between which devices it can migrate. So i created the migratable stereotype and the device stereotype to cover this requirement.

You mean that something like that is not allowed...?

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Paolo F Cantoni on October 30, 2020, 09:15:51 am
KP,

Thanks, I got that it can be done only by nested if's.

Paolo,

Well, actually I am creating a "new" language to cover characteristics of Cross-device applications which UML does not consider.
So I choose to not create a whole new language but to extend UML with profiles and not change the metamodel to keep the consistency.
So in the end in CDA we can migrate from one device to another while an action is executed. So I am showing that this action is Migratable
while its running and want to show between which devices it can migrate. So i created the migratable stereotype and the device stereotype to cover this requirement.

You mean that something like that is not allowed...?

Kind Regards,
Philipp
OK, Phillip,

Migratable is a property of the Action (an item). Presumably, not all actions are migratable.  If an action is migratable, it has two related devices (also items), the "migrating from" device and the "migrating to" device..  You could implement this concept as two relationships, between the action and the appropriate device.  Personally, I would add the property "can handle migration" to the device item so that you could check that the devices are appropriate to attempt the migration.

If you look carefully at the language I've used, you'll see that it (hopefully) correctly describes the semantics of what you're trying to do.  When creating a new language, you have to be able to express the model in narrative form.  Try that with your implementation - that should guide you into what needs to change.

HTH,
Paolo
Title: Re: Stereotype and Icons
Post by: Philipp91 on November 02, 2020, 09:09:31 am
Hey Paolo,

Thanks for your help! I am also working on the semantics which will also depend on the tool being used for this extension and your example was helpful.

Kind Regards,
Philipp
Title: Re: Stereotype and Icons
Post by: Paolo F Cantoni on November 02, 2020, 10:44:59 am
Hey Paolo,

Thanks for your help! I am also working on the semantics which will also depend on the tool being used for this extension and your example was helpful.

Kind Regards,
Philipp
My pleasure Philipp!
There's a reason my company is called -Semantica-.

One of my most favourite retorts is when people say:  "That's just a matter of semantics!" I reply: "It is EXACTLY a matter of semantics!!"

You may care to look up the "Helsinki Principle" (ISO/TR9007).

Paolo