Book a Demo

Author Topic: Shape script and UML Profiles  (Read 5170 times)

THS

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Shape script and UML Profiles
« on: March 07, 2007, 07:10:05 am »
Hi

I have created an UML-profile for servers used in a deployment model. I used the possibility to set a metafile for each kind of server, e.g. a webserver-icon (wmf) for a node with stereotype "server_web". So I can easely change the type of a server by changing the stereotype and the server-icon is changing, too. So far no problem.

On the other side I wrote a shape script that change the color dependig on a specific tagged value (e.g. green server icon if tagged value "status" is "in service"; red server icon if tagged value "status" is "out of service").

Unfortunately the combination of both features is not working. As long I enter a new node from the toolbox, select an alternate image (the servericon in wmf-format)and change the stereotype to the one with the shape script => no problem. But when I enter a new webserver from the UML-profile (with the same stereotype, e.g. server_web) the shape script functionality is not working.

Any clue from your side ? Are there any further information regarding shape script (I just found what 's in the EAhelp) ?

Thanks for your feedback.

Rgds,
Thomas

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape script and UML Profiles
« Reply #1 on: March 07, 2007, 10:41:30 am »
Off hand I'm not sure. Have you tried something like querying a tagged value property, to see if this makes the shape change. I don't have the syntax in front of me, but experiment with what's in the user guide. One thing though, I think the query without a 'value' parameter just checks whether the tag exists, regardless of value, but it might also check for a default. You need to watch out for this, or ensure you use all parameters.

[I know you said you are using stereotypes. I'm just trying to determine whether the shapes will respond at all, and possibly where the problem might be.]

David
No, you can't have it!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape script and UML Profiles
« Reply #2 on: March 07, 2007, 01:26:21 pm »
If you post your shape script here we might be able to suggest  a fix...
The Sparx Team
[email protected]

THS

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Shape script and UML Profiles
« Reply #3 on: March 08, 2007, 07:47:36 am »
Hi

Thanks for the fast feedback.

Here my script:

shape main    
{
      h_align = "center";
      noshadow = "true";
     
     if (HasTag("Version","1"))
      {      

      image("s_green.emf",0,0,100,100);
      return;
      }

      if (HasTag("Version","2"))
      {      

      image("s_blue.emf",0,0,100,100);
      return;
      }

      if (HasTag("Version","3"))
      {      

      image("s_red.emf",0,0,100,100);
      return;
      }
}

I play a little more with my testmodel and found the following issues:

a) image in wfm format do not work with shape script (or I do something wrong)

b) if you set bgcolor in the profile (for a specific stereotype) you can't manipulate/override that with shape script method

c) same if you set metafile

I have general problem to load emf-files I use in my shape script (see above). How is the correct method to that. I try diffrent ways (put file in the same folder as the profile; Image Manger; Stereotype from Toolbox/Profile than save as Profile and copy the image part into my profile).

Currently I can only use my s_red.emf picture, but not the two other (s_blue and s_green).

And another question: can I also use a value from a tag in the print() method. I read in an old post that Sparx has this issue on the roadmap list. Any news ?

Rgds from Switzerland
Thomas

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape script and UML Profiles
« Reply #4 on: March 08, 2007, 03:53:37 pm »
Quote
a) image in wfm format do not work with shape script (or I do something wrong)

I've tested your shape script with EA 6.5.804 using .wmf images and it is working for me.

The image() command uses the name of the image as it is stored in the model, not the filename. Although these will usually be the same thing, they needn't be, so go to "Settings > Images" and check that you are using the correct name.

A final hint: as a fall-through, put the command DrawNativeShape() as the last command in your script. This will ensure that the element's default shape is drawn if the tagged value "Version" isn't one of "1", "2" or "3".

Quote
b) if you set bgcolor in the profile (for a specific stereotype) you can't manipulate/override that with shape script method

Have you looked at the GetUserFillColor() function?

Quote
And another question: can I also use a value from a tag in the print() method.

Print("#tag:TagName#");
The Sparx Team
[email protected]

THS

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Shape script and UML Profiles
« Reply #5 on: March 09, 2007, 06:57:12 am »
This morning my images works (maybe I have to restart/reload EA to activate them or I don't know why).

GetUserFillColor() seems to be a nice functionality.

And the "#tag:TagName#" function is great.

Thanks for your support.