Class TLcdLabelConflictChecker

java.lang.Object
com.luciad.view.labeling.algorithm.TLcdLabelConflictChecker
All Implemented Interfaces:
ILcdCloneable, ILcdLabelConflictChecker, Cloneable

public class TLcdLabelConflictChecker extends Object implements ILcdLabelConflictChecker
This label conflict checker implements ILcdLabelConflictChecker by checking if a given label placements overlaps with other placements, label obstacles or the view bounds by calculating their intersection analytically.

This label conflict checker uses the bounds retrieved using TLcdLabelPlacement.getX(), TLcdLabelPlacement.getY(), TLcdLabelPlacement.getWidth(), TLcdLabelPlacement.getHeight() and TLcdLabelPlacement.getRotation().

Since:
10.1
  • Constructor Details

    • TLcdLabelConflictChecker

      public TLcdLabelConflictChecker()
  • Method Details

    • clone

      public TLcdLabelConflictChecker clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      See Also:
    • reset

      public void reset(Rectangle aViewBounds)
      Description copied from interface: ILcdLabelConflictChecker
      Resets the conflict checker. After calling this method the conflict checker behaves as if no placements or obstacles are added.
      Specified by:
      reset in interface ILcdLabelConflictChecker
      Parameters:
      aViewBounds - the view bounds.
    • addLabelObstacle

      public void addLabelObstacle(TLcdLabelObstacle aLabelObstacle)
      Description copied from interface: ILcdLabelConflictChecker
      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.

      Specified by:
      addLabelObstacle in interface ILcdLabelConflictChecker
      Parameters:
      aLabelObstacle - an obstacle.
    • removeLabelObstacle

      public void removeLabelObstacle(TLcdLabelObstacle aLabelObstacle)
      Description copied from interface: ILcdLabelConflictChecker
      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.

      Specified by:
      removeLabelObstacle in interface ILcdLabelConflictChecker
      Parameters:
      aLabelObstacle - a label obstacle.
    • getLabelObstacles

      public List<TLcdLabelObstacle> getLabelObstacles()
      Description copied from interface: ILcdLabelConflictChecker
      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.
      Specified by:
      getLabelObstacles in interface ILcdLabelConflictChecker
      Returns:
      a list of all added obstacles.
    • addLabelPlacement

      public void addLabelPlacement(TLcdLabelPlacement aPlacement)
      Description copied from interface: ILcdLabelConflictChecker
      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.

      Specified by:
      addLabelPlacement in interface ILcdLabelConflictChecker
      Parameters:
      aPlacement - a label placement.
    • removeLabelPlacement

      public void removeLabelPlacement(TLcdLabelPlacement aPlacement)
      Description copied from interface: ILcdLabelConflictChecker
      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.

      Specified by:
      removeLabelPlacement in interface ILcdLabelConflictChecker
      Parameters:
      aPlacement - a label placement.
    • getLabelPlacements

      public List<TLcdLabelPlacement> getLabelPlacements()
      Description copied from interface: ILcdLabelConflictChecker
      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.
      Specified by:
      getLabelPlacements in interface ILcdLabelConflictChecker
      Returns:
      a list of all added label placements.
    • getConflict

      public ILcdLabelConflictChecker.Conflict getConflict(TLcdLabelPlacement aPlacement)
      Description copied from interface: ILcdLabelConflictChecker
      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.

      Specified by:
      getConflict in interface ILcdLabelConflictChecker
      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.