Interface ILcdLabelConflictChecker
- All Superinterfaces:
Cloneable
,ILcdCloneable
- All Known Implementing Classes:
TLcdLabelConflictChecker
,TLcdNoDeclutterLabelConflictChecker
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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
This class represents a conflict. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLabelObstacle
(TLcdLabelObstacle aLabelObstacle) Add the given obstacle to this label conflict checker.void
addLabelPlacement
(TLcdLabelPlacement aPlacement) Add the given label placement to this label conflict checker.getConflict
(TLcdLabelPlacement aPlacement) Checks if the given label placement is valid, i.e. if it doesn't overlap with already added label placements or label obstacles.Returns all label obstacles that were added to (and not removed from) this conflict checker.Returns all label placements that were added to (and not removed from) this conflict checker.void
removeLabelObstacle
(TLcdLabelObstacle aLabelObstacle) Removes the given obstacle from the conflict checker.void
removeLabelPlacement
(TLcdLabelPlacement aPlacement) Removes the given label placement from the conflict checker.void
Resets the conflict checker.Methods inherited from interface com.luciad.util.ILcdCloneable
clone
-
Method Details
-
reset
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
Add the given obstacle to this label conflict checker. After this method is called, thegetConflict
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
Removes the given obstacle from the conflict checker. This method should only be called for the given obstacle if it had been added before byaddLabelObstacle
.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
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, thegetConflict
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
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 usingaddLabelPlacement
.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 benull
.- 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.
-