Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Jayson on July 09, 2014, 06:16:59 am
-
I am trying to assign an image to a custom stereotype by following the instructions in the help files.
Go into Settings->UML Types->Stereotypes
1 Specify the steretype (KPI)
2. Base Class (Class)
3. Select Metafile radio button and select an emf file.
4. Save.
5. Re-generate the MDG.
Some things that have me curious are:
1. The instructions don't tell me to specify a Group Name (whatever that is) despite there being a text field called Group Name.
2. After I have assigned the emf file, nothing shows up in the Preview pane.
I am using version 9.3.
Cheers
Jays :)
-
Two of your steps don't belong together:
Go into Settings->UML Types->Stereotypes
and
5. Re-generate the MDG.
At no point in creating an MDG Technology will you need to go into the Stereotypes table. They are either/or.
-
I am looking at the document "enterprise_architect_sdk.pdf" section 1.1 Custom Stereotypes, which states that to associate a meta-file image with a stereotype:
1. Select Settings->UML Types.
2. Type or select Stereotype name.
3. Select Base Class.
4 Click metafile radio button and assign button to locate required file.
5. Enter optional notes.
6. Click save.
I have assumed that this is the way that I assign an image to my stereotypes. If not, can you point me to the place that explains how to do it?
Cheers :)
-
Those steps are for stereotypes that are not part of any profile/technology. If you are defining a stereotype in a profile, you will need to apply the image to the «stereotype» class and save the profile with "Alternate Images" option ticked, and then you can re-generate your technology.
-
HI there
I've found where to apply the image to the stereotype easily enough, but can't find where to "tick" alternate images on the profile.
Can you please point me in the right direction?
Cheers :-)
-
Scratch that, I have found the alternate images option for the profile but when I regenerate, the MDG it doesnt show the image but rather still shows the standard object.
-
You are using EA 9, aren't you? It is possible that you may need to do something like this, creating a shape script for the stereotype:
shape main
{
image("imagename",0,0,100,100);
}You will also need to include the images in your MDG Technology - the wizard has a page to help you.
-
A bit off topic but something ill be putting forward as a feature request - just want to check if it sounds like a good idea/feasible.
in my shapescript id like to include something like:
image ("#TAG:location# flag.jpg", 0, 0, 100, 100)
I'd like the tag value loction to be substituted as it is in print statements...but it looks like the substituation only occurs in print statements. Would it be possible to just substitute the #TAG:<tag property># construct any where it appears within the shapescript ?
Regards,
Jon.
-
I guess that implementing a primitive string manipulation in shape script would be the best.
q.
-
I added an _image attribute to the stereotype and included the following script:
shape main{
image("Data Source_64.bmp",0,0,64,64)
}
and during the MDG generation I included Data Source_64.bmp in my build.
But I still get nothing.
-
Ok, so an update to this.
I have now managed to get one stereotype to display am image but another two that I have applied the same method to just show a blank grey square.
-
Sounds like your going though the pain barrier. Keep up the good work you'll get through it Jayson.
To get the image which you should have included in the MDG generation process you'll need to add the MDG name space of the image. This is the name you call the MDG. i.e. what you fill in on the 'Technology' field of the MDG Technology Creation Wizard Dialog.
So if you have a MDG Technology called 'MyMDG' you need to modify your code to something like this
shape main
{
image("MyMDG::imagename",0,0,100,100);
}
Good luck Mr Speer ;)
-
Thanks Sunshine, definite pain going on :D
But finally got that working thanks to you.
But once I did, I noticed that the name of the element doesn't appear which really makes the whole process pointless because I am currently looking at a dozen elements on a page that are indistinguishable without actually clicking on them.
Any chance you know how to add the element name?
Cheers
Jays :)
-
Within the shapescript:
println("#NAME#");
and if you want to see the stereotype:
println("<<#stereotype#>>");
-
That worked perfectly, thanks for that.
Is there any way to print this on the outside of the image box so that it doesn't sit on top of my nice pretty image?
-
I just put this part of the shape script at the end, and prefix it with a bunch of:
println(" ");
println(" ");
Until it appears below the shape.
There are probably more elegant solutions...
Andy
-
This one puts the name on the bottom edge of the shape:
shape main
{
layouttype="border";
image("ImageName",0,0,100,100);
addsubshape("name","S");
shape name
{
h_align="center";
print("#NAME#");
}
}
-
Awesome! Thanks a bunch :)
So I should be able to make it possible for the user to edit the name directly on the drawing using the editablefield property right?
I added:
editablefield = "name";
just before
print("#name#");
but nothing seemed to happen.
Is this because the text is outside the 100 x 100 box?
-
but nothing seemed to happen.
Press F2
-
You mean select the object with the mouse and hit F2?
Tried that and nothing.
-
That worked perfectly, thanks for that.
Is there any way to print this on the outside of the image box so that it doesn't sit on top of my nice pretty image?
In addition to the previous suggestion you could try putting the print statement in a shape label to get floating text label.
...
shape label
{
print("#name#")// draw a floating text label
}
RTM: http://www.sparxsystems.com/enterprise_architect_user_guide/10/extending_uml_models/writing_scripts.html