public class TLspNoDeclutterLabelConflictChecker extends Object implements ILspLabelConflictChecker
ILspLabelConflictChecker
does not check if placements overlap with
other placements. It does check if they overlap with obstacles or the view. The
latter is done using the delegate ILspLabelConflictChecker
that can be set in the
constructor. This delegate should never be a TLspNoDeclutterLabelConflictChecker
.ILspLabelConflictChecker.Conflict
Constructor and Description |
---|
TLspNoDeclutterLabelConflictChecker(ILspLabelConflictChecker aDelegate)
Creates an new
TLspNoDeclutterLabelConflictChecker using the given delegate
ILspLabelConflictChecker used for finding conflicts with obstacles
or the view bounds. |
Modifier and Type | Method and Description |
---|---|
void |
addObstacle(TLspLabelObstacle aObstacle)
Add the given obstacle to this conflict checker.
|
void |
addPlacement(TLspLabelPlacement aPlacement)
Add the given label placement to this conflict checker.
|
TLspNoDeclutterLabelConflictChecker |
clone()
Makes
Object.clone() public. |
ILspLabelConflictChecker.Conflict |
getConflict(TLspLabelPlacement aPlacement)
Checks if the given placement is valid, that is if it does not overlap with already added
placements or obstacles.
|
List<TLspLabelObstacle> |
getObstacles()
Returns all obstacles that were added to (and not removed from) this conflict checker.
|
List<TLspLabelPlacement> |
getPlacements()
Returns all label placements that were added to (and not removed from) this conflict checker.
|
void |
removeObstacle(TLspLabelObstacle aObstacle)
Removes the given obstacle from the conflict checker.
|
void |
removePlacement(TLspLabelPlacement aPlacement)
Removes the given label placement from the conflict checker.
|
void |
reset(Rectangle aViewBounds)
Resets the conflict checker.
|
public TLspNoDeclutterLabelConflictChecker(ILspLabelConflictChecker aDelegate)
TLspNoDeclutterLabelConflictChecker
using the given delegate
ILspLabelConflictChecker
used for finding conflicts with obstacles
or the view bounds.aDelegate
- a delegate ILspLabelConflictChecker
.public TLspNoDeclutterLabelConflictChecker clone()
ILcdCloneable
Makes Object.clone()
public.
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 );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()
public void reset(Rectangle aViewBounds)
ILspLabelConflictChecker
reset
in interface ILspLabelConflictChecker
aViewBounds
- the view bounds.public void addObstacle(TLspLabelObstacle aObstacle)
ILspLabelConflictChecker
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.
addObstacle
in interface ILspLabelConflictChecker
aObstacle
- an obstacle.public void removeObstacle(TLspLabelObstacle aObstacle)
ILspLabelConflictChecker
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.
removeObstacle
in interface ILspLabelConflictChecker
aObstacle
- an obstacle.public List<TLspLabelObstacle> getObstacles()
ILspLabelConflictChecker
getObstacles
in interface ILspLabelConflictChecker
public void addPlacement(TLspLabelPlacement aPlacement)
ILspLabelConflictChecker
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.
addPlacement
in interface ILspLabelConflictChecker
aPlacement
- a label placement.public void removePlacement(TLspLabelPlacement aPlacement)
ILspLabelConflictChecker
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.
removePlacement
in interface ILspLabelConflictChecker
aPlacement
- a label placement.public List<TLspLabelPlacement> getPlacements()
ILspLabelConflictChecker
getPlacements
in interface ILspLabelConflictChecker
public ILspLabelConflictChecker.Conflict getConflict(TLspLabelPlacement aPlacement)
ILspLabelConflictChecker
When no conflict is found, the returned Conflict
should be null
.
getConflict
in interface ILspLabelConflictChecker
aPlacement
- a label placement.null
if no conflict was found.