Package org.jjazz.rhythm.api
Class RP_State
java.lang.Object
org.jjazz.rhythm.api.RP_State
- All Implemented Interfaces:
RhythmParameter<String>,RpEnumerable<String>
- Direct Known Subclasses:
RP_STD_Feel,RP_STD_Fill,RP_STD_Variation,RP_SYS_Marker
A RhythmParameter whose value can be some specified strings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal doublecalculatePercentage(String value) final StringcalculateValue(double y) Calculate the RhythmParameter value corresponding to a percentage of the value range.<T> StringconvertValue(RhythmParameter<T> rp, T value) Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.booleanfinal Stringfinal StringThe description of this rhythm parameter.final StringgetDisplayValue(String value) Get a short String representation of the value.final StringgetId()final Stringfinal Stringfinal StringgetNextValue(String value) Get the next value after specified value.Get the list of possible values for this RhythmParameter.final StringgetPreviousValue(String value) Get the next value before specified value.getValueDescription(String 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(String value) Try to convert the specified string to a RhythmParameter value.saveAsString(String 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_State
public RP_State(String id, String name, String description, boolean isPrimary, String defaultValue, String... possibleValues) Create a RP_State RhythmParameter.Created instance is primary by default.
- Parameters:
id-name- The name of the RhythmParameter.description-isPrimary-defaultValue- String The default value.possibleValues- String[] The possible values for this parameter. By convention, min value is set to the 1st possible value, max value to the last one.
-
-
Method Details
-
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<String>- Returns:
-
hashCode
public int hashCode() -
equals
-
getId
- Specified by:
getIdin interfaceRhythmParameter<String>- Returns:
- A unique identifier. Usually the english name.
-
getDefaultValue
- Specified by:
getDefaultValuein interfaceRhythmParameter<String>- Returns:
- Object The default value.
-
isValidValue
- Specified by:
isValidValuein interfaceRhythmParameter<String>- 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<String>- Parameters:
y- A float between 0 and 1.- Returns:
- A RhythmParameter value.
-
calculatePercentage
- Specified by:
calculatePercentagein interfaceRpEnumerable<String>- 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<String>- Returns:
-
getMaxValue
- Specified by:
getMaxValuein interfaceRpEnumerable<String>
-
getMinValue
- Specified by:
getMinValuein interfaceRpEnumerable<String>
-
getDisplayName
- Specified by:
getDisplayNamein interfaceRhythmParameter<String>- 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<String>- Returns:
- Object
-
getPreviousValue
Description copied from interface:RpEnumerableGet the next value before specified value.- Specified by:
getPreviousValuein interfaceRpEnumerable<String>- 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<String>- Returns:
-
saveAsString
Description copied from interface:RhythmParameterTry to convert the specified RhythmParameter value to a string.- Specified by:
saveAsStringin interfaceRhythmParameter<String>- Returns:
- Can be null if value is invalid or RhytmParameter does not have this capability.
- See Also:
-
loadFromString
Description copied from interface:RhythmParameterTry to convert the specified string to a RhythmParameter value.- Specified by:
loadFromStringin interfaceRhythmParameter<String>- 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<String>- 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<String>- 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<String>- 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<String>- Returns:
- Can be an empty String.
-
toString
-