AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, Locatable3D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable
Direct Known Subclasses:
Shape3DGroup, ShapeAgentGroup_xjal, ShapeAgentPopulationGroup, ShapeModelElementsGroup, ShapeTopLevelPresentationGroup

public class ShapeGroup
extends Shape3D
implements com.anylogic.engine.internal.Child
Group shape. Contains a collection of shapes. Shapes may also be replicated. The user can add, remove and change shapes in the group dynamically.
Shapes contained in a group have reference to that group.
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

Constructor Summary

ConstructorDescription
ShapeGroup(Presentable presentable)
Constructs an empty group with default attributes.
ShapeGroup(Presentable presentable, boolean ispublic, double x, double y, double rotation, Object... contents)
Constructs a 2D-only group with specific attributes and possibly with some content
ShapeGroup(Presentable presentable, ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, double rotationZ, Object... contents)
Constructs a group with specific attributes and possibly with some content

Method Summary

Modifier and TypeMethodDescription
voidadd(Camera3D camera)
Adds a camera to the group.
voidadd(Light3D light)
Adds a light to the group.
voidadd(ReplicatedShape<?> rshape)
Adds a replicated shape to the group.
voidadd(Shape shape)
Adds a persistent shape to the group.
voidclear()
Removes all shapes from the group.
ShapeGroupclone()
Creates and returns a copy of this group (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.
SVGElementfindSVGElement(long svgId)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Objectget(int i)
Returns the shape with the given index.
PresentablegetPresentable()
Returns the presentable (Agent or Experiment) where this group belongs to.
doublegetRotation()
Returns the horizontal rotation of the shape.
doublegetRotationX()
Returns the rotation of the shape around X axis (CW from +Y to +Z).
doublegetRotationY()
Returns the rotation of the shape around Y axis (CW from +Z to +X).
doublegetRotationZ()
Returns the rotation of the shape around Z axis (CW from +X to +Y).
List<Object>getShapes()
Returns the collection of shapes in the group (not a copy).
intindexOf(Object shape)
Returns the index of the specified shape (either object of class Shape, or object of class ReplicatedShape) in this group, or -1 if this group does not contain the shape.
More formally, returns the index i such that get( i ) == shape, or -1 if there is no such index.
Note that implementation of this method is very inefficient (has linear complexity)
voidinitialize_xjal(boolean replaceAlways, boolean replaceWithNotEmpty, Object... contents)
This method is internal and shouldn't be called by user.
(may be removed in the next versions)
voidinsert(int index, ReplicatedShape<?> rshape)
Adds a replicated shape to the group at the specified index (which defines z-order of shape in 2D animation).
voidinsert(int index, Shape shape)
Adds a persistent shape to the group at the specified index (which defines z-order of shape in 2D animation).
voidonDraw()
A callback called by the group before the group has drawn itself (and only if the group drawing is needed - it is visible, etc.).
voidpostSVGShapeSpecificAttributes(List<String> att, List<String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
booleanremove(Camera3D camera)
Tries to remove a camera from the group, returns false if the camera was not contained.
booleanremove(Light3D light)
Tries to remove a light from the group, returns false if the light was not contained.
booleanremove(ReplicatedShape<?> rshape)
Tries to remove a replicated shape from the group, returns false if the shape was not contained.
booleanremove(Shape shape)
Tries to remove a persistent shape from the group, returns false if the shape was not contained.
voidresetSVGState()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidrestoreOwner(Object owner)
Deprecated.
voidsetRotation(double rotation)
Sets the horizontal rotation of the shape.
voidsetRotationX(double rotationX)
Sets rotation around X axis (CW from +Y to +Z) of the shape.
Note that 2D animation of the group is shrunk only when rotated vertically, i.e.
voidsetRotationY(double rotationY)
Sets rotation around Y axis (CW from +Z to +X) of the shape.
Note that 2D animation of the group is shrunk only when rotated vertically, i.e.
voidsetRotationZ(double rotationZ)
Sets the rotation of the shape around Z-axis.
voidsetVisible(boolean v)
Sets the visibility of the shape.
intsize()
Returns the number of shapes in the group.
booleanupdateDynamicPropertiesStructural(boolean publicOnly) 

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

canHandleClick, getDrawMode, getScaleZ, getZ, getZOffset, setDrawMode, setPos, setPos, setPos, 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.Locatable2D

getX, getY

Constructor Details

ShapeGroup

public ShapeGroup(Presentable presentable)
Constructs an empty group with default attributes.
Parameters:
presentable - the presentable object owning this shape

ShapeGroup

@AnyLogicLegacyAPI
public ShapeGroup(Presentable presentable,
 boolean ispublic,
 double x,
 double y,
 double rotation,
 Object... contents)
Constructs a 2D-only group with specific attributes and possibly with some content
Parameters:
presentable - the presentable object owning this shape
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of group
y - the y coordinate of group
rotation - the rotation of the group in radians
contents - the (possibly, empty) initial set of shapes (Shape objects, int ids, or ReplicatedShape objects)

ShapeGroup

public ShapeGroup(Presentable presentable,
 ShapeDrawMode drawMode,
 boolean ispublic,
 double x,
 double y,
 double z,
 double rotationZ,
 Object... contents)
Constructs a group with specific attributes and possibly with some content
Parameters:
presentable - the presentable object owning this shape
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 group
y - the y coordinate of group
z - the z coordinate of group
rotationZ - the rotation of the group in radians around Z axis (CW from +X to +Y)
contents - the (possibly, empty) initial set of shapes (Shape objects, int ids, Replicated shapes, 3D Cameras or 3D Lights)

Method Details

initialize_xjal

@AnyLogicInternalCodegenAPI
public void initialize_xjal(boolean replaceAlways,
 boolean replaceWithNotEmpty,
 Object... contents)
This method is internal and shouldn't be called by user.
(may be removed in the next versions)

setVisible

public void setVisible(boolean v)
Description copied from class: Shape
Sets the visibility of the shape.
Overrides:
setVisible in class Shape
Parameters:
v - visibility: true - visible, false - not

getShapes

public List<Object> getShapes()
Returns the collection of shapes in the group (not a copy). The collection can contain either members of class Shape for shapes, and of class ReplicatedShape for replicated shapes. It may also contain 3D lights and cameras.
Returns:
the collection of shapes in the group

size

public int size()
Returns the number of shapes in the group.
Returns:
the number of shapes in the group

get

public Object get(int i)
Returns the shape with the given index. The result may be a shape, replicated shape, 3D light or camera.
Parameters:
i - the index of the shape
Returns:
the shape with the given index

indexOf

public int indexOf(Object shape)
Returns the index of the specified shape (either object of class Shape, or object of class ReplicatedShape) in this group, or -1 if this group does not contain the shape.
More formally, returns the index i such that get( i ) == shape, or -1 if there is no such index.
Note that implementation of this method is very inefficient (has linear complexity)
Parameters:
shape - the shape to find index of
Returns:
the index of the shape or -1

add

public void add(Shape shape)
Adds a persistent shape to the group. Note that it is your responsibility to remove the shape from the another group, if any!
Parameters:
shape - the shape to add

add

public void add(ReplicatedShape<?> rshape)
Adds a replicated shape to the group. Note that it is your responsibility to remove the shape from the another group, if any!
Parameters:
rshape - the replicated shape to add

add

public void add(Light3D light)
Adds a light to the group. Note that it is your responsibility to remove the light from the another group, if any!
Parameters:
light - the light to add

add

public void add(Camera3D camera)
Adds a camera to the group. Note that it is your responsibility to remove the camera from the another group, if any!
Parameters:
camera - the camera to add

insert

public void insert(int index,
 Shape shape)
Adds a persistent shape to the group at the specified index (which defines z-order of shape in 2D animation). Note that it is your responsibility to remove the shape from the another group, if any!
Parameters:
index - index at which the specified shape is to be inserted (from 0 to size(), inclusive)
shape - the shape to add

insert

public void insert(int index,
 ReplicatedShape<?> rshape)
Adds a replicated shape to the group at the specified index (which defines z-order of shape in 2D animation). Note that it is your responsibility to remove the shape from the another group, if any!
Parameters:
index - index at which the specified shape is to be inserted (from 0 to size(), inclusive)
rshape - the replicated shape to add

remove

public boolean remove(Shape shape)
Tries to remove a persistent shape from the group, returns false if the shape was not contained.
Parameters:
shape - the shape to remove
Returns:
true if the group contained the shape, false otherwise

remove

public boolean remove(ReplicatedShape<?> rshape)
Tries to remove a replicated shape from the group, returns false if the shape was not contained.
Parameters:
rshape - the replicated shape to remove
Returns:
true if the group contained the shape, false otherwise

remove

public boolean remove(Light3D light)
Tries to remove a light from the group, returns false if the light was not contained.
Parameters:
light - the light to remove
Returns:
true if the group contained the light, false otherwise

remove

public boolean remove(Camera3D camera)
Tries to remove a camera from the group, returns false if the camera was not contained.
Parameters:
camera - the camera to remove
Returns:
true if the group contained the camera, false otherwise

clear

public void clear()
Removes all shapes from the group.

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

updateDynamicPropertiesStructural

@AnyLogicInternalAPI
public boolean updateDynamicPropertiesStructural(boolean publicOnly)
Overrides:
updateDynamicPropertiesStructural in class Shape
Returns:
true if:
1. update was done (usually for visible elements, respecting public flag etc.)
AND
2. further update of structural changes is applicable

onDraw

public void onDraw()
A callback called by the group before the group has drawn itself (and only if the group drawing is needed - it is visible, etc.). May be overridden at subclasses.

getPresentable

public Presentable getPresentable()
Returns the presentable (Agent or Experiment) where this group belongs to.
Overrides:
getPresentable in class Shape
Returns:
the presentable where this group belongs to

restoreOwner

@AnyLogicInternalCodegenAPI
@Deprecated
public void restoreOwner(Object owner)
Deprecated.
Description copied from class: Shape
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
Specified by:
restoreOwner in interface com.anylogic.engine.internal.Child
Overrides:
restoreOwner in class Shape
Parameters:
owner - owner of this object, usually Agent, Experiment or ShapeGroup

clone

public ShapeGroup clone()
Creates and returns a copy of this group (i.e. new shape instance).
The returned shape is the object of the same class
All shapes belonging to this group are cloned respectively
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
Overrides:
clone in class Shape

setRotation

public void setRotation(double rotation)
Sets the horizontal rotation of the shape.
Overrides:
setRotation in class Shape3D
Parameters:
rotation - the new value of horizontal rotation in radians
See Also:
setRotationZ(double)

setRotationZ

public void setRotationZ(double rotationZ)
Sets the rotation of the shape around Z-axis.
Parameters:
rotationZ - the new value of rotation around Z-axis in radians

setRotationY

public void setRotationY(double rotationY)
Sets rotation around Y axis (CW from +Z to +X) of the shape.
Note that 2D animation of the group is shrunk only when rotated vertically, i.e. sides of group contents aren't drawn
Parameters:
rotationY - the new value of rotation around Y axis (CW from +Z to +X), in radians

setRotationX

public void setRotationX(double rotationX)
Sets rotation around X axis (CW from +Y to +Z) of the shape.
Note that 2D animation of the group is shrunk only when rotated vertically, i.e. sides of group contents aren't drawn
Parameters:
rotationX - the new value of rotation around X axis (CW from +Y to +Z), in radians

getRotation

public double getRotation()
Returns the horizontal rotation of the shape.
Overrides:
getRotation in class Shape
Returns:
the horizontal rotation of the shape in radians, clockwise

getRotationZ

public double getRotationZ()
Returns the rotation of the shape around Z axis (CW from +X to +Y).
Returns:
the rotation of the shape around Z axis (CW from +X to +Y), in radians

getRotationY

public double getRotationY()
Returns the rotation of the shape around Y axis (CW from +Z to +X).
Returns:
the rotation of the shape around Y axis (CW from +Z to +X), in radians

getRotationX

public double getRotationX()
Returns the rotation of the shape around X axis (CW from +Y to +Z).
Returns:
the rotation of the shape around X axis (CW from +Y to +Z), in radians

resetSVGState

@AnyLogicInternalAPI
public void resetSVGState()
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
resetSVGState in interface SVGElement
Overrides:
resetSVGState 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 Shape
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO

findSVGElement

@AnyLogicInternalAPI
public SVGElement findSVGElement(long svgId)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
findSVGElement in interface SVGElement
Overrides:
findSVGElement in class Shape