Class Presentation
A slide presentation: slides of a common size, the theme they were designed with, and the formats it is read from and written to.
A presentation is immutable. PresentationModel is the editable, undoable facade a
SlideView edits; SlideShow plays one.
void toPdf(InputStream in, OutputStream out) throws IOException {
Presentation deck = Presentation.read(in, Presentation.Format.PPTX);
Log.p(deck.getSlides().size() + " slides, first: " + deck.getSlides().get(0).title());
deck.write(out, Presentation.Format.PDF);
}
Text inside slides is the word processing model of com.codename1.wordprocessing, so
every formatting feature a document has -- fonts, colors, lists, links, tables -- a slide
has too, laid out and drawn by the same code.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe formats a presentation is read from and written to. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal floatThe slide height in points.final longThe next numbernewIdhands out.The slides, never null.final ThemeThe theme.final StringThe title, or null.static final floatThe height of a 16:9 slide in points.static final float16:9 at 960 by 540 points, PowerPoint's and Keynote's default.final floatThe slide width in points. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Presentation.Formatdetect(byte[] data) Tells the format of a file from its content.booleanIndicates whether some other object is "equal to" this one.The slides.What the reader could not convert -- an unknown element, an undecodable Keynote object -- one line each.inthashCode()Returns a hash code value for the object.intA slide by id.This presentation with a slide inserted.newId(char prefix) An id that no element or slide in this presentation has, for a new element made from it.The text of every slide, slide by slide.static Presentationread(byte[] data) Reads a presentation from bytes, telling the format from the content: a ZIP holdingppt/presentation.xmlis PPTX, one with an ODF presentation mimetype is ODP, one withIndex/archives is Keynote, one holdingpresentation.xmlalone is.cn1slides, and a compound file is PowerPoint 97-2003.static Presentationread(InputStream in, Presentation.Format format) Reads a presentation.remove(int index) This presentation without a slide.byte[]toBytes(Presentation.Format format) The presentation as the bytes of a file.withNextId(long value) This presentation with another next id number.withSize(float w, float h) This presentation at another slide size.This presentation with one slide replaced.withSlides(List<Slide> value) This presentation with other slides.This presentation with another theme.This presentation with another title.withWarnings(List<String> value) This presentation with warnings.voidwrite(OutputStream out, Presentation.Format format) Writes the presentation.
-
Field Details
-
WIDE_WIDTH
public static final float WIDE_WIDTH16:9 at 960 by 540 points, PowerPoint's and Keynote's default.- See Also:
-
WIDE_HEIGHT
public static final float WIDE_HEIGHTThe height of a 16:9 slide in points.- See Also:
-
width
public final float widthThe slide width in points. -
height
public final float heightThe slide height in points. -
slides
-
theme
The theme. -
title
The title, or null. -
nextId
public final long nextIdThe next numbernewIdhands out.
-
-
Constructor Details
-
Presentation
public Presentation()An empty 16:9 presentation with the default theme. -
Presentation
public Presentation(float width, float height, List<Slide> slides, Theme theme, String title, long nextId, List<String> warnings) A presentation.
Parameters
-
width: the slide width in points, greater than zero -
height: the slide height in points, greater than zero -
slides: the slides, or null -
theme: the theme, or null for the default -
title: the title, or null -
nextId: the next id number -
warnings: what a reader could not convert, or null
-
-
-
Method Details
-
getSlides
-
getWarnings
-
newId
An id that no element or slide in this presentation has, for a new element made from it. The presentation is immutable, so callers that make several ids in a row use
PresentationModel.newIdorwithNextId.Parameters
prefix: a letter that starts the id
Returns
the id
-
indexOf
A slide by id.
Parameters
id: the id
Returns
the index or -1
-
withSlides
This presentation with other slides.
Parameters
value: the slides
Returns
the presentation
-
withSlide
This presentation with one slide replaced.
Parameters
-
index: the position -
slide: the slide
Returns
the presentation
-
-
insert
This presentation with a slide inserted.
Parameters
-
index: the position -
slide: the slide
Returns
the presentation
-
-
remove
This presentation without a slide.
Parameters
index: the position
Returns
the presentation
-
withSize
This presentation at another slide size. Elements keep their positions in points.
Parameters
-
w: the width in points -
h: the height in points
Returns
the presentation
-
-
withTheme
This presentation with another theme.
Parameters
value: the theme
Returns
the presentation
-
withTitle
This presentation with another title.
Parameters
value: the title
Returns
the presentation
-
withNextId
This presentation with another next id number.
Parameters
value: the number
Returns
the presentation
-
withWarnings
This presentation with warnings.
Parameters
value: the warnings
Returns
the presentation
-
plainText
The text of every slide, slide by slide.
Returns
the text
-
read
Reads a presentation.
Parameters
-
in: the stream; it is read to the end but not closed -
format: the format, which must be readable
Returns
the presentation
Throws
IOException: when the stream fails or the file is not in that format
- Throws:
IOException
-
-
read
Reads a presentation from bytes, telling the format from the content: a ZIP holding
ppt/presentation.xmlis PPTX, one with an ODF presentation mimetype is ODP, one withIndex/archives is Keynote, one holdingpresentation.xmlalone is.cn1slides, and a compound file is PowerPoint 97-2003.Parameters
data: the file
Returns
the presentation
Throws
IOException: when the bytes are none of the formats
- Throws:
IOException
-
detect
Tells the format of a file from its content.
Parameters
data: the file
Returns
the format
Throws
IOException: when it is none of the readable formats
- Throws:
IOException
-
write
Writes the presentation.
Parameters
-
out: the stream; it is flushed but not closed -
format: the format, which must be writable
Throws
IOException: when the stream fails or the format cannot be written
- Throws:
IOException
-
-
toBytes
The presentation as the bytes of a file.
Parameters
format: a writable format
Returns
the bytes
Throws
IOException: when the format cannot be written
- Throws:
IOException
-
equals
Description copied from class:ObjectIndicates whether some other object is "equal to" this one. The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false. The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true). -
hashCode
public int hashCode()Description copied from class:ObjectReturns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
-