關(guān)于文檔路徑:本次測試環(huán)境中為方便文檔管理,將文檔放在IDEA項(xiàng)目文件夾下(這里的文件路徑可以另外自定義) 。如下圖:
文章插圖
在IDEA程序中引入spire.presentation.jar工具,如下圖
文章插圖
在程序中鍵入如下代碼內(nèi)容:
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)建一個空白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);
//添加動畫效果,并設(shè)置動畫效果類型為PATH_USER(自定義類型)
AnimationEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.PATH_USER);
//獲取自定動畫的CommonBehavior集合
CommonBehaviorCollection commonBehaviorCollection = effect.getCommonBehaviorCollection();
//設(shè)置動畫動作運(yùn)動起點(diǎn)及路徑模式
AnimationMotion motion = (AnimationMotion)commonBehaviorCollection.get(0);
motion.setOrigin(AnimationMotionOrigin.LAYOUT);
motion.setPathEditMode(AnimationMotionPathEditMode.RELATIVE);
//設(shè)置動作路徑
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è)置動作路徑到動畫
motion.setPath(motionPath);
//保存文檔
ppt.saveToFile("result.pptx", FileFormat.PPTX_2013);
ppt.dispose();
}
}
完成代碼后,執(zhí)行程序,生成文檔(如上圖1中,文檔路徑),打開文檔后,可查看自定義動畫路徑效果:
文章插圖
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請您及時就醫(yī)或請專業(yè)人士給予相關(guān)指導(dǎo)!
「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助:- Java 檢測PPT文檔是否已簽名
- ppt怎樣添加水印文字 Java在PPT幻燈片中添加文字水印效果
- PPT如何自動折疊功能區(qū)以節(jié)省窗口空間?
- 墳組詞,解惑墳的筆順動畫,理解墳怎么組詞
- 睫組詞,說明睫的筆順動畫,了解睫怎么組詞
- 蠐組詞,概括蠐的筆順動畫,解惑蠐怎么組詞
- 每天做什么動作可以強(qiáng)腎 如何可以讓男人強(qiáng)腎,只需要每天六個動作?
- 腰椎盤突出的康復(fù)動作鍛煉 腰椎間盤突出的鍛煉,腰椎間盤突出矯正姿勢康復(fù)
- 爵士舞動作要素 多樣性的變化
- 爵士舞基本動作 強(qiáng)調(diào)角形及線條性
