Package org.jjazz.rhythm.api
Interface RhythmParameter<E>
- Type Parameters:
E
- The type of value of this RhythmParameter. E.toString() should return a short (max ~30 characters) user-readable string. Prefer an immutable class, but if value class is mutable, it must implement the MutableRpValue interface.
- All Known Implementing Classes:
RP_Integer
,RP_State
,RP_STD_Feel
,RP_STD_Fill
,RP_STD_Intensity
,RP_STD_Variation
,RP_StringSet
,RP_SYS_CustomPhrase
,RP_SYS_DrumsTransform
,RP_SYS_Marker
,RP_SYS_Mute
,RP_SYS_TempoFactor
public interface RhythmParameter<E>
Define a parameter that influences the way a Rhythm generates music.
A RhythmParameter implementation can have additional capabilities by implementing additional interfaces, such as RpEnumerable, RpCustomEditorProvider, RpViewerRendererFactory, etc.
-
Method Summary
Modifier and TypeMethodDescriptiondefault E
cloneValue
(E value) Clone the specified value.<T> E
convertValue
(RhythmParameter<T> rp, T rpValue) Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.static RhythmParameter<?>
findFirstCompatibleRp
(List<? extends RhythmParameter<?>> rps, RhythmParameter<?> rp) Return the first RhythmParameter in rps compatible with rp.The description of this rhythm parameter.getDisplayValue
(E value) Get a short String representation of the value.getId()
getValueDescription
(E value) Provide an optional description or help text associated to the specified value.boolean
isCompatibleWith
(RhythmParameter<?> rp) Indicate if rp is compatible with this RhythmParameter.default boolean
Indicate if this RhythmParameter is a primary parameter for its rhythm.boolean
isValidValue
(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.
-
Method Details
-
findFirstCompatibleRp
static RhythmParameter<?> findFirstCompatibleRp(List<? extends RhythmParameter<?>> rps, RhythmParameter<?> rp) Return the first RhythmParameter in rps compatible with rp.- Parameters:
rps
-rp
-- Returns:
- Null if no compatible RhythmParameter found
-
getId
String getId()- Returns:
- A unique identifier. Usually the english name.
-
getDisplayName
String getDisplayName()- Returns:
- The localized display name of the rhythm parameter.
-
getDescription
String getDescription()The description of this rhythm parameter.- Returns:
-
getDisplayValue
Get a short String representation of the value.- Parameters:
value
-- Returns:
- Can be an empty String.
-
getValueDescription
Provide an optional description or help text associated to the specified value.- Parameters:
value
-- Returns:
- Can be null.
-
getDefaultValue
E getDefaultValue()- Returns:
- Object The default value.
-
saveAsString
Try to convert the specified RhythmParameter value to a string.- Parameters:
value
-- Returns:
- Can be null if value is invalid or RhytmParameter does not have this capability.
- See Also:
-
loadFromString
Try to convert the specified string to a RhythmParameter value.- Parameters:
s
- A string produced by valueToString().- Returns:
- Can be null if conversion failed.
- See Also:
-
isValidValue
- Parameters:
value
-- Returns:
- True is value is valid.
-
cloneValue
Clone the specified value.The default implementation just return value, which is fine is E is an immutable class. If E is mutable, this method must be overridden.
- Parameters:
value
-- Returns:
- A copy of the specified value.
-
isCompatibleWith
Indicate if rp is compatible with this RhythmParameter.NOTE: if rp1 is compatible with rp2, then rp2 must be compatible with rp1 as well.
- Parameters:
rp
-- Returns:
- True if a rp's value can be converted to a value for this RhythmParameter.
-
convertValue
Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.- Type Parameters:
T
- A RhythmParameter value- Parameters:
rp
- A compatible RhythmParameterrpValue
- The value to convert- Returns:
- The rpValue converted for this RhythmParameter. Can't be null.
- Throws:
IllegalArgumentException
- If rp is not a compatible with this RhythmParameter.
-
isPrimary
default boolean isPrimary()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.
- Returns:
-