@@ -0,0 +1,3478 @@
+/*%0A * Soga2D%0A *%0A * Copyright 2011 Mat%C3%BA%C5%A1 Sul%C3%ADr.%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0A * THE SOFTWARE.%0A */%0Apackage soga2d.objects;%0A%0Aimport java.awt.image.BufferedImage;%0Aimport java.io.IOException;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask;%0Aimport soga2d.GraphicObject;%0A%0A/**%0A * The animation is displayed as a static image until the start() method is called. Then the frames are shown circularily (???) until the stop() method call. Finally, the static image is displayed again.%0A * @author Mat%C3%BA%C5%A1 Sul%C3%ADr%0A */%0Apublic class Animation extends GraphicObject %7B%0A%0A    private int interval;%0A    private BufferedImage staticImage;%0A    private BufferedImage%5B%5D frames;%0A    private int index = 0;%0A    private Timer timer;%0A    private boolean active = false;%0A%0A    /**%0A     * Constructs an animation.%0A     *%0A     * @param interval the time between two frames, in milliseconds%0A     * @param staticImage the static image to show when the animation is stopped%0A     * @param images the file names of the animation images%0A     */%0A    public Animation(int interval, String staticImage, String... images) throws IOException %7B%0A        this.interval = interval;%0A        this.frames = new BufferedImage%5Bimages.length%5D;%0A        this.staticImage = Picture.loadImage(staticImage);%0A        %0A        int i = 0;%0A        for (String fileName : images) %7B%0A            this.frames%5Bi++%5D = Picture.loadImage(fileName);%0A        %7D%0A%0A        showImage(this.staticImage);%0A    %7D%0A%0A    /**%0A     * Starts the animation.%0A     */%0A    public void start() %7B%0A        if (!active) %7B%0A            active = true;%0A            timer = new Timer();%0A%0A            timer.scheduleAtFixedRate(new TimerTask() %7B%0A%0A                @Override%0A                public void run() %7B%0A                    showNext();%0A                %7D%0A            %7D, 0, interval);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Stops the animation and displays the static image.%0A     */%0A    public void stop() %7B%0A        if (active) %7B%0A            active = false;%0A            timer.cancel();%0A%0A            index = 0;%0A            showImage(staticImage);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Shows the next animation frame.%0A     */%0A    private void showNext() %7B%0A        index = (index + 1) %25 frames.length;%0A        showImage(frames%5Bindex%5D);%0A    %7D%0A%0A    /**%0A     * Shows the specified image.%0A     * @param image the image to show%0A     */%0A    private void showImage(BufferedImage image) %7B%0A        beforeChange();%0A        this.image = image;%0A        afterChange();%0A    %7D%0A%7D%0A

Add animation support