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
static int NULL_VALUE
           
 
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, boolean allowNullValue)
          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)
           
 
Method Summary
 T convertDoubleToEnum(double doubleValue)
           
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, boolean allowNullValue)
          shortcut construction method; infers the type parameter from the declared type
 boolean getAllowNullValue()
           
 java.lang.Class<T> getEnumType()
           
 T getEnumValue()
          Retrieve the enum value of this YoVariable.
 T[] getEnumValues()
           
 double getValueAsDouble()
           
 void getValueString(java.lang.StringBuffer stringBuffer)
          Appends the value of this variable to the end of the given StringBuffer.
 void getValueStringFromDouble(java.lang.StringBuffer stringBuffer, double doubleValue)
           
 void getValueStringFromEnum(java.lang.StringBuffer stringBuffer, T enumValue)
           
 YoVariableType getYoVariableType()
           
 void set(T enumValue)
          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, fullNameEndsWithCaseInsensitive, getDescription, getFullNameWithNameSpace, getManualScalingMax, getManualScalingMin, getName, getName, getNameAndValueString, getNameAndValueStringFromDouble, 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
 

Field Detail

NULL_VALUE

public static final int NULL_VALUE
See Also:
Constant Field Values
Constructor Detail

EnumYoVariable

public EnumYoVariable(java.lang.String name,
                      java.lang.String description,
                      YoVariableRegistry registry,
                      java.lang.Class<T> enumType,
                      boolean allowNullValue)
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

EnumYoVariable

public EnumYoVariable(java.lang.String name,
                      YoVariableRegistry registry,
                      java.lang.Class<T> enumType)
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,
                                                                     boolean allowNullValue)
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

getEnumType

public java.lang.Class<T> getEnumType()

set

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

Parameters:
enumValue - Enum to store in this YoVariable

getAllowNullValue

public boolean getAllowNullValue()

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

convertDoubleToEnum

public T convertDoubleToEnum(double doubleValue)

getValueAsDouble

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

toString

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

getValueString

public void getValueString(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:
getValueString in class YoVariable
Parameters:
stringBuffer - StringBuffer to which the value will be appended

getValueStringFromDouble

public void getValueStringFromDouble(java.lang.StringBuffer stringBuffer,
                                     double doubleValue)
Specified by:
getValueStringFromDouble in class YoVariable

getValueStringFromEnum

public void getValueStringFromEnum(java.lang.StringBuffer stringBuffer,
                                   T enumValue)

getYoVariableType

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