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:
MapCanvasinvokesMapCanvas.createRenderer()in the JavaFX thread. That method shall take a snapshot of every information needed for performing the rendering in a background thread.MapCanvasinvokesrender()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.MapCanvasinvokescommit(MapCanvas)in the JavaFX thread. The nodes prepared at step 2 can be transferred toMapCanvas.floatingPanein that method.
- Since:
- 1.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancommit(MapCanvas canvas) Invoked in JavaFX thread afterrender()completion.intReturns the height (number of rows) of the view, in pixels.intReturns the width (number of columns) of the view, in pixels.protected abstract voidrender()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 anyMapCanvasproperty; 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.floatingPanechildren with the nodes (images, shaped, etc.) created byrender().- Parameters:
canvas- the canvas where drawing has been done.- Returns:
trueon success, orfalseif the rendering should be redone (for example because a change has been detected in the data).
-