Book a Demo

Author Topic: ShapeScript: Decoration aligned to left  (Read 4736 times)

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
ShapeScript: Decoration aligned to left
« on: May 06, 2013, 06:25:16 pm »
Hi,

I planned to create a custom class stereotype with a custom icon. My problem is that the icon is displayed on the left side of the class header instead of right. (Another problem, maybe related, is that the icon size can be higher than the class name compartment, a 100x100 size seems good, if I specify 150x150, e.g., the icon overlaps with other compartments.)

Here's the very simple ShapeScript I created:

Code: [Select]
decoration Icon
{
      image("UI - Popup", 0, 0, 100, 100);
}

As far as I can understand, the decoration should be aligned to the right side of the main shape, once decorations go to right per UML's definition.

I have also tried another ShapeScript:
Code: [Select]
shape main {
      
      drawnativeshape();      
      moveto(100, 0);
      addsubshape("Icon", 20, 20);
      
      shape Icon
      {
            h_align = "right";
            v_align = "top";
            //rectangle(100, 0, 120, 20);
            image("UI - Screen", 0, 0, 100, 100);
      }

}

Unfortunatelly, this resulted in the image aligned outside the box (on the right side). I also tried to draw a rectangle (the commented-out line) in the hope it will position the drawing cursor used by the image method, but with no luck.

Any tips on aligning the shape on right?
------------------------
Imprestige. Your issues in safe hands.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: ShapeScript: Decoration aligned to left
« Reply #1 on: May 06, 2013, 08:10:11 pm »
Each box has X and Y coordinates from 0 to 100. Your move to 0|100 goes outside. You can do that, but then you see what you see. Try a move to 0|80.

q.

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: ShapeScript: Decoration aligned to left
« Reply #2 on: May 06, 2013, 08:18:45 pm »
You were on the right track, but you need to add an orientation to the decoration, like so:

Code: [Select]
shape main {
      drawnativeshape();      
}
decoration icon
{
      orientation="SE";
      image("UI - Screen", 0, 0, 100, 100);
}      

Then the image will be displayed (in this case) in the lower left location of the class.

Btw there should be an image with exactly this name, "UI - Screen", in the image library, ie -without- an extension .bmp).

best regards,

Paulus
« Last Edit: May 06, 2013, 08:20:57 pm by pmaessen »

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
Re: ShapeScript: Decoration aligned to left
« Reply #3 on: May 07, 2013, 05:38:34 pm »
Quote
Each box has X and Y coordinates from 0 to 100. Your move to 0|100 goes outside. You can do that, but then you see what you see. Try a move to 0|80.

q.

Dear Qwerty, this is more than valuable information, I always wanted to make sure of the grid size is 100x100! Thanks a lot!

Gus
------------------------
Imprestige. Your issues in safe hands.

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
Re: ShapeScript: Decoration aligned to left
« Reply #4 on: May 07, 2013, 05:39:39 pm »
Quote
You were on the right track, but you need to add an orientation to the decoration, like so:

Paulus

And it works! Thanks, Paulus. (As per the image, yes, I do have an image with that name, it was only drawn on the wrong corner.)
------------------------
Imprestige. Your issues in safe hands.