Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paolo F Cantoni on April 08, 2010, 08:29:19 pm

Title: Alternate image in MDG
Post by: Paolo F Cantoni on April 08, 2010, 08:29:19 pm
I tried to create an alternate image for my MDG but I can't get it to work...  I'm obviously missing the "special sauce".

Can any kind soul show me how it's done?  There were no effective references in a search.

TIA,
Paolo
Title: Re: Alternate image in MDG
Post by: Michael Proske on April 22, 2010, 05:45:25 am
What exactly to you mean with "alternate image" ? Do you mean the icon that will be shown in the MDG Technologies dialog ? This icon should be only a 16x16 bitmap maybe this is the problem.
Title: Re: Alternate image in MDG
Post by: Rossco on April 22, 2010, 08:54:13 am
If you want to apply an alternative image for an element in diagrams you can do this using shape script and the image function

image(
       string imageId,
       int left,
       int top,
       int right,
       int bottom)

Where the image ID is the name of an image in your model
(Settings- >Images) and the rest is formating

Regards
Ross
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 22, 2010, 09:37:49 am
Quote
What exactly to you mean with "alternate image" ? Do you mean the icon that will be shown in the MDG Technologies dialog ? This icon should be only a 16x16 bitmap maybe this is the problem.
No Michael,

I have those OK - thanks.

I'm after what Ross was mentioning.

Ross, I was aware of using shape scripts - but the help implied I didn't need to do that.

The Help also suggested that I could use the paintbox to set Stereotype default fill, border and font colours - but that doesn't seem true either.  You have to use shapescripts also - which in this latter case don't have the same functionality.  :(

Paolo
Title: Re: Alternate image in MDG
Post by: Makulik on April 22, 2010, 06:28:08 pm
Hi paolo,

Do you need an alternate image for a profiled stereotype? i've been experiencing problems with the alternate images also. I wrote shape scripts to put images as additional decorations to stereotyped elements. when the profile was exported and then applied with a MDG technology, the images weren't drawn. I guess it's because of the images werent properly exported, or have different id's, i don't know. sometimes it worked, sometimes not  :P ...

the _image attribute of the stereotypes' metaclass needs to be private, type 'int' to get working with a shape script in the initial value. never tried to specify an image (id) directly there.

HTH
günther
Title: Re: Alternate image in MDG
Post by: Krzysztof Swiatkowski on April 22, 2010, 06:37:16 pm
If you don't need the picture, just colors then you can do it without the shapescript. You just need to set "Default appearance F4" in appearance menu. And then select "Color and Appearance" in Save Profile dialog.
Unfortunately the image probably needs to be drawn.
Some time ago there was a stereotype property for applying metafile to a stereotype but it don't remember its name :(.

HTH
Kris
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 22, 2010, 09:18:16 pm
Quote
If you don't need the picture, just colors then you can do it without the shapescript. You just need to set "Default appearance F4" in appearance menu. And then select "Color and Appearance" in Save Profile dialog.
[size=18]...[/size]
Hi Kris,

Thanks! My problem was I'd just coloured the element; NOT set the Default Appearance [F4].

Working now...

Paolo

Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 23, 2010, 11:55:03 am
Quote
My problem was I'd just coloured the element; NOT set the Default Appearance [F4].
Well,

I can now set the default appearance of the stereotyped element on creation from the profile.  What I CAN'T do is what I need - to create the default appearance of the stereotype.  I need to do the same as the Default Colours panel of the UML Types Stereotypes tab.

I need to be able to change the definition in the profile and when the new profile is loaded have the new definition applied to all the elements with that stereotype.

At present, using this current technology, if I change the Default appearance of the Stereotype - all the existing elements retain the old appearance - creating confusion all round.

Is it really THAT hard to get consistency?  I mean in a profile we're dealing with metadata.  The primary use case should be how to apply the characteristics at the stereotype (not element) level.  Being able to set the element specific characteristics is, at best, as supporting use case!

If, as I suspect, it isn't possible - at present.  I have a proposal for how to (easily) make that happen.

Thoughts?
Paolo
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 23, 2010, 10:17:30 pm
Quote
I tried to create an alternate image for my MDG but I can't get it to work...  I'm obviously missing the "special sauce".

Can any kind soul show me how it's done?  There were no effective references in a search.

TIA,
Paolo
Back to the original question...

I've created the emf file.  Added it to the profile (as per the Profile Structure Help topic) - checked it appears in the XML and still nothing...

Anyone got it to work?

Paolo
Title: Re: Alternate image in MDG
Post by: Krzysztof Swiatkowski on April 26, 2010, 09:45:26 am
Quote
Quote
I need to be able to change the definition in the profile and when the new profile is loaded have the new definition applied to all the elements with that stereotype.

Ah so that what you need Paolo. Well you need this friendly ShapeScript:
Code: [Select]
shape main{
      SetFillColor(0,0,255);
      SetPenColor(0,255,0);
      SetPenWidth(2);
      DrawNativeShape();
}

now you only need to add _image attribute to your stereotype and your on your way. With one exception: for some strange reason you cannot change text color - but thats general problem of the ShapeScripts.

But be aware that this path leads to the dark side of UML. With ShapeScript you can change the looks completly to the point of making it unreadable. You have been warned.
On the other hand "The Force" allows you to make "cloudy" UML::Nodes which can be handy :D
Sorry, It must be 1am SW mood I got into  ;D.

Regards
Kris
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 26, 2010, 09:55:34 am
Quote
[size=18]...[/size]
Ah so that what you need Paolo. Well you need this friendly ShapeScript:
[size=18]...[/size]
Hi Kris,

I'm well aware of shapescripts for MDG - I've been reporting bugs with them for most of last week...  ;)

As usual, their behaviour is self inconsistent.

My point is that the Help documentation says I can do some things WITHOUT shapescripts (such as set alternate images).  These don't work either (at least I can't make it work so far).

Frustrating isn't the word...

Paolo
Title: Re: Alternate image in MDG
Post by: Makulik on April 27, 2010, 01:11:26 am
[OT]
Quote
Sorry, It must be 1am SW mood I got into  ;D.

I'd better say, it seems the [size=12]force[/size][/color] touched you. Trying to be helpful shows you're on a good way ...  ;)

WBR
g.
[/OT]

Title: Re: Alternate image in MDG
Post by: Sunshine on April 30, 2010, 01:36:13 pm
As far as I know there are two approaches to applying alternative images to stereotypes.
a) Use shape script as mention in previous lists.
b) apply the alternative image to the stereo type on the profile diagram.

I think you are after the easiest option which is option b)
On your profile diagram where you inherit from an existing meta class you need apply the alternative image (ctrl+shft+w) to the new stereotype you are creating. Then when you save as profile ensure you have the alternative image tick box selected.

I've used both techniques on past versions of EA. Although haven't tried it with V7.5 or 8.0.
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on April 30, 2010, 10:58:49 pm
Quote
[size=18]...[/size]
I've used both techniques on past versions of EA. Although haven't tried it with V7.5 or 8.0.
Well, I've just tried option b) (which you've correctly noted is the one I'm after) on v8 and (just like before) it didn't work.  The image data IS generated into the XML file, but it doesn't seem to trigger the alternate image.

Can anybody confirm the process outlined for option b) works for v8?

TIA,
Paolo
Title: Re: Alternate image in MDG
Post by: Sunshine on June 29, 2010, 10:04:09 am
I've recently had the opportunity to create another profile using images. One of the things I've found is that there are two ways to deploy the technology xml file created by the tools>generate MDG Technology file menu.
a) copy the file to C:\Program Files\Sparx Systems\EA\MDGTechnologies and restart EA.
or
b) Import the technology file via resources>MDG Technologies.

Thinking back a few years now it was option b) I used to get alternative images working.

With option a) the toolbox associated with the new diagram type works but the images don't seem to show.
However with option b) the images show but the toolbox doesn't work.

Don't you love it. :-?

My workaround is to use both approaches so the images work with the toolbox. Alternatively you can reference the image in a shape script. I confess I haven't gone down that path as I have 78 stereotype and don't what to write 78 shapescripts.

Title: Re: Alternate image in MDG
Post by: beginner on June 29, 2010, 04:50:58 pm
It seems you need some kind of automation to automate automation.

b.
Title: Re: Alternate image in MDG
Post by: Sunshine on July 02, 2010, 07:23:10 am
Okay after a few days of trying different things to get alternative images to work from a stereo type in a profile. I've exhausted various options and the only things that seems to work is as described in my previous post. So I decided to raise the alternative images behaviour in profiles as a bug with Sparx Systems and see if they can fix it so you only have to deploy the MDG file once.
Title: Re: Alternate image in MDG
Post by: ecourt on July 07, 2010, 07:32:55 pm
Hi,

I have come across a similar problem with alternative images.  I found that if when creating the MDG technology file you select the images used in the shape scripts when you get to the images dialogue, that if you just copy the MDG xml file into the MDGTechnologies directory it works.  I have had some slightly odd behaviour is I imported the tehcnology and put it into thedirectory so now just copy the xml files into the directory.

Emma
Title: Re: Alternate image in MDG
Post by: Paolo F Cantoni on July 08, 2010, 10:25:11 am
Can you elaborate on that please Emma?

I'm not sure I understand the point you are making...

TIA,
Paolo
Title: Re: Alternate image in MDG
Post by: Sunshine on July 13, 2010, 07:17:37 am
Sparx Systems have come back to me regarding the images in MDG. Here is their response with suggested work around;

Quote
Thanks for your note.

There are two ways to deploy a technology:
1. Model-based deployment (import into Resources view) imports images but you can't use a number of features of technologies including custom toolboxes.

2. File-based deployment (using the Settings > MDG Technologies command) doesn't import images.

We do not recommend using both deployment methods simultaneously as the imported resources (e.g. stereotype definitions) will interfere with the external resources.

The better solution is to export images as reference data (Tools > Export Reference Data) and import the reference data into the target databases, and use the file-based deployment of the technology.  You may also consider applying the images using a shape script:

shape main
{
      layouttype="border";
      image("image.bmp",0,0,100,100);
      addsubshape("name","S");

      shape name
      {
            h_align="center";
            print("#NAME#");
      }
}

See the "Shape Scripts" topic in EA help for details.

I hope that helps.  If you have further questions or issues please let us know.

So it looks like my work around of deploying two different ways is not recommend. It doesn't look like they are going to fix the problem either. :(
Title: Re: Alternate image in MDG
Post by: Sunshine on July 28, 2010, 09:34:31 am
Just to clarify something about using images in shapescripts mentioned in the previous post, incase like me you thought you could get away with just one MDG Technology file. You still need to import the images into the model otherwise it doesn't work even though you can export the images into the MDG Technology file.   :(

If you don't you end up with a grey box indicating its referencing an image that doesn't exist in the model.

Here is the description of using the image() function from the help
Quote
Draws the image that has the name imageId in the Image Manager.

Note:
 
The image must exist within the model in which the stereotype is used. If it does not already exist in the model, you must import it as reference data.
Title: Re: Alternate image in MDG
Post by: jakob on April 28, 2011, 06:12:52 am
Quote
As far as I know there are two approaches to applying alternative images to stereotypes.
a) Use shape script as mention in previous lists.
b) apply the alternative image to the stereo type on the profile diagram.

I think you are after the easiest option which is option b)
On your profile diagram where you inherit from an existing meta class you need apply the alternative image (ctrl+shft+w) to the new stereotype you are creating. Then when you save as profile ensure you have the alternative image tick box selected.

I've used both techniques on past versions of EA. Although haven't tried it with V7.5 or 8.0.

I like option b) but this option seems not to work if you use more than one diagram to define your profile: When you export your Profile by right clicking on the profile package and clicking on Save Package as Profile... the images won't be included.  :(