GWT animation: fade in and fade out : Animation « GWT « Java






GWT animation: fade in and fade out

  

/*
 * Created on May 23, 2006
 * 
 * Copyright 2006, Robert Hanson
 * This library is dustributed under the GNU-LGPL 2.1.
 * http://creativecommons.org/licenses/LGPL/2.1/
 */
package org.hanson.gwt.widgets.client;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;

/**
 * Effect is a wrapper for the Scriptaculous effects JavaScript library,
 * which can be found at http://script.aculo.us/.
 * 
 * Example of using an effect with options:
 * 
 * <pre>
 *   Effect.highlight(widget, new EffectOption[]{
 *       new EffectOption("startcolor", "#ff0000")
 *   });
 * </pre>
 * 
 * Example of using an effect with no options:
 * 
 * <pre>
 *   Effect.fade(widget);
 * </pre>
 *
 * Example of using an effect on a specific element id:
 * 
 * <pre>
 *   Effect.switchOff(RootPanel.get("leftNav"));
 * </pre>
 * 
 * You must reference the Scriptaculous JavaScript code in your HTML
 * page to be able to use the wrapper.  Failure to do so will result in 
 * error messages similar to this, "'$wnd.Effect.Fade' is null or not an object".
 * 
 * <pre> 
 *  &lt;script type="text/javascript" src="script/prototype.js">&lt;/script>
 *  &lt;script type="text/javascript" src="script/scriptaculous.js">&lt;/script>
 * </pre>
 * 
 * You will also need to add the gwt-widgets jar file to your project classpath, 
 * and add the following reference in your .gwt.xml file:
 * 
 * <pre>
 *  &lt;inherits name='org.hanson.gwt.widgets.WidgetLibrary'/>
 * </pre>
 *  
 * @author Robert Hanson <iamroberthanson[at]gmail.com> http://roberthanson.blogspot.com
 */
public class Effect
{

    
    public static void appear (Widget widget) {
        appear(widget.getElement(), null);
    }

    public static void appear (Widget widget, EffectOption[] opts) {
        appear(widget.getElement(), buildOptions(opts));
    }

    private native static void appear (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Appear(element, opts);
    }-*/;



    
    public static void blindDown (Widget widget) {
        blindDown(widget.getElement(), null);
    }

    public static void blindDown (Widget widget, EffectOption[] opts) {
        blindDown(widget.getElement(), buildOptions(opts));
    }

    private native static void blindDown (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.BlindDown(element, opts);
    }-*/;



    
    public static void blindUp (Widget widget) {
        blindUp(widget.getElement(), createJsObject());
    }

    public static void blindUp (Widget widget, EffectOption[] opts) {
        blindUp(widget.getElement(), buildOptions(opts));
    }

    private native static void blindUp (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.BlindUp(element, opts);
    }-*/;



    
    public static void dropOut (Widget widget) {
        dropOut(widget.getElement(), null);
    }

    public static void dropOut (Widget widget, EffectOption[] opts) {
        dropOut(widget.getElement(), buildOptions(opts));
    }

    private native static void dropOut (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.DropOut(element, opts);
    }-*/;



    
    public static void fade (Widget widget) {
        fade(widget.getElement(), null);
    }

    public static void fade (Widget widget, EffectOption[] opts) {
        fade(widget.getElement(), buildOptions(opts));
    }

    private native static void fade (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Fade(element, opts);
    }-*/;



    
    public static void fold (Widget widget) {
        fold(widget.getElement(), null);
    }

    public static void fold (Widget widget, EffectOption[] opts) {
        fold(widget.getElement(), buildOptions(opts));
    }

    private native static void fold (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Fold(element, opts);
    }-*/;



    
    public static void grow (Widget widget) {
        grow(widget.getElement(), null);
    }

    public static void grow (Widget widget, EffectOption[] opts) {
        grow(widget.getElement(), buildOptions(opts));
    }

    private native static void grow (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Grow(element, opts);
    }-*/;



    
    public static void highlight (Widget widget) {
        highlight(widget.getElement(), null);
    }

    public static void highlight (Widget widget, EffectOption[] opts) {
        highlight(widget.getElement(), buildOptions(opts));
    }

    private native static void highlight (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Highlight(element, opts);
    }-*/;



    
    public static void keepFixed (Widget widget) {
        keepFixed(widget.getElement(), null);
    }

    public static void keepFixed (Widget widget, EffectOption[] opts) {
        keepFixed(widget.getElement(), buildOptions(opts));
    }

    private native static void keepFixed (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.KeepFixed(element, opts);
    }-*/;



    
    public static void move (Widget widget) {
        move(widget.getElement(), null);
    }

    public static void move (Widget widget, EffectOption[] opts) {
        move(widget.getElement(), buildOptions(opts));
    }

    private native static void move (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Move(element, opts);
    }-*/;



    
    public static void moveBy (Widget widget) {
        moveBy(widget.getElement(), null);
    }

    public static void moveBy (Widget widget, EffectOption[] opts) {
        moveBy(widget.getElement(), buildOptions(opts));
    }

    private native static void moveBy (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.MoveBy(element, opts);
    }-*/;



    
    public static void opacity (Widget widget) {
        opacity(widget.getElement(), null);
    }

    public static void opacity (Widget widget, EffectOption[] opts) {
        opacity(widget.getElement(), buildOptions(opts));
    }

    private native static void opacity (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Opacity(element, opts);
    }-*/;



    
    public static void parallel (Widget widget) {
        parallel(widget.getElement(), null);
    }

    public static void parallel (Widget widget, EffectOption[] opts) {
        parallel(widget.getElement(), buildOptions(opts));
    }

    private native static void parallel (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Parallel(element, opts);
    }-*/;



    
    public static void puff (Widget widget) {
        puff(widget.getElement(), null);
    }

    public static void puff (Widget widget, EffectOption[] opts) {
        puff(widget.getElement(), buildOptions(opts));
    }

    private native static void puff (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Puff(element, opts);
    }-*/;



    
    public static void pulsate (Widget widget) {
        pulsate(widget.getElement(), null);
    }

    public static void pulsate (Widget widget, EffectOption[] opts) {
        pulsate(widget.getElement(), buildOptions(opts));
    }

    private native static void pulsate (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Pulsate(element, opts);
    }-*/;



    
    public static void scale (Widget widget) {
        scale(widget.getElement(), null);
    }

    public static void scale (Widget widget, EffectOption[] opts) {
        scale(widget.getElement(), buildOptions(opts));
    }

    private native static void scale (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Scale(element, opts);
    }-*/;



    
    public static void scrollTo (Widget widget) {
        scrollTo(widget.getElement(), null);
    }

    public static void scrollTo (Widget widget, EffectOption[] opts) {
        scrollTo(widget.getElement(), buildOptions(opts));
    }

    private native static void scrollTo (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.ScrollTo(element, opts);
    }-*/;



    
    public static void shake (Widget widget) {
        shake(widget.getElement(), null);
    }

    public static void shake (Widget widget, EffectOption[] opts) {
        shake(widget.getElement(), buildOptions(opts));
    }

    private native static void shake (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Shake(element, opts);
    }-*/;



    
    public static void shrink (Widget widget) {
        shrink(widget.getElement(), null);
    }

    public static void shrink (Widget widget, EffectOption[] opts) {
        shrink(widget.getElement(), buildOptions(opts));
    }

    private native static void shrink (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Shrink(element, opts);
    }-*/;



    
    public static void slideDown (Widget widget) {
        slideDown(widget.getElement(), null);
    }

    public static void slideDown (Widget widget, EffectOption[] opts) {
        slideDown(widget.getElement(), buildOptions(opts));
    }

    private native static void slideDown (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.SlideDown(element, opts);
    }-*/;



    
    public static void slideUp (Widget widget) {
        slideUp(widget.getElement(), null);
    }

    public static void slideUp (Widget widget, EffectOption[] opts) {
        slideUp(widget.getElement(), buildOptions(opts));
    }

    private native static void slideUp (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.SlideUp(element, opts);
    }-*/;



    
    public static void squish (Widget widget) {
        squish(widget.getElement(), null);
    }

    public static void squish (Widget widget, EffectOption[] opts) {
        squish(widget.getElement(), buildOptions(opts));
    }

    private native static void squish (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.Squish(element, opts);
    }-*/;



    
    public static void switchOff (Widget widget) {
        switchOff(widget.getElement(), null);
    }

    public static void switchOff (Widget widget, EffectOption[] opts) {
        switchOff(widget.getElement(), buildOptions(opts));
    }

    private native static void switchOff (Element element, JavaScriptObject opts) /*-{
        new $wnd.Effect.SwitchOff(element, opts);
    }-*/;


    
    
    private static JavaScriptObject buildOptions (EffectOption[] opts) {
        JavaScriptObject jso = createJsObject();
        for (int i = 0; i < opts.length; i++) {
            addOption(jso, opts[i].getName(), opts[i].getValue());
        }
        return jso;
    }

    private static native void addOption (JavaScriptObject jso, String name, String value) /*-{
        jso[name] = value;
    }-*/;

    private static native JavaScriptObject createJsObject () /*-{
        return new Object();
    }-*/;

}


           
         
    
  








Related examples in the same category

1.Animation: Expand and collapse (Smart GWT)Animation: Expand and collapse (Smart GWT)
2.Animation Sequence Sample (Smart GWT)Animation Sequence Sample (Smart GWT)
3.Slide in and slide out animation (Smart GWT)Slide in and slide out animation (Smart GWT)
4.Zoom image animation (Smart GWT)Zoom image animation (Smart GWT)
5.Fade in and fade out animation (Smart GWT)Fade in and fade out animation (Smart GWT)
6.Layout animation (Smart GWT)Layout animation (Smart GWT)
7.Move in and move out animation (Smart GWT)Move in and move out animation (Smart GWT)
8.Window expanding and collapsing animation (Smart GWT)Window expanding and collapsing animation (Smart GWT)
9.Wipe in and wipe out animation (Smart GWT)Wipe in and wipe out animation (Smart GWT)
10.Image zooming and shrinking animation (Smart GWT)Image zooming and shrinking animation (Smart GWT)
11.Control the animation duration (Smart GWT)Control the animation duration (Smart GWT)
12.Autoscroll animation (Smart GWT)Autoscroll animation (Smart GWT)
13.Timer based animation (Smart GWT)Timer based animation (Smart GWT)
14.orbit-path animation (Smart GWT)orbit-path animation (Smart GWT)
15.Slide in and slide out (Ext GWT)Slide in and slide out (Ext GWT)
16.Fade in and Fade out (Ext GWT)Fade in and Fade out (Ext GWT)
17.Move to a position (Ext GWT)Move to a position (Ext GWT)
18.Blinking (Ext GWT)
19.Set Widget position (Ext GWT)