Interface IPickable

All Known Implementing Classes:
ShapeFeatureRenderer

public interface IPickable
Implemented by map renderers that support mouse-over hit testing.

Any layer that wants to contribute text to the feedback panel or the hover popup when the user moves the cursor over a feature should implement this interface and return a formatted string describing the feature under the cursor.

Contract

  • pick(Point, IContainer) must never throw; it should return null silently if no feature is hit or if the pick cache has not yet been populated by a render call.
  • The returned string may contain multiple lines separated by '\n' if the caller splits and displays them individually, but a single line is the common case.
  • Implementations are expected to use a cached version of the projected geometry built during the most recent ShapeFeatureRenderer.render(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer) call, so picking is O(n) in the number of cached features and does not require re-projecting coordinates.

Render-before-pick dependency

Because picking uses the cached projected geometry, pick must be called after at least one render call. In practice this is always satisfied because mouse-over events cannot fire before the component is painted. Callers should still null-check the return value.

Current implementors

  • ShapeFeatureRenderer — picks polygon, polyline, and point features from arbitrary shapefile layers and returns the names and values of the configured feedback fields.
  • Method Summary

    Modifier and Type
    Method
    Description
    pick(Point mouseLocal, IContainer container)
    Returns a human-readable description of the feature under the given mouse position, or null if no feature is hit.
  • Method Details

    • pick

      String pick(Point mouseLocal, IContainer container)
      Returns a human-readable description of the feature under the given mouse position, or null if no feature is hit.

      The description is suitable for both the feedback pane and hover popup (e.g. "Lake Superior" or "Amazon River length: 6400 km").

      Parameters:
      mouseLocal - the cursor position in the container's local (screen) coordinate space; must not be null
      container - the container providing coordinate transforms; must not be null
      Returns:
      a non-empty description string, or null if no feature was hit