package at.oefai.aaa.animation;

import org.w3c.dom.svg.SVGPoint;

/**
 * SVG anim for directly setting the position of an object to a named position.
 * @author Stefan Rank
 */
public class SetPosition extends BaseSVGAnim {
    private volatile boolean done = false;

    public BaseAnim newInstance() { return new SetPosition(); }

    protected void doFirstTime() {
        assert (this.args.size() == 2) : "wrong arguments for SetPosition";
        SVGPoint dest = getNamedPointRandDisplace(this.args.get(1).getString());
        if (dest != null) {
            String agent = this.args.get(0).getString();
            displacePointByNamed(dest, agent + "Displace");
            showElement(agent + SHADOW_POSTFIX);
            setElementsPos(getNamedElement(agent), dest);
        }
        this.done = true;
    }


    public boolean isFinished() {
        return this.done;
    }

    protected void doIt() {
        //done the first time
    }

}
