Skip to content

RenderListener Extension

Jody Garnett edited this page Nov 4, 2019 · 16 revisions
  • Contact: taba90
  • TLDR: RenderListener Extension

Description

The StreamingRenderer allows receiving events via the RenderListener interface. The current interface tracks only end-of-rendering events for single features, as well as rendering errors tracking. We intend to extend it in order to make possible the tracking of layers' and associated labels' events. The interface will be extended using default methods to avoid breacking existing implementations.

/** Event issued when the layer begins rendering */
    default void layerStart(Layer layer) {
        // does nothing
    }
    /** Event issued when the layer completed rendering. May not be issued */
    default void layerEnd(Layer layer) {
        // does nothing
    }
    /** Event issued when labelling starts. May not be issued if there are no labels to paint. */
    default void labellingStart() {
        // does nothing
    }
    /** Event issued when labelling ends. May not be issued */
    default void labellingEnd() {
        // does nothing
    }

The modifications would allow to have, for instance, an implementation that tracks layers' and labels' rendering times: the layerStart event would be issued when the StreamingRenderer start processing a layer getting the start time, while layerEnd once all its features are done getting the end time; labelling start and end events would be triggered, instead, around label cache operations; finally the renderingComplete event would be issued at the end of rendering process.

References:

Assigned to Release

GeoTools 23.x; backport to 22.x and 21.x

Status

Choose one of:

  • Under Discussion
  • In Progress
  • Completed
  • Rejected,
  • Deferred

Voting:

  • Andrea Aime: +0
  • Ian Turton: +1
  • Jody Garnett: +1
  • Nuno Oliveira: +1
  • Simone Giannecchini: +0
  • Torben Barsballe:

Tasks

Adding new default methods to RenderListener Interface.

API Change

Before:

public interface RenderListener {

    /**
     * Reports that a specific feature has been rendered. The same feature might be reported
     * multiple times, if
     *
     * @param feature
     */
    public void featureRenderer(SimpleFeature feature);

    /**
     * Reports a rendering error. The rendering is not normally stopped on it, a listener that wants
     * to stop it can call {@link GTRenderer#stopRendering()}
     *
     * @param e
     */
    public void errorOccurred(Exception e);
}

After:

public interface RenderListener {

    /**
     * Reports that a specific feature has been rendered. The same feature might be reported
     * multiple times, if
     *
     * @param feature
     */
    public void featureRenderer(SimpleFeature feature);

    /**
     * Reports a rendering error. The rendering is not normally stopped on it, a listener that wants
     * to stop it can call {@link GTRenderer#stopRendering()}
     *
     * @param e
     */
    public void errorOccurred(Exception e);

    /** Event issued when the layer begins rendering */
    default void layerStart(Layer layer) {
        // does nothing
    }
    /** Event issued when the layer completed rendering. May not be issued */
    default void layerEnd(Layer layer) {
        // does nothing
    }
    /** Event issued when labelling starts. May not be issued if there are no labels to paint. */
    default void labellingStart() {
        // does nothing
    }
    /** Event issued when labelling ends. May not be issued */
    default void labellingEnd() {
        // does nothing
    }
    /** Event issued when rendering ends. Always issued. */
    default void renderingComplete() {
        // does nothing
    }
}
Clone this wiki locally