Package org.apache.sis.portrayal
Class TransformChangeEvent
java.lang.Object
java.util.EventObject
java.beans.PropertyChangeEvent
org.apache.sis.portrayal.TransformChangeEvent
- All Implemented Interfaces:
Serializable
A change in the "objective to display" transform that
Canvas
uses for rendering data.
That transform is updated frequently following gestures events such as zoom, translation or rotation.
All events fired by Canvas
for the "objectiveToDisplay" property
are instances of this class.
This specialization provides methods for computing the difference between the old and new state.
Multi-threading
This class is not thread-safe. All listeners should process this event in the same thread.- Since:
- 1.3
- Version:
- 1.3
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The reason why the "objective to display" transform changed. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LinearTransform
The change from old coordinates to new coordinates, computed when first needed.private AffineTransform
Value ofdisplayChange
orobjectiveChange
precomputed by the code that fired this event.private Exception
Non-null ifcanNotCompute(String, NoninvertibleTransformException)
already reported an error.private LinearTransform
The change from old coordinates to new coordinates, computed when first needed.private AffineTransform
Value ofdisplayChange
orobjectiveChange
precomputed by the code that fired this event.private final TransformChangeEvent.Reason
The reason why the "objective to display" transform changed.private static final long
For cross-version compatibility.Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorsConstructorDescriptionTransformChangeEvent
(Canvas source, LinearTransform oldValue, LinearTransform newValue, AffineTransform objective, AffineTransform display, TransformChangeEvent.Reason reason) Creates a new event for an incremental change of the "objective to display" property.TransformChangeEvent
(Canvas source, LinearTransform oldValue, LinearTransform newValue, TransformChangeEvent.Reason reason) Creates a new event for a change of the "objective to display" property. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
canNotCompute
(String method, Exception e) Invoked when a change cannot be computed.Returns the change from old display coordinates to new display coordinates.Returns the change in display coordinates as a Java2D affine transform.Gets the new "objective to display" transform.Returns the change from old objective coordinates to new objective coordinates.Returns the change in objective coordinates as a Java2D affine transform.Gets the old "objective to display" transform.Returns the reason why the "objective to display" transform changed.Returns the canvas on which this event initially occurred.(package private) final boolean
isSameSource
(Canvas source) Quick and non-overrideable check about whether the specified source is the source of this event.Methods inherited from class java.beans.PropertyChangeEvent
getPropagationId, getPropertyName, setPropagationId, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
reason
The reason why the "objective to display" transform changed.- See Also:
-
displayChange
The change from old coordinates to new coordinates, computed when first needed.- See Also:
-
objectiveChange
The change from old coordinates to new coordinates, computed when first needed.- See Also:
-
displayChange2D
Value ofdisplayChange
orobjectiveChange
precomputed by the code that fired this event. If not precomputed, will be computed when first needed. -
objectiveChange2D
Value ofdisplayChange
orobjectiveChange
precomputed by the code that fired this event. If not precomputed, will be computed when first needed. -
error
Non-null ifcanNotCompute(String, NoninvertibleTransformException)
already reported an error. This is used for avoiding to report many times the same error.
-
-
Constructor Details
-
TransformChangeEvent
public TransformChangeEvent(Canvas source, LinearTransform oldValue, LinearTransform newValue, TransformChangeEvent.Reason reason) Creates a new event for a change of the "objective to display" property. The old and new transforms should not be null, except on initialization or for lazy computation: a nullnewValue
means to take the value fromCanvas.getObjectiveToDisplay()
when needed.- Parameters:
source
- the canvas that fired the event.oldValue
- the old "objective to display" transform, ornull
if none.newValue
- the new transform, ornull
for lazy computation.reason
- the reason why the "objective to display" transform changed..- Throws:
IllegalArgumentException
- ifsource
isnull
.
-
TransformChangeEvent
public TransformChangeEvent(Canvas source, LinearTransform oldValue, LinearTransform newValue, AffineTransform objective, AffineTransform display, TransformChangeEvent.Reason reason) Creates a new event for an incremental change of the "objective to display" property. The incremental change can be specified by theobjective
and/or thedisplay
argument. Usually only one of those two arguments is non-null.- Parameters:
source
- the canvas that fired the event.oldValue
- the old "objective to display" transform, ornull
if none.newValue
- the new transform, ornull
for lazy computation.objective
- the incremental change in objective coordinates, ornull
for lazy computation.display
- the incremental change in display coordinates, ornull
for lazy computation.reason
- the reason why the "objective to display" transform changed..- Throws:
IllegalArgumentException
- ifsource
isnull
.
-
-
Method Details
-
isSameSource
Quick and non-overrideable check about whether the specified source is the source of this event. -
getSource
Returns the canvas on which this event initially occurred.- Overrides:
getSource
in classEventObject
- Returns:
- the canvas on which this event initially occurred.
-
getReason
Returns the reason why the "objective to display" transform changed. It may be because of canvas initialization, or an adjustment for a change of CRS without change in the viewing area, or a navigation for viewing a different area.- Returns:
- the reason why the "objective to display" transform changed.
-
getOldValue
Gets the old "objective to display" transform.- Overrides:
getOldValue
in classPropertyChangeEvent
- Returns:
- the old "objective to display" transform, or
null
if none.
-
getNewValue
Gets the new "objective to display" transform. It should be the current value ofCanvas.getObjectiveToDisplay()
.- Overrides:
getNewValue
in classPropertyChangeEvent
- Returns:
- the new "objective to display" transform.
-
getObjectiveChange
Returns the change from old objective coordinates to new objective coordinates. When the "objective to display" transform changed (e.g. because the user did a zoom, translation or rotation), this method expresses how the "real world" coordinates (typically in metres) of any point on the screen changed.Example: if the map is shifted 10 metres toward the right side of the canvas, then (assuming no rotation or axis flip) the x translation coefficient of the change is +10 (same sign thanThegetDisplayChange()
). Note that it may correspond to any amount of pixels, depending on the zoom factor.getObjectiveChange2D()
method gives the same transform as a Java2D object. That change can be replicated on another canvas by giving the transform toPlanarCanvas.transformObjectiveCoordinates(AffineTransform)
.- Returns:
- the change in objective coordinates. Usually not
null
, unless one of the canvas is initializing or has a non-invertible transform.
-
getDisplayChange
Returns the change from old display coordinates to new display coordinates. When the "objective to display" transform changed (e.g. because the user did a zoom, translation or rotation), this method expresses how the display coordinates (typically pixels) of any given point on the map changed.Example: if the map is shifted 10 pixels toward the right side of the canvas, then (assuming no rotation or axis flip) the x translation coefficient of the change is +10: the points on the map which were located at x=0 pixel before the change are now located at x=10 pixels after the change.ThegetDisplayChange2D()
method gives the same transform as a Java2D object. That change can be replicated on another canvas by giving the transform toPlanarCanvas.transformDisplayCoordinates(AffineTransform)
.- Returns:
- the change in display coordinates. Usually not
null
, unless one of the canvas is initializing or has a non-invertible transform.
-
getObjectiveChange2D
Returns the change in objective coordinates as a Java2D affine transform. This method is suitable for two-dimensional canvas only. For performance reason, it does not clone the returned transform.- Returns:
- the change in objective coordinates. Do not modify.
- See Also:
-
getDisplayChange2D
Returns the change in display coordinates as a Java2D affine transform. This method is suitable for two-dimensional canvas only. For performance reason, it does not clone the returned transform.- Returns:
- the change in display coordinates. Do not modify.
- See Also:
-
canNotCompute
Invoked when a change cannot be computed. It should never happen because "objective to display" transforms should always be invertible. If this error nevertheless happens, consider the change as a missing optional information.
-