Class StreamingRendererJFX

java.lang.Object
org.jorigin.geotools.StreamingRendererJFX
All Implemented Interfaces:
GTRendererJFX

public class StreamingRendererJFX extends Object implements GTRendererJFX
A GeoTools map renderer that draws directly onto a JavaFX Canvas using the JavaFX GraphicsContext API — no AWT dependency.

The rendering pipeline iterates over the MapContent layers and handles each layer type:

  • FeatureLayer — vector layers with SLD-based symbolization (polygon, line, point symbolizers); geometries are converted to JavaFX path commands via JTS CoordinateSequence traversal.
  • WMSLayer — raster layers fetched from a WMS server via a GetMap request; the response image is loaded asynchronously and drawn onto the canvas when available.
  • WMTSMapLayer — tiled raster layers fetched through the GridCoverage2DReader exposed by WMTSMapLayer; the read (which performs GetTile requests and composites the tiles) runs on a background thread and the resulting image is drawn onto the canvas when available.

Layer compositing: WMS layers are drawn asynchronously on top of whatever is already on the canvas; feature layers are drawn synchronously on top of WMS content. The canvas is only cleared on resize — during pan/zoom the old image remains visible until the new WMS response arrives.

Usage (on the JavaFX application thread):


   StreamingRendererJFX renderer = new StreamingRendererJFX();
   somePane.getChildren().add(renderer.getCanvas());
   renderer.paint(mapContent, 800, 600, envelope);
 

paint(org.geotools.map.MapContent, double, double, org.geotools.geometry.jts.ReferencedEnvelope) must be called on the JavaFX application thread. stopRendering() may be called from any thread.

Author:
Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a streaming renderer with default parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.scene.canvas.Canvas
    Returns the Canvas node onto which the map is rendered.
    void
    paint(org.geotools.map.MapContent content, double w, double h, org.geotools.geometry.jts.ReferencedEnvelope area)
    Renders the given map content onto the internal Canvas.
    void
    Signals the current render to stop after the current feature.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StreamingRendererJFX

      public StreamingRendererJFX()
      Create a streaming renderer with default parameters.
  • Method Details

    • getCanvas

      public javafx.scene.canvas.Canvas getCanvas()
      Returns the Canvas node onto which the map is rendered. Add it to the JavaFX scene graph to display the map.
      Specified by:
      getCanvas in interface GTRendererJFX
      Returns:
      the display canvas
    • paint

      public void paint(org.geotools.map.MapContent content, double w, double h, org.geotools.geometry.jts.ReferencedEnvelope area)
      Renders the given map content onto the internal Canvas.

      Must be called on the JavaFX application thread.

      Specified by:
      paint in interface GTRendererJFX
      Parameters:
      content - the map content to render
      w - target width in pixels
      h - target height in pixels
      area - the world-coordinate envelope to render
    • stopRendering

      public void stopRendering()
      Signals the current render to stop after the current feature. Safe to call from any thread.
      Specified by:
      stopRendering in interface GTRendererJFX