AnyLogic AnyLogic
Expand
Font size
  • java.lang.Object
    • com.anylogic.engine.presentation.ReplicatedShape<T>
All Implemented Interfaces:
com.anylogic.engine.internal.Child, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>

public abstract class ReplicatedShape<T extends Shape>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, com.anylogic.engine.internal.Child, SVGElement, java.lang.Iterable<T>, LevelElement
Persistent replicated shape - a container for a number of shapes of the same type but possibly different properties. Both the number of shapes and their properties may change dynamically.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

Constructors 
ReplicatedShape()  
Constructor Description

Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
ReplicatedShape<T> clone()
Creates and returns a copy of this replicated shape (i.e. new instance).
The returned shape is the object of the same class
All shapes of this replicated shape are cloned respectively
If this shape belongs to some group, its clone will also be added to that group
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
boolean contains​(double px, double py)
Tests if any of the shapes in this replicated shape contains the point with the given coordinates
int createShapes()
Creates missing and removes redundant shapes so that current number of shapes in this replicated shape equals value returned by getReplication()
abstract T createShapeWithStaticProperties_xjal​(int index)
Creates a new shape with static properties already set.
void executeUserAction​(java.lang.String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
SVGElement findSVGElement​(long svgId)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
T get​(int i)
Returns the shape with the given index.
Number of shapes is maintained to be equal with getReplication(): shapes are created/deleted automatically during frame drawing requests or by explicit createShapes() call.
ShapeGroup getGroup()
Returns the group containing this replicated shape.
Level getLevel()
Returns the level containing this shape.
abstract int getReplication()
Returns the current number of shapes in replicated shape.
abstract java.lang.Class<T> getShapeClass()
Returns the class of shapes in replicated shape.
long getSVGId()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
int indexOf​(T shape)
Returns the index of a given shape in this replicated shape.
java.util.Iterator<T> iterator()
Returns iterator over shapes created so far.
Number of shapes is maintained to be equal with getReplication(): shapes are created/deleted automatically during frame drawing requests or by explicit createShapes() call.
void onAggregatorVisibilityChanged()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void removeSVGFromOwner​(Shape oldOwner)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void resetSVGState()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void restoreOwner​(java.lang.Object owner)
Deprecated.
void setLevel​(Level level)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void setShapeDynamicProperties_xjal​(T shape, int index)
Sets the dynamic properties of a shape with the given index.
int size()
Returns the current number of shapes, which may not always equal to what is returned by getReplication().
void updateDynamicPropertiesStructural​(boolean publicOnly)
Updates dynamic properties of the replicated shape in a given context, adding and removing the shapes as needed.
SVGElement updateSVGProperties​(java.util.List<SVGCommand> commands, ShapeDrawMode drawMode, boolean publicOnly, SVGElement owner, SVGElement elbehind)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client.
Modifier and Type Method Description

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 java.lang.Iterable

forEach, spliterator

Constructor Detail

ReplicatedShape

public ReplicatedShape()

Method Detail

size

public int size()
Returns the current number of shapes, which may not always equal to what is returned by getReplication().
Returns:
the current number of shapes

indexOf

public int indexOf​(T shape)
Returns the index of a given shape in this replicated shape.
Parameters:
shape - the shape
Returns:
the index of the shape, -1 if the shape is not in this replicated shape

get

public T get​(int i)
Returns the shape with the given index.
Number of shapes is maintained to be equal with getReplication(): shapes are created/deleted automatically during frame drawing requests or by explicit createShapes() call.
Parameters:
i - the index
Returns:
the shape with the given index

iterator

public java.util.Iterator<T> iterator()
Returns iterator over shapes created so far.
Number of shapes is maintained to be equal with getReplication(): shapes are created/deleted automatically during frame drawing requests or by explicit createShapes() call.
Specified by:
iterator in interface java.lang.Iterable<T extends Shape>
Since:
8.3.3

getReplication

public abstract int getReplication()
Returns the current number of shapes in replicated shape. Must be defined in a subclass.

getShapeClass

public abstract java.lang.Class<T> getShapeClass()
Returns the class of shapes in replicated shape. Must be defined in a subclass.

createShapeWithStaticProperties_xjal

@AnyLogicInternalCodegenAPI
public abstract T createShapeWithStaticProperties_xjal​(int index)
Creates a new shape with static properties already set. Must be defined in a subclass.
Parameters:
index - the desired shape index
Returns:
a new shape

setShapeDynamicProperties_xjal

@AnyLogicInternalCodegenAPI
public void setShapeDynamicProperties_xjal​(T shape,
                                           int index)
Sets the dynamic properties of a shape with the given index. By default does nothing.
Parameters:
shape - the shape
index - the shape index

removeSVGFromOwner

@AnyLogicInternalAPI
public void removeSVGFromOwner​(Shape oldOwner)
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:
removeSVGFromOwner in interface SVGElement

getGroup

public ShapeGroup getGroup()
Returns the group containing this replicated shape.
Returns:
the group containing this replicated shape

contains

public boolean contains​(double px,
                        double py)
Tests if any of the shapes in this replicated shape contains the point with the given coordinates
Parameters:
px - the x coordinate of the click
py - the y coordinate of the click
Returns:
true if if any of the shapes in this replicated shape contains the point, false otherwise

updateDynamicPropertiesStructural

@AnyLogicInternalAPI
public final void updateDynamicPropertiesStructural​(boolean publicOnly)
Updates dynamic properties of the replicated shape in a given context, adding and removing the shapes as needed.
Parameters:
publicOnly - if true, the shape is only drawn if it is public

createShapes

public int createShapes()
Creates missing and removes redundant shapes so that current number of shapes in this replicated shape equals value returned by getReplication()
Returns:
current number of shapes in this replicated shape

restoreOwner

@AnyLogicInternalCodegenAPI
@Deprecated
public void restoreOwner​(java.lang.Object owner)
Deprecated.
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
Parameters:
owner - owner of this object, usually Agent, Experiment or ShapeGroup

clone

public final ReplicatedShape<T> clone()
Creates and returns a copy of this replicated shape (i.e. new instance).
The returned shape is the object of the same class
All shapes of this replicated shape are cloned respectively
If this shape belongs to some group, its clone will also be added to that group
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

getLevel

public Level getLevel()
Returns the level containing this shape. The returned value is null for shapes in the experiments.
Specified by:
getLevel in interface HasLevel
Returns:
the level containing this shape

setLevel

@AnyLogicInternalAPI
public void setLevel​(Level level)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use Level#add(Shape) instead.
Specified by:
setLevel in interface LevelElement

onAggregatorVisibilityChanged

public void onAggregatorVisibilityChanged()
Description copied from interface: AggregatableAnimationElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
onAggregatorVisibilityChanged in interface AggregatableAnimationElement

getSVGId

@AnyLogicInternalAPI
public long getSVGId()
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:
getSVGId in interface SVGElement

updateSVGProperties

@AnyLogicInternalAPI
public SVGElement updateSVGProperties​(java.util.List<SVGCommand> commands,
                                      ShapeDrawMode drawMode,
                                      boolean publicOnly,
                                      SVGElement owner,
                                      SVGElement elbehind)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client. If the element is not yet in the SVG scene, generates "C" command, if it is there, but some properties are out of date, generates "U" command. If SVG drawing of this element is not needed because of public only settings, or permanently not needed, or not supported yet, returns false and does nothing.
Specified by:
updateSVGProperties in interface SVGElement
Parameters:
commands - the list of commands to add to
drawMode - TODO
publicOnly - drawing context: if true, only shapes that are marked as public only are updated
owner - the SVG element that serves as a container for this element
elbehind - the SVG element behind this one, or null if none or if order is irrelevant
Returns:
the actual owner this element has been added to or null if element is not drawn (e.g. drawing of this element is not needed because of public only settings, permanently not needed or not supported - hence SVG id is not set). The actual owner may differ from the given owner when the svg element is added to a different place (e.g. GIS map).

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

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

executeUserAction

@AnyLogicInternalAPI
public void executeUserAction​(java.lang.String value)
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:
executeUserAction in interface SVGElement
How can we improve this article?