Class PlanarCanvas
- All Implemented Interfaces:
Localized
Multi-threading
PlanarCanvas is not thread-safe. Synchronization, if desired, must be done by the caller.
Another common strategy is to interact with PlanarCanvas from a single thread,
for example the Swing or JavaFX event queue.- Since:
- 1.1
- Version:
- 1.3
-
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 org.apache.sis.portrayal.Canvas
DISPLAY_BOUNDS_PROPERTY, displayBounds, OBJECTIVE_CRS_PROPERTY, OBJECTIVE_TO_DISPLAY_PROPERTY, POINT_OF_INTEREST_PROPERTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPlanarCanvas(Locale locale) Creates a new two-dimensional canvas. -
Method Summary
Modifier and TypeMethodDescription(package private) final org.opengis.geometry.DirectPositionAllocates a position which can hold a coordinates in objective or display CRS.(package private) final LinearTransformReturns the affine conversion from objective CRS to display coordinate system.(package private) final voidgetDisplayAxes(org.opengis.metadata.spatial.DimensionNameType[] axisTypes) Gets the name of display axes and stores them in the given array.Returns the size and location of the display device.(package private) final intReturns the number of dimensions of the display device.(package private) final voidsetObjectiveToDisplayImpl(LinearTransform newValue) Sets the conversion from objective CRS to display coordinate system.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 org.apache.sis.portrayal.Canvas
getDisplayCRS, getGeographicArea, getGridGeometry, getLocale, getObjectiveCRS, getObjectivePOI, getObjectiveToDisplay, getPointOfInterest, getSpatialResolution, setDisplayBounds, setGridGeometry, setObjectiveCRS, setObjectiveToDisplay, setPointOfInterestMethods inherited from class org.apache.sis.portrayal.Observable
addPropertyChangeListener, firePropertyChange, firePropertyChange, hasPropertyChangeListener, removePropertyChangeListener
-
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.
-
-
Constructor Details
-
PlanarCanvas
Creates a new two-dimensional canvas.- Parameters:
locale- the locale to use for labels and some messages, ornullfor default.
-
-
Method Details
-
getDisplayDimensions
final int getDisplayDimensions()Returns the number of dimensions of the display device.- Overrides:
getDisplayDimensionsin classCanvas
-
getDisplayAxes
final void getDisplayAxes(org.opengis.metadata.spatial.DimensionNameType[] axisTypes) Gets the name of display axes and stores them in the given array. Those display axis names are used for debugging purposes only, as an additional information provided to developers. Those names should not be used for any "real" work.- Overrides:
getDisplayAxesin classCanvas- Parameters:
axisTypes- where to store the name of display axes. The array length will be at leastBIDIMENSIONAL(it will often be longer).
-
allocatePosition
final org.opengis.geometry.DirectPosition allocatePosition()Allocates a position which can hold a coordinates in objective or display CRS.- Overrides:
allocatePositionin classCanvas
-
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 createdCanvas, before data are added and canvas is configured. It should not benullanymore once aCanvasis 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:
-
createObjectiveToDisplay
Returns the affine conversion from objective CRS to display coordinate system. The transform returned by this method is a snapshot taken at the time this method is invoked; subsequent changes in the objective to display conversion are not reflected in the returned transform.The
Canvas.objectiveToDisplaytransform in parent class is used as an immutable snapshot of theobjectiveToDisplaytransform in this class. That snapshot is created when needed and reset tonullwhenobjectiveToDisplayis modified.- Overrides:
createObjectiveToDisplayin classCanvas- Returns:
- snapshot of the affine conversion from objective CRS
to display coordinate system (never
null). - See Also:
-
setObjectiveToDisplayImpl
Sets the conversion from objective CRS to display coordinate system. Contrarily to other setter methods, this method does not notify listeners about that change; it is caller responsibility to send a "objectiveToDisplay" change event. This method does not update the "pointOfInterest" property; the point of interest may move outside the view area as a result of this method call.- Overrides:
setObjectiveToDisplayImplin classCanvas- Parameters:
newValue- the new objective to display conversion.- Throws:
IllegalArgumentException- if the given transform is not two-dimensional or is not affine.- 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:
-