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

public class SlideRenderer

  1. Object
  2. SlideRenderer

Paints slides on a Graphics: thumbnails, the editor’s canvas and the slide show all draw through this class, and PDF export draws the same elements with the same geometry.

Text is laid out by com.codename1.wordprocessing.DocumentLayout and drawn by LayoutPainter, charts by com.codename1.ui.chart.Chart, and diagrams are arranged by com.codename1.graph.arrange – nothing here measures or draws text by itself.

Image thumbnail(Presentation deck) {
    SlideRenderer renderer = new SlideRenderer();
    return renderer.toImage(deck, deck.getSlides().get(0), 320);
}

Nested types

class SlideRenderer.ElementStateHow a slide show is showing an element partway through a build: its opacity, offset, scale and how much of it a wipe has revealed.

Constructors

public SlideRenderer()

Methods

public Measurer getMeasurer()The measurer text is laid out with on the screen.
public void paint(Graphics g, Presentation presentation, Slide slide, int x, int y, float scale)Paints a slide.
public void paint(Graphics g, Presentation presentation, Slide slide, int x, int y, float scale, Map<String, SlideRenderer.ElementState> states)Paints a slide with some elements partway through their builds.
public void paintElement(Graphics g, SlideElement e, int x, int y, float scale)Paints one element, for a view that draws a dragged element by itself.
public Image toImage(Presentation presentation, Slide slide, int width)Renders a slide into a new image.
public void clearCache()Forgets laid out text and rendered charts, for when memory is short.
public static GeneralPath outline(ShapeElement s)The outline of a shape in slide points, flipped as the shape says.

Inherited methods

Constructor details

SlideRenderer

public SlideRenderer()

Method details

getMeasurer

public Measurer getMeasurer()
The measurer text is laid out with on the screen.

Returns

the measurer

paint

public void paint(Graphics g, Presentation presentation, Slide slide, int x, int y, float scale)
Paints a slide.

Parameters

g Graphics
the graphics
presentation Presentation
the presentation the slide belongs to
slide Slide
the slide
x int
where the slide’s left edge goes, in pixels
y int
where its top edge goes
scale float
pixels per point

paint

public void paint(Graphics g, Presentation presentation, Slide slide, int x, int y, float scale, Map<String, SlideRenderer.ElementState> states)
Paints a slide with some elements partway through their builds.

Parameters

g Graphics
the graphics
presentation Presentation
the presentation
slide Slide
the slide
x int
left edge in pixels
y int
top edge
scale float
pixels per point
states Map<String, SlideRenderer.ElementState>
element states by id, or null to paint every element as it is

paintElement

public void paintElement(Graphics g, SlideElement e, int x, int y, float scale)
Paints one element, for a view that draws a dragged element by itself.

Parameters

g Graphics
the graphics
e SlideElement
the element
x int
where the slide’s left edge is, in pixels
y int
where its top edge is
scale float
pixels per point

toImage

public Image toImage(Presentation presentation, Slide slide, int width)
Renders a slide into a new image.

Parameters

presentation Presentation
the presentation
slide Slide
the slide
width int
the image width in pixels; the height follows the slide’s proportions

Returns

the image

clearCache

public void clearCache()
Forgets laid out text and rendered charts, for when memory is short.

outline

public static GeneralPath outline(ShapeElement s)
The outline of a shape in slide points, flipped as the shape says.

Parameters

s ShapeElement
the shape

Returns

the path