Class SwitchValueInterpolator


  • public class SwitchValueInterpolator
    extends Interpolator
    SwitchValueInterpolator behavior. This class defines a behavior that modifies the selected child of the target switch node by linearly interpolating between a pair of specified child index values (using the value generated by the specified Alpha object).
    • Constructor Detail

      • SwitchValueInterpolator

        public SwitchValueInterpolator​(Alpha alpha,
                                       Switch target)
        Constructs a SwitchValueInterpolator behavior that varies its target Switch node's child index between 0 and n-1, where n is the number of children in the target Switch node.
        Parameters:
        alpha - the alpha object for this interpolator
        target - the Switch node affected by this interpolator
      • SwitchValueInterpolator

        public SwitchValueInterpolator​(Alpha alpha,
                                       Switch target,
                                       int firstChildIndex,
                                       int lastChildIndex)
        Constructs a SwitchValueInterpolator behavior that varies its target Switch node's child index between the two values provided.
        Parameters:
        alpha - the alpha object for this interpolator
        target - the Switch node affected by this interpolator
        firstChildIndex - the index of first child in the Switch node to select
        lastChildIndex - the index of last child in the Switch node to select
    • Method Detail

      • setFirstChildIndex

        public void setFirstChildIndex​(int firstIndex)
        This method sets the firstChildIndex for this interpolator.
        Parameters:
        firstIndex - the new index for the first child
      • getFirstChildIndex

        public int getFirstChildIndex()
        This method retrieves this interpolator's firstChildIndex.
        Returns:
        the interpolator's firstChildIndex
      • setLastChildIndex

        public void setLastChildIndex​(int lastIndex)
        This method sets the lastChildIndex for this interpolator.
        Parameters:
        lastIndex - the new index for the last child
      • getLastChildIndex

        public int getLastChildIndex()
        This method retrieves this interpolator's lastSwitchIndex.
        Returns:
        the interpolator's maximum scale value
      • setTarget

        public void setTarget​(Switch target)
        This method sets the target for this interpolator.
        Parameters:
        target - the target Switch node
      • getTarget

        public Switch getTarget()
        This method retrieves this interpolator's target Switch node reference.
        Returns:
        the interpolator's target Switch node
      • processStimulus

        public void processStimulus​(java.util.Enumeration criteria)
        This method is invoked by the behavior scheduler every frame. It maps the alpha value that corresponds to the current time into a child index value and updates the specified Switch node with this new child index value.
        Specified by:
        processStimulus in class Behavior
        Parameters:
        criteria - an enumeration of the criteria that triggered this stimulus
      • updateNodeReferences

        public void updateNodeReferences​(NodeReferenceTable referenceTable)
        Callback used to allow a node to check if any nodes referenced by that node have been duplicated via a call to cloneTree. This method is called by cloneTree after all nodes in the sub-graph have been duplicated. The cloned Leaf node's method will be called and the Leaf node can then look up any node references by using the getNewObjectReference method found in the NodeReferenceTable object. If a match is found, a reference to the corresponding Node in the newly cloned sub-graph is returned. If no corresponding reference is found, either a DanglingReferenceException is thrown or a reference to the original node is returned depending on the value of the allowDanglingReferences parameter passed in the cloneTree call.

        NOTE: Applications should not call this method directly. It should only be called by the cloneTree method.

        Overrides:
        updateNodeReferences in class Behavior
        Parameters:
        referenceTable - a NodeReferenceTableObject that contains the getNewObjectReference method needed to search for new object instances.
        See Also:
        NodeReferenceTable, Node.cloneTree(), DanglingReferenceException