Class DefaultCodeDelegate

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Random RND  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double abs​(double n)
      Calculate the absolute value of the given value.
      double acos​(double value)
      Returns the arc cosine of a value.
      PArray array​(String s)
      Parse the given String into a PArray.
      PArray array​(Property p)
      Attempt to extract a PArray from the given Property.
      PArray array​(Value v)
      Convert the given Value into a PArray.
      void arrayCopy​(Object src, int srcPosition, Object dst, int dstPosition, int length)
      Copies an array (or part of an array) to another array.
      void arrayCopy​(Object src, Object dst)
      Copies an array to another array.
      void arrayCopy​(Object src, Object dst, int length)
      Copies an array (or part of an array) to another array.
      double asin​(double value)
      Returns the arc sine of a value.
      double atan​(double value)
      Returns the arc tangent of a value.
      double atan2​(double y, double x)
      Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
      boolean b​(String s)
      Parse the given String into a boolean according to the parsing rules of PBoolean.
      boolean b​(Property p)
      Extract the Property's current value as a boolean.
      boolean b​(Value v)
      Convert the provided Value into a boolean according to the parsing rules of PBoolean.
      double constrain​(double amt, double low, double high)
      Constrain a value between the range of the given low and high values.
      int constrain​(int amt, int low, int high)
      Constrain a value between the range of the given low and high values.
      double cos​(double angle)
      Returns the trigonometric cosine of an angle.
      double d​(String s)
      Parse the provided String into a double, or zero if invalid.
      double d​(Property p)
      Extract a double from the Property's current Value, or zero if the value cannot be coerced.
      double d​(Value v)
      Convert the provided Value into a double, or zero if the Value cannot be coerced.
      double degrees​(double radians)
      Converts an angle in radians to an angle in degrees.
      double dist​(double x1, double y1, double x2, double y2)
      Calculates the distance between two points.
      double dist​(double x1, double y1, double z1, double x2, double y2, double z2)
      Calculates the distance between two points.
      double exp​(double a)
      Calculate Euler's number raised to the power of the given value.
      int i​(String s)
      Parse the provided String into an int, or zero if invalid.
      int i​(Property p)
      Extract an int from the Property's current Value, or zero if the value cannot be coerced.
      int i​(Value v)
      Convert the provided Value into an int, or zero if the Value cannot be coerced.
      double lerp​(double start, double stop, double amt)
      Calculates a number between two numbers at a specific increment.
      double log​(double a)
      Calculate the natural logarithm if the given value.
      double map​(double value, double start1, double stop1, double start2, double stop2)
      Re-map (scale) an input value from one range to another.
      double max​(double... values)
      Calculate the maximum value in the provided array.
      double max​(double a, double b)
      Calculate the maximum of two values.
      double max​(double a, double b, double c)
      Calculate the maximum of three values.
      int max​(int... values)
      Calculate the maximum value in the provided array.
      int max​(int a, int b)
      Calculate the maximum of two values.
      int max​(int a, int b, int c)
      Calculate the maximum of three values.
      double min​(double... values)
      Calculate the minimum value in the provided array.
      double min​(double a, double b)
      Calculate the minimum of two values.
      double min​(double a, double b, double c)
      Calculate the minimum of three values.
      int min​(int... values)
      Calculate the minimum value in the provided array.
      int min​(int a, int b)
      Calculate the minimum of two values.
      int min​(int a, int b, int c)
      Calculate the minimum of three values.
      double noise​(double x)
      Computes the Perlin noise function value at point x.
      double noise​(double x, double y)
      Computes the Perlin noise function value at the point x, y.
      double noise​(double x, double y, double z)
      Computes the Perlin noise function value at x, y, z.
      void noiseDetail​(int lod)  
      void noiseDetail​(int lod, double falloff)  
      void noiseSeed​(long what)  
      double norm​(double value, double start, double stop)
      Normalizes a number from another range into a value between 0 and 1.
      double pow​(double a, double b)
      Calculate the value of the first argument raised to the power of the second argument.
      double radians​(double degrees)
      Converts an angle in degrees to an angle in radians.
      double random​(double max)
      Return a random number between zero and max (exclusive)
      double random​(double min, double max)
      Return a random number between min (inclusive) and max (exclusive)
      double randomOf​(double... values)
      Return a random element from an array of values.
      int randomOf​(int... values)
      Return a random element from an array of values.
      String randomOf​(String... values)
      Return a random element from an array of values.
      int round​(double amt)
      Round a value to the nearest integer.
      String s​(Property p)
      Extract the Property's current value into a String representation.
      String s​(Value v)
      Convert the provided Value into a String representation.
      double sin​(double angle)
      Returns the trigonometric sine of an angle
      double sq​(double a)
      Calculate the square of the given value.
      double sqrt​(double a)
      Calculate the square root of the given value.
      double tan​(double angle)
      Returns the trigonometric tangent of an angle.
    • Field Detail

      • RND

        protected final Random RND
    • Constructor Detail

      • DefaultCodeDelegate

        public DefaultCodeDelegate()
    • Method Detail

      • d

        public final double d​(Property p)
        Extract a double from the Property's current Value, or zero if the value cannot be coerced.
        Parameters:
        p -
        Returns:
      • d

        public final double d​(Value v)
        Convert the provided Value into a double, or zero if the Value cannot be coerced.
        Parameters:
        v -
        Returns:
      • d

        public final double d​(String s)
        Parse the provided String into a double, or zero if invalid.
        Parameters:
        s -
        Returns:
      • i

        public final int i​(Property p)
        Extract an int from the Property's current Value, or zero if the value cannot be coerced.
        Parameters:
        p -
        Returns:
      • i

        public final int i​(Value v)
        Convert the provided Value into an int, or zero if the Value cannot be coerced.
        Parameters:
        v -
        Returns:
      • i

        public final int i​(String s)
        Parse the provided String into an int, or zero if invalid.
        Parameters:
        s -
        Returns:
      • b

        public final boolean b​(Property p)
        Extract the Property's current value as a boolean. If the value cannot be coerced, returns false.
        Parameters:
        p -
        Returns:
      • b

        public final boolean b​(Value v)
        Convert the provided Value into a boolean according to the parsing rules of PBoolean. If the Value cannot be coerced, returns false.
        Parameters:
        v -
        Returns:
      • b

        public final boolean b​(String s)
        Parse the given String into a boolean according to the parsing rules of PBoolean. If the String is invalid, returns false.
        Parameters:
        s -
        Returns:
      • s

        public final String s​(Property p)
        Extract the Property's current value into a String representation.
        Parameters:
        p -
        Returns:
      • s

        public final String s​(Value v)
        Convert the provided Value into a String representation.
        Parameters:
        v -
        Returns:
      • array

        public final PArray array​(Value v)
        Convert the given Value into a PArray. If the Value is already a PArray it will be returned, otherwise an attempt will be made to coerce it. If the Value cannot be converted, an empty PArray will be returned.
        Parameters:
        s -
        Returns:
      • array

        public final PArray array​(String s)
        Parse the given String into a PArray. If the String is not a valid representation of an array, returns an empty PArray.
        Parameters:
        s -
        Returns:
      • random

        public final double random​(double max)
        Return a random number between zero and max (exclusive)
        Parameters:
        max - the upper bound of the range
        Returns:
      • random

        public final double random​(double min,
                                   double max)
        Return a random number between min (inclusive) and max (exclusive)
        Parameters:
        min - the lower bound of the range
        max - the upper bound of the range
        Returns:
      • randomOf

        public final double randomOf​(double... values)
        Return a random element from an array of values.
        Parameters:
        values - list of values, may not be empty
        Returns:
        random element
      • randomOf

        public final int randomOf​(int... values)
        Return a random element from an array of values.
        Parameters:
        values - list of values, may not be empty
        Returns:
        random element
      • randomOf

        public final String randomOf​(String... values)
        Return a random element from an array of values.
        Parameters:
        values - list of values, may not be empty
        Returns:
        random element
      • abs

        public final double abs​(double n)
        Calculate the absolute value of the given value. If the value is positive, the value is returned. If the value is negative, the negation of the value is returned.
        Parameters:
        n -
        Returns:
      • sq

        public final double sq​(double a)
        Calculate the square of the given value.
        Parameters:
        a -
        Returns:
      • sqrt

        public final double sqrt​(double a)
        Calculate the square root of the given value.
        Parameters:
        a -
        Returns:
        See Also:
        Math.sqrt(double)
      • log

        public final double log​(double a)
        Calculate the natural logarithm if the given value.
        Parameters:
        a -
        Returns:
        See Also:
        Math.log(double)
      • exp

        public final double exp​(double a)
        Calculate Euler's number raised to the power of the given value.
        Parameters:
        a -
        Returns:
        See Also:
        Math.exp(double)
      • pow

        public final double pow​(double a,
                                double b)
        Calculate the value of the first argument raised to the power of the second argument.
        Parameters:
        a - the base
        b - the exponent
        Returns:
        the value ab
        See Also:
        Math.pow(double, double)
      • max

        public final int max​(int a,
                             int b)
        Calculate the maximum of two values.
        Parameters:
        a -
        b -
        Returns:
      • max

        public final int max​(int a,
                             int b,
                             int c)
        Calculate the maximum of three values.
        Parameters:
        a -
        b -
        c -
        Returns:
      • max

        public final int max​(int... values)
        Calculate the maximum value in the provided array.
        Parameters:
        values - value list - must not be empty
        Returns:
        maximum value
      • max

        public final double max​(double a,
                                double b)
        Calculate the maximum of two values.
        Parameters:
        a -
        b -
        Returns:
      • max

        public final double max​(double a,
                                double b,
                                double c)
        Calculate the maximum of three values.
        Parameters:
        a -
        b -
        c -
        Returns:
      • max

        public final double max​(double... values)
        Calculate the maximum value in the provided array.
        Parameters:
        values - value list - must not be empty
        Returns:
        maximum value
      • min

        public final int min​(int a,
                             int b)
        Calculate the minimum of two values.
        Parameters:
        a -
        b -
        Returns:
      • min

        public final int min​(int a,
                             int b,
                             int c)
        Calculate the minimum of three values.
        Parameters:
        a -
        b -
        c -
        Returns:
      • min

        public final int min​(int... values)
        Calculate the minimum value in the provided array.
        Parameters:
        values - value list - must not be empty
        Returns:
        minimum value
      • min

        public final double min​(double a,
                                double b)
        Calculate the minimum of two values.
        Parameters:
        a -
        b -
        Returns:
      • min

        public final double min​(double a,
                                double b,
                                double c)
        Calculate the minimum of three values.
        Parameters:
        a -
        b -
        c -
        Returns:
      • min

        public final double min​(double... values)
        Calculate the minimum value in the provided array.
        Parameters:
        values - value list - must not be empty
        Returns:
        minimum value
      • constrain

        public final int constrain​(int amt,
                                   int low,
                                   int high)
        Constrain a value between the range of the given low and high values.
        Parameters:
        amt - input value
        low - lowest allowed value
        high - highest allowed value
        Returns:
        constrained value
      • constrain

        public final double constrain​(double amt,
                                      double low,
                                      double high)
        Constrain a value between the range of the given low and high values.
        Parameters:
        amt - input value
        low - lowest allowed value
        high - highest allowed value
        Returns:
        constrained value
      • round

        public final int round​(double amt)
        Round a value to the nearest integer.
        Parameters:
        amt - input value
        Returns:
        rounded value
      • degrees

        public final double degrees​(double radians)
        Converts an angle in radians to an angle in degrees.
        Parameters:
        radians -
        Returns:
        See Also:
        Math.toDegrees(double)
      • radians

        public final double radians​(double degrees)
        Converts an angle in degrees to an angle in radians.
        Parameters:
        degrees -
        Returns:
        See Also:
        Math.toRadians(double)
      • sin

        public final double sin​(double angle)
        Returns the trigonometric sine of an angle
        Parameters:
        angle -
        Returns:
        See Also:
        Math.sin(double)
      • cos

        public final double cos​(double angle)
        Returns the trigonometric cosine of an angle.
        Parameters:
        angle -
        Returns:
        See Also:
        Math.cos(double)
      • tan

        public final double tan​(double angle)
        Returns the trigonometric tangent of an angle.
        Parameters:
        angle -
        Returns:
        See Also:
        Math.tan(double)
      • asin

        public final double asin​(double value)
        Returns the arc sine of a value.
        Parameters:
        value -
        Returns:
        See Also:
        Math.asin(double)
      • acos

        public final double acos​(double value)
        Returns the arc cosine of a value.
        Parameters:
        value -
        Returns:
        See Also:
        Math.acos(double)
      • atan

        public final double atan​(double value)
        Returns the arc tangent of a value.
        Parameters:
        value -
        Returns:
        See Also:
        Math.atan(double)
      • atan2

        public final double atan2​(double y,
                                  double x)
        Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
        Parameters:
        y -
        x -
        Returns:
        See Also:
        Math.atan2(double, double)
      • map

        public final double map​(double value,
                                double start1,
                                double stop1,
                                double start2,
                                double stop2)
        Re-map (scale) an input value from one range to another. Numbers outside the range are not clamped.
        Parameters:
        value - the value to be converted
        start1 - lower bound of the value's current range
        stop1 - upper bound of the value's current range
        start2 - lower bound of the value's target range
        stop2 - upper bound of the value's target range
        Returns:
      • dist

        public final double dist​(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
        Calculates the distance between two points.
        Parameters:
        x1 - x-coordinate of the first point
        y1 - y-coordinate of the first point
        x2 - x-coordinate of the second point
        y2 - y-coordinate of the second point
        Returns:
      • dist

        public final double dist​(double x1,
                                 double y1,
                                 double z1,
                                 double x2,
                                 double y2,
                                 double z2)
        Calculates the distance between two points.
        Parameters:
        x1 - x-coordinate of the first point
        y1 - y-coordinate of the first point
        z1 - z-coordinate of the first point
        x2 - x-coordinate of the second point
        y2 - y-coordinate of the second point
        z2 - z-coordinate of the second point
        Returns:
      • lerp

        public final double lerp​(double start,
                                 double stop,
                                 double amt)
        Calculates a number between two numbers at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. The lerp function is convenient for creating motion along a straight path and for drawing dotted lines.
        Parameters:
        start - first value
        stop - second value
        amt - between 0.0 and 1.0
        Returns:
      • norm

        public final double norm​(double value,
                                 double start,
                                 double stop)
        Normalizes a number from another range into a value between 0 and 1.

        Identical to map(value, low, high, 0, 1);

        Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful.

        Parameters:
        value - the incoming value to be converted
        start - lower bound of the value's current range
        stop - upper bound of the value's current range
        Returns:
      • noise

        public final double noise​(double x)
        Computes the Perlin noise function value at point x.
        Parameters:
        x -
        Returns:
      • noise

        public final double noise​(double x,
                                  double y)
        Computes the Perlin noise function value at the point x, y.
        Parameters:
        x -
        y -
        Returns:
      • noise

        public final double noise​(double x,
                                  double y,
                                  double z)
        Computes the Perlin noise function value at x, y, z.
        Parameters:
        x -
        z -
        y -
        Returns:
      • noiseDetail

        public final void noiseDetail​(int lod)
        Parameters:
        lod -
      • noiseDetail

        public final void noiseDetail​(int lod,
                                      double falloff)
        Parameters:
        lod -
        falloff -
      • noiseSeed

        public final void noiseSeed​(long what)
        Parameters:
        what -
      • arrayCopy

        public final void arrayCopy​(Object src,
                                    int srcPosition,
                                    Object dst,
                                    int dstPosition,
                                    int length)
        Copies an array (or part of an array) to another array. The src array is copied to the dst array, beginning at the position specified by srcPos and into the position specified by dstPos. The number of elements to copy is determined by length.
        Parameters:
        src -
        srcPosition -
        dst -
        dstPosition -
        length -
      • arrayCopy

        public final void arrayCopy​(Object src,
                                    Object dst,
                                    int length)
        Copies an array (or part of an array) to another array. The src array is copied to the dst array. The number of elements to copy is determined by length.
        Parameters:
        src -
        dst -
        length -
      • arrayCopy

        public final void arrayCopy​(Object src,
                                    Object dst)
        Copies an array to another array. The src array is copied to the dst array.
        Parameters:
        src -
        dst -