001: /*
002: * Copyright (c) 2006-2007 Valerio Proietti
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
020: * THE SOFTWARE.
021: *
022: * Contributors:
023: * Valerio Proietti - initial API and implementation
024: * MyGWT - derived implementation
025: */
026: package net.mygwt.ui.client.fx;
027:
028: import java.util.ArrayList;
029: import java.util.List;
030:
031: import com.google.gwt.user.client.Element;
032:
033: /**
034: * Excutes a set of effects.
035: *
036: * <p>
037: * This code is based on code from the MooTools Project by Valerio Proietti.
038: * </p>
039: *
040: * <dl>
041: * <dt><b>Events:</b></dt>
042: *
043: * <dd><b>EffectStart</b> : (source) <br>
044: * <div>Fires after an effect is started.</div>
045: * <ul>
046: * <li>source : this</li>
047: * </ul>
048: * </dd>
049: *
050: * <dd><b>EffecCancel</b> : (source) <br>
051: * <div>Fires after an effect has been cancelled.</div>
052: * <ul>
053: * <li>source : this</li>
054: * </ul>
055: * </dd>
056: *
057: * <dd><b>EffecComplete</b> : (source) <br>
058: * <div>Fires after an effect has been completed.</div>
059: * <ul>
060: * <li>source : this</li>
061: * </ul>
062: * </dd>
063: * </dl>
064: * <dl>
065: */
066: public class FXStyles extends FX {
067:
068: protected List effects;
069:
070: /**
071: * Creates a new instance.
072: */
073: public FXStyles() {
074: effects = new ArrayList();
075: }
076:
077: /**
078: * Creates and adds an effect to the queue.
079: *
080: * @param elem the animation element
081: * @param style the style being changed
082: * @param from the start value
083: * @param to the env value
084: */
085: public void addEffect(Element elem, String style, double from,
086: double to) {
087: effects.add(new Effect(elem, style, from, to));
088: }
089:
090: /**
091: * Adds an effect to the queue.
092: *
093: * @param effect the effect to be added
094: */
095: public void addEffect(Effect effect) {
096: effects.add(effect);
097: }
098:
099: /**
100: * Runs all effects in the queue.
101: */
102: public void start() {
103: Effect[] earray = new Effect[effects.size()];
104: for (int i = 0; i < effects.size(); i++) {
105: earray[i] = (Effect) effects.get(i);
106: }
107: start(earray);
108: }
109:
110: }
|