Class MapCanvas.StaticGraphics

Object
StaticGraphics
Enclosing class:
Map­Canvas

public static class MapCanvas.StaticGraphics extends Object
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 floating­Pane 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 floating­Pane 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 Details

  • Constructor Details

    • StaticGraphics

      protected StaticGraphics(MapCanvas canvas)
      Creates a snapshot of the objective to display transform from the given canvas. This constructor is made available for Map­Canvas subclasses wanting to override their Map­Canvas​.using­Fixed­Transform() 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

      protected MapCanvas.StaticGraphics unique()
      Returns a unique instance of this snapshot. If the canvas specified at construction time already contains an Static­Graphics of the same class as this and with equal objective­CRS and objective­To­Display transform, then that snapshot is returned and this should be discarded. Otherwise, this method returns this.
      Returns:
      a unique instance of this snapshot.
    • getChildren

      public ObservableList<Node> 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 as Fade­Transition and 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.