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(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                     FileOutputStream fos = null;
                     try {
                         fos = new FileOutputStream("frame_" + sender.getFrameIndex() + ".png");
                         args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     } finally {
                         if (fos != null) {
                             try {
                                 fos.close();
                             } catch (IOException 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(Size frameSize)Creates a new instance of the PresentationAnimationsGenerator.
PresentationAnimationsGenerator(SizeF 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(Size frameSize)

public PresentationAnimationsGenerator(Size frameSize)

Creates a new instance of the PresentationAnimationsGenerator.

Parameters:

ParameterTypeDescription
frameSizeSizeThe frame size.

PresentationAnimationsGenerator(SizeF frameSize)

public PresentationAnimationsGenerator(SizeF frameSize)

Creates a new instance of the PresentationAnimationsGenerator.

Parameters:

ParameterTypeDescription
frameSizeSizeFThe frame size.

dispose()

public final void dispose()

Disposes the instance of the PresentationAnimationsGenerator.

getFrameSize()

public Size getFrameSize()

Gets the frame size.

Returns: Size

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(new PresentationAnimationsGenerator.NewAnimation() {
             public void invoke(IPresentationAnimationPlayer 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(new PresentationAnimationsGenerator.NewAnimation() {
                 public void invoke(IPresentationAnimationPlayer animationPlayer) {
                     // handle new animation
                 }
             });
             player.setFrameTick(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs 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, new PresentationPlayer.FrameTick() {
             public void invoke(PresentationPlayer player, FrameTickEventArgs playerArgs) {
                 player.setFrameTick(new PresentationPlayer.FrameTick() {
                     public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                         FileOutputStream fos = null;
                         try {
                             fos = new FileOutputStream("frame_" + sender.getFrameIndex() + ".png");
                             args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                         } catch (IOException e) {
                             throw new RuntimeException(e);
                         } finally {
                             if (fos != null) {
                                 try {
                                     fos.close();
                                 } catch (IOException e) {
                                     e.printStackTrace();
                                 }
                             }
                         }
                     }
                 });
             }
         });
     } 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