com.xj.anylogic.engine.presentation
Class ShapeSlider

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.presentation.ShapeControl
          extended by com.xj.anylogic.engine.presentation.ShapeSlider
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.event.ChangeListener

public class ShapeSlider
extends ShapeControl
implements javax.swing.event.ChangeListener

Slider control. Embeds JSlider.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
 double value
          The current value of the slider that can be accessed in the overridden action() method.
 
Fields inherited from class com.xj.anylogic.engine.presentation.ShapeControl
TYPE_DOUBLE, TYPE_INT, TYPE_STRING
 
Fields inherited from class com.xj.anylogic.engine.presentation.Shape
UNKNOWN_NAME
 
Constructor Summary
ShapeSlider(Presentable p, boolean ispublic, int x, int y, int width, int height, java.awt.Color backgroundColor, boolean vertical, double min, double max)
          Deprecated. use ShapeSlider(Presentable, boolean, int, int, int, int, Color, boolean, double, double, int)
ShapeSlider(Presentable p, boolean ispublic, int x, int y, int width, int height, java.awt.Color backgroundColor, boolean vertical, double min, double max, int valueType)
          Creates a persistent slider control.
 
Method Summary
 void action()
          Executes the action associated with a non-persistent slider.
 int getIntValue()
          Returns the current double value of the slider.
 javax.swing.JComponent getJComponent()
          Returns the embedded JSlider.
 double getMax()
          Returns the maximum value of the slider.
 double getMin()
          Returns the minimum value of the slider.
 double getValue()
          Returns the current value of the slider.
 void setRange(double min, double max)
          Sets the minimum and maximum values of the slider.
 void setRange(double min, double max, boolean callAction)
          Sets the minimum and maximum values of the slider.
 void setValue(double val)
          Sets the value of the slider.
 void setValue(double val, boolean callAction)
          Sets the value of the slider.
 void setValueToDefault()
          Sets the value of a non-persistent slider to what was provided as the default one.
 void stateChanged(javax.swing.event.ChangeEvent event)
          ChangeListener implementation.
 void update()
          Updates the specific properties of a non-persistent slider that are to be updated on each frame: min/max.
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeControl
clone, contains, draw, getHeight, getPresentable, getWidth, isEnabled, onClickAt, restoreOwner, setEnabled, setHeight, setWidth
 
Methods inherited from class com.xj.anylogic.engine.presentation.Shape
canHandleClick, getGroup, getName, getRotation, getScaleX, getScaleY, getX, getY, isVisible, onClick, setPos, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

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 Detail

ShapeSlider

@Deprecated
public ShapeSlider(Presentable p,
                              boolean ispublic,
                              int x,
                              int y,
                              int width,
                              int height,
                              java.awt.Color backgroundColor,
                              boolean vertical,
                              double min,
                              double max)
Deprecated. use ShapeSlider(Presentable, boolean, int, int, int, int, Color, boolean, double, double, int)


ShapeSlider

public ShapeSlider(Presentable p,
                   boolean ispublic,
                   int x,
                   int y,
                   int width,
                   int height,
                   java.awt.Color backgroundColor,
                   boolean vertical,
                   double min,
                   double max,
                   int 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
backgroundColor - the background color
vertical - if true - vertical, otherwise horizontal
min - the minimum value of the slider
max - the maximum value of the slider
valueType - the type of the value edited in the slider, supported types: ShapeControl.TYPE_DOUBLE, ShapeControl.TYPE_INT
Method Detail

action

public void action()
Executes the action associated with a non-persistent slider. This method must be overridden for persistent sliders.

Specified by:
action in class ShapeControl

getJComponent

public javax.swing.JComponent getJComponent()
Returns the embedded JSlider.

Specified by:
getJComponent in class ShapeControl

setValueToDefault

public void setValueToDefault()
Sets the value of a non-persistent slider to what was provided as the default one.
Doesn't execute user action code

Overrides:
setValueToDefault in class ShapeControl

setValue

public void setValue(double val)
Sets the value of the slider. Action is executed in the same thread.
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. Action is executed in the same thread.
Executes user action code (if any exists) if callAction parameter is true

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 double value of the slider.
This method may only be used in sliders with value type ShapeControl.TYPE_INT

Returns:
the current double 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 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

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

update

public void update()
Updates the specific properties of a non-persistent slider that are to be updated on each frame: min/max.

Overrides:
update in class ShapeControl

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
ChangeListener implementation. Starts action execution.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.