• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ImageAnimationEvent类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中net.sf.freecol.common.io.sza.ImageAnimationEvent的典型用法代码示例。如果您正苦于以下问题:Java ImageAnimationEvent类的具体用法?Java ImageAnimationEvent怎么用?Java ImageAnimationEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ImageAnimationEvent类属于net.sf.freecol.common.io.sza包,在下文中一共展示了ImageAnimationEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeWithUnitOutForAnimation

点赞 2

import net.sf.freecol.common.io.sza.ImageAnimationEvent; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void executeWithUnitOutForAnimation(JLabel unitLabel) {
    final GUI gui = getGUI();

    // Tile position should now be valid.
    if (gui.getTilePosition(this.tile) == null) {
        logger.warning("Failed attack animation for " + this.unit
            + " at tile: " + this.tile);
        return;
    }

    final Rectangle rect = gui.getTileBounds(this.tile);
    final ImageIcon icon = (ImageIcon)unitLabel.getIcon();
    for (AnimationEvent event : animation) {
        long time = System.nanoTime();
        if (event instanceof ImageAnimationEvent) {
            final ImageAnimationEvent ievent = (ImageAnimationEvent)event;
            Image image = ievent.getImage();
            if (mirror) {
                // FIXME: Add mirroring functionality to SimpleZippedAnimation
                image = ImageLibrary.createMirroredImage(image);
            }
            icon.setImage(image);
            gui.paintImmediatelyCanvasIn(rect);
            time = ievent.getDurationInMs()
                - (System.nanoTime() - time) / 1000000;
            if (time > 0) Utils.delay(time, "Animation delayed.");
        }
    }
    gui.refresh();
}
 

开发者ID:FreeCol,
项目名称:freecol,
代码行数:34,
代码来源:UnitImageAnimation.java

示例2: animate

点赞 2

import net.sf.freecol.common.io.sza.ImageAnimationEvent; //导入依赖的package包/类
/**
 * Do the animation.
 */
public void animate() {
    if (gui.getTilePosition(tile) == null) return;

    // Painting the whole screen once to get rid of disposed dialog-boxes.
    gui.paintImmediatelyCanvasInItsBounds();
    gui.executeWithUnitOutForAnimation(unit, tile, (JLabel unitLabel) -> {
            gui.requireFocus(tile);
            for (AnimationEvent event : animation) {
                long time = System.nanoTime();
                if (event instanceof ImageAnimationEvent) {
                    final ImageAnimationEvent ievent = (ImageAnimationEvent) event;
                    final ImageIcon icon = (ImageIcon)unitLabel.getIcon();
                    Image image = ievent.getImage();
                    if(mirror) {
                        // FIXME: Add mirroring functionality to SimpleZippedAnimation
                        image = ImageLibrary.createMirroredImage(image);
                    }
                    icon.setImage(image);
                    gui.paintImmediatelyCanvasIn(getDirtyAnimationArea());
                    
                    time = ievent.getDurationInMs()
                        - (System.nanoTime() - time) / 1000000;
                    if (time > 0) Utils.delay(time, "Animation delayed.");
                }
            }
            gui.refresh();
        });
}
 

开发者ID:wintertime,
项目名称:FreeCol,
代码行数:32,
代码来源:UnitImageAnimation.java

示例3: animate

点赞 2

import net.sf.freecol.common.io.sza.ImageAnimationEvent; //导入依赖的package包/类
/**
 * Do the animation.
 */
public void animate() {
    if (gui.getTilePosition(tile) == null) return;

    // Painting the whole screen once to get rid of disposed dialog-boxes.
    gui.paintImmediatelyCanvasInItsBounds();
    gui.executeWithUnitOutForAnimation(unit, tile, new OutForAnimationCallback() {
        public void executeWithUnitOutForAnimation(final JLabel unitLabel) {
            for (AnimationEvent event : animation) {
                long time = System.nanoTime();
                if (event instanceof ImageAnimationEvent) {
                    final ImageAnimationEvent ievent = (ImageAnimationEvent) event;
                    final ImageIcon icon = (ImageIcon)unitLabel.getIcon();
                    icon.setImage(ievent.getImage());
                    gui.paintImmediatelyCanvasIn(getDirtyAnimationArea());

                    time = ievent.getDurationInMs()
                        - (System.nanoTime() - time) / 1000000;
                    if (time > 0) {
                        try {
                            Thread.sleep(time);
                        } catch (InterruptedException ex) {
                            //ignore
                        }
                    }
                }
            }             
        }
    });
}
 

开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:33,
代码来源:UnitImageAnimation.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)