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
-
Method Summary
Modifier and TypeMethodDescriptionfinal double
calculatePercentage
(String value) final String
calculateValue
(double y) Calculate the RhythmParameter value corresponding to a percentage of the value range.<T> String
convertValue
(RhythmParameter<T> rp, T value) Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.boolean
final String
final String
The description of this rhythm parameter.final String
getDisplayValue
(String value) Get a short String representation of the value.final String
getId()
final String
final String
final String
getNextValue
(String value) Get the next value after specified value.Get the list of possible values for this RhythmParameter.final String
getPreviousValue
(String value) Get the next value before specified value.getValueDescription
(String value) Provide an optional description or help text associated to the specified value.int
hashCode()
boolean
isCompatibleWith
(RhythmParameter<?> rp) Indicate if rp is compatible with this RhythmParameter.boolean
Indicate if this RhythmParameter is a primary parameter for its rhythm.final boolean
isValidValue
(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:RhythmParameter
Indicate 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:
isPrimary
in interfaceRhythmParameter<String>
- Returns:
-
hashCode
public int hashCode() -
equals
-
getId
- Specified by:
getId
in interfaceRhythmParameter<String>
- Returns:
- A unique identifier. Usually the english name.
-
getDefaultValue
- Specified by:
getDefaultValue
in interfaceRhythmParameter<String>
- Returns:
- Object The default value.
-
isValidValue
- Specified by:
isValidValue
in interfaceRhythmParameter<String>
- Returns:
- True is value is valid.
-
calculateValue
Description copied from interface:RpEnumerable
Calculate 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:
calculateValue
in interfaceRpEnumerable<String>
- Parameters:
y
- A float between 0 and 1.- Returns:
- A RhythmParameter value.
-
calculatePercentage
- Specified by:
calculatePercentage
in interfaceRpEnumerable<String>
- Returns:
- A percentage between 0 and 1 representing value in the range of the possible values.
-
getDescription
Description copied from interface:RhythmParameter
The description of this rhythm parameter.- Specified by:
getDescription
in interfaceRhythmParameter<String>
- Returns:
-
getMaxValue
- Specified by:
getMaxValue
in interfaceRpEnumerable<String>
-
getMinValue
- Specified by:
getMinValue
in interfaceRpEnumerable<String>
-
getDisplayName
- Specified by:
getDisplayName
in interfaceRhythmParameter<String>
- Returns:
- The localized display name of the rhythm parameter.
-
getNextValue
Description copied from interface:RpEnumerable
Get the next value after specified value.- Specified by:
getNextValue
in interfaceRpEnumerable<String>
- Returns:
- Object
-
getPreviousValue
Description copied from interface:RpEnumerable
Get the next value before specified value.- Specified by:
getPreviousValue
in interfaceRpEnumerable<String>
- Returns:
- Object
-
getPossibleValues
Description copied from interface:RpEnumerable
Get the list of possible values for this RhythmParameter.Only the first 10000 values are returned.
- Specified by:
getPossibleValues
in interfaceRpEnumerable<String>
- Returns:
-
saveAsString
Description copied from interface:RhythmParameter
Try to convert the specified RhythmParameter value to a string.- Specified by:
saveAsString
in interfaceRhythmParameter<String>
- Returns:
- Can be null if value is invalid or RhytmParameter does not have this capability.
- See Also:
-
loadFromString
Description copied from interface:RhythmParameter
Try to convert the specified string to a RhythmParameter value.- Specified by:
loadFromString
in interfaceRhythmParameter<String>
- Parameters:
s
- A string produced by valueToString().- Returns:
- Can be null if conversion failed.
- See Also:
-
getValueDescription
Description copied from interface:RhythmParameter
Provide an optional description or help text associated to the specified value.- Specified by:
getValueDescription
in interfaceRhythmParameter<String>
- Returns:
- Can be null.
-
isCompatibleWith
Description copied from interface:RhythmParameter
Indicate 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:
isCompatibleWith
in interfaceRhythmParameter<String>
- Returns:
- True if a rp's value can be converted to a value for this RhythmParameter.
-
convertValue
Description copied from interface:RhythmParameter
Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.- Specified by:
convertValue
in 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:RhythmParameter
Get a short String representation of the value.- Specified by:
getDisplayValue
in interfaceRhythmParameter<String>
- Returns:
- Can be an empty String.
-
toString
-