Package com.anylogic.engine.presentation
- Field Summary
- Constructor Summary
- Method Summary
- Methods inherited from class com.anylogic.engine.presentation.Shape3D
- Methods inherited from class com.anylogic.engine.presentation.Shape
- Methods inherited from class java.lang.Object
- Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement
- Methods inherited from interface com.anylogic.engine.Locatable2D
- Constructor Details
- Method Details
- initialize_xjal
- setVisible
- getShapes
- size
- get
- indexOf
- add
- add
- add
- add
- insert
- insert
- remove
- remove
- remove
- remove
- clear
- contains
- updateDynamicPropertiesStructural
- onDraw
- getPresentable
- restoreOwner
- clone
- setRotation
- setRotationZ
- setRotationY
- setRotationX
- getRotation
- getRotationZ
- getRotationY
- getRotationX
- resetSVGState
- postSVGShapeSpecificAttributes
- findSVGElement
- java.lang.Object
- com.anylogic.engine.presentation.Shape
- com.anylogic.engine.presentation.Shape3D
- com.anylogic.engine.presentation.ShapeGroup
- 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.
Shapes contained in a group have reference to that group.
- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
Constructor | Description |
---|---|
ShapeGroup |
Constructs an empty group with default attributes.
|
ShapeGroup |
Constructs a 2D-only group with specific attributes and possibly with some content
|
ShapeGroup |
Constructs a group with specific attributes and possibly with some content
|
Modifier and Type | Method | Description |
---|---|---|
void | add |
Adds a camera to the group.
|
void | add |
Adds a light to the group.
|
void | add |
Adds a replicated shape to the group.
|
void | add |
Adds a persistent shape to the group.
|
void | clear() |
Removes all shapes from the group.
|
ShapeGroup | clone() |
Creates and returns a copy of this group (i.e.
|
boolean | contains |
Test if the shape contains the point with the given coordinates
(relative to this shape's container, i.e.
|
SVGElement | findSVGElement |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
Object | get |
Returns the shape with the given index.
|
Presentable | getPresentable() |
Returns the presentable (
Agent or Experiment ) where this group
belongs to. |
double | getRotation() |
Returns the horizontal rotation of the shape.
|
double | getRotationX() |
Returns the rotation of the shape around X axis (CW from +Y to +Z).
|
double | getRotationY() |
Returns the rotation of the shape around Y axis (CW from +Z to +X).
|
double | getRotationZ() |
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).
|
int | indexOf |
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) |
void | initialize_xjal |
This method is internal and shouldn't be called by user.
(may be removed in the next versions) |
void | insert |
Adds a replicated shape to the group at the specified index (which
defines z-order of shape in 2D animation).
|
void | insert |
Adds a persistent shape to the group at the specified index (which
defines z-order of shape in 2D animation).
|
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.).
|
void | postSVGShapeSpecificAttributes |
Posts general properties specific to a particular shape class.
|
boolean | remove |
Tries to remove a camera from the group,
returns
false if the camera was not contained. |
boolean | remove |
Tries to remove a light from the group,
returns
false if the light was not contained. |
boolean | remove |
Tries to remove a replicated shape from the group,
returns
false if the shape was not contained. |
boolean | remove |
Tries to remove a persistent shape from the group,
returns
false if the shape was not contained. |
void | resetSVGState() |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
void | restoreOwner |
Deprecated.
|
void | setRotation |
Sets the horizontal rotation of the shape.
|
void | setRotationX |
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. |
void | setRotationY |
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. |
void | setRotationZ |
Sets the rotation of the shape around Z-axis.
|
void | setVisible |
Sets the visibility of the shape.
|
int | size() |
Returns the number of shapes in the group.
|
boolean | updateDynamicPropertiesStructural |
canHandleClick, getDrawMode, getScaleZ, getZ, getZOffset, setDrawMode, setPos, setPos, setPos, setScale, setScale, setScaleZ, setZ
executeUserAction, getGroup, getLevel, getName, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, randomPointInside, removeSVGFromOwner, removeSVGImage, setLevel, setPublic_xjal, setScale, setScaleX, setScaleY, setX, setY, updateDynamicProperties, updateSVGProperties
public ShapeGroup(Presentable presentable)
Constructs an empty group with default attributes.
- Parameters:
presentable
- the presentable object owning this shape
@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 shapeispublic
- iftrue
, the shape is visible on container's presentationx
- the x coordinate of groupy
- the y coordinate of grouprotation
- the rotation of the group in radianscontents
- the (possibly, empty) initial set of shapes (Shape objects, int ids, or ReplicatedShape objects)
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 shapedrawMode
- where to draw this shape: 2D, 3D or 2D+3Dispublic
- iftrue
, the shape is visible on container's presentationx
- the x coordinate of groupy
- the y coordinate of groupz
- the z coordinate of grouprotationZ
- 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)
@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)
(may be removed in the next versions)
public void setVisible(boolean v)
Description copied from class:
Shape
Sets the visibility of the shape.
- Overrides:
setVisible
in classShape
- Parameters:
v
- visibility:true
- visible,false
- not
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
public int size()
Returns the number of shapes in the group.
- Returns:
- the number of shapes in the group
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
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
More formally, returns the index
Note that implementation of this method is very inefficient (has linear complexity)
-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
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
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
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
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
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 (from0
tosize()
, inclusive)shape
- the shape to add
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 (from0
tosize()
, inclusive)rshape
- the replicated shape to add
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
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
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
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
public void clear()
Removes all shapes from the group.
public boolean contains(double px, double py)
Description copied from class:
Shape
@AnyLogicInternalAPI public boolean updateDynamicPropertiesStructural(boolean publicOnly)
- Overrides:
updateDynamicPropertiesStructural
in classShape
- Returns:
true
if:
1. update was done (usually for visible elements, respecting public flag etc.)
AND
2. further update of structural changes is applicable
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.
public Presentable getPresentable()
Returns the presentable (
Agent
or Experiment
) where this group
belongs to.- Overrides:
getPresentable
in classShape
- Returns:
- the presentable where this group belongs to
@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
This method restores owner of this object
The method is used in snapshot saving/loading
- Specified by:
restoreOwner
in interfacecom.anylogic.engine.internal.Child
- Overrides:
restoreOwner
in classShape
- Parameters:
owner
- owner of this object, usuallyAgent
,Experiment
orShapeGroup
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
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
public void setRotation(double rotation)
Sets the horizontal rotation of the shape.
- Overrides:
setRotation
in classShape3D
- Parameters:
rotation
- the new value of horizontal rotation in radians- See Also:
-
setRotationZ(double)
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
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
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
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
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
public double getRotation()
Returns the horizontal rotation of the shape.
- Overrides:
getRotation
in classShape
- Returns:
- the horizontal rotation of the shape in radians, clockwise
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
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
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
@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.
it may be removed/renamed in future.
- Specified by:
resetSVGState
in interfaceSVGElement
- Overrides:
resetSVGState
in classShape
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 classShape
- Parameters:
att
- attribute namesval
- attribute valuespublicOnly
- TODO
@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.
it may be removed/renamed in future.
- Specified by:
findSVGElement
in interfaceSVGElement
- Overrides:
findSVGElement
in classShape