Author Topic: Shape scripting Language  (Read 5545 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Shape scripting Language
« on: October 13, 2005, 04:57:58 am »
Hi,

Any chance the Sparxians (or anyone else) could give us some information as to the Shape Scripting Language mentioned in the [size=13]6.0 powerpoint presentation[/size].

Just so we can plan how we might use this new facility...

Paolo
« Last Edit: October 13, 2005, 04:59:28 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #1 on: October 26, 2005, 10:20:08 pm »
Hello Paolo,

Sorry about the late response.

Shape Scripts provide a means to override the presentation of EA's drawn elements (nodes, paths, and labels).

In the case of nodes, scripts may control the drawing of the entire node, or just the little icons that sometimes appear in the top left corner (eg. Tables).  

The bounding box of a node is a canvas for the scripts to draw on.  A number of commands are at users' disposal to draw geometric primitives such as lines, rectangles, ellipses, arcs, polygons, and text.

Paths have 3 overridable regions: the line segments and  the two arrow heads.   The arrow heads each have rectangular canvas' that scripts may draw to, just like nodes.  The canvas's rotate with the line, or may be at a fixed orthagonal angle protruding from joining element.  Each line segment of a path may also become a canvas that is rotated so that the top corners of the canvas are the respective start and end points of the segment.

We've provided basic conditional branching based on properties of the element being drawn.  This means users can dynamicly change the appearance of a particuar node by changing say it's status type, or by adding a particular tagged value.

The shapescripts are applied to elements based on the elements Type & Stereotype - just like the current Metafile override facility (for those unfamiliar with this feature please see Configuration->Stereotypes->UML).

There are a few limitations - at this stage the language is pretty basic; expressions are limited to the condition part of an if statement and currently are no user definable variables.  Only properties of the drawn element are exposed; traversing to data in other parts of the model is not currently supported.
Hopefully these limitations may be overcome in time.

Here's an example script that results in a element being drawn as it usually would, but with a small circle being drawn in the the top right region of a node - the circle is green if the node has the status of "Approved", red otherwise:

Code: [Select]

decoration dot
{
 //Position the decoration in the
 //north eastern region of the node
 orientation = "ne";

 if(HasStatus("Approved"))
   SetFillColor(0,255,0); //Set the fill to green
 else
   SetFillColor(255,0,0); //Set the fill to red

 StartPath();
 //Draw a circle with the bounding rect of
 //x1=0%, y1=0%, x2=100%, y2=100%
 Ellipse(0,0,100,100);
 EndPath();

 //Paint the path
 FillAndStrokePath();
}


The following script replaces the entire element with a rectangle, and draws it's name in the center:

Code: [Select]

shape main
{
 h_align = "center";
 v_align = "center";

 StartPath();
 Rectangle(0,0,100,100);
 EndPath();

 FillAndStrokePath();

 Print("#NAME#");
}


Questions are welcome.

Ash
« Last Edit: October 26, 2005, 11:38:46 pm by AshK »
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shape scripting Language
« Reply #2 on: October 26, 2005, 11:18:17 pm »
Thanks Ash,

Looks Good!

When will we have a more formal definition (say via a page on the Sparx site or Help) for the entire script language?

Also, how will these glyphs interact with the existing text on the shape (like say the external parent which are also at top right)?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #3 on: October 27, 2005, 12:17:05 am »
Glad you like the look :)

The help file will be the definitive reference, and will be available with the 6.0 beta.

Quote
Also, how will these glyphs interact with the existing text on the shape (like say the external parent which are also at top right)?


You're asking if you can replace only a portion of an elements presentation, leaving the other parts intact.  In this case no, not at this stage.  With exception to the decorations (as in the first example), using a script generated glyph is an all or none affair - that is if you provide a shape called "main", then the script becomes responsible for drawing the entire element.

Currently nodes have 2 overridable named regions:

- main, the whole element
- label, each node has a detached, movable, and resizable canvas.

In addition, nodes may also have 0..* decorations (1st example).  These may be placed in any of the 8 compass points (or center).  These decorations are drawn on top of the element, regardless of whether it was drawn using a script or EA's usual code.

We could allow other named regions, so users could modify only part of an elements presentation.  To use your external parent example:

shape externalParentCompartment
{
...
}

or perhaps, the region for a single attribute:

shape attributeCompartment
{
...
}

We'll surely consider adding such named regions.

Ash
« Last Edit: October 27, 2005, 12:28:43 am by AshK »
The Sparx Team
[email protected]

thomaskilian

  • Guest
Re: Shape scripting Language
« Reply #4 on: October 27, 2005, 01:10:26 am »
Looks like a new toy. Likely useful but also source of a lot of bugs - and still many open construction places (rtf, code gen, transformation, etc.). I'd better like to see the open issues closed before making place for new ones...

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shape scripting Language
« Reply #5 on: October 27, 2005, 01:56:18 am »
Quote
Looks like a new toy. Likely useful but also source of a lot of bugs - and still many open construction places (RTF, code gen, transformation, etc.). I'd better like to see the open issues closed before making place for new ones...
Thomas,

As you know, I agree with you, but since Santa will be bringing new toys regardless, the sooner we can evaluate and report bugs the quicker they might get fixed.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shape scripting Language
« Reply #6 on: October 27, 2005, 01:58:32 am »
Ash,

Will all the standard EA icons and shapes be available to we users?

Typically, we want to create new icons by modifying existing ones...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

hb01

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • think before you code
    • View Profile
Re: Shape scripting Language
« Reply #7 on: October 28, 2005, 02:33:07 am »
Sounds promising!  8)
Would I be able to create transparent images this way? Transparent png's do'nt seem to work in EA at the moment.

Regards,

Hans

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shape scripting Language
« Reply #8 on: November 09, 2005, 06:32:40 pm »
Hi,

has anybody had a play with this yet?  What did you do?  What were your experiences?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #9 on: November 09, 2005, 06:54:31 pm »
Quote
Ash,

Will all the standard EA icons and shapes be available to we users?

Typically, we want to create new icons by modifying existing ones...

Paolo


Hi Paolo,

The standard icons are drawn with EA's legacy drawing code, so we won't have an shapescript implementation available to give.

However, both the BPMN and the SYSML profiles use the shapescripts extensivly and will be exposed to users for reference/modification.

Ash
The Sparx Team
[email protected]

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #10 on: November 09, 2005, 06:54:58 pm »
I would like to admit that the current documentation for the Shapes feature is both incomplete and outdated.
Please expect an update very soon.

My appologies if this has wasted anyones time.

Ash
The Sparx Team
[email protected]

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #11 on: November 09, 2005, 07:02:25 pm »
Quote
Sounds promising!  8)
Would I be able to create transparent images this way? Transparent png's do'nt seem to work in EA at the moment.

Regards,

Hans


Hi Hans,

No, the shape scripts currently do not support the rendering of raster/vector files, though this is a possability.

I'll place a request for a review of EA's PNG rendering - sounds like it shouldn't be to difficult to implement.

Ash
The Sparx Team
[email protected]

tcarpenter

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Shape scripting Language
« Reply #12 on: November 19, 2005, 12:30:28 pm »
The shape scripting language is an answer to a prayer for me.  ;D

However, the help file for 6.0 does not, as promised above, give a complete set of commands.  ??? Commands used in your example files as well as some samples from staff in this forum do not even appear there - e.g. h_align, v_align, orientation, etc.

Is there any way we can get a reliable set of commands and their allowable parameters?

Thanks,
Ted