Object
Renderer
- Direct Known Subclasses:
MapCanvasAWT.Renderer
- Enclosing class:
MapCanvas
A snapshot of
MapCanvas
state to render as a map, together with rendering code.
This class is instantiated and used as below:
MapCanvas
invokesMapCanvas.createRenderer()
in the JavaFX thread. That method shall take a snapshot of every information needed for performing the rendering in a background thread.MapCanvas
invokesrender()
in a background thread. That method creates or updates the nodes to show in the canvas but without reading or writing any canvas property; that method should use only the snapshot taken in step 1.MapCanvas
invokescommit(MapCanvas)
in the JavaFX thread. The nodes prepared at step 2 can be transferred toMapCanvas.floatingPane
in that method.
- Since:
- 1.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
commit
(MapCanvas canvas) Invoked in JavaFX thread afterrender()
completion.int
Returns the height (number of rows) of the view, in pixels.int
Returns the width (number of columns) of the view, in pixels.protected abstract void
render()
Invoked in a background thread for rendering the map.
-
Constructor Details
-
Renderer
protected Renderer()
-
-
Method Details
-
getWidth
public int getWidth()Returns the width (number of columns) of the view, in pixels.- Returns:
- number of pixels to render horizontally.
-
getHeight
public int getHeight()Returns the height (number of rows) of the view, in pixels.- Returns:
- number of pixels to render vertically.
-
render
Invoked in a background thread for rendering the map. This method should not access anyMapCanvas
property; if some canvas properties are needed, they should have been copied at construction time.- Throws:
Exception
- if an error occurred while preparing data or rendering them.
-
commit
Invoked in JavaFX thread afterrender()
completion. This method can update theMapCanvas.floatingPane
children with the nodes (images, shaped, etc.) created byrender()
.- Parameters:
canvas
- the canvas where drawing has been done.- Returns:
true
on success, orfalse
if the rendering should be redone (for example because a change has been detected in the data).
-