Class PlanarCanvas
- All Implemented Interfaces:
Localized
- Direct Known Subclasses:
MapCanvas
Thread safety
PlanarCanvas is not thread-safe.
A single thread should be used for interactions with all instances of PlanarCanvas that are
linked together by CanvasFollower or other listeners.
External synchronization is generally not sufficient because listeners may create a graph of canvases,
and it is difficult to ensure that a lock is kept during all the graph traversal.- Since:
- 1.1
-
Field Summary
FieldsModifier 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
ConstructorsModifierConstructorDescriptionprotectedPlanarCanvas(Locale locale) Creates a new two-dimensional canvas. -
Method Summary
Modifier and TypeMethodDescriptionReturns the size and location of the display device.voidUpdates the objective to display transform as if the given transform was applied after the current transform.voidUpdates the objective to display transform as if the given transform was applied before the current transform.Methods inherited from class Canvas
getDisplayCRS, getGeographicArea, getGridGeometry, getLocale, getObjectiveCRS, getObjectiveToDisplay, getPointOfInterest, getSpatialResolution, setDisplayBounds, setGridGeometry, setObjectiveCRS, setObjectiveToDisplay, 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.voidsetObjectiveToDisplay(LinearTransform newValue) Sets the conversion from objective CRS to display coordinate system.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
-
BIDIMENSIONAL
protected static final int BIDIMENSIONALThe 2 constant for identifying code specific to bi-dimensional case.- See Also:
-
objectiveToDisplay
The conversion from objective CRS to the display coordinate system as a Java2D affine transform. This transform will be modified in-place when user applies zoom, translation or rotation on the view area. Subclasses should generally not modify this affine transform directly; invoke one of thetransformFooCoordinates(AffineTransform)methods instead.- See Also:
-
-
Constructor Details
-
PlanarCanvas
Creates a new two-dimensional canvas.- Parameters:
locale- the locale to use for labels and some messages, ornullfor default.
-
-
Method Details
-
getDisplayBounds
Returns the size and location of the display device. The unit of measurement isUnits.PIXELand coordinate values are usually (but not necessarily) integers.This value may be
nullon newly createdPlanarCanvas, before data are added and canvas is configured. It should not benullanymore once aPlanarCanvasis ready for displaying.The returned envelope is a copy: display changes happening after this method invocation will not be reflected in the returned envelope.
- Overrides:
getDisplayBoundsin classCanvas- Returns:
- size and location of the display device in pixel coordinates.
- See Also:
-
transformObjectiveCoordinates
Updates the objective to display transform as if the given transform was applied before the current transform. For example if the givenbeforetransform is a translation, then the translation vector is in units of the objective CRS (typically metres on the map).This method does nothing if the given transform is identity. Otherwise an "objectiveToDisplay" property change event will be sent with the
TransformChangeEvent.Reason.OBJECTIVE_NAVIGATIONreason after the change became effective. Depending on the implementation, the change may not take effect immediately. For example, subclasses may do the rendering in a background thread.- Parameters:
before- coordinate conversion to apply before the current objective to display transform.- See Also:
-
transformDisplayCoordinates
Updates the objective to display transform as if the given transform was applied after the current transform. For example if the givenaftertransform is a translation, then the translation vector is in pixel units.This method does nothing if the given transform is identity. Otherwise an "objectiveToDisplay" property change event will be sent with the
TransformChangeEvent.Reason.DISPLAY_NAVIGATIONreason after the change became effective. Depending on the implementation, the change may not take effect immediately. For example, subclasses may do the rendering in a background thread.- Parameters:
after- coordinate conversion to apply after the current objective to display transform.- See Also:
-