AnyLogic
Expand
Font size
All Implemented Interfaces:
Area2D, Area3D, com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, UsdElement, Serializable, Cloneable
Direct Known Subclasses:
ShapeRoundedRectangle

public class ShapeRectangle
extends ShapeLineFill
implements Area3D
Persistent rectangle shape.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Fields inherited from class com.anylogic.engine.presentation.Shape3D

UNKNOWN_NAME

Fields inherited from interface com.anylogic.engine.presentation.UsdElement

ID_NOT_SET

Constructor Summary

ConstructorDescription
ShapeRectangle()
Constructs a rectangle with default attributes.
ShapeRectangle(boolean ispublic, double x, double y, double rotation, Paint lineColor, Paint fillColor, double width, double height, double lineWidth, LineStyle lineStyle)
Constructs a 2D-only rectangle with specific attributes.
ShapeRectangle(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, double rotation, Paint lineColor, Paint fillColor, double width, double height, double zHeight, double lineWidth, LineStyle lineStyle)
Constructs a rectangle with specific attributes.

Method Summary

Modifier and TypeMethodDescription
ShapeRectangleclone()
Creates and returns a copy of this shape (i.e.
booleancontains(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
PointgetCenter()
Returns (x, y) coordinates of the rectangle center in 2D (returned z is the base-level of rectangle).
PointgetCenter3D()
Returns (x, y, z) coordinates of the rectangle center.
doublegetHeight()
Returns the height of the rectangle.
doublegetWidth()
Returns the width of the rectangle.
voidpostSVGShapeSpecificAttributes(List<String> att, List<String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
PointrandomPointInside(Random rng)
Returns the randomly chosen point inside the shape area.
This method utilises the given Random Number Generator.
Throws error if this shape type doesn't support returning random point inside.
voidsetHeight(double height)
Sets the height of the rectangle.
voidsetSize(double width, double height)
Sets the width and height of the rectangle.
voidsetSize(double width, double height, double zHeight)
Sets the width, height and height along z axis (z-height) of the rectangle.
voidsetWidth(double width)
Sets the width of the rectangle.

Methods inherited from class com.anylogic.engine.presentation.Shape3D

canHandleClick, getDrawMode, getScaleZ, getZ, setDrawMode, setPos, setPos, setPos, setRotation, setScale, setScale, setScaleZ, setZ

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Methods inherited from interface com.anylogic.engine.Area2D

getX, getY

Methods inherited from interface com.anylogic.engine.Area3D

getZ, getZHeight

Methods inherited from interface com.anylogic.engine.Locatable3D

getZOffset

Constructor Details

ShapeRectangle

public ShapeRectangle()
Constructs a rectangle with default attributes.

ShapeRectangle

@AnyLogicLegacyAPI
public ShapeRectangle(boolean ispublic,
 double x,
 double y,
 double rotation,
 Paint lineColor,
 Paint fillColor,
 double width,
 double height,
 double lineWidth,
 LineStyle lineStyle)
Constructs a 2D-only rectangle with specific attributes.
Parameters:
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the rectangle upper left corner
y - the y coordinate of the rectangle upper left corner
rotation - the rotation of the rectangle in radians
lineColor - line color (or Texture) of the rectangle
fillColor - fill color (or Texture) of the rectangle
width - the width of the rectangle
height - the height of the rectangle
lineWidth - the line width of the rectangle
lineStyle - the line stroke style of the rectangle (solid, dotted, dashed)

ShapeRectangle

public ShapeRectangle(ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 double rotation,
 Paint lineColor,
 Paint fillColor,
 double width,
 double height,
 double zHeight,
 double lineWidth,
 LineStyle lineStyle)
Constructs a rectangle with specific attributes.
Parameters:
drawMode - where to draw this shape: 2D, 3D or 2D+3D
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the rectangle upper left corner on the XY-projection
y - the y coordinate of the rectangle upper left corner on the XY-projection
z - the z coordinate of the rectangle base
rotation - the rotation of the rectangle around Z-axis from +X to +Y, in radians
lineColor - line color (or Texture) of the rectangle
fillColor - fill color (or Texture) of the rectangle
width - the width of the rectangle on the XY-projection
height - the height of the rectangle on the XY-projection
zHeight - the height of a rectangle along Z-axis
lineWidth - the line width of the rectangle
lineStyle - the line stroke style of the rectangle (only solid is supported)

Method Details

setWidth

public void setWidth(double width)
Sets the width of the rectangle.
Parameters:
width - the new width of the rectangle

getWidth

public double getWidth()
Returns the width of the rectangle.
Specified by:
getWidth in interface Area2D
Returns:
the width of the rectangle

setHeight

public void setHeight(double height)
Sets the height of the rectangle.
Parameters:
height - the new height of the rectangle

getHeight

public double getHeight()
Returns the height of the rectangle.
Specified by:
getHeight in interface Area2D
Returns:
the height of the rectangle

getCenter

public Point getCenter()
Returns (x, y) coordinates of the rectangle center in 2D (returned z is the base-level of rectangle).
Returns:
coordinates of the rectangle center

getCenter3D

public Point getCenter3D()
Returns (x, y, z) coordinates of the rectangle center.
Returns:
coordinates of the rectangle center

setSize

public 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

setSize

public void setSize(double width,
 double height,
 double zHeight)
Sets the width, height and height along z axis (z-height) of the rectangle.
Parameters:
width - the new width of the rectangle
height - the new height of the rectangle
zHeight - the new z-height of the rectangle

randomPointInside

public Point randomPointInside(Random rng)
Description copied from class: Shape
Returns the randomly chosen point inside the shape area.
This method utilises the given Random Number Generator.
Throws error if this shape type doesn't support returning random point inside.
Overrides:
randomPointInside in class Shape
Parameters:
rng - the random number generator.
Returns:
the randomly chosen point inside the shape area.

contains

public boolean contains(double px,
 double py)
Description copied from class: Shape
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)
Specified by:
contains in class Shape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

clone

public ShapeRectangle clone()
Description copied from class: Shape
Creates and returns a copy of this shape (i.e. new shape instance).
The returned shape is the object of the same class
The returned copy isn't automatically added to the group this shape belongs to.
The clone is created in the context of the same experiment or agent

Note that cloning of GIS shape, controls and charts is not supported
Overrides:
clone in class Shape

postSVGShapeSpecificAttributes

public void postSVGShapeSpecificAttributes(List<String> att,
 List<String> val,
 boolean publicOnly)
Description copied from class: Shape
Posts general properties specific to a particular shape class. Is triggered by SVG_DIRTY_SHAPE flag. Made public for occasional posting of additional SVG properties from outside engine (e.g. from libraries)
Overrides:
postSVGShapeSpecificAttributes in class ShapeLineFill
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO