Book a Demo

Author Topic: Specify label position in ShapeScript  (Read 3043 times)

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Specify label position in ShapeScript
« on: May 16, 2013, 11:24:51 pm »
Good afternoon,

I'm currently trying to create a custom shapescript for a stereotype derived from Port.

Code: [Select]
shape main{
 startpath();

 rectangle(0,0,100,100);        

 endpath();

 setfillcolor(0,0,0);

 fillandstrokepath();
}

shape label {
      if (hasproperty("parentedge","top"))
      {
            setorigin("NE",0,0);
            println("top");
      }
      
      if (hasproperty("parentedge","bottom"))
      {
            setorigin("SE",0,0);
            println("bottom");
      }
      
      if (hasproperty("parentedge","left"))
      {
            setorigin("NW",0,0);
            println("left");
      }
      
      if (hasproperty("parentedge","right"))
      {
            setorigin("NE",0,0);
            println("right");      
      }
}

As you probably see, I want the port's label to change its relative position depending on the ports position relative to its parent element. The text of the labels is always correct, so that I can assume that the right if statement is entered! But the position change doesn't work at all.

1) How does setorigin() work?
2) Where is the reference origin to which I specify the offsets?
3) Is setorigin() the right method to do the job?

Thanks in advance!