Interface ILspLabelConflictChecker

All Superinterfaces:
Cloneable, ILcdCloneable
All Known Implementing Classes:
TLspLabelConflictChecker, TLspNoDeclutterLabelConflictChecker

public interface ILspLabelConflictChecker extends ILcdCloneable
This interface defines methods to check if adding label placements causes conflicts, depending on other label placement, 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 placements and a list of obstacles.
 List<TLspLabelPlacement> possible_placements = ...
 List<TLspLabelObstacle> obstacles = ...

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

 // Add all obstacles to the conflict checker.
 for ( TLspLabelObstacle obstacle : obstacles )
   conflict_checker.addLabelObstacle( obstacle );

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

 
Since:
2012.0
  • 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.
    • addObstacle

      void addObstacle(TLspLabelObstacle aObstacle)
      Add the given obstacle to this 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:
      aObstacle - an obstacle.
    • removeObstacle

      void removeObstacle(TLspLabelObstacle aObstacle)
      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 addObstacle.

      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:
      aObstacle - an obstacle.
    • getObstacles

      List<TLspLabelObstacle> getObstacles()
      Returns all 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.
    • addPlacement

      void addPlacement(TLspLabelPlacement aPlacement)
      Add the given label placement to this 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.
    • removePlacement

      void removePlacement(TLspLabelPlacement 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 addPlacement.

      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.
    • getPlacements

      List<TLspLabelPlacement> getPlacements()
      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 placement is valid, that is if it does not overlap with already added placements or obstacles. It also checks if the given placement at least partially overlaps with the view bounds. The given placement should be properly initialized and should contain a valid bounds. The given 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.