public abstract class Property extends Object
@P
). The Property type also backs
other none-resource-loading properties - use p(String id)
to access the backing Property.Modifier and Type | Class and Description |
---|---|
static class |
Property.Animator
Provides keyframe animation support for Property.
|
Modifier and Type | Method and Description |
---|---|
Property.Animator |
animator()
Return the Animator for the Property, creating it if necessary.
|
Property |
clearLinks()
Clear all Linkables from the Property.
|
org.praxislive.core.Value |
get()
Return the current value.
|
boolean |
getBoolean()
Return the current value as a boolean, or false if the value isn't a
valid boolean.
|
boolean |
getBoolean(boolean def)
Return the current value as a boolean, or the provided default if the
value isn't a valid boolean.
|
double |
getDouble()
Return the current value as a double, or zero if the value isn't numeric.
|
double |
getDouble(double def)
Return the current value as a double, or the provided default if the
value isn't numeric.
|
int |
getInt()
Return the current value as an int, or zero if the value isn't numeric.
|
int |
getInt(int def)
Return the current value as an int, or the provided default if the value
isn't numeric.
|
boolean |
isAnimating()
Return whether the property is currently animating.
|
Property |
link(DoubleConsumer... consumers) |
Property |
link(DoubleConsumer consumer)
Call the provided consumer with the double value whenever the value
changes.
|
<T> Property |
linkAs(Function<org.praxislive.core.Value,T> converter,
Consumer<T>... consumers) |
<T> Property |
linkAs(Function<org.praxislive.core.Value,T> converter,
Consumer<T> consumer)
Call the provided consumer when the value changes, transformed using the
converter into the required type T.
|
Property |
set(double value)
Set the current value.
|
Property |
set(org.praxislive.core.Value value)
Set the current value.
|
Property.Animator |
to(double... to)
Animate the property value to the provided values.
|
Linkable.Double |
values()
Return a new
Linkable.Double for observing changing values. |
<T extends org.praxislive.core.Value> |
valuesAs(Class<T> type)
Return a new
Linkable for observing changing values. |
<T> Linkable<T> |
valuesAs(Function<org.praxislive.core.Value,T> converter)
Return a new
Linkable for observing changing values. |
public org.praxislive.core.Value get()
public double getDouble()
DefaultCodeDelegate.d(org.praxislive.code.userapi.Property)
public double getDouble(double def)
public int getInt()
DefaultCodeDelegate.i(org.praxislive.code.userapi.Property)
public int getInt(int def)
public boolean getBoolean()
public boolean getBoolean(boolean def)
public Property set(org.praxislive.core.Value value)
value
- Value subclass to setpublic Property set(double value)
value
- double value to setpublic Property link(DoubleConsumer consumer)
values().link(consumer);
. The
double value will be as if calling getDouble()
.consumer
- double consumerpublic Property link(DoubleConsumer... consumers)
public Linkable.Double values()
Linkable.Double
for observing changing values. The
double value will be as if calling getDouble()
.public <T> Property linkAs(Function<org.praxislive.core.Value,T> converter, Consumer<T> consumer)
valuesAs(converter).link(consumer);
.T
- typeconverter
- convert Value into required typeconsumer
- public <T> Property linkAs(Function<org.praxislive.core.Value,T> converter, Consumer<T>... consumers)
public <T> Linkable<T> valuesAs(Function<org.praxislive.core.Value,T> converter)
Linkable
for observing changing values. The value
will be mapped to the required type using the passed in converter.T
- required typeconverter
- convert Value into required typepublic <T extends org.praxislive.core.Value> Linkable<T> valuesAs(Class<T> type)
Linkable
for observing changing values. The value
will be mapped to the provided Value sub-type. If the value cannot be
coerced into the required type no value will be received by the created
Linkable.T
- required typetype
- Sub-type of Valuepublic Property clearLinks()
public Property.Animator animator()
public Property.Animator to(double... to)
animator().to(...)
.
This method returns the animator so that you can chain calls, eg.
prop.to(1, 0).in(1, 0.25).easeInOut();
public boolean isAnimating()