Class MapCanvasAWT
Object
Observable
Canvas
PlanarCanvas
MapCanvas
MapCanvasAWT
- All Implemented Interfaces:
Localized
- Direct Known Subclasses:
CoverageCanvas
A canvas for maps to be rendered using Java2D from Abstract Window Toolkit.
The map is rendered using Java2D in a background thread, then copied in a JavaFX image.
Java2D is used for rendering the map because it may contain too many elements for a scene graph.
After the map has been rendered, other JavaFX nodes can be put on top of the map, typically for
controls by the user.
- Since:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA snapshot ofMapCanvasAWTstate to paint as an image.Nested classes/interfaces inherited from class MapCanvas
MapCanvas.StaticGraphicsModifier and TypeClassDescriptionstatic classJavaFX nodes rendered using a snapshot of the objective to display transform. -
Property Summary
Properties inherited from class MapCanvas
error, positionalAccuracy, renderingTypePropertyDescriptionReturns a property giving the exception or error that occurred during last rendering operation.final ReadOnlyObjectProperty<Length> Returns a property which gives an estimation of positional accuracy, typically in metres.Returns a property telling whether a rendering is in progress. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ImageViewThe node where the rendered map will be shown.final ObjectProperty<Insets> Number of additional pixels to paint on each sides of the image, outside the viewing area.Fields inherited from class MapCanvas
fixedPane, floatingPaneModifier and TypeFieldDescriptionprotected final StackPaneThe pane showing the map and other JavaFX nodes to keep at fixed position regardless pans, zooms or rotations applied on the map.protected final PaneThe pane showing the map and any other JavaFX nodes to scale and translate together with the map.Fields inherited from class PlanarCanvas
BIDIMENSIONAL, objectiveToDisplayModifier and TypeFieldDescriptionprotected static final intThe 2 constant for identifying code specific to bi-dimensional case.protected final AffineTransformThe conversion from objective CRS to the display coordinate system as a Java2D affine transform.Fields inherited from class Canvas
DISPLAY_BOUNDS_PROPERTY, OBJECTIVE_CRS_PROPERTY, OBJECTIVE_TO_DISPLAY_PROPERTY, POINT_OF_INTEREST_PROPERTYModifier and TypeFieldDescriptionstatic final StringThe "displayBounds" property name, used for notifications about changes in bounds of display device.static final StringThe "objectiveCRS" property name, used for notifications about changes in objective CRS.static final StringThe "objectiveToDisplay" property name, used for notifications about changes in objective to display conversion.static final StringThe "pointOfInterest" property name, used for notifications about changes in point of interest. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MapCanvasAWT.RendererInvoked in JavaFX thread for creating a renderer to be executed in a background thread.Methods inherited from class MapCanvas
clearError, errorOccurred, errorProperty, getContentIdentifier, getObjectiveBounds, initialize, positionalAccuracyProperty, renderingProperty, requestRepaint, reset, runAfterRendering, setObjectiveBounds, setObjectiveToDisplay, setPositionalAccuracy, toString, transformDisplayCoordinates, transformObjectiveCoordinates, usingFixedTransformModifier and TypeMethodDescriptionprotected final voidClears the error message in the status bar.protected voidSets the error property to the given value.Returns a property giving the exception or error that occurred during last rendering operation.Returns an identifier of the rendered data.Returns the data bounds to use for computing the initial "objective to display" transform.protected voidinitialize(GridGeometry visibleArea) Sets the objective bounds and/or the zoom level and objective CRS to use for the initial view of data.final ReadOnlyObjectProperty<Length> Returns a property which gives an estimation of positional accuracy, typically in metres.Returns a property telling whether a rendering is in progress.final voidRequests the map to be rendered again, possibly with new data.voidreset()Resets the map view to its default zoom level and default position with no rotation.protected booleanrunAfterRendering(Runnable task) Registers a task to execute after the background thread finished its current rendering task.voidsetObjectiveBounds(Envelope visibleArea) Sets the data bounds to use for computing the initial value ofPlanarCanvas.objectiveToDisplay.voidsetObjectiveToDisplay(LinearTransform newValue) Sets the conversion from objective CRS to display coordinate system.protected voidsetPositionalAccuracy(Quantity<Length> accuracy) Sets an estimation of the positional accuracy of the pixels or features that are rendered on the map.Returns a string representation of this canvas for debugging purposes.voidUpdates the objective to display transform with the given transform in pixel coordinates.voidUpdates the objective to display transform with the given transform in objective coordinates.Returns a pane where graphics can be added as if the objective to display transform was static.Methods inherited from class PlanarCanvas
getDisplayBoundsModifier and TypeMethodDescriptionReturns the size and location of the display device.Methods inherited from class Canvas
getDisplayCRS, getGeographicArea, getGridGeometry, getLocale, getObjectiveCRS, getObjectiveToDisplay, getPointOfInterest, getSpatialResolution, setDisplayBounds, setGridGeometry, setObjectiveCRS, setPointOfInterestModifier and TypeMethodDescriptionfinal EngineeringCRSReturns the Coordinate Reference System of the display device.Returns the geographic bounding box encompassing the area shown on the display device.Returns canvas properties (CRS, display bounds, conversion) encapsulated in a grid geometry.Returns the locale used for texts or for producing some error messages.Returns the Coordinate Reference System in which all data are transformed before displaying.Returns the (usually affine) conversion from objective CRS to display coordinate system.getPointOfInterest(boolean objective) Returns the coordinates of a point considered representative of the data.Returns an estimation of the resolution (in metres) at the point of interest.voidsetDisplayBounds(Envelope newValue) Sets the size and location of the display device.voidsetGridGeometry(GridGeometry newValue) Sets canvas properties from the given grid geometry.voidsetObjectiveCRS(CoordinateReferenceSystem newValue, DirectPosition anchor) Sets the Coordinate Reference System in which all data are transformed before displaying.voidsetPointOfInterest(DirectPosition newValue) Sets the coordinates of a representative point inside the data bounding box.Methods inherited from class Observable
addPropertyChangeListener, firePropertyChange, firePropertyChange, hasPropertyChangeListener, removePropertyChangeListenerModifier and TypeMethodDescriptionfinal voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Registers a listener for the property of the given name.protected voidNotifies all registered listeners that a property changed its value.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Notifies all registered listeners that a property of the given name changed its value.protected final booleanhasPropertyChangeListener(String propertyName) Returnstrueif the given property has at least one listener.final voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Unregisters a property listener.
-
Field Details
-
imageMargin
Number of additional pixels to paint on each sides of the image, outside the viewing area. Computing a larger image reduces the black borders that user sees during translations or during zoom out before the new image is repainted. -
image
The node where the rendered map will be shown. Its content is prepared in a background thread byMapCanvasAWT.Renderer. Subclasses should not set the image content directly.
-
-
Constructor Details
-
MapCanvasAWT
Creates a new canvas for JavaFX application.- Parameters:
locale- the locale to use for labels and some messages, ornullfor default.
-
-
Method Details
-
createRenderer
Invoked in JavaFX thread for creating a renderer to be executed in a background thread. Subclasses should copy in this method allMapCanvasproperties that the background thread will need for performing the rendering process.- Specified by:
createRendererin classMapCanvas- Returns:
- rendering process to be executed in background thread,
or
nullif there is nothing to paint.
-