Rounded Rectangle

Rounded rectangle is one of the primitive presentation shapes that you can use to draw presentations for your models.

Rounded rectangle is a rectangle with chamfered corners. However, these two shapes have one more significant difference: rectangles can have three dimensions and appear in 3D animation, while rounded rectangles can't. So, if you plan to create 3D animation for your model, we recommend you to use rectangles, not rounded rectangles. This will enable adding these shapes in 3D animation scene. 

 To draw a rounded rectangle
  1. Drag the  Rounded Rectangle element from the Presentation palette to the graphical editor.
  2. Resize the rectangle as you need.
  3. If needed, you can change the radius of rounding by adjusting the Corner radius value in the Position and size section of the rounded rectangle properties.

Properties

General

Name – The name of the shape. It is used to identify and access the shape from code.

Ignore – If selected, the shape is excluded from the model.

Visible on upper level – If selected, the shape is also visible on the upper level where this agent lives.

Icon – If selected, the shape is considered as a part of the agent's icon. Please note that icon shapes are not shown in 3D animation.

Lock – If selected, the shape is locked. Locked shapes do not react to mouse clicks - it is impossible to select them in the graphical editor until you unlock them. It is frequently needed when you use a shape as a background image for your animation and you want to prevent editing this shape while drawing other shapes over it.

Visible – Here you specify whether the shape is visible on the animation at the model runtime, or not. Choose yes or no using the control. If you expect visibility to change dynamically or to depend on some conditions, you may specify the expression defining the shape's visibility here. This expression will be dynamically reevaluated at the model runtime. It should return boolean value. The shape is visible when the specified expression evaluates to true, and not visible otherwise.

Appearance

Fill color – Shape's fill color. Click inside the control and choose the required color using the Colors dialog box. Choose No Fill, if you do not want shape to be filled.
If you expect color to change dynamically or to depend on some conditions, you may specify here the expression defining the shape's fill color. This expression will be dynamically reevaluated at the model runtime. The expression should return an instance of Java class Color.

Line color – The outline color. Click inside the control and choose the required color using the Colors dialog box. Choose No Line, if you do not want outline to be drawn.

Line width – Outline width. Choose width from the drop-down list, or enter the value in pixels in the field to the right.

Line style – [Enabled only if the 2D only option is selected in the Show in advanced property] The outline style. Choose from the drop-down list, whether you want solid, dashed, or dotted outline to be drawn. 

Position and size

X – X-coordinate of the rectangle's upper left corner.

Y – Y-coordinate of the rectangle's upper left corner.

Width – Width of the rectangle (in pixels).

Height – Height of the rectangle (in pixels).

Rotation – The shape's rotation angle in XY plane. 

Corner radius – The corner radius of the rectangle (pixels).

Scale X – Here you can specify the expression returning the X-direction scale factor for the shape.*

Scale Y – Here you can specify the expression returning the Y-direction scale factor for the shape.*

You can dynamically scale the shape at the model runtime by specifying expressions in the Scale X, ScaleY,and optionally Scale Z parameters.

Advanced

Replication – The replication factor of the shape. Here you specify how many copies of the shape will be created (the integer number). If you leave this field empty, only one shape will be created.

On click – Code that will be called each time a user clicks on the shape at the model runtime.

Show name – If selected, the shape's name will be displayed on a presentation diagram.

Functions

Position

Function

Description

double getX()

double getY()

Returns the X (Y) coordinate of the shape (namely, the X coordinate of its upper left corner).

void setX(double x)

void setY(double y)

Sets the X (Y) coordinate of the shape.

Parameters:
x - the new value of X coordinate
y - the new value of Y coordinate

void setPos(double x,
double y)

Sets new coordinates for the shape.

Parameters:
x - the new value of x coordinate
y - the new value of y coordinate

Point getCenter()

Returns coordinates of the rectangle center.

Size, scaling

Function

Description

void setSize
(double width, double height)

Sets the width and height of the rectangle.

Parameters:
width - the new width of the rectangle
height - the new height of the rectangle

double getWidth()

Returns the width of the shape.

double getHeight()

Returns the height of the shape.

void setWidth(double width)

Sets the width of the shape equal to width.

void setHeight(double height)

Sets the height of the shape equal to height.

double getScaleX()

double getScaleY()

Returns the scale of the shape along X (Y) axis.

void setScaleX(double sx)

void setScaleY(double sy)

Sets the scale of the shape along X (Y) axis.

Parameters:
sx - the new value of scale along X axis* 
sy - the new value of scale along Y axis* 

* 1 = keep original size

void setScale(double sx, double sy)

Sets the scales of the shape along both axes.

Parameters:
sx - the new value of scale along X axis, 1 = keep original size
sy - the new value of scale along Y axis, 1 = keep original size

void setScale(double s)

Sets the same scale of the shape along both axes.

Parameter:
s - the new value of scale along both axis, 1 = keep original size

Rotation

Function

Description

double getRotation()

Returns the rotation of the shape in radians, clockwise.

void setRotation(double r)

Sets the rotation of the shape.

Parameter:
r - the new value of rotation in radians

Visibility

Function

Description

boolean isVisible()

Checks the visibility of the shape. If the shape is visible, returns true, otherwise returns false.

void setVisible(boolean v)

Sets the visibility of the shape.

Parameter:
v - visibility: if true - the shape is set to be visible, if false - not visible.

Fill color

Function

Description

Color getFillColor()

Returns the fill color of the shape, or null if shape has no fill color or has textured fill (in this case getFillTexture() should be used instead) 

Texture getFillTexture()

Returns the fill texture of the shape, if the shape has fill texture 

void setFillColor
(Color fillColor)

Sets the fill color of the shape.

Parameter:
fillColor - the new fill color, if null, the shape is not filled

void setFillColor
(Object fillColor)

Sets the fill color (or Texture) of the shape.

Parameter:
fillColor - the new fill color, if null, the shape is not filled

Outline

Function

Description

Color getLineColor()

Returns the line color of the shape, or null if shape has no line color or has textured line (in this case getLineTexture() should be used instead) 

Texture getLineTexture()

Returns the outline texture, if the shape outline has texture.

void setLineColor(Color lineColor)

Sets the line color of the shape.

Parameter:
lineColor - the new line color, if null, the shape line is not drawn

void setLineColor(Object lineColor)

Sets the line color (or Texture) of the shape.

Parameter:
lineColor - the new line color, if null, the shape line is not drawn

double getLineWidth()

Returns the width of the shape outline. 

void setLineWidth
(double width)

Sets the width of the shape outline, 0 means thinnest possible.

Parameter:
width - the new width of the shape outline

int getLineStyle()

Returns the style of the shape outline: 

LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED 

void setLineStyle(int style)

Sets the style of the shape outline: LINE_STYLE_SOLID, LINE_STYLE_DOTTED or LINE_STYLE_DASHED

Parameter:
style - the new style of the shape outline

Corner radius

Function

Description

double getRadius()

Returns the corner radius of the rounded rectangle.

void setRadius(double radius)

Sets the corner radius of the rounded rectangle. 

Parameter:
radius - the corner radius of the rounded rectangle

Points inside the shape

Function

Description

boolean contains(double px, double py)

Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y) . Returns true if the shape contains the point with the given coordinates.

Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container

Point randomPointInside()

Returns the randomly chosen point inside the shape area.

This function utilises Random Number Generator of the Presentable object containing this shape. (Will throw an exception if the shape has been created from code and hasn't been added to any group, - in this case use randomPointInside(Random rng)).

Returns null if the shape has no points (e.g. polyline with no points).

Throws error if this shape type doesn't support returning random point inside.

Point randomPointInside
(java.util.Random rng)

Returns the randomly chosen point inside the shape area. This function utilises the given Random Number Generator. Throws error if this shape type doesn't support returning random point inside.

Parameter:
rng - the random number generator.


Related topics

Moving presentation shapes

Resizing presentation shapes

Rotating presentation shapes

Changing shape color

Changing shape's position in stacking order

 Aligning shapes

 API reference: ShapeRoundedRectangle class