Class SlideView

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class SlideView extends Container

An editor for a presentation: a strip of slide thumbnails, the slide being edited and its speaker notes.

Tap an element to select it, drag it to move, drag a corner or edge handle to resize and the round handle above it to rotate (snapping to 15 degrees); every drag is one undo step. Double tap a shape to edit its text in place -- the editor is a com.codename1.wordprocessing.DocumentView, so typing, selection, the clipboard and the keyboard behave exactly as they do in a document. Every edit goes through the PresentationModel, so getModel().undo() undoes it.

void edit(Form form, byte[] bytes) throws IOException {
    PresentationModel model = new PresentationModel(Presentation.read(bytes));
    SlideView editor = new SlideView(model);
    form.add(BorderLayout.CENTER, editor);
    editor.addShape("roundRect");
}
  • Constructor Details

    • SlideView

      public SlideView(PresentationModel model)

      An editor of a model.

      Parameters
      • model: the model every edit goes through
  • Method Details

    • initComponent

      protected void initComponent()
      Description copied from class: Component
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • deinitialize

      protected void deinitialize()
      Description copied from class: Component
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
      Overrides:
      deinitialize in class Component
    • getModel

      public PresentationModel getModel()

      The model.

      Returns

      the model

    • getRenderer

      public SlideRenderer getRenderer()

      The renderer the slides are painted with.

      Returns

      the renderer

    • getNotesView

      public DocumentView getNotesView()

      The notes editor, to hide it or style it.

      Returns

      the notes view

    • getSlideIndex

      public int getSlideIndex()

      The index of the slide being edited.

      Returns

      the index

    • setSlideIndex

      public void setSlideIndex(int index)

      Edits another slide.

      Parameters
      • index: the slide
    • getSelection

      public String getSelection()

      The id of the selected element, or null.

      Returns

      the id

    • setSelection

      public void setSelection(String elementId)

      Selects an element of the current slide.

      Parameters
      • elementId: the id, or null for nothing
    • addSelectionListener

      public void addSelectionListener(ActionListener<ActionEvent> l)

      Adds a listener told when the selection or the slide changes.

      Parameters
      • l: the listener
    • removeSelectionListener

      public void removeSelectionListener(ActionListener<ActionEvent> l)

      Removes a selection listener.

      Parameters
      • l: the listener
    • addShape

      public String addShape(String geometry)

      Adds a preset shape in the middle of the slide and selects it.

      Parameters
      • geometry: a preset name, see ShapeGeometry.presets()
      Returns

      the new element's id

    • addTextBox

      public String addTextBox()

      Adds a text box and starts editing it.

      Returns

      the new element's id

    • addPicture

      public String addPicture(Picture picture)

      Adds a picture, fitted inside half the slide, and selects it.

      Parameters
      • picture: the picture
      Returns

      the new element's id

    • deleteSelection

      public boolean deleteSelection()

      Removes the selected element.

      Returns

      false when nothing was selected

    • bringToFront

      public void bringToFront()
      Moves the selected element in front of every other.
    • sendToBack

      public void sendToBack()
      Moves the selected element behind every other.
    • beginTextEdit

      public boolean beginTextEdit(String elementId)

      Starts editing a shape's text in place.

      Parameters
      • elementId: a shape on the current slide
      Returns

      false when the element is not a shape

    • getTextEditor

      public DocumentView getTextEditor()

      The text editor while a shape's text is being edited, else null.

      Returns

      the editor

    • endTextEdit

      public void endTextEdit()
      Ends in-place text editing; the text is already in the model.