Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class SlideView

  1. Object
  2. Component
  3. Container
  4. SlideView

ImplementsAnimation, Editable, Iterable<Component>, StyleListener

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");
}

Constructors

public SlideView(PresentationModel model)An editor of a model.

Methods

protected void initComponent()Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state
protected void deinitialize()Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
public PresentationModel getModel()The model.
public SlideRenderer getRenderer()The renderer the slides are painted with.
public DocumentView getNotesView()The notes editor, to hide it or style it.
public int getSlideIndex()The index of the slide being edited.
public void setSlideIndex(int index)Edits another slide.
public String getSelection()The id of the selected element, or null.
public void setSelection(String elementId)Selects an element of the current slide.
public void addSelectionListener(ActionListener<ActionEvent> l)Adds a listener told when the selection or the slide changes.
public void removeSelectionListener(ActionListener<ActionEvent> l)Removes a selection listener.
public String addShape(String geometry)Adds a preset shape in the middle of the slide and selects it.
public String addTextBox()Adds a text box and starts editing it.
public String addPicture(Picture picture)Adds a picture, fitted inside half the slide, and selects it.
public boolean deleteSelection()Removes the selected element.
public void bringToFront()Moves the selected element in front of every other.
public void sendToBack()Moves the selected element behind every other.
public boolean beginTextEdit(String elementId)Starts editing a shape’s text in place.
public DocumentView getTextEditor()The text editor while a shape’s text is being edited, else null.
public void endTextEdit()Ends in-place text editing; the text is already in the model.

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

SlideView

public SlideView(PresentationModel model)
An editor of a model.

Parameters

model PresentationModel
the model every edit goes through

Method details

initComponent

protected void initComponent()
Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state

deinitialize

protected void deinitialize()
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.

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 int
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 String
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 ActionListener<ActionEvent>
the listener

removeSelectionListener

public void removeSelectionListener(ActionListener<ActionEvent> l)
Removes a selection listener.

Parameters

l ActionListener<ActionEvent>
the listener

addShape

public String addShape(String geometry)
Adds a preset shape in the middle of the slide and selects it.

Parameters

geometry String
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 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 String
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.