Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Drawing Methods
When you create a shape using a Shape Script, you define the values of the shape using methods. The values include things such as:
• | What the shape is - a rectangle, a line, a sphere |
• | The size of the shape |
• | The colors of the shape and borders |
• | The compartments and compartment text the shape has |
• | The text and labels displayed in and around the shape |
• | Whether the shape consists of or includes a captured image |
You can list the valid methods (commands) for any point in a script by pressing Ctrl+Space.
Method Syntax
<MethodName> "(" <ParameterList> ")";";
Example
shape main
{
//Initialisation Attributes - these must be before drawing commands
noshadow = "true";
h_align = "center";
//drawing commands (Methods)
rectangle(0,0,100,100);
println("foo bar");
}
Methods
Method Name |
Description |
See also |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
addsubshape(
|
Adds a sub-shape with the name shapename that must be defined within the current shape definition. |
|
||||||||||||
appendcompartmenttext( |
Appends additional strings to a compartment's text. The compartment the text is added to depends on the compartment name set using setcompartmentname (see below) prior to using appendcompartmenttext. This method must be called to have the compartment displayed.
|
|||||||||||||
arc( |
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);
|
|
||||||||||||
arcto(
|
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(
|
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
if(HasTag("horizontal","true")) { When this is set, (Alt+Z) also resizes the shape to the defined dimensions. The minimum value for both int width and int height is 10.
|
|
||||||||||||
drawnativeshape() |
Renders the shape in 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.
|
|
||||||||||||
drawparentshape() |
Used when extending non-UML Object types. Renders the shape as defined from a parent stereotype. Behaves identical to drawnativeshape() if no inherited shape script is available.
|
|||||||||||||
ellipse(
|
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( |
Hides the label specified by labelname, where labelname is one of the following values:
|
|
||||||||||||
image( |
Draws the image that has the name imageId in the Image Manager. 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 or select it from within a technology file. If the image is in a technology file, it should have a filename of the format <technology ID>::<imagename>.<extension>.
|
|||||||||||||
lineto(
|
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(
|
Moves the pen cursor to the point specified by x and y. |
|
||||||||||||
polygon(
|
Draws a regular polygon with center at the point (centerx, centery), and numberofsides number of sides. |
|
||||||||||||
print( |
Prints the specified text string. You cannot change the font size or type of this text.
|
|
||||||||||||
printifdefined(
|
Prints the truepart if the given property exists and has a non-empty value, otherwise prints the optional falsepart. You cannot change the font size or type of this text. |
|
||||||||||||
println( |
Appends a line of text to the shape and a line break. You cannot change the font size or type of this text.
|
|
||||||||||||
printwrapped( |
Prints the specified text string, wrapped over multiple lines if the text is wider than its containing shape. You cannot change the font size or type of this text.
|
|
||||||||||||
rectangle(
|
Draws a rectangle with extents at left, top, right, bottom. Values are percentages. |
|
||||||||||||
roundrect(
|
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. |
|
||||||||||||
setcompartmentname( |
Sets a compartment name to the string provided. This method must be used before calling appendcompartmenttext (above); calling this after calling appendcompartmenttext clears any text that has already been added to the compartment.
|
|||||||||||||
setdefaultcolors() |
Returns the brush and pen color to the default settings, or to the user-defined colors if available.
|
|||||||||||||
setfillcolor( setfillcolor(
|
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 such as: GetUserFillColor() or GetUserBorderColor() This color takes precedence over any other color definition that applies to the element, except for the fill color assigned from the Format toolbar.
|
|
||||||||||||
setfixedregion(
|
Fixes a region in a connector into which a sub-shape can be drawn, so that the sub-shape is not rescaled with the length or orientation of the connector line. For an example, see the end of the table in the Example Scripts topic. |
|||||||||||||
setfontcolor( setfontcolor(
|
Sets the font color of a text string. You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries such as: GetUserFontColor() or GetUserFillColor()
You can use this command with any of the text print commands.
|
|||||||||||||
setlinestyle( |
Changes the stroke pattern for commands that use the pen. string linestyle: has the following valid styles:
|
|
||||||||||||
setorigin( |
Positions floating text labels relative to the main shape.
|
|
||||||||||||
setpen( setpen(
|
Sets the pen to the defined color and optionally sets the pen width. This method is only for line-drawing commands. It does not affect any text print commands. |
|||||||||||||
setpencolor( setpencolor( |
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
GetUserFillColor()
This method is only for line-drawing commands. It does not affect any text print commands.
|
|||||||||||||
setpenwidth( |
Sets the width of the pen. Pen width should be between 1 and 5 This method is only for line-drawing commands. It does not affect any text print commands.
|
|
||||||||||||
showlabel( |
Reveals the hidden label specified by labelname, where labelname is one of the following values:
|
|
||||||||||||
startcloudpath( |
Similar to StartPath, except that it draws the path with cloud-like curved segments (puffs). Parameters:
|
|
||||||||||||
startpath() |
Starts the sequence of drawing commands that define a path.
|
|
||||||||||||
strokepath() |
Draws the outline of the previously defined path with the current pen.
|
|