Class LabelIndex

Object
LabelIndex

public class LabelIndex extends Object
Stores label envelopes and detects interference by overlap or proximity.

Backed by LabelQuadtree for O(log n) spatial pruning with true early-exit on first hit. Pass margin large enough to contain any label that may be positioned outside the display area (e.g. with partialsEnabled).

Author:
Andrea Aime
  • Constructor Details

    • LabelIndex

      public LabelIndex(Rectangle displayArea, int margin)
      Parameters:
      displayArea - rendering area in screen coordinates
      margin - extra space beyond displayArea to accommodate labels outside the display area
  • Method Details

    • labelsWithinDistance

      public boolean labelsWithinDistance(Rectangle2D bounds, double distance)
      Returns true if any label in the index is within distance of bounds. The bounds are expanded by the distance (no curved buffer).
    • addLabel

      public void addLabel(LabelCacheItem item, Rectangle2D bounds)
      Adds a label into the index.
    • reserveArea

      public void reserveArea(List<Rectangle2D> reserved)
      Reserves the areas indicated by these rectangles.