Author Topic: Custom UML Sterotypes (Shapes)  (Read 10575 times)

Frisky

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • Saving the world, one line of IL at a time...
    • View Profile
Custom UML Sterotypes (Shapes)
« on: April 18, 2006, 11:18:01 am »
Not getting the alpha I wanted using the PNG, I tried creating a custom shape. For example, I decided to try something simple, so I created a database shape. I entered the shape script, and it previews find. I add an object to the diagram and give it the new sterotype. But, the image of the object does not change. It is still a beige square.

What am I doing wrong? I followed the documentation in the EA Help file.

Do the custom shapes have to be turned on or something?

Frisky

Frisky
---
"Logic will get you from A to B. Imagination will take you everywhere." – A. Einstein

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #1 on: April 18, 2006, 01:02:15 pm »
Hi Frisky,

Here's the answer you don't want, but also a ray of hope.

I've been asking shape scripts for a while. They are a fairly new feature, and the documentation is not up to date as yet, but they are definitely working on it. My (uneducated) guess is that this will likely synchronize with the product about the time version 6.5 is released. My best guess is that this will be quite soon.

Do a search on forum messages with ShapeScript (or "Shape Script" with the space). Also, try searching my messages on this subject over the last 60 - 75 days or so. Those threads will give you some ideas.

Also, take a look at the BPMN add-in. They have used shape scripts for several of the stereotypes, although they do not cover all the bases.

Let me know how you do on this. I'm still hanging up on a few things and we can compare notes.

David
No, you can't have it!

nara_c

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #2 on: April 18, 2006, 02:33:19 pm »
Quote
Not getting the alpha I wanted using the PNG, I tried creating a custom shape. For example, I decided to try something simple, so I created a database shape. I entered the shape script, and it previews find. I add an object to the diagram and give it the new sterotype. But, the image of the object does not change. It is still a beige square.

What am I doing wrong? I followed the documentation in the EA Help file.

Do the custom shapes have to be turned on or something?

Frisky



Hi Frisky,

It is possible to do what you want in a couple of ways. You can either use Shapescript or Images.  Not sure what you got wrong and why it is not working but here are a few hints based on your post.  I have used both approaches with a lot of success and use a fairly customised element set in EA for our project needs.

* You could have another stereotype 'Database' that is conflicting with the one you created.

* You may not have saved the stereotype after creating the shapescript (refer the steps below).

* You may have set the baseclass to the wrong element type while defining your sterotype.


Steps to create & save stereotypes with shapescript.
1) Create a new stereotype called "database" and in the Base class drop down select "Object", optionally type in notes if you choose so you can differentiate your stereotype from any preexisting database stereotypes.

2) Select 'Shapescript' in override appearance and enter your shapescript text, after pre-viewing close the shapescript editor and ensure you click the 'save' button.  Else the script you entered will not be saved - bit of a bother for now but you will get used to this soon.

3) Now try and apply the stereotype on an object element and you should see your notation appear.

Let me know how you get along.  If you still have problems raise a help request with EA or post your shapescript here and I will try and see what the problem is.

Frisky

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • Saving the world, one line of IL at a time...
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #3 on: April 26, 2006, 01:08:44 pm »
Thanks for the help.

Yes, I have tried this many times. The shape shows up in the preview, both on the shape editor page, and on the Sterotype editor page. But, it has no effect when I apply the sterotype on the diagram. However, if I do the exact same thing, and use a Metafile, the sterotype image is applied to the item. It appears that scripted shapes are not turned on or something.

Temporarily, we have used the EMF Metafiles. But, the shape scripting looks promising and allows us to have cleanly resized images.

Frisky

Frisky
---
"Logic will get you from A to B. Imagination will take you everywhere." – A. Einstein

nara_c

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #4 on: April 26, 2006, 02:20:50 pm »
Quote
Thanks for the help.

Yes, I have tried this many times. The shape shows up in the preview, both on the shape editor page, and on the Sterotype editor page. But, it has no effect when I apply the sterotype on the diagram. However, if I do the exact same thing, and use a Metafile, the sterotype image is applied to the item. It appears that scripted shapes are not turned on or something.
Frisky



Surprised you are facing this behaviour.  Have you checked with Sparks support? They are excellent and generally get back within 24 hrs from my experience.  I do not believe this is intended behaviour.

Good luck.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #5 on: April 26, 2006, 02:59:10 pm »
Hi again Frisky,

What are your settings in the diagram properties?

Also, just to be absolutely sure, what exactly do you mean when you say:
Quote
apply the sterotype on the diagram
Are you applying the stereotype to an element you have placed on the diagram? If so, is the element the correct base type - from the Settungs / UML / Stereotypes dialog? And, are you absolutely sure you have saved the stereotype before you exited the above dialog (or even changed to another stereotype)? [I know the last question is rather pedantic, but I seem to fail on this at least half the time, and the dialog is very fragile regarding this point.]

David
No, you can't have it!

StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #6 on: April 27, 2006, 05:46:22 am »
hi all, I recently noticed that not all elements can change their image. E.g. an activity in an activity diagram can be changed but not an action. When you use the short-cut (CTRL-Shift-W) on an action, nothing happens. Same on activities opens the image manager. Furthermore selecting an action and choosing <settings> <images...> pops up the image manager and you can select an alternate image. But after <OK> nothing has changed.

Seems that for any unknown reason some elements can not change their image and you can find this by pressing CTRL-Shift-W ???

Stefan

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #7 on: April 27, 2006, 05:53:54 am »
In the case of shape scripts Sparx has been extending the range of elements that can be modified (or at least decorated). Check the release notes for the last few builds.

I do not know if they have been making similar inroads with assignment of alternate graphics (the 'old' way).

This is an area I'd like to see expanded. Paolo doubtless say this should be consistent across the board; I would doubtless agree. Worth starting a "Suggestions" thread folks?
No, you can't have it!

nara_c

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #8 on: April 27, 2006, 02:14:36 pm »
Quote
hi all, I recently noticed that not all elements can change their image. E.g. an activity in an activity diagram can be changed but not an action. When you use the short-cut (CTRL-Shift-W) on an action, nothing happens. Same on activities opens the image manager. Furthermore selecting an action and choosing <settings> <images...> pops up the image manager and you can select an alternate image. But after <OK> nothing has changed.

Seems that for any unknown reason some elements can not change their image and you can find this by pressing CTRL-Shift-W ???

Stefan


Stefan,

I faced the same behaviour when I tried to apply images for Entry and Exit points in State Diagrams to model Service Component models based on IBM SCA notation.  

I created images for my notations and then set them up as a UML Profile.  But it did not apply on the images.  On closer inspection of the context options on the embedded element on the shape I noticed that the "Use Alternate image..." option was not even available.  I figured this is the reason the shape assigned to the stereotype via images was not working.

I raised an issues with Sparks support and they were prompt to reply (as always) and provided a work around.  I believe this is not intended behaviour and has been scheduled for fixing in future versions.

The following is Sparks support response to the issue:

"Thank you for raising this issue. This isn't a characteristic of embedded elements; some embedded elements (e.g. ObjectNode) allow alternate images. It's simply that we haven't implemented it yet for state nodes. We will try to get it fixed in the near future."

followed by

"Further to my previous answer, I think you can achieve what you want using shape scripts. If you import the attached XML into your model (Tools | Import Reference Data) you will find a couple of stereotypes which I've created for you. The base type is set to "<all>" so you can use them with any element type. You can tweak the shape script by "Settings | UML | Stereotypes" then selecting the stereotype and clicking the "Edit" button. Any questions, please ask.

Hope this helps."


With this ShapeScript

Shape Main
{
   NoShadow=True;
   SetFillColor(153,204,0);
   setpenwidth(2);
   MoveTo(0,0);
   StartPath();
   LineTo(80,0);
   LineTo(100,50);
   LineTo(80,100);
   LineTo(0,100);
   LineTo(20,50);
   EndPath();
   FillAndStrokePath();
}


NOTE: For applying stereotypes on embedded elements it is important to set the Stereotype Base Class as <All> else it will not work.

Hope this helps fix your issue.

StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #9 on: April 28, 2006, 12:00:31 am »
Hi nara_c,

thanks, that works great!

sigh, next problem: where is the name of the element? When I assign an image via image manager, the elements name goes below the image. But when I use stereotyped images, the name is missing, even if the image is transparent. Is there a command for displaying the elements name and/or position?

Another problem: Our model is in a database. When I deliver it to remote locations I have to export it to XML first. But the image manager and the shape scripts are not part of the XML-export. Is there a solution how to backup the entire model and its environment to a local XML- or EAP-file?

Stefan

thomaskilian

  • Guest
Re: Custom UML Sterotypes (Shapes)
« Reply #10 on: April 28, 2006, 01:42:59 am »
Stefan, I asked this (naming issue) some time ago and got a reply. Sorry, no time to search for the thread by myself :-[
« Last Edit: April 28, 2006, 01:43:32 am by thomaskilian »

StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile

nara_c

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #12 on: May 01, 2006, 08:01:41 pm »
Quote
Hi nara_c,

Another problem: Our model is in a database. When I deliver it to remote locations I have to export it to XML first. But the image manager and the shape scripts are not part of the XML-export. Is there a solution how to backup the entire model and its environment to a local XML- or EAP-file?

Stefan



Stefan,

Your solution would be to perform an export of the entire Model and also 'Export Reference Data...' from the tools menu.  This second option enables you to take master data such as Stereotypes, Images etc, which are model specific and move them to another model using the Export & then Import options.

It is not the most elegant of solutions for now, since you can only select what type of refence data to export and not which specific elements (i.e.) you can export all images or all Stereotypes.  

You could try to edit this at the XML Level once the reference data is exported to remove items you do not want.

Quote

sigh, next problem: where is the name of the element? When I assign an image via image manager, the elements name goes below the image. But when I use stereotyped images, the name is missing, even if the image is transparent. Is there a command for displaying the elements name and/or position?

Stefan


With regard to your question on sharpe script, you seem to have found the answer on another post with Thomas's help.  I think shapescripts are a great extension feature but unfortunately the documentation is lacking, a fact Sparks Systems are gracious enough to admit.  In saying that the Customer support are most helpful in providing answers on a per user request.

I have been maitaining a list of their repsonses and have managed to collect some undocumented ShapeScript commands.  I will post all the responses I have to date on a new thread and it will be great if others can do the same.  Hopefully we will have an unofficial list of commands until the documentation is updated.

Check out this post:

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=general;action=display;num=1146538868;start=0#0

Hope this helps.  

Cheers


StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #13 on: May 03, 2006, 08:13:10 am »
Hi nara_c
Quote
Your solution would be to perform an export of the entire Model and also 'Export Reference Data...' from the tools menu.  This second option enables you to take master data such as Stereotypes, Images etc, which are model specific and move them to another model using the Export & then Import options.

In-between I tried <tools> <data management> <data transfer> <DBMS to EAP>. This is very useful for saving the entire database to a local file but has the disadvantage that it is not good for delivering models to our stakeholders. It contains not only the great models but also the "playground" (our EA experimental area).
Your suggestion is better for our purpose.

Quote
With regard to your question on sharpe script, you seem to have found the answer on another post with Thomas's help.

This is my shape for actions and activities (and any other symbol) with stereotype "LiDo" (to mark elements with attached Linked Documents):

shape main
{
layouttype="border";
roundrect(0,0,100,100,20,20); // Case Outline
roundrect(50,05,90,32,2,2); // Doc Outline
moveto(55,10); // The Lines
lineto(85,10);
moveto(55,15);
lineto(85,15);
moveto(55,20);
lineto(85,20);
moveto(55,25);
lineto(70,25);

text("LD",80,06);
addsubshape("name","center");

   text name
   {
   h_align="center";
   v_align="center";
   Print("#NAME#");
   }
}
Sparx: I hope I can trash this soon (sorry, off topic).

Thanks to all for help!
Stefan

StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile
Re: Custom UML Sterotypes (Shapes)
« Reply #14 on: May 09, 2006, 11:38:23 pm »
Hi all, I have two minor problems I'd like to mention in this thread:
    [1] In the above shape, if the name of an element is longer than the size of the icon in the diagram, the letters are cut off to the left and to the right. I tried PrintWrapped("#NAME#") instead, but then the #NAME# is somewhere outside the shape (... has something to do with v_align).

    [2] Is there a method to protect shapes and stereotypes against changes of my colleages?

tfh
Stefan