Class MapCanvas.StaticGraphics
Object
StaticGraphics
- Enclosing class:
MapCanvas
JavaFX nodes rendered using a snapshot of the objective to display transform.
This object provides a way to show shapes more easily than adding them as
floatingPane children,
but at the expanse of quality. This object is easier to use because it allows to ignore the dynamic nature
of the transform managed by the enclosing canvas.
Instead, users can add shapes with coordinate values computed with a snapshot of the transform at the time when this instance is obtained,
then ignore all changes in the enclosing canvas that may happen afterward.
While this object allows a much easier strategy than adding shapes into floatingPane
and tracking objective to display changes, the result is rougher (especially after zooms).
For this reason, this object should be used for short-lived shapes such as animation effects,
when the high-quality strategy is not worth the effort. The nodes added through this object
may disappear at any time, for example after a change of objective CRS.
- Since:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe CRS which is the source of the objective to display transform.final LinearTransformThe (usually affine) conversion from objective CRS to display coordinate system. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStaticGraphics(MapCanvas canvas) Creates a snapshot of the objective to display transform from the given canvas. -
Method Summary
Modifier and TypeMethodDescriptionReturns children to show with coordinates computed from the objective to display snapshot.protected MapCanvas.StaticGraphicsunique()Returns a unique instance of this snapshot.
-
Field Details
-
objectiveCRS
The CRS which is the source of the objective to display transform. This is the value ofCanvas.getObjectiveCRS()at the time when thisStaticGraphicsinstance has been obtained. May benullif the snapshot was created beforeCanvaswas initialized with data.- See Also:
-
objectiveToDisplay
The (usually affine) conversion from objective CRS to display coordinate system. This is the value ofCanvas.getObjectiveToDisplay()at the time when thisStaticGraphicsinstance has been obtained. This is nevernull.- See Also:
-
-
Constructor Details
-
StaticGraphics
Creates a snapshot of the objective to display transform from the given canvas. This constructor is made available forMapCanvassubclasses wanting to override theirMapCanvas.usingFixedTransform()method. This constructor should be used in a code equivalent to the following snippet:@Override public StaticGraphics usingFixedTransform() { return new MySubclass(this).unique(); }- Parameters:
canvas- the enclosing canvas.- See Also:
-
-
Method Details
-
unique
Returns a unique instance of this snapshot. If the canvas specified at construction time already contains anStaticGraphicsof the same class asthisand with equalobjectiveCRSandobjectiveToDisplaytransform, then that snapshot is returned andthisshould be discarded. Otherwise, this method returnsthis.- Returns:
- a unique instance of this snapshot.
-
getChildren
Returns children to show with coordinates computed from the objective to display snapshot. The shapes added in the children list should use an animation effect such asFadeTransitionand be removed from the list after a few seconds. This method shall be invoked from the JavaFX thread.- Returns:
- children to show using the objective to display snapshot.
-