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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
commit
(MapCanvas canvas) Invoked in JavaFX thread after successfulpaint(Graphics2D)
completion.protected abstract void
paint
(Graphics2D gr) Invoked afterrender()
for doing the actual map painting.protected void
render()
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 needGraphics2D
handler. Doing work in advance allow to hold theGraphics2D
handler for a shorter time.The default implementation does nothing.
- Specified by:
render
in 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 ifVolatileImage
content is invalidated in the middle of rendering process. This method should not access anyMapCanvas
property; 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.floatingPane
children with the nodes (images, shaped, etc.) created byrender()
. If this method detects that data has changed during the timeRenderer
was working in background, then this method can returntrue
for requesting a new repaint. In such case that repaint will use a newMapCanvasAWT.Renderer
instance; the current instance will not be reused.The default implementation does nothing and returns
true
.- Specified by:
commit
in classMapCanvas.Renderer
- Parameters:
canvas
- the canvas where drawing has been done. It will be aMapCanvasAWT
instance.- Returns:
true
on success, orfalse
if the rendering should be redone (for example because a change has been detected in the data).
-