Book a Demo

Author Topic: Shape Scripts & and simple stereotypes icons  (Read 6069 times)

Peter Bull

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Shape Scripts & and simple stereotypes icons
« on: March 14, 2009, 12:49:58 am »
Hi

I want to add little icons in the corner of native shapes to indicate common stereotypes rather than using the <<stereotype>>.

Whilst I can use the Sparx Shape Scripts I can't seem to work out a simple way of drawing the native shape, adding a graphic in the corner and removing the <<stereotype>> from the native shape.  It is the removal the <<steretype>> that is my bugbear.

Can anyone help me?

Pete


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #1 on: March 14, 2009, 09:47:58 am »
You can do something along these lines, but there are a couple of caveats you should know about:
  • This works on a diagram-level basis, and for each diagram it is all or nothing (i.e. if you don't want to display one stereotype you will not be able to display any).
  • It will become the default for new diagrams.
    • But you can change it back, which will reset the default.
    • It will not retroactively change any diagrams you've already created.
    • You can change the setting for older diagrams manually if you want them to change.
  • And finally... I do not know if it works when you use shape scripts to draw native shapes; shape scripts seem to have less flexibility when they call the native drawing engine.
With all the cautionary notes out of the way, here's what to do. Open one of your diagrams, then invoke the diagram Properties Window. Click the Elements tab. Clear the Show Element Stereotypes check box (near the top left). Now close the dialog; the changes do not appear until you exit.

As I inferred above, EA will remember this setting for new diagrams you create in future (until you change the setting back of course). It will not retroactively adjust any diagrams other than the one you have open. If you want to change another diagram, open it and do the same thing; each diagram stores its own copy of this setting.

HTH, David

PS: Please post back and let the rest of us know if this works with the shape scripts.
No, you can't have it!

Peter Bull

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #2 on: March 17, 2009, 08:54:07 pm »
Thanks David

I can confirm it works with shape scripts as you suggest.

I can turn the stereotypes off per view/diagram and add my icons which is OK providing I want to stereotype every object by adding an icon/graphic.

Actually, all I really wish to do is extend the existing node stereotype icons/graphics to include things like firewalls and load balancers.  Any infrequently used bits of hardware I'd like to keep stereotyping with text.  So your response is a partial answer.

Cheers

Pete

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #3 on: March 18, 2009, 01:13:59 am »
Thanks Pete,

You have confirmed that the setting works with shape scripts, which is far better than my failing memory.

Now to your remaining issue...

I gather you want to decorate your scripts with one or more icons. This would be something along the lines of how EA decorates certain glyphs to indicate various Web stereotypes for example.

There is good news on this front, to a point. Yes, you can add an icon to your shape, or define one to add to a shape EA draws (which is not quite the same as drawing a native shape in a script).

Use the "decoration" shape type to define a small shape that will appear at a corner or edge of your shape. You will have to play around with this a bit. There are some undocumented 'rules' regarding size and such; it really is trial and error.

AFAIK you cannot define an image for this, but have to actually draw the shame. Note: This may have changed since I last mentioned it to Sparx; I have not had the time and need to test it.

You are also limited to a single decoration. Once again, this might have changed since I reported this limitation to Sparx.

Finally, this did not work with native shapes drawn via shape scripts. Yet again, Sparx may have resolved this by now. Either way, you should be able to define a shape script that has only a decoration (i.e. no "shape" keyword). This would cause a stereotyped element to be drawn by EA, and then to have your decoration applied.

HTH, David

PS: If you can confirm that any of the above limitations have been lifted, please post back here. For any that still apply and that you consider constraints, I strongly urge you to submit a feature request to Sparx. Use the link near the bottom of any forum page.
No, you can't have it!

Peter Bull

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #4 on: March 18, 2009, 04:01:58 am »
Hi David

I have found "Decoration", or the "how to quit Sparx 7.5beta3 without selecting Exit or clicking the red cross" as I prefer to call it.

Does it add an icon to an existing shape - and if so, will it remove the stereotype text?  I can draw my image on top of the native shape OK.  It is getting rid of the stereotype text (which isn't needed if you have the graphic) which is my problem.

Cheers

Pete




mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #5 on: March 18, 2009, 08:52:43 am »
Quote
I have found "Decoration", or the "how to quit Sparx 7.5beta3 without selecting Exit or clicking the red cross" as I prefer to call it.

Could you clarify what you mean by this? If it's crashing we'd want to address it ASAP. If you could elaborate by sending a bug report into Sparx Support with some detailed information on how to reproduce it, we'd be most appreciative.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #6 on: March 18, 2009, 09:47:57 am »
Quote
AFAIK you cannot define an image for this, but have to actually draw the shame. Note: This may have changed since I last mentioned it to Sparx; I have not had the time and need to test it.

You are also limited to a single decoration. Once again, this might have changed since I reported this limitation to Sparx.

Hi David, good news...

1. Yes you can put images in decoration shapes. I've just tested it (EA 7.1.834) with EMF and "too big" BMP files and they get scaled down to 16x16. I'd expect WMF, JPG, GIF and PNG to work too, but I didn't try them.

2. You can have multiple decoration shapes in a single shape script.

Here's an example (Replace "Image34742" with any image you have loaded in your model. Go to Settings > Images to open the Image Manager):

Code: [Select]
decoration top_left
{
      orientation="NW";
      setfillcolor(255,0,0);
      ellipse(0,0,100,100);
}

decoration bottom_right
{
      orientation="SE";
      image("Image34742",0,0,100,100);
}
The Sparx Team
[email protected]

Peter Bull

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #7 on: March 18, 2009, 07:36:40 pm »
Yup - decorations work fine but how do I remove the stereotype from the text in the object?  If I use a decoration to show a stereotype I don't need the <<stereotype>> text too.


Incidentally, I used the wrong syntax in setting the decoration in 7.5B3 and it crashed a lot whenever I tried to view the diagram with the stereotyped node in it.

Thanks

Pete

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #8 on: March 18, 2009, 09:38:07 pm »
OK, we need to deal with two things.

First, can you use the Diagram Options dialog to remove the text without losing your decorations? Open the dialog (F5 will do it) and click the Elements tab. Clear the Show Element Stereotypes box, then exit the dialog to force your diagram to update itself. The new setting will be remembered as the default for diagrams you create in future. You will need to change older diagrams manually.

Now to the crashing...

Please send a bug report to Sparx immediately. Compress a copy of your project and attach it to the report. Sparx takes crashes very seriously, and we don't want this problem persisting into the production version. If they can get a grip on the problem early then it could well be resolved in a build or two.

David
No, you can't have it!

Peter Bull

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #9 on: March 18, 2009, 09:41:12 pm »
Thanks David

I can use the diagram level option, but do not wish to.  I want to be able to mix objects stereotyped with text and others stereotyped with a graphic, on the same diagram.

I shall sort the bug report out.

Cheers

Pete

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape Scripts & and simple stereotypes icons
« Reply #10 on: March 18, 2009, 10:00:47 pm »
Peter,

I am not sure if you can turn off the stereotype label. AFAIK once you let EA draw the symbol you are stuck. If your script draws it (i.e. with the shape keyword) you have control, but you lose the power of the EA drawing engine.

Let's see if the Sparxians, or any other users, can come to the rescue here. Perhaps I've missed something - certainly not the first time - or there is a workaround.

David

PS: Get the bug report in fast. Remember to use the bug report specifically for the EA 7.5 beta. You'll find a link on the Bugs and Issues section of the forum (above the user posts) or on the beta download page. If you cannot attach a file - I think you can, but just don't remember for sure - then follow up with an email to Sparx support (see the About Us link at the top of any forum page) and attach the file to that.
No, you can't have it!