Class IntRangeParameter

  • All Implemented Interfaces:
    java.lang.Cloneable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener

    public class IntRangeParameter
    extends Parameter

    This is a parameter with type integer with a limited range. Its value is an integer token that is constrained to lie within the boundaries specified by its two parameters, min and max. These specify the minimum and maximum values. A user interface will typically use this information to represent the parameter value using a slider which can be decorated by labels indicating the minimum and maximum values. The actual text displayed by the labels can be set using the minLabel and maxLabel parameters which default to showing the actual minimum and maximum int value. The default values for min and max are 0 and 100, respectively, and the default value for this parameter is 50.

    Since:
    Ptolemy II 3.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Christoph Daniel Schulze
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • max

        public Parameter max
        The maximum value. This is has an integer value, and defaults to 100.
      • min

        public Parameter min
        The minimum value. This is has an integer value, and defaults to 0.
      • maxLabel

        public StringParameter maxLabel
        The label text displayed for the maximum end of the slider. This is a String, and defaults to $max, which is expanded to the value of the max parameter in the user interface.
      • minLabel

        public StringParameter minLabel
        The label text displayed for the minimum end of the slider. This is a String, and defaults to $min, which is expanded to the value of the min parameter in the user interface.
    • Constructor Detail

      • IntRangeParameter

        public IntRangeParameter​(NamedObj container,
                                 java.lang.String name)
                          throws IllegalActionException,
                                 NameDuplicationException
        Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this attribute.
        Throws:
        IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
        NameDuplicationException - If the name coincides with an attribute already in the container.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        React to a change in an attribute by ensuring that the current value remains within the range given by min and max.
        Overrides:
        attributeChanged in class Variable
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If the change is not acceptable to this container (should not be thrown).
      • getCurrentValue

        public int getCurrentValue()
                            throws IllegalActionException
        Return the current value of this parameter as an integer.
        Returns:
        The current value.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
      • getMaxValue

        public int getMaxValue()
                        throws IllegalActionException
        Return the maximum value of this parameter as an integer.
        Returns:
        The maximum value.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
      • getMinValue

        public int getMinValue()
                        throws IllegalActionException
        Return the minimum value of this parameter.
        Returns:
        The minimum value.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
      • _setTokenAndNotify

        protected void _setTokenAndNotify​(Token newToken)
                                   throws IllegalActionException
        Description copied from class: Variable
        Set the token value and type of the variable, and notify the container that the value (and type, if appropriate) has changed. Also notify value dependents that they need to be re-evaluated, and notify any listeners that have been registered with addValueListener(). If setTypeEquals() has been called, then attempt to convert the specified token into one of the appropriate type, if needed, rather than changing the type.
        Overrides:
        _setTokenAndNotify in class Variable
        Parameters:
        newToken - The new value of the variable.
        Throws:
        IllegalActionException - If the token type is not compatible with specified constraints, or if you are attempting to set to null a variable that has value dependents.