AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable

public class ShapeSlider
extends ShapeInputControl
Slider control. Embeds JSlider.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class com.anylogic.engine.presentation.ShapeControl

ShapeControl.ValueType

Field Summary

Modifier and TypeFieldDescription
doublevalue
The current value of the slider that can be accessed in the overridden action() method.
Use getValue() to obtain the current slider value from other places

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

TYPE_DOUBLE, TYPE_INT, TYPE_STRING

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

UNKNOWN_NAME

Constructor Summary

ConstructorDescription
ShapeSlider(Presentable p, boolean ispublic, double x, double y, double width, double height, boolean enabled, boolean vertical, double min, double max, double step, ShapeControl.ValueType valueType)
Creates a persistent slider control.
ShapeSlider(Presentable p, boolean ispublic, double x, double y, double width, double height, boolean enabled, boolean vertical, double min, double max, ShapeControl.ValueType valueType)
Deprecated.
ShapeSlider(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, boolean enabled, boolean vertical, double min, double max, ShapeControl.ValueType valueType)
Deprecated.
may be removed in future releases
ShapeSlider(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, boolean vertical, double min, double max, ShapeControl.ValueType valueType)
Deprecated.
may be removed in future releases

Method Summary

Modifier and TypeMethodDescription
voidexecuteUserAction(String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
intgetIntValue()
Returns the current int value of the slider.
This method may only be used in sliders with value type ShapeControl.TYPE_INT
doublegetMax()
Returns the maximum value of the slider.
doublegetMin()
Returns the minimum value of the slider.
doublegetStep()
Returns the step of the slider.
doublegetValue()
Returns the current value of the slider.
voidsetRange(double min, double max)
Sets the minimum and maximum values of the slider.
Doesn't execute user action code
If slider is configured to work with int values (see ShapeControl.TYPE_INT), the given [min, max] range may be automatically corrected to have integer bounds (within the given double bounds)
This method does nothing if the slider already has such range
voidsetRange(double min, double max, boolean callAction)
Sets the minimum and maximum values of the slider.
If the slider value appears out of range or not on the new step grid, it is brought within range and snapped to the grid.
voidsetStep(double step)
Sets the step of the slider.
voidsetStep(double step, boolean callAction)
Sets the step of the slider.
voidsetValue(double val)
Sets the value of the slider.
voidsetValue(double val, boolean callAction)
Sets the value of the slider.
If the value is out of range or not on the step grid (if any), sets the closest valid value.

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

postSVGShapeSpecificAttributes

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

action, clone, contains, executeAction, getHeight, getPresentable, getWidth, isEnabled, randomPointInside, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth

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

value

@AnyLogicInternalAPI
public double value
The current value of the slider that can be accessed in the overridden action() method.
Use getValue() to obtain the current slider value from other places

Constructor Details

ShapeSlider

@Deprecated
public ShapeSlider(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 Color backgroundColor,
 boolean vertical,
 double min,
 double max,
 ShapeControl.ValueType valueType)
Deprecated.
may be removed in future releases

ShapeSlider

@Deprecated
public ShapeSlider(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 Color backgroundColor,
 boolean enabled,
 boolean vertical,
 double min,
 double max,
 ShapeControl.ValueType valueType)
Deprecated.
may be removed in future releases

ShapeSlider

public ShapeSlider(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 boolean enabled,
 boolean vertical,
 double min,
 double max,
 double step,
 ShapeControl.ValueType valueType)
Creates a persistent slider control. You should override the action() method.
Parameters:
p - the presentable object owning this control
ispublic - if true, the control is visible on container's presentation
x - the x coordinate
y - the y coordinate
width - the width
height - the height
enabled - the initial enabled state
vertical - if true - vertical, otherwise horizontal
min - the minimum value of the slider
max - the maximum value of the slider
step - the step of the slider, use 0 to disable steps
valueType - the type of the value edited in the slider, supported types: ShapeControl.TYPE_DOUBLE, ShapeControl.TYPE_INT

ShapeSlider

@Deprecated
public ShapeSlider(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 boolean enabled,
 boolean vertical,
 double min,
 double max,
 ShapeControl.ValueType valueType)
Deprecated.

Method Details

setValue

public void setValue(double val)
Sets the value of the slider. If the value is out of range or not on the step grid (if any), sets the closest valid value. If the value is NaN, sets the default value.
Doesn't execute user action code
Parameters:
val - the new value

setValue

public void setValue(double val,
 boolean callAction)
Sets the value of the slider.
If the value is out of range or not on the step grid (if any), sets the closest valid value. If the value is NaN, sets the default value.
Executes user action code (if any exists) if callAction parameter is true; action is executed in the same thread.
Parameters:
val - the new value
callAction - if true user action code (if any exists) will be executed

getValue

public double getValue()
Returns the current value of the slider.
Returns:
the current value of the slider

getIntValue

public int getIntValue()
Returns the current int value of the slider.
This method may only be used in sliders with value type ShapeControl.TYPE_INT
Returns:
the current int value of the slider

setRange

public void setRange(double min,
 double max)
Sets the minimum and maximum values of the slider.
Doesn't execute user action code
If slider is configured to work with int values (see ShapeControl.TYPE_INT), the given [min, max] range may be automatically corrected to have integer bounds (within the given double bounds)
This method does nothing if the slider already has such range
Parameters:
min - the new minimum value
max - the new maximum value

setRange

public void setRange(double min,
 double max,
 boolean callAction)
Sets the minimum and maximum values of the slider.
If the slider value appears out of range or not on the new step grid, it is brought within range and snapped to the grid. If current slider value changes, executes user action code (if any exists) in the same thread - if callAction parameter is true
If slider is configured to work with int values (see ShapeControl.TYPE_INT), the given [min, max] range may be automatically corrected to have integer bounds (within the given double bounds)
This method does nothing if the slider already has such range
Parameters:
min - the new minimum value
max - the new maximum value
callAction - if true user action code (if any exists) will be executed if current slider value changes

setStep

public void setStep(double step)
Sets the step of the slider. If the slider value appears not on the new step grid, it is snapped to the new grid. The slider action is not executed in any case.
Parameters:
step - the step of the slider, use 0 to work without any specific step

setStep

public void setStep(double step,
 boolean callAction)
Sets the step of the slider. If the slider value appears not on the new step grid, it is snapped to the new grid. If current slider value changes, executes user action code (if any exists) in the same thread - if callAction parameter is true
Parameters:
step - the step of the slider, use 0 to work without any specific step
callAction - if true user action code (if any exists) will be executed if current slider value changes

getMin

public double getMin()
Returns the minimum value of the slider.
Returns:
the minimum value of the slider

getMax

public double getMax()
Returns the maximum value of the slider.
Returns:
the maximum value of the slider

getStep

public double getStep()
Returns the step of the slider.
Returns:
the step of the slider, or 0 when slider works without any specific step (default behavior)

executeUserAction

@AnyLogicInternalAPI
public void executeUserAction(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
Overrides:
executeUserAction in class Shape