PresentationAnimationsGenerator

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable

public class PresentationAnimationsGenerator implements System.IDisposable

Represents a generator of the animations in the Presentation.


Presentation pres = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(pres);
     try {
         PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
         try {
             player.setFrameTick((sender, args) ->
             {
                 try {
                     ImageIO.write(args.getFrame(), "PNG", new java.io.File("frame_" + sender.getFrameIndex() + ".png"));
                 } catch (IOException e) {
                     throw new RuntimeException(e);
                 }
             });
             animationsGenerator.run(pres.getSlides());
         } finally {
             if (player != null) player.dispose();
         }
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Constructors

ConstructorDescription
PresentationAnimationsGenerator(Presentation presentation)Creates a new instance of the PresentationAnimationsGenerator.
PresentationAnimationsGenerator(Dimension frameSize)Creates a new instance of the PresentationAnimationsGenerator.
PresentationAnimationsGenerator(Dimension2D frameSize)Creates a new instance of the PresentationAnimationsGenerator.

Methods

MethodDescription
dispose()Disposes the instance of the PresentationAnimationsGenerator.
getFrameSize()Gets the frame size.
getDefaultDelay()Gets or sets default delay time [ms].
setDefaultDelay(int value)Gets or sets default delay time [ms].
getIncludeHiddenSlides()Get or sets if hidden slides should be included.
setIncludeHiddenSlides(boolean value)Get or sets if hidden slides should be included.
getExportedSlides()Get the number of the exported slides count.
setNewAnimation(PresentationAnimationsGenerator.NewAnimation anim)Set a new animation event.
run(System.Collections.Generic.IGenericEnumerable slides)Run the animation events generation for each slide.
run(System.Collections.Generic.IGenericEnumerable slides, int fps, PresentationPlayer.FrameTick onFrame)Run the animation events generation for each slide.

PresentationAnimationsGenerator(Presentation presentation)

public PresentationAnimationsGenerator(Presentation presentation)

Creates a new instance of the PresentationAnimationsGenerator.

Parameters:

ParameterTypeDescription
presentationPresentationThe frame size will be set with accordance to the Presentation.getSlideSize

PresentationAnimationsGenerator(Dimension frameSize)

public PresentationAnimationsGenerator(Dimension frameSize)

Creates a new instance of the PresentationAnimationsGenerator.

Parameters:

ParameterTypeDescription
frameSizejava.awt.DimensionThe frame size.

PresentationAnimationsGenerator(Dimension2D frameSize)

public PresentationAnimationsGenerator(Dimension2D frameSize)

Creates a new instance of the PresentationAnimationsGenerator.

Parameters:

ParameterTypeDescription
frameSizejava.awt.geom.Dimension2DThe frame size.

dispose()

public final void dispose()

Disposes the instance of the PresentationAnimationsGenerator.

getFrameSize()

public Dimension getFrameSize()

Gets the frame size.

Returns: java.awt.Dimension

getDefaultDelay()

public final int getDefaultDelay()

Gets or sets default delay time [ms].


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.setDefaultDelay(1000); // 1s
         // ...
         animationsGenerator.run(presentation.getSlides());
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Returns: int

setDefaultDelay(int value)

public final void setDefaultDelay(int value)

Gets or sets default delay time [ms].


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.setDefaultDelay(1000); // 1s
         // ...
         animationsGenerator.run(presentation.getSlides());
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
valueint

getIncludeHiddenSlides()

public final boolean getIncludeHiddenSlides()

Get or sets if hidden slides should be included.


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.setIncludeHiddenSlides(false);
         // ...
         animationsGenerator.run(presentation.getSlides());
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Returns: boolean

setIncludeHiddenSlides(boolean value)

public final void setIncludeHiddenSlides(boolean value)

Get or sets if hidden slides should be included.


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.setIncludeHiddenSlides(false);
         // ...
         animationsGenerator.run(presentation.getSlides());
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
valueboolean

getExportedSlides()

public final int getExportedSlides()

Get the number of the exported slides count.

Returns: int

setNewAnimation(PresentationAnimationsGenerator.NewAnimation anim)

public void setNewAnimation(PresentationAnimationsGenerator.NewAnimation anim)

Set a new animation event.


Presentation presentation = new Presentation("SimpleAnimations.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.setNewAnimation(animationPlayer -> {
             System.out.println(String.format("Animation total duration: %f", animationPlayer.getDuration()));
         });
         animationsGenerator.run(presentation.getSlides());
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
animNewAnimationAnimation event.

run(System.Collections.Generic.IGenericEnumerable slides)

public final void run(System.Collections.Generic.IGenericEnumerable<ISlide> slides)

Run the animation events generation for each slide.


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
         try {
             animationsGenerator.setNewAnimation(animationPlayer ->
             {
                 // handle new animation
             });
             player.setFrameTick((sender, args) ->
             {
                 // handle frame tick within the new animation
             });
             animationsGenerator.run(presentation.getSlides());
         } finally {
             if (player != null) player.dispose();
         }
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
slidescom.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.slides.ISlide>

run(System.Collections.Generic.IGenericEnumerable slides, int fps, PresentationPlayer.FrameTick onFrame)

public final void run(System.Collections.Generic.IGenericEnumerable<ISlide> slides, int fps, PresentationPlayer.FrameTick onFrame)

Run the animation events generation for each slide.


Presentation presentation = new Presentation("animated.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation.getSlideSize().getSize());
     try {
         animationsGenerator.run(presentation.getSlides(), 33, (player, playerArgs) ->
         {
             player.setFrameTick((sender, args) ->
             {
                 try {
                     ImageIO.write(args.getFrame(), "PNG", new java.io.File("frame_" + sender.getFrameIndex() + ".png"));
                 } catch (IOException e) {
                     throw new RuntimeException(e);
                 }
             });
         });
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
slidescom.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.slides.ISlide>
fpsint
onFrameFrameTick