Book a Demo

Author Topic: Partly hidden stereotyped connector with shapescript to change the color  (Read 9294 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Hello,

I have created a number of stereotyped "Connectors" that have an enum tagged value e.g. Type.
I wrote a shapescript to change the line colour according to the tagged value:

Code: [Select]
shape main{
if (HasTag('type','A'))
{
SetPenColor(0, 0, 0); //Black
}
if (HasTag('type','B'))
{
SetPenColor(255, 255, 0); //Yellow
}
if (HasTag('type','C'))
{
SetPenColor(255, 165, 0); //Orange
}
DrawNativeShape();
}

This works well except that part of this connector is hidden. If I move it around, it's more or less hidden (it can even be fully hidden if I set the line style to Direct):



I wonder if the sterelotype label (which I hide) could generate some kind of conflict.

Am I missing something in my shapescript?

Thanks,
Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #1 on: November 21, 2020, 04:27:23 am »
Looks good to me. Probably an EA version issue? I know Shapescript gets hickups when you use shapes at the ends and bend the  connector (I should report that as bug, but it's wasted time since it won't be fixed anyway).

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #2 on: November 23, 2020, 08:10:26 am »
Is DrawNativeShape() allowed with connectors? Try moveto(0,0); lineto(100,0); instead.
The Sparx Team
[email protected]

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #3 on: November 23, 2020, 06:27:43 pm »
Is DrawNativeShape() allowed with connectors?
Yes, it is. But it doesn't do anything in a connector script.

/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #4 on: November 23, 2020, 06:34:12 pm »
Is DrawNativeShape() allowed with connectors? Try moveto(0,0); lineto(100,0); instead.
As per help it's explicitely not allowed. I'm surprised! Anyhow, if you care, I had a shape with a ball similar to the nesting connector. Cut down:
Code: [Select]
shape target{
Ellipse(0,-8,16,8);
}
shape main {
MoveTo(0, 0);
LineTo(90,0);
}
which sort of looked ok. Until you make a bend somewhere. Just see what happens...

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #5 on: November 23, 2020, 06:36:23 pm »
Hello,

Thank you for the advice.
It partially sorted the issue as the line is properly rendered. I have to redraw the arrow end which is not rendered with the custom line, but otherwise it's fine.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #6 on: November 23, 2020, 07:19:41 pm »
Is DrawNativeShape() allowed with connectors? Try moveto(0,0); lineto(100,0); instead.
As per help it's explicitely not allowed.
Not quite. "This method is only enabled for element Shape Scripts; line Shape Scripts are not supported."

The editor allows you to call DrawNativeShape() in a connector script, and the auto-completion also includes it. So the claim that it isn't enabled is simply wrong.
It isn't supported in connector scripts, but the editor permits and in fact encourages you to use it anyway.

/U
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #7 on: November 23, 2020, 07:32:49 pm »
That would be a bug in the editor's intellisense then. Not that I care in any direction...

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #8 on: November 23, 2020, 08:00:20 pm »
Well, it seems the editor doesn't recognize whether the script is for an element or a connector. I'd call that poor design rather than a bug.

/U
My theories are always correct, just apply them to the right reality.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #9 on: November 23, 2020, 09:49:42 pm »
Well, it seems the editor doesn't recognize whether the script is for an element or a connector. I'd call that poor design rather than a bug.

/U
Formally, it's a design defect.

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

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #10 on: November 24, 2020, 08:32:32 am »
Well, it seems the editor doesn't recognize whether the script is for an element or a connector.


It could be both. I've had stereotypes that extend both Class and Association; it makes writing the shape main a bit fiddly but EA copes.
The Sparx Team
[email protected]

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Partly hidden stereotyped connector with shapescript to change the color
« Reply #11 on: November 24, 2020, 07:50:12 pm »
Well, it seems the editor doesn't recognize whether the script is for an element or a connector.
It could be both. I've had stereotypes that extend both Class and Association; it makes writing the shape main a bit fiddly but EA copes.

Fair point. And the editor tooltip does tell you that DrawNativeShape() won't work for a connector script. But who has time to read those? :)

/U
My theories are always correct, just apply them to the right reality.