Book a Demo

Author Topic: Shape script labels  (Read 8554 times)

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Shape script labels
« on: May 21, 2008, 07:52:27 am »
I came up with the following shape script to put one label in the upper right corner of a box and another label in the center.  But, I find that there are times when I want to stretch this box vertically in order to put subcomponents over the top of it.  If I do that, the subshapes get stretch proportionally, so the #name# label ends up a bit over vertically centered.  That isn't really desirable since I am likely to want to put a subcomponent over the middle like that.  I can adjust the size of the top subshape and move the #name# label farther up, but not only does it not move as far as I would like when the box is tall, but it then overlays the label in the upper right.

Is there any way to get one in the upper right and the other a bit below it, but centered so that when the box is vertically minimized the #name# label is more or less centered, but it floats fairly near the top when the box is vertically stretched?

shape main
{
  setfillcolor(204,255,255);
  setpen(0,0,0,2);
  rectangle(0,0,100,100);

  addsubshape("stereotype",100,20);  // I have played with
  addsubshape("namelabel", 100,80);  // these values
  
  shape stereotype
  {
    v_align = "top";
    h_align = "right";
    println("«oeProgram» ");
  }
  
  shape namelabel
  {
    v_align = "top";
    h_align = "center";
    println("#name#");
  }
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Shape script labels
« Reply #1 on: May 21, 2008, 08:22:49 am »
Try setting scalable to false for your namelabel subshape.
« Last Edit: May 21, 2008, 08:23:02 am by simonm »

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Re: Shape script labels
« Reply #2 on: May 21, 2008, 09:10:26 am »
Thanks ... I'll give that a try.

peter.zrnko

  • EA User
  • **
  • Posts: 253
  • Karma: +0/-0
    • View Profile
Re: Shape script labels
« Reply #3 on: May 22, 2008, 07:15:21 pm »
Try to use decoration.

This shapescript is working well. It adds a little icon in the top left corner. This icon has a constant size whether the big shape is streched or not.

Code: [Select]
shape main {
    drawnativeshape();
}

decoration noStore {
         orientation = "NW";
      preferredwidth = 110;
      preferredheight = 110;
    if (HasTag("stored","false")) {
            rectangle(10,35,110,85);
            ellipse(10,10,110,60);
            ellipse(10,60,110,110);
            setpen(255,0,0,3);      
            moveto(15,105);
            lineto(105,15);
      }
}
Peter

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Re: Shape script labels
« Reply #4 on: May 23, 2008, 02:37:51 am »
I thought about using icons, but we have a fairly large number of stereotypes to encode and I despaired of coming up with enough meaningful symbols to convey the intent.

Plus, my real problem here isn't the stereotype label that I am putting in the upper right corner, but rather the name of the element which should be below that, but should remain near the top when the element is stretched.  The scalable idea sounds like the right trick and I hope to have a few minutes to try it soon!

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Re: Shape script labels
« Reply #5 on: May 24, 2008, 08:10:34 am »
Well, Simon, interesting idea, but not quite the right effect.  With scalable = true, then the script I gave puts the stereotype label in the upper right corner, but with scalable = false, then it puts it right justified within 100, regardless of the actual width of the element.  Likewise, while the scalesable = false means that I can control the vertical position of the #name# label, it also means that it is centered on an absolute width, regardless of how wide the element is.  Since some component have quite long names, I can't really fix this by just using a value higher than 100 for the width.

Seems what I need to be able to do is set vertical scalability separately from horizontal scalability.

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Re: Shape script labels
« Reply #6 on: May 24, 2008, 08:15:11 am »
Also curious, in the following revised script:

shape main
{
  setfillcolor(204,255,255);
  setpen(0,0,0,2);
  rectangle(0,0,100,100);

  addsubshape("stereotype",200,20);
  addsubshape("namelabel", 200,20);
  
  shape stereotype
  {
    scalable = "false";
    v_align = "top";
    h_align = "right";
    println("«oeProgram» ");
  }
  
  shape namelabel
  {
    scalable = "false";
    v_align = "top";
    h_align = "center";
    println("#name#");
  }
}

With the values shown, the preview is close to what it was with the scalable = true, but not quite.  If I make the containing rectangle 200 wide, then the preview box goes right off the size of the dialog and the label is positioned in the same way is is with the values above.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape script labels
« Reply #7 on: May 24, 2008, 08:52:11 pm »
Methinks we've been missing an option or two all along. Shape scripts continue to be too approximate for close work. Without cleaner control over position and sizing - text and elements both and separately - this will remain the case.
No, you can't have it!

Thomas Mercer-Hursh

  • EA User
  • **
  • Posts: 386
  • Karma: +0/-0
  • Computing Integrity
    • View Profile
Re: Shape script labels
« Reply #8 on: May 25, 2008, 02:16:38 am »
Seems to me that shape scripts is an area where a very small amount of attention to additional functionality would multiply their utility.  What I would like to see is a combination of:

1. Basing all visual appearance on publicly available shapescripts instead of built-in "magic";

2. Ability to modify the end decorations;

3. A handful of added features such as font control and, obviously, separate control of x and y scalability.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Shape script labels
« Reply #9 on: May 25, 2008, 08:40:51 pm »
Yes, I certainly agree. This whole area looks like something that could yield huge gains without bending the rest of the product out of shape.

Evolution of shape scripts has been painfully slow, and even more painfully limited in scope. I know I've made many requests for improvement, with only occasional results.

But, we live in hope...
No, you can't have it!