Package org.apache.sis.gui.map
Class MapCanvasAWT.Renderer
Object
MapCanvas.Renderer
Renderer
- Enclosing class:
MapCanvasAWT
A snapshot of
This class should not access any
MapCanvasAWT state to paint as an image.
The snapshot is created in JavaFX thread by the MapCanvasAWT.createRenderer() method,
then the rendering process is executed in a background thread.
Methods are invoked in the following order:
| Method | Thread | Remarks |
|---|---|---|
MapCanvas.createRenderer() | JavaFX thread | Collects all needed information. |
render() | Background thread | Computes what can be done in advance. |
paint(Graphics2D) | Background thread | Holds a Graphics2D. |
commit(MapCanvas) | JavaFX thread | Saves data to cache for reuse. |
MapCanvasAWT property from a method invoked in background thread
(render() and paint(Graphics2D)). It may access MapCanvasAWT properties from the
commit(MapCanvas) method.- Since:
- 1.1
Defined in the sis-javafx module
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancommit(MapCanvas canvas) Invoked in JavaFX thread after successfulpaint(Graphics2D)completion.protected abstract voidpaint(Graphics2D gr) Invoked afterrender()for doing the actual map painting.protected voidrender()Invoked in a background thread beforepaint(Graphics2D).Methods inherited from class MapCanvas.Renderer
getHeight, getWidth
-
Constructor Details
-
Renderer
protected Renderer()Creates a new renderer. The width and height are initially zero; they will get a non-zero values beforepaint(Graphics2D)is invoked.
-
-
Method Details
-
render
Invoked in a background thread beforepaint(Graphics2D). Subclasses can override this method if some rendering steps do not needGraphics2Dhandler. Doing work in advance allow to hold theGraphics2Dhandler for a shorter time.The default implementation does nothing.
- Specified by:
renderin classMapCanvas.Renderer- Throws:
Exception- if an error occurred while preparing data.
-
paint
Invoked afterrender()for doing the actual map painting. This method is invoked in a background thread, potentially many times ifVolatileImagecontent is invalidated in the middle of rendering process. This method should not access anyMapCanvasproperty; if some canvas properties are needed, they should have been copied at construction time.- Parameters:
gr- the Java2D handler to use for rendering the map.
-
commit
Invoked in JavaFX thread after successfulpaint(Graphics2D)completion. This method can update theMapCanvas.floatingPanechildren with the nodes (images, shaped, etc.) created byrender(). If this method detects that data has changed during the timeRendererwas working in background, then this method can returntruefor requesting a new repaint. In such case that repaint will use a newMapCanvasAWT.Rendererinstance; the current instance will not be reused.The default implementation does nothing and returns
true.- Specified by:
commitin classMapCanvas.Renderer- Parameters:
canvas- the canvas where drawing has been done. It will be aMapCanvasAWTinstance.- Returns:
trueon success, orfalseif the rendering should be redone (for example because a change has been detected in the data).
-