Class Property

  • Direct Known Subclasses:
    PropertyControl

    public abstract class Property
    extends Object
    A field type for properties (see @P). The Property type also backs other none-resource-loading properties - use p(String id) to access the backing Property.
    • Constructor Detail

      • Property

        protected Property()
    • Method Detail

      • setImpl

        protected abstract void setImpl​(long time,
                                        double value)
                                 throws Exception
        Throws:
        Exception
      • getImpl

        protected abstract Value getImpl()
      • getImpl

        protected abstract double getImpl​(double def)
      • get

        public Value get()
        Return the current value.
        Returns:
        value
      • getDouble

        public double getDouble​(double def)
        Return the current value as a double, or the provided default if the value isn't numeric.
        Returns:
        current value as double
      • getInt

        public int getInt​(int def)
        Return the current value as an int, or the provided default if the value isn't numeric. Floating point values are rounded to the nearest int.
        Returns:
        current value as int
      • getBoolean

        public boolean getBoolean()
        Return the current value as a boolean, or false if the value isn't a valid boolean.
        Returns:
        current value as boolean
      • getBoolean

        public boolean getBoolean​(boolean def)
        Return the current value as a boolean, or the provided default if the value isn't a valid boolean.
        Returns:
        current value as boolean
      • set

        public Property set​(Value value)
        Set the current value. Also stops any active animation.
        Parameters:
        value - Value subclass to set
        Returns:
        this
      • set

        public Property set​(double value)
        Set the current value. Also stops any active animation.
        Parameters:
        value - double value to set
        Returns:
        this
      • link

        public Property link​(DoubleConsumer consumer)
        Call the provided consumer with the double value whenever the value changes. This is a shorthand for doubles().link(consumer);. The double value will be as if calling getDouble().
        Parameters:
        consumer - double consumer
        Returns:
        this
      • values

        @Deprecated(forRemoval=true)
        public Linkable.Double values()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Return a new Linkable.Double for observing changing values. The double value will be as if calling getDouble().

        This method is deprecated. Switch to doubles() instead.

        Returns:
        Linkable.Double of values.
      • linkAs

        public <T> Property linkAs​(Function<Value,​T> converter,
                                   Consumer<T> consumer)
        Call the provided consumer when the value changes, transformed using the converter into the required type T. This is shorthand for valuesAs(converter).link(consumer);.
        Type Parameters:
        T - type
        Parameters:
        converter - convert Value into required type
        consumer -
        Returns:
        this
      • valuesAs

        public <T> Linkable<T> valuesAs​(Function<Value,​T> converter)
        Return a new Linkable for observing changing values. The value will be mapped to the required type using the passed in converter.
        Type Parameters:
        T - required type
        Parameters:
        converter - convert Value into required type
        Returns:
        Linkable of values
      • valuesAs

        public <T extends ValueLinkable<T> valuesAs​(Class<T> type)
        Return a new 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.
        Type Parameters:
        T - required type
        Parameters:
        type - Sub-type of Value
        Returns:
        Linkable of values
      • clearLinks

        public Property clearLinks()
        Clear all Linkables from the Property.
        Returns:
        this
      • animator

        public Property.Animator animator()
        Return the Animator for the Property, creating it if necessary.
        Returns:
        property animator
      • to

        public Property.Animator to​(double... to)
        Animate the property value to the provided values. This is a shorthand for calling animator().to(...).

        This method returns the animator so that you can chain calls, eg. prop.to(1, 0).in(1, 0.25).easeInOut();

        Returns:
        property animator
      • isAnimating

        public boolean isAnimating()
        Return whether the property is currently animating.
        Returns:
        property animator active
      • finishAnimating

        protected void finishAnimating()
      • updateLinks

        protected void updateLinks​(double value)
      • updateLinks

        protected void updateLinks​(Value value)
      • hasLinks

        protected boolean hasLinks()
      • reset

        protected void reset​(boolean full)