Java에서 PowerPoint의 텍스트 및 도형에 애니메이션 효과를 적용하는 방법

애니메이션은 PowerPoint 문서를 보다 역동적이고 매력적으로 만드는 데 도움이 될 수 있습니다. PowerPoint 슬라이드에서 텍스트나 도형 모두에 애니메이션을 적용할 수 있습니다. 이 기사에서는 Free Spire.Presentation for Java 라이브러리를 사용하여 Java에서 프로그래밍 방식으로 PowerPoint의 텍스트 및 모양에 애니메이션 효과를 적용하는 방법을 보여 드리겠습니다.

설치



maven을 사용하는 경우 프로젝트의 pom.xml 파일에서 Free Spire.Presentation for Java 라이브러리에 대한 종속성을 지정해야 합니다.

<repositories>  
        <repository>  
            <id>com.e-iceblue</id>  
            <name>e-iceblue</name>  
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>  
        </repository>  
</repositories>  
<dependencies>  
    <dependency>  
        <groupId>e-iceblue</groupId>  
        <artifactId>spire.presentation.free</artifactId>  
        <version>3.9.0</version>  
    </dependency>  
</dependencies>


Maven이 아닌 프로젝트의 경우 this website에서 무료 Spire.Presentation for Java 팩을 다운로드하고 패키지의 압축을 풀고 lib 폴더의 Spire.Presentation.jar을 종속 항목으로 프로젝트에 추가합니다.

도형에 애니메이션 효과 적용



Free Spire.Presentation for Java는 151개의 애니메이션 효과를 지원하며 AnimationEffectType enum에서 애니메이션 효과의 전체 목록을 볼 수 있습니다. 다음 예제는 도형에 부메랑 효과를 추가하는 방법을 보여줍니다.

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

import java.awt.geom.Rectangle2D;

public class AnimateShapes {
    public static void main(String []args) throws Exception {
        //Create a Presentation instance
        Presentation ppt = new Presentation();
        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Add a shape to slide
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.CUBE, new Rectangle2D.Double(250, 150, 150, 150));

        //Add animation effect to the shape
        AnimationEffect effect= slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.BOOMERANG);

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


산출:

텍스트에 애니메이션 효과 적용



텍스트에 애니메이션 효과를 추가할 수도 있습니다. 다음 예제는 도형의 특정 단락에 애니메이션 효과를 추가하는 방법을 보여줍니다.

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

import java.awt.geom.Rectangle2D;

public class AnimateText {
    public static void main(String []args) throws Exception {
        //Create an instance of presentation document
        Presentation ppt = new Presentation();

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Add a shape to the slide
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Double(250, 150, 250, 100));

        //Add text to the shape
        shape.appendTextFrame("This example shows how to apply animation to text in PPT document.");

        //Apply animation effect to the first paragraph in the shape
        AnimationEffect animation = shape.getSlide().getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.FLOAT);
        animation.setStartEndParagraphs(0, 0);

        //Save the document
        ppt.saveToFile("AddAnimationToText.pptx", FileFormat.PPTX_2013);
    }
}


산출:

좋은 웹페이지 즐겨찾기