Class RP_EnumState<E extends Enum<E>>
java.lang.Object
org.jjazz.rhythm.api.RP_EnumState<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Cloneable,RhythmParameter<E>,RpEnumerable<E>
public class RP_EnumState<E extends Enum<E>>
extends Object
implements RhythmParameter<E>, RpEnumerable<E>, Cloneable
A variant of RP_State built from an enum value.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal doublecalculatePercentage(E value) final EcalculateValue(double y) Calculate the RhythmParameter value corresponding to a percentage of the value range.<T> EconvertValue(RhythmParameter<T> rp, T value) Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.booleanGet a copy of this RhythmParameter.final Efinal StringThe description of this rhythm parameter.final StringgetDisplayValue(E value) Get a short String representation of the value.final StringgetId()final Efinal Efinal EgetNextValue(E value) Get the next value after specified value.Get the list of possible values for this RhythmParameter.final EgetPreviousValue(E value) Get the next value before specified value.getValueDescription(E value) Provide an optional description or help text associated to the specified value.inthashCode()booleanisCompatibleWith(RhythmParameter<?> rp) Indicate if rp is compatible with this RhythmParameter.booleanIndicate if this RhythmParameter is a primary parameter for its rhythm.final booleanisValidValue(E value) Try to convert the specified string to a RhythmParameter value.saveAsString(E value) Try to convert the specified RhythmParameter value to a string.toString()Methods inherited from interface org.jjazz.rhythm.api.RhythmParameter
cloneValue
-
Constructor Details
-
RP_EnumState
public RP_EnumState(String id, String name, String description, boolean isPrimary, Class<E> enumClass, E defaultValue) Create a RP_EnumState RhythmParameter.The possible values are the possible enum values. The min value if the first value of the enum, the max value the last one.
- Parameters:
id-name- The name of the RhythmParameter.description-isPrimary-enumClass-defaultValue- E The default value.
-
-
Method Details
-
getCopy
Description copied from interface:RhythmParameterGet a copy of this RhythmParameter.- Specified by:
getCopyin interfaceRhythmParameter<E extends Enum<E>>- Parameters:
r- Can be null. Optionally set the target Rhythm of the returned RhythmParameter -though it might be ignored by the implementing method.- Returns:
-
isPrimary
public boolean isPrimary()Description copied from interface:RhythmParameterIndicate if this RhythmParameter is a primary parameter for its rhythm.This information is made available mainly for the user interface, e.g. to select which RhythmParameters to show first.
Default implementation returns true.
- Specified by:
isPrimaryin interfaceRhythmParameter<E extends Enum<E>>- Returns:
-
hashCode
-
equals
-
getId
-
getDefaultValue
- Specified by:
getDefaultValuein interfaceRhythmParameter<E extends Enum<E>>- Returns:
- Object The default value.
-
isValidValue
- Specified by:
isValidValuein interfaceRhythmParameter<E extends Enum<E>>- Parameters:
value-- Returns:
- True is value is valid.
-
calculateValue
Description copied from interface:RpEnumerableCalculate the RhythmParameter value corresponding to a percentage of the value range.For example if RhythmParameter is an integer between 0 and 4: percentage=0 -> value=0 percentage=0.5 -> value=2 percentage=1 -> value=4.
- Specified by:
calculateValuein interfaceRpEnumerable<E extends Enum<E>>- Parameters:
y- A float between 0 and 1.- Returns:
- A RhythmParameter value.
-
calculatePercentage
- Specified by:
calculatePercentagein interfaceRpEnumerable<E extends Enum<E>>- Parameters:
value-- Returns:
- A percentage between 0 and 1 representing value in the range of the possible values.
-
getDescription
Description copied from interface:RhythmParameterThe description of this rhythm parameter.- Specified by:
getDescriptionin interfaceRhythmParameter<E extends Enum<E>>- Returns:
-
getMaxValue
- Specified by:
getMaxValuein interfaceRpEnumerable<E extends Enum<E>>
-
getMinValue
- Specified by:
getMinValuein interfaceRpEnumerable<E extends Enum<E>>
-
getDisplayName
- Specified by:
getDisplayNamein interfaceRhythmParameter<E extends Enum<E>>- Returns:
- The localized display name of the rhythm parameter.
-
getNextValue
Description copied from interface:RpEnumerableGet the next value after specified value.- Specified by:
getNextValuein interfaceRpEnumerable<E extends Enum<E>>- Parameters:
value-- Returns:
- Object
-
getPreviousValue
Description copied from interface:RpEnumerableGet the next value before specified value.- Specified by:
getPreviousValuein interfaceRpEnumerable<E extends Enum<E>>- Parameters:
value-- Returns:
- Object
-
getPossibleValues
Description copied from interface:RpEnumerableGet the list of possible values for this RhythmParameter.Only the first 10000 values are returned.
- Specified by:
getPossibleValuesin interfaceRpEnumerable<E extends Enum<E>>- Returns:
-
saveAsString
Description copied from interface:RhythmParameterTry to convert the specified RhythmParameter value to a string.- Specified by:
saveAsStringin interfaceRhythmParameter<E extends Enum<E>>- Parameters:
value-- Returns:
- Can be null if value is invalid.
- See Also:
-
loadFromString
Description copied from interface:RhythmParameterTry to convert the specified string to a RhythmParameter value.- Specified by:
loadFromStringin interfaceRhythmParameter<E extends Enum<E>>- Parameters:
s- A string produced by valueToString().- Returns:
- Can be null if conversion failed.
- See Also:
-
getValueDescription
Description copied from interface:RhythmParameterProvide an optional description or help text associated to the specified value.- Specified by:
getValueDescriptionin interfaceRhythmParameter<E extends Enum<E>>- Parameters:
value-- Returns:
- Can be null.
-
isCompatibleWith
Description copied from interface:RhythmParameterIndicate if rp is compatible with this RhythmParameter.NOTE: if rp1 is compatible with rp2, then rp2 must be compatible with rp1 as well.
- Specified by:
isCompatibleWithin interfaceRhythmParameter<E extends Enum<E>>- Parameters:
rp-- Returns:
- True if a rp's value can be converted to a value for this RhythmParameter.
-
convertValue
Description copied from interface:RhythmParameterConvert the value of a compatible RhythmParameter to a value for this RhythmParameter.- Specified by:
convertValuein interfaceRhythmParameter<E extends Enum<E>>- Type Parameters:
T- A RhythmParameter value- Parameters:
rp- A compatible RhythmParametervalue- The value to convert- Returns:
- The rpValue converted for this RhythmParameter. Can't be null.
-
getDisplayValue
Description copied from interface:RhythmParameterGet a short String representation of the value.- Specified by:
getDisplayValuein interfaceRhythmParameter<E extends Enum<E>>- Parameters:
value-- Returns:
- Can be an empty String.
-
toString
-