Object
EventObject
PropertyChangeEvent
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
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The reason why the "objective to display" transform changed. -
Field Summary
Fields inherited from class EventObject
source
-
Constructor Summary
ConstructorDescriptionTransformChangeEvent
(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 TypeMethodDescriptionReturns 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.Methods inherited from class PropertyChangeEvent
getPropagationId, getPropertyName, setPropagationId, toString
-
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
-
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:
-