Prev Next

Shape Attributes

When you define a shape using a Shape Script, you define the properties of that shape using attributes. Properties include:

  • The position of the shape relative to the diagram and to other elements
  • The positions of components of the shape relative to the shape borders
  • Whether the shape has user-editable regions
  • Whether the shape can be resized, scaled, rotated or docked

Attribute Syntax

attribute "=" value ";"

Example

     shape main

     {

          //Initialisation attributes - must be before drawing commands

          noshadow = "true";

          h_align = "center";

          //drawing commands

          rectangle (0,0,100,100);

          println ("foo bar");

     }

Attributes

Attribute Name

Description

See also

bottomAnchorOffset

(int,int)

Description: When creating a Shape Script for an embedded element (such as a Port), use this attribute to offset the shape from the bottom edge of its parent.

For example:

     bottomAnchorOffset= (0,-10);

     move embedded element up 10 pixels from the bottom edge.

dockable

string

Description: Makes the shape default to dockable, so that it can be aligned with and joined to other elements (both other Shape Scripts and standard elements) on a diagram. You cannot reverse the dockable status with the 'Appearance' menu option; to change the status, you must edit the Shape Script.

Valid values: standard or off

Element Context Menu Operations

editableField

string

Description: Defines a shape as an editable region of the element.

This field impacts element shapes only, line glyphs are not supported.

Valid Values: alias, name, note, stereotype

endPointY, endPointX

integer

Description: Only used for the reserved target and source shapes for connectors; this point determines where the main connector line connects to the end shapes.

Default: 0 and 0

fixedAspectRatio

string

Description: Set to True to fix the aspect ratio. Do not use this if you do not want to fix the aspect ratio.

h_Align

string

Description: Affects horizontal placement of printed text and sub-shapes depending on the layoutType attribute.

Valid values: left, center, or right

layoutType

string

Description: Determines how sub-shapes are sized and positioned.

Valid values: leftright, topdown, border

Sub-Shapes

leftAnchorOffset

(int,int)

Description: When creating a Shape Script for an embedded element (such as a Port), use this attribute to offset the shape from the left edge of its parent.

For example:

     leftAnchorOffset= (10,0);

     move embedded element right 10 pixels from the left edge

noShadow

string

Description: Set to true to suppress the shapes shadow from being rendered.

Valid values: true or false (default= false)

orientation

string

Description: Applies to decoration shapes only, to determine where the decoration is positioned within the containing element glyph.

Valid values: NW, N, NE, E, SE, S, SW, W

preferredHeight

Description: Used by the border layoutType - north and south.

Used in drawing the source and target shapes for connectors to determine how wide the line is.

preferredWidth

Description: Used by the border layoutType - east and west.

Used by leftright layoutType shapes where scalable is false to determine how much space they occupy for layout purposes.

rightAnchorOffset

(int,int)

Description: When creating a Shape Script for an embedded element (such as a Port), use this attribute to offset the shape from the right edge of its parent.

For example:

     rightAnchorOffset= (- 10,0);

     move embedded element left 10 pixels from the right edge.

rotatable

string

Description: Set to False to prevent rotation of the shape. This attribute is only applicable to the source and target shapes for line glyphs.

Valid values: True or False (default = True)

scalable

string

Description: Set to False to stop the shape from being relatively sized to the associated diagram glyph.

Valid values: True or False (default= True)

topAnchorOffset

(int,int)

Description: When creating a Shape Script for an embedded element (such as a Port), use this attribute to offset the shape from the top edge of its parent.

For example:

     topAnchorOffset= (0,10);

     move embedded element down 10 pixels from the top edge.

v_Align

string

Description: Affects vertical placement of printed text and sub-shapes depending on the layoutType attribute.

Valid values: top, center, or bottom