Class ValuesUnderCursor.Formatter

Object
Formatter
All Implemented Interfaces:
Runnable
Enclosing class:
Values­Under­Cursor

protected abstract static class ValuesUnderCursor.Formatter extends Object implements Runnable
Task for fetching and formatting values in a background thread. The background thread and the interaction with JavaFX thread are managed by the enclosing class. The same Formatter instance can be reused as long as the source of data does not change.

As a rule of thumbs, all properties in Values­Under­Cursor class shall be read and written from the JavaFX thread, while all properties in this Formatter class may be read and written from any thread.

Since:
1.3
  • Constructor Details

    • Formatter

      protected Formatter(ValuesUnderCursor owner)
      Creates a new formatter instance.
      Parameters:
      owner - instance of the enclosing class which will evaluate values under cursor position.
  • Method Details

    • run

      public void run()
      Invoked in a background thread for formatting values at the most recent position. If the cursor moves while this method is formatting values, then this method will continue its execution for formatting also the values at new positions until the cursor stop moving.

      This method does not need to be invoked explicitly; it is invoked automatically by Values­Under­Cursor. But it may be overridden for adding pretreatment or post-treatment.

      Specified by:
      run in interface Runnable
    • evaluate

      public abstract String evaluate(DirectPosition point)
      Returns a string representation of data under the given "real world" position. The position CRS should be non-null for avoiding ambiguity about what is the default CRS. The position CRS may be anything; this method shall transform coordinates itself if needed.

      This method is invoked by run() in a background thread. Implementations are responsible for fetching data in a thread-safe manner.

      Parameters:
      point - the cursor location in arbitrary CRS (usually the CRS shown in the status bar). May be null for declaring that the point is outside canvas region.
      Returns:
      string representation of data under given position, or null if none.