Add Animations to Shapes in PowerPoint in Java

Animation can make a PowerPoint document more dynamic. In this article, we'll introduce how to add animations to shapes in a PowerPoint document using Spire.Presentation for Java.

import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;
import com.spire.presentation.drawing.animation.AnimationEffectType;

import java.awt.*;

import java.awt.geom.Rectangle2D;

public class SetAnimation {
    public static void main(String[] args) throws Exception {
        //create a PowrePoint document 
        Presentation ppt = new Presentation();
        //add a slide
        ISlide slide = ppt.getSlides().get(0);

        //Add a shape to slide
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.CUBE, new Rectangle2D.Double(50, 150, 150, 150));
        shape.getFill().setFillType(FillFormatType.SOLID);
        shape.getFill().getSolidColor().setColor(Color.orange);
        shape.getShapeStyle().getLineColor().setColor(Color.white);

        //Add animation to the shape
        slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.FADED_SWIVEL);

        //save the document
        ppt.saveToFile("AddAnimationToShape.pptx", FileFormat.PPTX_2013);
    }
}

Add Animations to Shapes in PowerPoint in Java