001package Torello.Browser;
002
003import java.util.*;
004import javax.json.*;
005import javax.json.stream.*;
006import java.io.*;
007
008import java.lang.reflect.Method;
009import java.lang.reflect.Parameter;
010import java.util.function.Function;
011
012import Torello.Java.Additional.*;
013
014import static Torello.Java.Additional.JFlag.*;
015
016import Torello.Java.StrCmpr;
017import Torello.JavaDoc.StaticFunctional;
018import Torello.JavaDoc.JDHeaderBackgroundImg;
019import Torello.JavaDoc.Excuse;
020
021/**
022 * <SPAN CLASS=CopiedJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN>
023 * 
024 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
025 */
026@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
027@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
028public class Animation
029{
030    // ********************************************************************************************
031    // ********************************************************************************************
032    // Class Header Stuff
033    // ********************************************************************************************
034    // ********************************************************************************************
035
036
037    // No Pubic Constructors
038    private Animation () { }
039
040    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
041    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
042    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
043    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
044
045    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
046    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
047    // offically, two empty-vectors.  One for String's, and the other for Classes.
048
049    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
050    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
051
052    static
053    {
054        for (Method m : Animation.class.getMethods())
055        {
056            // This doesn't work!  The parameter names are all "arg0" ... "argN"
057            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
058            //
059            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
060
061            Vector<Class<?>> parameterTypesList = new Vector<>();
062        
063            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
064
065            parameterTypes.put(
066                m.getName(),
067                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
068            );
069        }
070    }
071
072    static
073    {
074        Vector<String> v = null;
075
076        parameterNames.put("disable", EMPTY_VEC_STR);
077
078        parameterNames.put("enable", EMPTY_VEC_STR);
079
080        v = new Vector<String>(1);
081        parameterNames.put("getCurrentTime", v);
082        Collections.addAll(v, new String[]
083        { "id", });
084
085        parameterNames.put("getPlaybackRate", EMPTY_VEC_STR);
086
087        v = new Vector<String>(1);
088        parameterNames.put("releaseAnimations", v);
089        Collections.addAll(v, new String[]
090        { "animations", });
091
092        v = new Vector<String>(1);
093        parameterNames.put("resolveAnimation", v);
094        Collections.addAll(v, new String[]
095        { "animationId", });
096
097        v = new Vector<String>(2);
098        parameterNames.put("seekAnimations", v);
099        Collections.addAll(v, new String[]
100        { "animations", "currentTime", });
101
102        v = new Vector<String>(2);
103        parameterNames.put("setPaused", v);
104        Collections.addAll(v, new String[]
105        { "animations", "paused", });
106
107        v = new Vector<String>(1);
108        parameterNames.put("setPlaybackRate", v);
109        Collections.addAll(v, new String[]
110        { "playbackRate", });
111
112        v = new Vector<String>(3);
113        parameterNames.put("setTiming", v);
114        Collections.addAll(v, new String[]
115        { "animationId", "duration", "delay", });
116    }
117
118
119    // ********************************************************************************************
120    // ********************************************************************************************
121    // Types - Static Inner Classes
122    // ********************************************************************************************
123    // ********************************************************************************************
124
125    /** Animation instance. */
126    public static class _Animation extends BaseType
127    {
128        /** For Object Serialization.  java.io.Serializable */
129        protected static final long serialVersionUID = 1;
130        
131        public boolean[] optionals()
132        { return new boolean[] { false, false, false, false, false, false, false, false, true, true, }; }
133        
134        /** <CODE>Animation</CODE>'s id. */
135        public final String id;
136        
137        /** <CODE>Animation</CODE>'s name. */
138        public final String name;
139        
140        /** <CODE>Animation</CODE>'s internal paused state. */
141        public final boolean pausedState;
142        
143        /** <CODE>Animation</CODE>'s play state. */
144        public final String playState;
145        
146        /** <CODE>Animation</CODE>'s playback rate. */
147        public final Number playbackRate;
148        
149        /** <CODE>Animation</CODE>'s start time. */
150        public final Number startTime;
151        
152        /** <CODE>Animation</CODE>'s current time. */
153        public final Number currentTime;
154        
155        /** Animation type of <CODE>Animation</CODE>. */
156        public final String type;
157        
158        /**
159         * <CODE>Animation</CODE>'s source animation node.
160         * <BR />
161         * <BR /><B>OPTIONAL</B>
162         */
163        public final Animation.AnimationEffect source;
164        
165        /**
166         * A unique ID for <CODE>Animation</CODE> representing the sources that triggered this CSS
167         * animation/transition.
168         * <BR />
169         * <BR /><B>OPTIONAL</B>
170         */
171        public final String cssId;
172        
173        /**
174         * Constructor
175         *
176         * @param id <CODE>Animation</CODE>'s id.
177         * 
178         * @param name <CODE>Animation</CODE>'s name.
179         * 
180         * @param pausedState <CODE>Animation</CODE>'s internal paused state.
181         * 
182         * @param playState <CODE>Animation</CODE>'s play state.
183         * 
184         * @param playbackRate <CODE>Animation</CODE>'s playback rate.
185         * 
186         * @param startTime <CODE>Animation</CODE>'s start time.
187         * 
188         * @param currentTime <CODE>Animation</CODE>'s current time.
189         * 
190         * @param type Animation type of <CODE>Animation</CODE>.
191         * <BR />Acceptable Values: ["CSSTransition", "CSSAnimation", "WebAnimation"]
192         * 
193         * @param source <CODE>Animation</CODE>'s source animation node.
194         * <BR /><B>OPTIONAL</B>
195         * 
196         * @param cssId 
197         * A unique ID for <CODE>Animation</CODE> representing the sources that triggered this CSS
198         * animation/transition.
199         * <BR /><B>OPTIONAL</B>
200         */
201        public _Animation(
202                String id, String name, boolean pausedState, String playState, Number playbackRate, 
203                Number startTime, Number currentTime, String type, Animation.AnimationEffect source, 
204                String cssId
205            )
206        {
207            // Exception-Check(s) to ensure that if any parameters which are not declared as
208            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
209            
210            if (id == null)           BRDPC.throwNPE("id");
211            if (name == null)         BRDPC.throwNPE("name");
212            if (playState == null)    BRDPC.throwNPE("playState");
213            if (playbackRate == null) BRDPC.throwNPE("playbackRate");
214            if (startTime == null)    BRDPC.throwNPE("startTime");
215            if (currentTime == null)  BRDPC.throwNPE("currentTime");
216            if (type == null)         BRDPC.throwNPE("type");
217            
218            // Exception-Check(s) to ensure that if any parameters which must adhere to a
219            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
220            
221            BRDPC.checkIAE(
222                "type", type,
223                "CSSTransition", "CSSAnimation", "WebAnimation"
224            );
225            
226            this.id            = id;
227            this.name          = name;
228            this.pausedState   = pausedState;
229            this.playState     = playState;
230            this.playbackRate  = playbackRate;
231            this.startTime     = startTime;
232            this.currentTime   = currentTime;
233            this.type          = type;
234            this.source        = source;
235            this.cssId         = cssId;
236        }
237        
238        /**
239         * JSON Object Constructor
240         * @param jo A Json-Object having data about an instance of {@code 'Animation'}.
241         */
242        public _Animation (JsonObject jo)
243        {
244            this.id            = ReadJSON.getString(jo, "id", false, true);
245            this.name          = ReadJSON.getString(jo, "name", false, true);
246            this.pausedState   = ReadJSON.getBoolean(jo, "pausedState");
247            this.playState     = ReadJSON.getString(jo, "playState", false, true);
248            this.playbackRate  = ReadJSON.getNUMBER(jo, "playbackRate", false, true);
249            this.startTime     = ReadJSON.getNUMBER(jo, "startTime", false, true);
250            this.currentTime   = ReadJSON.getNUMBER(jo, "currentTime", false, true);
251            this.type          = ReadJSON.getString(jo, "type", false, true);
252            this.source        = ReadJSON.XL.getObject(jo, "source", Animation.AnimationEffect.class, true, false);
253            this.cssId         = ReadJSON.getString(jo, "cssId", true, false);
254        }
255        
256    }
257    
258    /** AnimationEffect instance */
259    public static class AnimationEffect extends BaseType
260    {
261        /** For Object Serialization.  java.io.Serializable */
262        protected static final long serialVersionUID = 1;
263        
264        public boolean[] optionals()
265        { return new boolean[] { false, false, false, false, false, false, false, true, true, false, }; }
266        
267        /** <CODE>AnimationEffect</CODE>'s delay. */
268        public final Number delay;
269        
270        /** <CODE>AnimationEffect</CODE>'s end delay. */
271        public final Number endDelay;
272        
273        /** <CODE>AnimationEffect</CODE>'s iteration start. */
274        public final Number iterationStart;
275        
276        /** <CODE>AnimationEffect</CODE>'s iterations. */
277        public final Number iterations;
278        
279        /** <CODE>AnimationEffect</CODE>'s iteration duration. */
280        public final Number duration;
281        
282        /** <CODE>AnimationEffect</CODE>'s playback direction. */
283        public final String direction;
284        
285        /** <CODE>AnimationEffect</CODE>'s fill mode. */
286        public final String fill;
287        
288        /**
289         * <CODE>AnimationEffect</CODE>'s target node.
290         * <BR />
291         * <BR /><B>OPTIONAL</B>
292         */
293        public final Integer backendNodeId;
294        
295        /**
296         * <CODE>AnimationEffect</CODE>'s keyframes.
297         * <BR />
298         * <BR /><B>OPTIONAL</B>
299         */
300        public final Animation.KeyframesRule keyframesRule;
301        
302        /** <CODE>AnimationEffect</CODE>'s timing function. */
303        public final String easing;
304        
305        /**
306         * Constructor
307         *
308         * @param delay <CODE>AnimationEffect</CODE>'s delay.
309         * 
310         * @param endDelay <CODE>AnimationEffect</CODE>'s end delay.
311         * 
312         * @param iterationStart <CODE>AnimationEffect</CODE>'s iteration start.
313         * 
314         * @param iterations <CODE>AnimationEffect</CODE>'s iterations.
315         * 
316         * @param duration <CODE>AnimationEffect</CODE>'s iteration duration.
317         * 
318         * @param direction <CODE>AnimationEffect</CODE>'s playback direction.
319         * 
320         * @param fill <CODE>AnimationEffect</CODE>'s fill mode.
321         * 
322         * @param backendNodeId <CODE>AnimationEffect</CODE>'s target node.
323         * <BR /><B>OPTIONAL</B>
324         * 
325         * @param keyframesRule <CODE>AnimationEffect</CODE>'s keyframes.
326         * <BR /><B>OPTIONAL</B>
327         * 
328         * @param easing <CODE>AnimationEffect</CODE>'s timing function.
329         */
330        public AnimationEffect(
331                Number delay, Number endDelay, Number iterationStart, Number iterations, 
332                Number duration, String direction, String fill, Integer backendNodeId, 
333                Animation.KeyframesRule keyframesRule, String easing
334            )
335        {
336            // Exception-Check(s) to ensure that if any parameters which are not declared as
337            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
338            
339            if (delay == null)          BRDPC.throwNPE("delay");
340            if (endDelay == null)       BRDPC.throwNPE("endDelay");
341            if (iterationStart == null) BRDPC.throwNPE("iterationStart");
342            if (iterations == null)     BRDPC.throwNPE("iterations");
343            if (duration == null)       BRDPC.throwNPE("duration");
344            if (direction == null)      BRDPC.throwNPE("direction");
345            if (fill == null)           BRDPC.throwNPE("fill");
346            if (easing == null)         BRDPC.throwNPE("easing");
347            
348            this.delay           = delay;
349            this.endDelay        = endDelay;
350            this.iterationStart  = iterationStart;
351            this.iterations      = iterations;
352            this.duration        = duration;
353            this.direction       = direction;
354            this.fill            = fill;
355            this.backendNodeId   = backendNodeId;
356            this.keyframesRule   = keyframesRule;
357            this.easing          = easing;
358        }
359        
360        /**
361         * JSON Object Constructor
362         * @param jo A Json-Object having data about an instance of {@code 'AnimationEffect'}.
363         */
364        public AnimationEffect (JsonObject jo)
365        {
366            this.delay           = ReadJSON.getNUMBER(jo, "delay", false, true);
367            this.endDelay        = ReadJSON.getNUMBER(jo, "endDelay", false, true);
368            this.iterationStart  = ReadJSON.getNUMBER(jo, "iterationStart", false, true);
369            this.iterations      = ReadJSON.getNUMBER(jo, "iterations", false, true);
370            this.duration        = ReadJSON.getNUMBER(jo, "duration", false, true);
371            this.direction       = ReadJSON.getString(jo, "direction", false, true);
372            this.fill            = ReadJSON.getString(jo, "fill", false, true);
373            this.backendNodeId   = ReadJSON.getINTEGER(jo, "backendNodeId", true);
374            this.keyframesRule   = ReadJSON.XL.getObject(jo, "keyframesRule", Animation.KeyframesRule.class, true, false);
375            this.easing          = ReadJSON.getString(jo, "easing", false, true);
376        }
377        
378    }
379    
380    /** Keyframes Rule */
381    public static class KeyframesRule extends BaseType
382    {
383        /** For Object Serialization.  java.io.Serializable */
384        protected static final long serialVersionUID = 1;
385        
386        public boolean[] optionals()
387        { return new boolean[] { true, false, }; }
388        
389        /**
390         * CSS keyframed animation's name.
391         * <BR />
392         * <BR /><B>OPTIONAL</B>
393         */
394        public final String name;
395        
396        /** List of animation keyframes. */
397        public final Animation.KeyframeStyle[] keyframes;
398        
399        /**
400         * Constructor
401         *
402         * @param name CSS keyframed animation's name.
403         * <BR /><B>OPTIONAL</B>
404         * 
405         * @param keyframes List of animation keyframes.
406         */
407        public KeyframesRule(String name, Animation.KeyframeStyle[] keyframes)
408        {
409            // Exception-Check(s) to ensure that if any parameters which are not declared as
410            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
411            
412            if (keyframes == null) BRDPC.throwNPE("keyframes");
413            
414            this.name       = name;
415            this.keyframes  = keyframes;
416        }
417        
418        /**
419         * JSON Object Constructor
420         * @param jo A Json-Object having data about an instance of {@code 'KeyframesRule'}.
421         */
422        public KeyframesRule (JsonObject jo)
423        {
424            this.name       = ReadJSON.getString(jo, "name", true, false);
425            this.keyframes  = (jo.getJsonArray("keyframes") == null)
426            ? null
427            : ReadArrJSON.DimN.objArr(jo.getJsonArray("keyframes"), null, 0, Animation.KeyframeStyle[].class);
428        }
429        
430    }
431    
432    /** Keyframe Style */
433    public static class KeyframeStyle extends BaseType
434    {
435        /** For Object Serialization.  java.io.Serializable */
436        protected static final long serialVersionUID = 1;
437        
438        public boolean[] optionals()
439        { return new boolean[] { false, false, }; }
440        
441        /** Keyframe's time offset. */
442        public final String offset;
443        
444        /** <CODE>AnimationEffect</CODE>'s timing function. */
445        public final String easing;
446        
447        /**
448         * Constructor
449         *
450         * @param offset Keyframe's time offset.
451         * 
452         * @param easing <CODE>AnimationEffect</CODE>'s timing function.
453         */
454        public KeyframeStyle(String offset, String easing)
455        {
456            // Exception-Check(s) to ensure that if any parameters which are not declared as
457            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
458            
459            if (offset == null) BRDPC.throwNPE("offset");
460            if (easing == null) BRDPC.throwNPE("easing");
461            
462            this.offset  = offset;
463            this.easing  = easing;
464        }
465        
466        /**
467         * JSON Object Constructor
468         * @param jo A Json-Object having data about an instance of {@code 'KeyframeStyle'}.
469         */
470        public KeyframeStyle (JsonObject jo)
471        {
472            this.offset  = ReadJSON.getString(jo, "offset", false, true);
473            this.easing  = ReadJSON.getString(jo, "easing", false, true);
474        }
475        
476    }
477    
478    /** Event for when an animation has been cancelled. */
479    public static class animationCanceled extends BrowserEvent
480    {
481        /** For Object Serialization.  java.io.Serializable */
482        protected static final long serialVersionUID = 1;
483        
484        public boolean[] optionals()
485        { return new boolean[] { false, }; }
486        
487        /** Id of the animation that was cancelled. */
488        public final String id;
489        
490        /**
491         * Constructor
492         *
493         * @param id Id of the animation that was cancelled.
494         */
495        public animationCanceled(String id)
496        {
497            super("Animation", "animationCanceled", 1);
498            
499            // Exception-Check(s) to ensure that if any parameters which are not declared as
500            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
501            
502            if (id == null) BRDPC.throwNPE("id");
503            
504            this.id  = id;
505        }
506        
507        /**
508         * JSON Object Constructor
509         * @param jo A Json-Object having data about an instance of {@code 'animationCanceled'}.
510         */
511        public animationCanceled (JsonObject jo)
512        {
513            super("Animation", "animationCanceled", 1);
514        
515            this.id  = ReadJSON.getString(jo, "id", false, true);
516        }
517        
518    }
519    
520    /** Event for each animation that has been created. */
521    public static class animationCreated extends BrowserEvent
522    {
523        /** For Object Serialization.  java.io.Serializable */
524        protected static final long serialVersionUID = 1;
525        
526        public boolean[] optionals()
527        { return new boolean[] { false, }; }
528        
529        /** Id of the animation that was created. */
530        public final String id;
531        
532        /**
533         * Constructor
534         *
535         * @param id Id of the animation that was created.
536         */
537        public animationCreated(String id)
538        {
539            super("Animation", "animationCreated", 1);
540            
541            // Exception-Check(s) to ensure that if any parameters which are not declared as
542            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
543            
544            if (id == null) BRDPC.throwNPE("id");
545            
546            this.id  = id;
547        }
548        
549        /**
550         * JSON Object Constructor
551         * @param jo A Json-Object having data about an instance of {@code 'animationCreated'}.
552         */
553        public animationCreated (JsonObject jo)
554        {
555            super("Animation", "animationCreated", 1);
556        
557            this.id  = ReadJSON.getString(jo, "id", false, true);
558        }
559        
560    }
561    
562    /** Event for animation that has been started. */
563    public static class animationStarted extends BrowserEvent
564    {
565        /** For Object Serialization.  java.io.Serializable */
566        protected static final long serialVersionUID = 1;
567        
568        public boolean[] optionals()
569        { return new boolean[] { false, }; }
570        
571        /** Animation that was started. */
572        public final Animation._Animation animation;
573        
574        /**
575         * Constructor
576         *
577         * @param animation Animation that was started.
578         */
579        public animationStarted(Animation._Animation animation)
580        {
581            super("Animation", "animationStarted", 1);
582            
583            // Exception-Check(s) to ensure that if any parameters which are not declared as
584            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
585            
586            if (animation == null) BRDPC.throwNPE("animation");
587            
588            this.animation  = animation;
589        }
590        
591        /**
592         * JSON Object Constructor
593         * @param jo A Json-Object having data about an instance of {@code 'animationStarted'}.
594         */
595        public animationStarted (JsonObject jo)
596        {
597            super("Animation", "animationStarted", 1);
598        
599            this.animation  = ReadJSON.XL.getObject(jo, "animation", Animation._Animation.class, false, true);
600        }
601        
602    }
603    
604    
605    // Counter for keeping the WebSocket Request ID's distinct.
606    private static int counter = 1;
607    
608    /**
609     * Disables animation domain notifications.
610     * 
611     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
612     * {@link Ret0}&gt;</CODE>
613     *
614     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
615     * browser receives the invocation-request.
616     *
617     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
618     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
619     * {@code >} to ensure the Browser Function has run to completion.
620     */
621    public static Script<String, JsonObject, Ret0> disable()
622    {
623        final int          webSocketID = 8000000 + counter++;
624        final boolean[]    optionals   = new boolean[0];
625        
626        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
627        String requestJSON = WriteJSON.get(
628            parameterTypes.get("disable"),
629            parameterNames.get("disable"),
630            optionals, webSocketID,
631            "Animation.disable"
632        );
633        
634        // This Remote Command does not have a Return-Value.
635        return new Script<>
636            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
637    }
638    
639    /**
640     * Enables animation domain notifications.
641     * 
642     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
643     * {@link Ret0}&gt;</CODE>
644     *
645     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
646     * browser receives the invocation-request.
647     *
648     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
649     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
650     * {@code >} to ensure the Browser Function has run to completion.
651     */
652    public static Script<String, JsonObject, Ret0> enable()
653    {
654        final int          webSocketID = 8001000 + counter++;
655        final boolean[]    optionals   = new boolean[0];
656        
657        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
658        String requestJSON = WriteJSON.get(
659            parameterTypes.get("enable"),
660            parameterNames.get("enable"),
661            optionals, webSocketID,
662            "Animation.enable"
663        );
664        
665        // This Remote Command does not have a Return-Value.
666        return new Script<>
667            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
668    }
669    
670    /**
671     * Returns the current time of the an animation.
672     * 
673     * @param id Id of animation.
674     * 
675     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
676     * Number&gt;</CODE>
677     * 
678     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
679     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
680     * Number&gt;</CODE> will be returned.
681     *
682     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
683     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
684      * may be retrieved.</I>
685     *
686     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
687     * <BR /><BR /><UL CLASS=JDUL>
688     * <LI><CODE>Number (<B>currentTime</B></CODE>)
689     *     <BR />Current time of the page.
690     * </LI>
691     * </UL> */
692    public static Script<String, JsonObject, Number> getCurrentTime(String id)
693    {
694        // Exception-Check(s) to ensure that if any parameters which are not declared as
695        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
696        
697        if (id == null) BRDPC.throwNPE("id");
698        
699        final int       webSocketID = 8002000 + counter++;
700        final boolean[] optionals   = { false, };
701        
702        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
703        String requestJSON = WriteJSON.get(
704            parameterTypes.get("getCurrentTime"),
705            parameterNames.get("getCurrentTime"),
706            optionals, webSocketID,
707            "Animation.getCurrentTime",
708            id
709        );
710        
711        // 'JSON Binding' ... Converts Browser Response-JSON to 'Number'
712        Function<JsonObject, Number> responseProcessor = (JsonObject jo) ->
713            ReadJSON.getNUMBER(jo, "currentTime", false, true);
714        
715        // Pass the 'defaultSender' to Script-Constructor
716        // The sender that is used can be changed before executing script.
717        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
718    }
719    
720    /**
721     * Gets the playback rate of the document timeline.
722     * 
723     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
724     * Number&gt;</CODE>
725     * 
726     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
727     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
728     * Number&gt;</CODE> will be returned.
729     *
730     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
731     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
732      * may be retrieved.</I>
733     *
734     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
735     * <BR /><BR /><UL CLASS=JDUL>
736     * <LI><CODE>Number (<B>playbackRate</B></CODE>)
737     *     <BR />Playback rate for animations on page.
738     * </LI>
739     * </UL> */
740    public static Script<String, JsonObject, Number> getPlaybackRate()
741    {
742        final int          webSocketID = 8003000 + counter++;
743        final boolean[]    optionals   = new boolean[0];
744        
745        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
746        String requestJSON = WriteJSON.get(
747            parameterTypes.get("getPlaybackRate"),
748            parameterNames.get("getPlaybackRate"),
749            optionals, webSocketID,
750            "Animation.getPlaybackRate"
751        );
752        
753        // 'JSON Binding' ... Converts Browser Response-JSON to 'Number'
754        Function<JsonObject, Number> responseProcessor = (JsonObject jo) ->
755            ReadJSON.getNUMBER(jo, "playbackRate", false, true);
756        
757        // Pass the 'defaultSender' to Script-Constructor
758        // The sender that is used can be changed before executing script.
759        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
760    }
761    
762    /**
763     * Releases a set of animations to no longer be manipulated.
764     * 
765     * @param animations List of animation ids to seek.
766     * 
767     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
768     * {@link Ret0}&gt;</CODE>
769     *
770     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
771     * browser receives the invocation-request.
772     *
773     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
774     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
775     * {@code >} to ensure the Browser Function has run to completion.
776     */
777    public static Script<String, JsonObject, Ret0> releaseAnimations(String[] animations)
778    {
779        // Exception-Check(s) to ensure that if any parameters which are not declared as
780        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
781        
782        if (animations == null) BRDPC.throwNPE("animations");
783        
784        final int       webSocketID = 8004000 + counter++;
785        final boolean[] optionals   = { false, };
786        
787        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
788        String requestJSON = WriteJSON.get(
789            parameterTypes.get("releaseAnimations"),
790            parameterNames.get("releaseAnimations"),
791            optionals, webSocketID,
792            "Animation.releaseAnimations",
793            (Object) animations
794        );
795        
796        // This Remote Command does not have a Return-Value.
797        return new Script<>
798            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
799    }
800    
801    /**
802     * Gets the remote object of the Animation.
803     * 
804     * @param animationId Animation id.
805     * 
806     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
807     * {@link RunTime.RemoteObject}&gt;</CODE>
808     * 
809     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
810     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
811     * {@link RunTime.RemoteObject}&gt;</CODE> will be returned.
812     *
813     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
814     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
815      * may be retrieved.</I>
816     *
817     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
818     * <BR /><BR /><UL CLASS=JDUL>
819     * <LI><CODE>{@link RunTime.RemoteObject} (<B>remoteObject</B></CODE>)
820     *     <BR />Corresponding remote object.
821     * </LI>
822     * </UL> */
823    public static Script<String, JsonObject, RunTime.RemoteObject> resolveAnimation
824        (String animationId)
825    {
826        // Exception-Check(s) to ensure that if any parameters which are not declared as
827        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
828        
829        if (animationId == null) BRDPC.throwNPE("animationId");
830        
831        final int       webSocketID = 8005000 + counter++;
832        final boolean[] optionals   = { false, };
833        
834        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
835        String requestJSON = WriteJSON.get(
836            parameterTypes.get("resolveAnimation"),
837            parameterNames.get("resolveAnimation"),
838            optionals, webSocketID,
839            "Animation.resolveAnimation",
840            animationId
841        );
842        
843        // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.RemoteObject'
844        Function<JsonObject, RunTime.RemoteObject> responseProcessor = (JsonObject jo) ->
845            ReadJSON.XL.getObject(jo, "remoteObject", RunTime.RemoteObject.class, false, true);
846        
847        // Pass the 'defaultSender' to Script-Constructor
848        // The sender that is used can be changed before executing script.
849        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
850    }
851    
852    /**
853     * Seek a set of animations to a particular time within each animation.
854     * 
855     * @param animations List of animation ids to seek.
856     * 
857     * @param currentTime Set the current time of each animation.
858     * 
859     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
860     * {@link Ret0}&gt;</CODE>
861     *
862     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
863     * browser receives the invocation-request.
864     *
865     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
866     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
867     * {@code >} to ensure the Browser Function has run to completion.
868     */
869    public static Script<String, JsonObject, Ret0> seekAnimations
870        (String[] animations, Number currentTime)
871    {
872        // Exception-Check(s) to ensure that if any parameters which are not declared as
873        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
874        
875        if (animations == null)  BRDPC.throwNPE("animations");
876        if (currentTime == null) BRDPC.throwNPE("currentTime");
877        
878        final int       webSocketID = 8006000 + counter++;
879        final boolean[] optionals   = { false, false, };
880        
881        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
882        String requestJSON = WriteJSON.get(
883            parameterTypes.get("seekAnimations"),
884            parameterNames.get("seekAnimations"),
885            optionals, webSocketID,
886            "Animation.seekAnimations",
887            animations, currentTime
888        );
889        
890        // This Remote Command does not have a Return-Value.
891        return new Script<>
892            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
893    }
894    
895    /**
896     * Sets the paused state of a set of animations.
897     * 
898     * @param animations Animations to set the pause state of.
899     * 
900     * @param paused Paused state to set to.
901     * 
902     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
903     * {@link Ret0}&gt;</CODE>
904     *
905     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
906     * browser receives the invocation-request.
907     *
908     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
909     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
910     * {@code >} to ensure the Browser Function has run to completion.
911     */
912    public static Script<String, JsonObject, Ret0> setPaused
913        (String[] animations, boolean paused)
914    {
915        // Exception-Check(s) to ensure that if any parameters which are not declared as
916        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
917        
918        if (animations == null) BRDPC.throwNPE("animations");
919        
920        final int       webSocketID = 8007000 + counter++;
921        final boolean[] optionals   = { false, false, };
922        
923        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
924        String requestJSON = WriteJSON.get(
925            parameterTypes.get("setPaused"),
926            parameterNames.get("setPaused"),
927            optionals, webSocketID,
928            "Animation.setPaused",
929            animations, paused
930        );
931        
932        // This Remote Command does not have a Return-Value.
933        return new Script<>
934            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
935    }
936    
937    /**
938     * Sets the playback rate of the document timeline.
939     * 
940     * @param playbackRate Playback rate for animations on page
941     * 
942     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
943     * {@link Ret0}&gt;</CODE>
944     *
945     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
946     * browser receives the invocation-request.
947     *
948     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
949     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
950     * {@code >} to ensure the Browser Function has run to completion.
951     */
952    public static Script<String, JsonObject, Ret0> setPlaybackRate(Number playbackRate)
953    {
954        // Exception-Check(s) to ensure that if any parameters which are not declared as
955        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
956        
957        if (playbackRate == null) BRDPC.throwNPE("playbackRate");
958        
959        final int       webSocketID = 8008000 + counter++;
960        final boolean[] optionals   = { false, };
961        
962        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
963        String requestJSON = WriteJSON.get(
964            parameterTypes.get("setPlaybackRate"),
965            parameterNames.get("setPlaybackRate"),
966            optionals, webSocketID,
967            "Animation.setPlaybackRate",
968            playbackRate
969        );
970        
971        // This Remote Command does not have a Return-Value.
972        return new Script<>
973            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
974    }
975    
976    /**
977     * Sets the timing of an animation node.
978     * 
979     * @param animationId Animation id.
980     * 
981     * @param duration Duration of the animation.
982     * 
983     * @param delay Delay of the animation.
984     * 
985     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
986     * {@link Ret0}&gt;</CODE>
987     *
988     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
989     * browser receives the invocation-request.
990     *
991     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
992     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
993     * {@code >} to ensure the Browser Function has run to completion.
994     */
995    public static Script<String, JsonObject, Ret0> setTiming
996        (String animationId, Number duration, Number delay)
997    {
998        // Exception-Check(s) to ensure that if any parameters which are not declared as
999        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1000        
1001        if (animationId == null) BRDPC.throwNPE("animationId");
1002        if (duration == null)    BRDPC.throwNPE("duration");
1003        if (delay == null)       BRDPC.throwNPE("delay");
1004        
1005        final int       webSocketID = 8009000 + counter++;
1006        final boolean[] optionals   = { false, false, false, };
1007        
1008        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1009        String requestJSON = WriteJSON.get(
1010            parameterTypes.get("setTiming"),
1011            parameterNames.get("setTiming"),
1012            optionals, webSocketID,
1013            "Animation.setTiming",
1014            animationId, duration, delay
1015        );
1016        
1017        // This Remote Command does not have a Return-Value.
1018        return new Script<>
1019            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1020    }
1021    
1022}