Drawing Methods

Method Name

Description

addsubshape(
       string shapename[,
       int width,
       int height])

Adds a sub-shape with the name shapename that must be defined within the current shape definition.

arc(
       int left,
       int top,
       int right,
       int bottom,
       int startingpointx,
       int startingpointy,
       int endingpointx,
       int endingpointy)

Draws an elliptical anticlockwise arc with the ellipse having extents at left, top, right and bottom. The start point of the arc is defined by the intersection of the ellipse and the line from the center of the ellipse to the point (startingpointx, startingpointy). The end of the arc is similarly defined by the intersection of the ellipse and the line from the center of the ellipse to the point (endingpointx, endingpointy).

For example:

Arc(0, 0, 100, 100, 95, 0, 5, 0);

arc

arcto(
       int left,
       int top,
       int right,
       int bottom,
       int startingpointx,
       int startingpointy,
       int endingpointx,
       int endingpointy)

As for the arc method, except that a line is drawn from the current position to the starting point of the arc, and then the current position is updated to the end point of the arc.

bezierto(
       int controlpoint1x,
       int controlpoint1y,
       int controlpoint2x,
       int controlpoint2y,
       int endpointx,
       int endpointy)

Draws a bezier curve and updates the pen position.

defSize(int width, int height)

Sets the default size of the element.

This can appear in IF and ELSE clauses with different values in each, and causes the element to be resized automatically each time the values change. For example:

  if(HasTag("horizontal","true")) {
           defSize(100,20);
           rectangle(0,0,100,100);
  }
  else {
           defSize(20,100);
           rectangle(0,0,100,100);
  }
 
The above example sets the shape to the specified default size each time the
Tagged Value horizontal is changed.

When this is set, [Alt]+[Z] also resizes the shape to the defined dimensions.

Note:

The minimum value for both int width and int height is 10.

drawnativeshape()

Causes Enterprise Architect to render the shape using its usual, non-Shapescript notation. Subsequent drawing commands are super-imposed over the native notation.

This method is only enabled for element Shape Scripts; line Shape Scripts are not supported.

ellipse(
       int left,
       int top,
       int right,
       int bottom)

Draws an ellipse with extents defined by left, top, right and bottom.

endpath()

Ends the sequence of drawing commands that define a path.

fillandstrokepath()

Fills the previously defined path with the current fill color, then draws its outline with the current pen.

fillpath()

Fills the previously defined path with the current fill color.

hidelabel(
       string labelname)

Hides the label specified by labelname.

image(
       string imageId,
       int left,
       int top,
       int right,
       int bottom)

Draws the image that has the name imageId in the Image Manager.

Note:

The image must exist within the model in which the stereotype is used. If it does not already exist in the model, you must import it as reference data.

lineto(
       int x,
       int y)

Draws a line from the current cursor position to a point specified by x and y, and then updates the pen cursor to that position.

moveto(
       int x,
       int y)

Moves the pen cursor to the point specified by x and y.

polygon(
       int centerx,
       int centery,
       int numberofsides,
       int radius,
       float rotation)

Draws a regular polygon with center at the point (centerx, centery), and numberofsides number of sides.

print(
       string text)

Prints the specified text string.

Note:

You cannot change the font size, type or color of this text.

printifdefined(
       string propertyname,
       string truepart[,
       string falsepart])

Prints the truepart if the given property exists and has a non-empty value, otherwise prints the optional falsepart.

Note:

You cannot change the font size, type or color of this text.

println(
       string text)

Appends a line of text to the shape and a line break.

Note:

You cannot change the font size, type or color of this text.

printwrapped(
       string text)

Prints the specified text string, wrapped over multiple lines if the text is wider than its containing shape.

Note:

You cannot change the font size, type or color of this text.

rectangle(
       int left,
       int top,
       int right,
       int bottom)

Draws a rectangle with extents at left, top, right, bottom. Values are percentages.

roundrect(
       int left,
       int top,
       int right,
       int bottom,
       int abs_cornerwidth,
       int abs_cornerheight)

Draws a rectangle with rounded corners, with extents defined by left, top, right and bottom. The size for the corners is defined by abs_cornerwidth and abs_cornerheight; these values do not scale with the shape.

setdefaultcolors()

Returns the brush and pen color to the default settings, or to the user-defined colors if available. See Color Queries.

setfillcolor(
       int red,
       int green,
       int blue)

setfillcolor(
       Color newColor)

Sets the fill color.

You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries; for example:

GetUserFillColor()

setlinestyle(
       string linestyle)

Changes the stroke pattern for commands that use the pen.

Parameters:

string linestyle: the following styles are valid:

  • solid
  • dash
  • dot
  • dashdot
  • dashdotdot

setorigin(
       string relativeTo,
       int xOffset,
       int yOffset)

Positions floating text labels relative to the main shape.

relativeTo is one of N, NE, E, SE, S, SW, W, NW, CENTER

xOffset and yOffset are in pixels, not percentage values, and can be negative.

setpen(
       int red,
       int green,
       int blue[,
       int penwidth])

Sets the pen to the defined color and optionally sets the pen width.

Note:

This method is only for line-drawing commands. It does not affect any text commands.

setpencolor(
       int red,
       int green,
       int blue)

setpencolor(
       Color newColor)

Sets the pen color.

You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries; for example:

GetUserFillColor()

Note:

This method is only for line-drawing commands. It does not affect any text commands.

setpenwidth(
       int penwidth)

Sets the width of the pen. Pen width should be between 1 and 5.

Note:

This method is only for line-drawing commands. It does not affect any text commands.

showlabel(
       string labelname)

Reveals the hidden label specified by labelname.

startcloudpath(
       puffWidth,
       puffHeight,
       noise)

Similar to StartPath, except that it draws the path with cloud-like curved segments (puffs).

Parameters:

  • float puffWidth (default = 30), the horizontal distance between puffs
  • float puffHeight (default = 15), the vertical distance between puffs
  • float noise (default = 1.0), the randomization of the puffs' positions.

startpath()

Starts the sequence of drawing commands that define a path.

strokepath()

Draws the outline of the previously defined path with the current pen.