Class UnitImageAnimation


  • public final class UnitImageAnimation
    extends Animation
    Class for in-place animation of units.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • alternatives

        public static final java.util.Map<Direction,​java.util.List<Direction>> alternatives
        Alternate directions to check when a directional animation is not found.
      • mirror

        private boolean mirror
        Reflect the images?
    • Constructor Detail

      • UnitImageAnimation

        public UnitImageAnimation​(Unit unit,
                                  Tile tile,
                                  SimpleZippedAnimation animation)
        Build a new image animation.
        Parameters:
        unit - The Unit to be animated.
        tile - The Tile where the animation occurs.
        animation - The SimpleZippedAnimation to show.
    • Method Detail

      • setMirrored

        public void setMirrored​(boolean mirror)
        Set the mirror state.
        Parameters:
        mirror - The new mirror state.
      • trialDirections

        private static java.util.List<Direction> trialDirections​(Direction direction)
        Get a list of directions to try when looking for a direction-keyed animation given a preferred direction which has failed.
        Parameters:
        direction - The preferred Direction.
        Returns:
        A list of Directions.
      • build

        public static UnitImageAnimation build​(Unit unit,
                                               Tile tile,
                                               Direction dirn,
                                               java.lang.String base,
                                               float scale)
        Static quasi-constructor that can fail harmlessly.
        Parameters:
        unit - The Unit to be animated.
        tile - The Tile where the animation occurs.
        dirn - The Direction of the attack.
        base - The base prefix for the animation resource.
        scale - The gui scale.
        Returns:
        The animation found or null if none present.
      • executeWithLabel

        public void executeWithLabel​(javax.swing.JLabel unitLabel,
                                     Animations.Procedure paintCallback)
        The code to be executed when a unit is out for animation.
        Specified by:
        executeWithLabel in class Animation
        Parameters:
        unitLabel - A JLabel with an image of the unit to animate.
        paintCallback - A callback to request that the animation area be repainted.