Class TLspLabelConflictChecker

java.lang.Object
com.luciad.view.lightspeed.label.TLspLabelConflictChecker
All Implemented Interfaces:
ILcdCloneable, ILspLabelConflictChecker, Cloneable

public class TLspLabelConflictChecker extends Object implements ILspLabelConflictChecker
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 TLspLabelPlacement.getX(), TLspLabelPlacement.getY(), TLspLabelPlacement.getWidth(), TLspLabelPlacement.getHeight() and TLspLabelPlacement.getRotation().

Since:
2012.0
  • Constructor Details

    • TLspLabelConflictChecker

      public TLspLabelConflictChecker()
  • Method Details

    • clone

      public TLspLabelConflictChecker 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:
    • getPadding

      public double getPadding()
      Returns the padding around the label placements.
      Returns:
      the padding around the label placements.
      See Also:
    • setPadding

      public void setPadding(double aPadding)

      Sets the padding around the label placements. This padding is added to the bounds of the placement, enlarging it. In practice this means that the bigger the padding, the more space each label occupies, and the less labels can be placed. Note that this setting only applies to label placements, and not to obstacles.

      By default, this value is 0.0.

      Note that it is possible to change the padding at runtime. E.g. when setting the padding to a new value right before calling addPlacement of getConflict, the new padding value is used for the newly added placement (but not for the placements that were added before).

      Parameters:
      aPadding - the padding.
      Throws:
      IllegalArgumentException - when the given padding is smaller than 0.
      See Also:
    • reset

      public void reset(Rectangle aViewBounds)
      Description copied from interface: ILspLabelConflictChecker
      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 ILspLabelConflictChecker
      Parameters:
      aViewBounds - the view bounds.
    • addObstacle

      public void addObstacle(TLspLabelObstacle aLabelObstacle)
      Description copied from interface: ILspLabelConflictChecker
      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.

      Specified by:
      addObstacle in interface ILspLabelConflictChecker
      Parameters:
      aLabelObstacle - an obstacle.
    • removeObstacle

      public void removeObstacle(TLspLabelObstacle aLabelObstacle)
      Description copied from interface: ILspLabelConflictChecker
      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.

      Specified by:
      removeObstacle in interface ILspLabelConflictChecker
      Parameters:
      aLabelObstacle - an obstacle.
    • getObstacles

      public List<TLspLabelObstacle> getObstacles()
      Description copied from interface: ILspLabelConflictChecker
      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.
      Specified by:
      getObstacles in interface ILspLabelConflictChecker
      Returns:
      a list of all added obstacles.
    • addPlacement

      public void addPlacement(TLspLabelPlacement aPlacement)
      Description copied from interface: ILspLabelConflictChecker
      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.

      Specified by:
      addPlacement in interface ILspLabelConflictChecker
      Parameters:
      aPlacement - a label placement.
    • removePlacement

      public void removePlacement(TLspLabelPlacement aPlacement)
      Description copied from interface: ILspLabelConflictChecker
      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.

      Specified by:
      removePlacement in interface ILspLabelConflictChecker
      Parameters:
      aPlacement - a label placement.
    • getPlacements

      public List<TLspLabelPlacement> getPlacements()
      Description copied from interface: ILspLabelConflictChecker
      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:
      getPlacements in interface ILspLabelConflictChecker
      Returns:
      a list of all added label placements.
    • getConflict

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

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