Book a Demo

Author Topic: Shape for port!  (Read 5412 times)

harvinder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Shape for port!
« on: August 02, 2010, 03:02:39 pm »
I am creating a uml profile in which I am trying to customize port stereotype.

The script used is as below,

Code: [Select]

shape main
{
    setfillcolor(255,0,0); // (R,G,B)
    startpath(); // Start to trace out a path
    moveto(0,0);
    lineto(0,40);
    lineto(20,30);
    lineto(40,40);
    lineto(40,0);
    lineto(0,0);
    
    endpath();  // End tracing out a path
        // Fill the traced path with the fill color
    fillandstrokepath();
    return;
}
When I attach this stereotype object to a class, the size is coming properly, however when I select the shape, selected area is shown bigger than the shape.

Any idea on how to solve this problem?

thanks
harvinder

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shape for port!
« Reply #1 on: August 02, 2010, 03:31:58 pm »
Hi Harvinder,

If you are saying that even after your shape script is applied the selected size is still the original 100% size, then I don't think there's a solution.

There is no direct relationship between the shape you create with the shape script and the selection size of the element.  It would need a specific Shapescript method (such as SetSelectionShape()  or some such) to specifically set it.  There is no such method available.

HTH,
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: Shape for port!
« Reply #2 on: August 02, 2010, 03:37:26 pm »
The numbers in the moveto() and lineto() commands are percentages, not pixels, so drawing to the bottom right corner of your shape should be lineto(100,100); not lineto(40,40); and other commands will also need to change. If you want your port to display as 40x40 pixels, then you will need to use the command defsize(40,40);
The Sparx Team
[email protected]

harvinder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Shape for port!
« Reply #3 on: August 02, 2010, 03:44:52 pm »
I made following changes in script
Code: [Select]
shape main
{
    fixedAspectRatio= "true";
    dockable = "standard";
    scalable = false;
    defSize(100,100);
    setfillcolor(255,200,0); // (R,G,B)
    rectangle(0,0,20,20);
    return;
}

and then changed the generated xml (uml profile)
Previously
Code: [Select]
           <Stereotype name="TestNet Input" notes="The input port" cx="90" cy="70" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">
to
Code: [Select]
           <Stereotype name="TestNet Input" notes="The input port" cx="20" cy="20" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">

and it is showing up properly

Question, what determines cx and cy? Only when did I set cx=20 and cy=20 does it show properly

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape for port!
« Reply #4 on: August 02, 2010, 03:56:49 pm »
Quote
Question, what determines cx and cy?
Search the help for _sizeX and _sizeY
The Sparx Team
[email protected]

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
« Last Edit: August 02, 2010, 04:21:59 pm by RoyC »
Best Regards, Roy

harvinder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Shape for port!
« Reply #6 on: August 02, 2010, 04:19:56 pm »
thanks guys, I am able to get the desired results now.

One more query, I have this stereotype <<TestNet Input>> port1 showing up, how may I customize it to just display say Input1

thanks
harvinder

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Shape for port!
« Reply #7 on: September 09, 2010, 04:24:07 am »
Harvinder, would you please re-post your final shape script.  We are having this same problem.  I am about to submit a bug report if I cannot find an answer.

Also, your shape script does not have quotes around all values.  I wonder if the "false" without quotes is effective.

Thank you!  Jim.