Java에서 PowerPoint의 텍스트 및 도형에 애니메이션 효과를 적용하는 방법
11042 단어 powerpointanimationjava
설치
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);
}
}
산출:
Reference
이 문제에 관하여(Java에서 PowerPoint의 텍스트 및 도형에 애니메이션 효과를 적용하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/eiceblue/how-to-apply-animation-effect-to-text-and-shapes-in-powerpoint-in-java-35jo텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)