AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable
Direct Known Subclasses:
Chart, ShapeInputControl, ShapeWindow3D

public abstract class ShapeControl
extends Shape
implements com.anylogic.engine.internal.Child
The base class for all controls, i.e. presentation shapes that have JComponents, (like buttons, sliders, text fields, and also charts).
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Modifier and TypeClassDescription
static enum ShapeControl.ValueType 

Field Summary

Modifier and TypeFieldDescription
static final ShapeControl.ValueTypeTYPE_DOUBLE
Control value-type constant for double number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls
static final ShapeControl.ValueTypeTYPE_INT
Control value-type constant for int number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls
static final ShapeControl.ValueTypeTYPE_STRING
Control value-type constant for String editing mode, applicable for ShapeTextField, ShapeComboBox.
See constructors of these controls

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

UNKNOWN_NAME

Method Summary

Modifier and TypeMethodDescription
voidaction()
Executes the action associated with the control.
Shapeclone()
Cloning of controls is not supported
(Other shapes except GIS and charts allow cloning)
This method throws UnsupportedOperationException if called
booleancontains(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
voidexecuteAction()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
doublegetHeight()
Returns the height of the control.
PresentablegetPresentable()
Returns the presentable object owning the control
doublegetWidth()
Returns the width of the control.
booleanisEnabled()
Tests if the control is enabled or disabled.
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.
voidrestoreOwner(Object owner)
Deprecated.
voidsetEnabled(boolean yes)
Sets the control enabled or disabled
voidsetHeight(double height)
Sets the height of the control.
voidsetValueToDefault()
Sets the value of the control to what was provided as the default one.
voidsetWidth(double width)
Sets the width of the control.

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

Field Details

TYPE_DOUBLE

public static final ShapeControl.ValueType TYPE_DOUBLE
Control value-type constant for double number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls

TYPE_INT

public static final ShapeControl.ValueType TYPE_INT
Control value-type constant for int number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls

TYPE_STRING

public static final ShapeControl.ValueType TYPE_STRING
Control value-type constant for String editing mode, applicable for ShapeTextField, ShapeComboBox.
See constructors of these controls

Method Details

action

@AnyLogicInternalCodegenAPI
public void action()
Executes the action associated with the control. This method does nothing by default and may be overridden.

setValueToDefault

public void setValueToDefault()
Sets the value of the control to what was provided as the default one.

setEnabled

public void setEnabled(boolean yes)
Sets the control enabled or disabled
Parameters:
yes - the new enabled state

isEnabled

public boolean isEnabled()
Tests if the control is enabled or disabled.
Returns:
true if enabled, otherwise false

setWidth

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

getWidth

public double getWidth()
Returns the width of the control.
Returns:
the width of the control

setHeight

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

getHeight

public double getHeight()
Returns the height of the control.
Returns:
the height of the control

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.

executeAction

@AnyLogicInternalAPI
public void executeAction()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

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

getPresentable

public Presentable getPresentable()
Returns the presentable object owning the control
Overrides:
getPresentable in class Shape
Returns:
the presentable object owning the control

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 Shape clone()
Cloning of controls is not supported
(Other shapes except GIS and charts allow cloning)
This method throws UnsupportedOperationException if called
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 Shape
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO