国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Java 給PPT添加動(dòng)畫效果的示例

瀏覽:84日期:2022-05-23 16:17:53

PPT幻燈片中對(duì)形狀可設(shè)置動(dòng)畫效果,常見(jiàn)的動(dòng)畫效果為內(nèi)置的固定類型,即動(dòng)畫效果和路徑是預(yù)先設(shè)定好的固定模板,但在設(shè)計(jì)動(dòng)畫效果時(shí),用戶也可以按照自己的喜好自定義動(dòng)畫動(dòng)作路徑。下面,通過(guò)Java后端程序代碼來(lái)展示如何給PPT添加動(dòng)畫效果。包括預(yù)設(shè)動(dòng)畫以及自定動(dòng)畫效果的方法。

本次測(cè)試環(huán)境包括: 目標(biāo)測(cè)試文檔:Power Point 2013 編譯環(huán)境:IntelliJ IDEA 2018 JDK版本:1.8.0 PPT庫(kù)版本:spire.presentation.jar 4.3.2

注:在通過(guò)該P(yáng)PT庫(kù)來(lái)添加動(dòng)畫類型(AnimationEffectType)時(shí),可添加約150種不同類型。

Java程序代碼1. 添加預(yù)設(shè)動(dòng)畫效果

a. 新建PPT文檔,添加形狀,設(shè)置動(dòng)畫效果

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 AddAnimationToShape { public static void main(String[]args) throws Exception{ //創(chuàng)建PowerPoint文檔 Presentation ppt = new Presentation(); //獲取幻燈片 ISlide slide = ppt.getSlides().get(0); //添加一個(gè)形狀到幻燈片 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); //設(shè)置形狀動(dòng)畫效果 slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.CHANGE_LINE_COLOR); //保存文檔 ppt.saveToFile('AddAnimationToShape.pptx', FileFormat.PPTX_2013); }}

Java 給PPT添加動(dòng)畫效果的示例

b.加載已有PPT文檔,獲取形狀動(dòng)畫效果,進(jìn)行動(dòng)畫效果設(shè)置,這里可做更為詳細(xì)的動(dòng)畫設(shè)置,包括動(dòng)畫重復(fù)播放類型、次數(shù)、持續(xù)時(shí)間、延遲時(shí)間等.

import com.spire.presentation.*;import com.spire.presentation.drawing.animation.AnimationEffect;public class RepeatAnimation { public static void main(String[] args) throws Exception{ //加載測(cè)試文檔 Presentation ppt = new Presentation(); ppt.loadFromFile('test.pptx'); //獲取第一張幻燈片 ISlide slide = ppt.getSlides().get(0); //獲取幻燈片中第一個(gè)動(dòng)畫效果 AnimationEffect animation = slide.getTimeline().getMainSequence().get(0); //設(shè)置動(dòng)畫效果循環(huán)播放類型、次數(shù)、持續(xù)時(shí)間、延遲時(shí)間 animation.getTiming().setAnimationRepeatType(AnimationRepeatType.Number); animation.getTiming().setRepeatCount(2);//設(shè)置重復(fù)次數(shù) animation.getTiming().setDuration(2);//設(shè)置持續(xù)時(shí)間 animation.getTiming().setTriggerDelayTime(2);//設(shè)置延遲時(shí)間 //animation.getTiming().setAnimationRepeatType(AnimationRepeatType.UtilEndOfSlide);//設(shè)置動(dòng)畫循環(huán)播放至幻燈片末 //animation.getTiming().setAnimationRepeatType(AnimationRepeatType.UtilNextClick);//設(shè)置動(dòng)畫循環(huán)播放至下次點(diǎn)擊 //保存結(jié)果文檔 ppt.saveToFile('RepeatAnimation.pptx', FileFormat.PPTX_2013); ppt.dispose(); }}

Java 給PPT添加動(dòng)畫效果的示例

2. 添加自定義動(dòng)畫效果

import com.spire.presentation.*;import com.spire.presentation.collections.CommonBehaviorCollection;import com.spire.presentation.drawing.FillFormatType;import com.spire.presentation.drawing.animation.*;import java.awt.*;import java.awt.geom.Point2D;public class CustomAnimationPath { public static void main(String[] args) throws Exception { //創(chuàng)建一個(gè)空白PPT文檔 Presentation ppt = new Presentation(); //獲取第一張幻燈片(新建的幻燈片文檔默認(rèn)已包含一張幻燈片) ISlide slide = ppt.getSlides().get(0); //添加形狀到幻燈片 IAutoShape shape = slide.getShapes().appendShape(ShapeType.FIVE_POINTED_STAR,new Rectangle(180, 100, 170, 170)); shape.getFill().setFillType(FillFormatType.GRADIENT); shape.getFill().getGradient().getGradientStops().append(0, KnownColors.LIGHT_PINK); shape.getFill().getGradient().getGradientStops().append(1, KnownColors.PURPLE); shape.getShapeStyle().getLineColor().setColor(Color.white); //添加動(dòng)畫效果,并設(shè)置動(dòng)畫效果類型為PATH_USER(自定義類型) AnimationEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.PATH_USER); //獲取自定動(dòng)畫的CommonBehavior集合 CommonBehaviorCollection commonBehaviorCollection = effect.getCommonBehaviorCollection(); //設(shè)置動(dòng)畫動(dòng)作運(yùn)動(dòng)起點(diǎn)及路徑模式 AnimationMotion motion = (AnimationMotion)commonBehaviorCollection.get(0); motion.setOrigin(AnimationMotionOrigin.LAYOUT); motion.setPathEditMode(AnimationMotionPathEditMode.RELATIVE); //設(shè)置動(dòng)作路徑 MotionPath motionPath = new MotionPath(); motionPath.addPathPoints(MotionCommandPathType.MOVE_TO,new Point2D.Float[]{new Point2D.Float(0,0)},MotionPathPointsType.CURVE_AUTO,true); motionPath.addPathPoints(MotionCommandPathType.LINE_TO,new Point2D.Float[]{new Point2D.Float(0.1f,0.1f)},MotionPathPointsType.CURVE_AUTO,true); motionPath.addPathPoints(MotionCommandPathType.LINE_TO,new Point2D.Float[]{new Point2D.Float(-0.1f,0.2f)},MotionPathPointsType.CURVE_AUTO,true); motionPath.addPathPoints(MotionCommandPathType.END,new Point2D.Float[]{},MotionPathPointsType.CURVE_AUTO,true); //設(shè)置動(dòng)作路徑到動(dòng)畫 motion.setPath(motionPath); //保存文檔 ppt.saveToFile('result.pptx', FileFormat.PPTX_2013); ppt.dispose(); }}

Java 給PPT添加動(dòng)畫效果的示例

以上就是Java 給PPT添加動(dòng)畫效果的示例的詳細(xì)內(nèi)容,更多關(guān)于Java 給PPT添加動(dòng)畫效果的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: ppt
相關(guān)文章:
主站蜘蛛池模板: 国产大陆精品另类xxxx | 国产盗摄一区二区 | 成人精品视频在线观看播放 | 久久99久久精品久久久久久 | 国产或人精品日本亚洲77美色 | 国内外成人免费在线视频 | 亚洲国产精品一区二区三区在线观看 | 一及黄色毛片 | 免费特黄 | 在线播放免费一级毛片欧美 | 成人亚洲国产综合精品91 | 国产99视频精品一区 | 精品亚洲视频在线观看 | 成年男女拍拍拍免费视频 | 午夜视频久久 | 68久久久久欧美精品观看 | 欧美性高清视频免费看www | 亚洲毛片在线免费观看 | 国产性自爱拍偷在在线播放 | 国产日韩线路一线路二 | 亚洲久久久久久久 | 97高清国语自产拍中国大陆 | 久久r视频 | 成人影院一区二区三区 | 国产三级精品久久三级国专区 | 亚洲热视频| 日韩美女一级视频 | 美女张开腿让男人捅爽 | 色九九 | 日韩美女在线视频 | 欧美日韩视频一区二区在线观看 | avtt天堂网 手机资源 | a毛片免费全部播放完整成 a毛片免费全部在线播放毛 | 免费一级欧美大片在线观看 | 亚洲精品一区二区三区www | 手机看片福利视频 | 一色屋色费精品视频在线观看 | www中文字幕在线观看 | 国产亚洲午夜精品a一区二区 | 日本美女黄色一级片 | 亚洲欧美影院 |