com.yobotics.simulationconstructionset
Class EnumYoVariable<T extends java.lang.Enum<T>>

java.lang.Object
  extended by com.yobotics.simulationconstructionset.YoVariable
      extended by com.yobotics.simulationconstructionset.EnumYoVariable<T>
All Implemented Interfaces:
java.io.Serializable

public class EnumYoVariable<T extends java.lang.Enum<T>>
extends YoVariable

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.yobotics.simulationconstructionset.YoVariable
MAX_LENGTH_SHORT_NAME
 
Constructor Summary
EnumYoVariable(java.lang.String name, java.lang.String description, YoVariableRegistry registry, java.lang.Class<T> enumType)
          Creates a new YoVariable with the given name and type and adds it to the specified registry.
EnumYoVariable(java.lang.String name, YoVariableRegistry registry, java.lang.Class<T> enumType)
          Creates a new variable of type ENUM based on the provided array of values and registered with the given YoVariableRegistry.
 
Method Summary
static
<T extends java.lang.Enum<T>>
EnumYoVariable<T>
create(java.lang.String name, java.lang.Class<T> enumType, YoVariableRegistry registry)
          shortcut construction method; infers the type parameter from the declared type
static
<T extends java.lang.Enum<T>>
EnumYoVariable<T>
create(java.lang.String name, java.lang.String description, java.lang.Class<T> enumType, YoVariableRegistry registry)
          shortcut construction method; infers the type parameter from the declared type
 T getEnumValue()
          Retrieve the enum value of this YoVariable.
 T[] getEnumValues()
           
 void getValue(java.lang.StringBuffer stringBuffer)
          Appends the value of this variable to the end of the given StringBuffer.
 double getValueAsDouble()
           
 YoVariableType getYoVariableType()
           
 void set(T nextStateEnum)
          Set the enum value of this variable.
 void setValueFromDouble(double value)
           
 java.lang.String toString()
           
 boolean valueEquals(T value)
          Check if the value contained by this variable is equal to the given enum.
 
Methods inherited from class com.yobotics.simulationconstructionset.YoVariable
addVariableChangedListener, fullNameEndsWith, getDescription, getFullNameWithNameSpace, getManualScalingMax, getManualScalingMin, getName, getName, getNameAndValue, getNameSpace, getNumericValueAsAString, getShortName, getVariableChangedListeners, getYoVariableRegistry, hasSameFullName, notifyVariableChangedListeners, removeAllVariableChangedListeners, removeVariableChangedListener, setManualScalingMinMax
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumYoVariable

public EnumYoVariable(java.lang.String name,
                      YoVariableRegistry registry,
                      java.lang.Class<T> enumType)
Creates a new variable of type ENUM based on the provided array of values and registered with the given YoVariableRegistry.

Parameters:
name - name to be used for all references of this variable by SCS
registry - YoVariableRegistry with which this variable is to be registered.
See Also:
YoVariableRegistry

EnumYoVariable

public EnumYoVariable(java.lang.String name,
                      java.lang.String description,
                      YoVariableRegistry registry,
                      java.lang.Class<T> enumType)
Creates a new YoVariable with the given name and type and adds it to the specified registry. This constructor allows the user to provide a simple description of the variable, which can come in handy when faced with thousands. The description is displayed in the VarPanel component of the GUI. This variant also allows the user to specify min and max values for manual scaling of graphs.

Parameters:
name - name to be used for all references of this variable by SCS
description - a short description
registry - YoVariableRegistry
enumType - the class representing the type of the enum
Method Detail

create

public static <T extends java.lang.Enum<T>> EnumYoVariable<T> create(java.lang.String name,
                                                                     java.lang.Class<T> enumType,
                                                                     YoVariableRegistry registry)
shortcut construction method; infers the type parameter from the declared type


create

public static <T extends java.lang.Enum<T>> EnumYoVariable<T> create(java.lang.String name,
                                                                     java.lang.String description,
                                                                     java.lang.Class<T> enumType,
                                                                     YoVariableRegistry registry)
shortcut construction method; infers the type parameter from the declared type


valueEquals

public boolean valueEquals(T value)
Check if the value contained by this variable is equal to the given enum. If this YoVariable is not of enum type a warning will be printed to the console.

Parameters:
value - Enum to be compared
Returns:
boolean

set

public void set(T nextStateEnum)
Set the enum value of this variable. If not of enum type a warning will be printed.

Parameters:
nextStateEnum - Enum to store in this YoVariable

getEnumValues

public T[] getEnumValues()

getEnumValue

public T getEnumValue()
Retrieve the enum value of this YoVariable. If this variable is not of enum type a warning will be printed.

Returns:
Enum value of this

setValueFromDouble

public void setValueFromDouble(double value)
Specified by:
setValueFromDouble in class YoVariable

getValueAsDouble

public double getValueAsDouble()
Specified by:
getValueAsDouble in class YoVariable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getValue

public void getValue(java.lang.StringBuffer stringBuffer)
Appends the value of this variable to the end of the given StringBuffer. This representation is based on variable type.

Specified by:
getValue in class YoVariable
Parameters:
stringBuffer - StringBuffer to which the value will be appended

getYoVariableType

public YoVariableType getYoVariableType()
Specified by:
getYoVariableType in class YoVariable