AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, java.io.Serializable, java.lang.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

Nested Classes 
static class  ShapeControl.ValueType  
Modifier and Type Class Description

Field Summary

Fields 
static ShapeControl.ValueType TYPE_DOUBLE
Control value-type constant for double number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls
static ShapeControl.ValueType TYPE_INT
Control value-type constant for int number editing mode, applicable for ShapeSlider, ShapeTextField, ShapeComboBox.
See constructors of these controls
static ShapeControl.ValueType TYPE_STRING
Control value-type constant for String editing mode, applicable for ShapeTextField, ShapeComboBox.
See constructors of these controls
Modifier and Type Field Description

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

UNKNOWN_NAME

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods 
void action()
Executes the action associated with the control.
Shape clone()
Cloning of controls is not supported
(Other shapes except GIS and charts allow cloning)
This method throws UnsupportedOperationException if called
boolean contains​(double px, double py)
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)
void executeAction()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
double getHeight()
Returns the height of the control.
Presentable getPresentable()
Returns the presentable object owning the control
double getWidth()
Returns the width of the control.
boolean isEnabled()
Tests if the control is enabled or disabled.
void postSVGShapeSpecificAttributes​(java.util.List<java.lang.String> att, java.util.List<java.lang.String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
Point randomPointInside​(java.util.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.
void restoreOwner​(java.lang.Object owner)
Deprecated.
void setEnabled​(boolean yes)
Sets the control enabled or disabled
void setHeight​(double height)
Sets the height of the control.
void setValueToDefault()
Sets the value of the control to what was provided as the default one.
void setWidth​(double width)
Sets the width of the control.
Modifier and Type Method Description

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

canHandleClick, executeUserAction, findSVGElement, getDrawMode, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, removeSVGFromOwner, removeSVGImage, resetSVGState, setLevel, setPos, setPos, setPublic_xjal, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties

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 Detail

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 Detail

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​(java.util.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​(java.lang.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​(java.util.List<java.lang.String> att,
                                           java.util.List<java.lang.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
How can we improve this article?