Book a Demo

Author Topic: Shape scripting and element names  (Read 7033 times)

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Shape scripting and element names
« on: February 22, 2006, 05:57:00 am »
Have I missed something ?  
If I add a shape script to a stereotype, it certainly displays on diagrams, but I then can't see the element name.  Even if I make the shape smaller than the available element selection area, no text appears.  

What am I doing wrong ?
thanks

thomaskilian

  • Guest
Re: Shape scripting and element names
« Reply #1 on: February 22, 2006, 06:34:43 am »
I guess nothing. There is no function to place the element name (an/or other properties) in the shape.

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Re: Shape scripting and element names
« Reply #2 on: February 22, 2006, 06:37:08 am »
Looks that way Thomas, although I thought the name might appear if you don't use the whole area allocated to the element for the shape.   Also you if you use an image, the element name still appears underneath it.   A bit inconsistent I think !

thomaskilian

  • Guest
Re: Shape scripting and element names
« Reply #3 on: February 22, 2006, 06:40:10 am »
This feature is quite new and probably they still work on improvements/corrections. It's also not unlikely that there are some yet undocumented treasures.  However, we should report these flaws and ask for improvements.

Takeshi K

  • EA User
  • **
  • Posts: 630
  • Karma: +43/-1
    • View Profile
    • Sparx Systems Japan
Re: Shape scripting and element names
« Reply #4 on: February 22, 2006, 01:50:56 pm »
Hello all,

I think you must specify where to show the element name when you set some script to stereotype.

This is a sample from BPMN add-in:
(DataObject stereotype)

shape label
{

setOrigin("SW",0,0);

print("#NAME#");
}

I think it's acceptable because EA doesn't know if script creator wants to show the name or not.

--
t-kouno
--
t-kouno

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape scripting and element names
« Reply #5 on: February 22, 2006, 02:43:03 pm »
Takeshi's answer above shows how to create a floating text box. Alternatively, to have the text inside the shape, try something like the following:
Code: [Select]

shape main
{
   layouttype="border";

   // all drawing instructions here...

   addsubshape("name","center");

   text name
   {
       h_align="center"';
       PrintWrapped("#NAME#");
   }
}

Using the border layout allows you to add subshapes to the edges of a shape or in the centre. The alternatives are "leftright" or "topbottom". Have a look at the activity shapescript in the BPMN add-in for an example of multiple-nested subshapes where a subshape is created left to right and then added to the bottom edge of a border layout.

Sorry we're still working on the shape script help, but we're happy to offer any help in the mean time.

Neil
The Sparx Team
[email protected]

mylesJ

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Shape scripting and element names
« Reply #6 on: February 23, 2006, 06:16:11 am »
This is very interesting. I didn't realise shape script had these additional commands.

I wanted to extend the different GUI elements that are available for designing user interfaces. I noticed that there was not a GUI table element availble so posted previously if I could create one with shape script. It soon became apparent that I could not because of the limitations of the scripting language. However, it is perhaps now possible.

Can you take a look at my previous posting and let me know if it is possible using shape scripts undocumented commands to achieve a table like GUI element?

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

thomaskilian

  • Guest
Re: Shape scripting and element names
« Reply #7 on: February 27, 2006, 05:21:28 am »
It would be nice to have something that fixes the aspect ratio of a shape. Similarly to sizing an <<entity>> shape that always keeps the circle.

Another problem: I was not able to place the name text below the shape (I want something like the entity shape).

thomaskilian

  • Guest
Re: Shape scripting and element names
« Reply #8 on: February 28, 2006, 05:18:44 am »
Here are some more #-Statements I dragged out of the EXE
#AUTHOR#
#CONTENTS#
#CONTENT#
#TYPE#
#SCOPE#
#CONST#
#ABSTRACT#
#STATIC#
#PARAMS#
#ALIAS#
#CONCURRENCY#
#STEREOTYPE#
#ISQUERY#
#CONSTRAINTS#
#TAGLABEL#
#NOTE#
#CONNTYPE#
etc.

I noticed for some of them that they produce meaningful results. I did not check all of them and probably they are context sensitive.

The forthcoming documentation will explain them for sure ;)
« Last Edit: February 28, 2006, 05:21:51 am by thomaskilian »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape scripting and element names
« Reply #9 on: February 28, 2006, 03:39:58 pm »
Quote
I was not able to place the name text below the shape (I want something like the entity shape).


Try something like:
Code: [Select]

shape main
{
 layoutType="Border";

 AddSubShape("Icon","Center");
 AddSubShape("Name","S");  // S for South

 shape Icon
 {
   startpath();
   ellipse(0,0,100,100);
   endpath();
   fillandstrokepath();

   moveto(0,100);
   lineto(100,100);
 }

 shape Name
 {
   PreferredHeight=20;
   H_Align="Center";
   Print("#NAME#");
 }
}
The Sparx Team
[email protected]

thomaskilian

  • Guest
Re: Shape scripting and element names
« Reply #10 on: March 01, 2006, 05:40:21 am »
Quote

Try something like:
...

Thanks Neil! Never could have guessed the "S" option. I also tried a second parameter after "Center", which did 'something' ;). I will wait for the documentation.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape scripting and element names
« Reply #11 on: March 01, 2006, 05:49:33 am »
[Thanks Thomas, I was not sure whether I could do this. I also had not noticed the "Remove" button, so was unaware that I could delete a specific post. Some people might think I was unobservant; those people would be correct...]

Hi folks,

Here is an excerpt from Neil's response to my earlier query on a similar subject. It may extend the usefulness of Thomas' list:
Quote
It looks as if most of the properties of an
element can be queried with the HasProperty() function and then
displayed with the text substitution macros. Here is the list of
properties that can be queried for diagram objects:

name, scope, type, classifier, propertytype, stereoType, alias,
language, complexity, version, phase, language, packageName, author,
status, dateCreated, dateModified, keywords, isTagged, isAbstract,
multiplicity, isroot, isleaf, isSpec, isActive, persistence, notes,
cardinality, visibility, concurrency, isEmbedded, parentEdge

So you can do something like:

if (HasProperty("language","Java"))
{
PrintWrapped("#dateCreated#");
}



My experiments to date suggest (but I'm not sure as yet) that the strings inside the # marks are case sensitive. My best guess is that you should try all upper case (as Thomas has listed) first.

HTH, David
No, you can't have it!