Interface ILcdLabelConflictChecker

All Superinterfaces:
Cloneable, ILcdCloneable
All Known Implementing Classes:
TLcdLabelConflictChecker, TLcdNoDeclutterLabelConflictChecker

public interface ILcdLabelConflictChecker extends ILcdCloneable
This interface defines methods to check if adding label placements causes conflicts, depending on other label placement, label obstacles and the view.

The following code snippet shows a typical usage of this interface. Note : this code is only needed for labeling algorithm implementations.


 // Given : a list of possible label placements and a list of label obstacles.
 List<TLcdLabelPlacement> possible_placements = ...
 List<TLcdLabelObstacle> label_obstacles = ...

 // Create and reset a label conflict checker.
 ILcdLabelConflictChecker conflict_checker = ...
 conflict_checker.reset( new Rectangle( 0, 0, view_width, view_height ) );

 // Add all label obstacles to the label conflict checker.
 for ( TLcdLabelObstacle label_obstacle : label_obstacles )
   conflict_checker.addLabelObstacle( label_obstacle );

 // Create a list of label placements which do not overlap with label obstacles or other label placements.
 List<TLcdLabelPlacement> result = new ArrayList<TLcdLabelPlacement>();
 for ( TLcdLabelPlacement placement : possible_placements ) {
   if ( conflict_checker.getConflict( placement ) == null ) {
     // No conflicts.
     conflict_checker.addLabelPlacement( placement );
     result.add( placement );
   }
 }

 
Since:
10.1
  • Method Details

    • reset

      void reset(Rectangle aViewBounds)
      Resets the conflict checker. After calling this method the conflict checker behaves as if no placements or obstacles are added.
      Parameters:
      aViewBounds - the view bounds.
    • addLabelObstacle

      void addLabelObstacle(TLcdLabelObstacle aLabelObstacle)
      Add the given obstacle to this label conflict checker. After this method is called, the getConflict method can use the given obstacle to detect conflicts.

      After calling this method, it is possible that this bounds conflict checker keeps a reference to the given obstacle. By consequence, the given obstacle should not be changed outside this method. The given obstacle cannot be changed inside this method.

      Adding the same obstacle instance twice should have the exact same effect as adding the obstacle instance only once.

      Parameters:
      aLabelObstacle - an obstacle.
    • removeLabelObstacle

      void removeLabelObstacle(TLcdLabelObstacle aLabelObstacle)
      Removes the given obstacle from the conflict checker. This method should only be called for the given obstacle if it had been added before by addLabelObstacle.

      After calling this method, it is possible that this bounds conflict checker keeps a reference to the given obstacle. By consequence, the given obstacle should never be changed outside this method. The given obstacle cannot be changed inside this method.

      Parameters:
      aLabelObstacle - a label obstacle.
    • getLabelObstacles

      List<TLcdLabelObstacle> getLabelObstacles()
      Returns all label obstacles that were added to (and not removed from) this conflict checker. Adjusting the returned list should not influence the working of this conflict checker. The returned obstacles should not be adjusted.
      Returns:
      a list of all added obstacles.
    • addLabelPlacement

      void addLabelPlacement(TLcdLabelPlacement aPlacement)
      Add the given label placement to this label conflict checker. The given label placement should be properly initialized and should contain a valid bounds. After this method is called, the getConflict method can use the given placement to detect conflicts.

      After calling this method, it is possible that this bounds conflict checker keeps a reference to the given label placement. By consequence, the bounds information in the given placement should not be changed outside this method. The given label placement cannot be changed inside this method.

      Adding the same label placement instance twice should have the exact same effect as adding the label placement instance only once.

      Parameters:
      aPlacement - a label placement.
    • removeLabelPlacement

      void removeLabelPlacement(TLcdLabelPlacement aPlacement)
      Removes the given label placement from the conflict checker. The given label placement should be properly initialized and should contain a valid bounds. This method should only be called for the given label placement if it had been added before using addLabelPlacement.

      After calling this method, it is possible that this bounds conflict checker keeps a reference to the given label placement. By consequence, the bounds inside the given label placement should never be changed outside this method. The given bounds cannot be changed inside this method.

      Parameters:
      aPlacement - a label placement.
    • getLabelPlacements

      List<TLcdLabelPlacement> getLabelPlacements()
      Returns all label placements that were added to (and not removed from) this conflict checker. Adjusting the returned list should not influence the working of this conflict checker. The bounds inside the returned label placements should not be adjusted.
      Returns:
      a list of all added label placements.
    • getConflict

      Checks if the given label placement is valid, i.e. if it doesn't overlap with already added label placements or label obstacles. It also checks if the given label placement at least partially overlaps with the view bounds. The given label placement should be properly initialized and should contain a valid bounds. The given label placement cannot be changed inside this method.

      When no conflict is found, the returned Conflict should be null.

      Parameters:
      aPlacement - a label placement.
      Returns:
      a conflict object containing information about the cause(s) of the conflict, or null if no conflict was found.