public class LabelCandidate extends Object implements IPlaneObject
LabelCandidate
describes one valid placement for a label considering the label model.
Generic labeling algorithms place labels according to their label model. To get valid locations for the label, the label
model generates various
LabelCandidate
s. One of these candidates will be chosen to provide the actual placement of the label.
Constructor and Description |
---|
LabelCandidate(YOrientedRectangle labelBox,
Object param,
ILabelLayout owner)
Creates a new instance of
LabelCandidate described by its box, model parameter and internal flag. |
LabelCandidate(YOrientedRectangle labelBox,
Object param,
ILabelLayout owner,
boolean internal)
Creates a new instance of
LabelCandidate described by its box, model parameter and internal flag. |
LabelCandidate(YPoint pos,
YDimension size,
Object param,
ILabelLayout owner)
Creates a new instance of
LabelCandidate described by location, size, model parameter and internal flag. |
LabelCandidate(YPoint pos,
YDimension size,
Object param,
ILabelLayout owner,
boolean internal)
Creates a new instance of
LabelCandidate described by location, size, model parameter and internal flag. |
Modifier and Type | Method and Description |
---|---|
YRectangle |
getBoundingBox()
Gets the bounding box of this candidate.
|
YOrientedRectangle |
getBox()
Gets the oriented box of this candidate.
|
double |
getCustomProfit()
Gets the custom profit for this candidate.
|
double |
getEdgeOverlapPenalty()
Gets a penalty for a candidate position that overlaps the path of an edge.
|
double |
getHeight()
Gets the height of the candidate's bounding box.
|
YPoint |
getLocation()
Gets the coordinates of the upper-left corner of the candidate's bounds.
|
Object |
getModelParameter()
Gets the model parameter that was used by the underlying model to generate this label candidate.
|
double |
getNodeOverlapPenalty()
Gets a penalty for a candidate position that overlaps the box of a node.
|
double |
getOverlapPenalty()
Gets the sum of node overlap penalty and edge overlap penalty.
|
ILabelLayout |
getOwner()
Gets the
ILabelLayout for which this candidate was created. |
YDimension |
getSize()
Gets the width and height of the candidate's bounds.
|
double |
getWidth()
Gets the width of the candidate's bounds.
|
double |
getX()
Gets the minimum x-coordinate of the candidate's bounds.
|
double |
getY()
Gets the minimum y-coordinate of the candidate's bounds.
|
boolean |
isInternal()
Gets whether or not this candidate describes an internal label.
|
boolean |
isPropagated()
Gets whether or not this candidate's box had already been chosen by the labeling algorithm.
|
void |
propagate()
Replaces the model parameter and box of the owner with the model parameter and box of this candidate.
|
void |
setCustomProfit(double value)
Sets the custom profit for this candidate.
|
void |
setEdgeOverlapPenalty(double value)
Sets a penalty for a candidate position that overlaps the path of an edge.
|
void |
setNodeOverlapPenalty(double value)
Sets a penalty for a candidate position that overlaps the box of a node.
|
String |
toString()
Returns a
String representation of this LabelCandidate . |
public LabelCandidate(YOrientedRectangle labelBox, Object param, ILabelLayout owner)
LabelCandidate
described by its box, model parameter and internal flag.labelBox
- the box that specifies the candidate's size and positionparam
- the parameters of the label model associated with this candidateowner
- the label associated with the candidatepublic LabelCandidate(YOrientedRectangle labelBox, Object param, ILabelLayout owner, boolean internal)
LabelCandidate
described by its box, model parameter and internal flag.labelBox
- the box that specifies the candidate's size and positionparam
- the parameters of the label model associated with this candidateowner
- the label associated with the candidateinternal
- true
if the candidate is allowed to overlap with its owner, false
otherwisepublic LabelCandidate(YPoint pos, YDimension size, Object param, ILabelLayout owner)
LabelCandidate
described by location, size, model parameter and internal flag.pos
- the location of the upper left corner of the candidatesize
- the size of the candidateparam
- the parameters of the label model associated with this candidateowner
- the label associated with the candidatepublic LabelCandidate(YPoint pos, YDimension size, Object param, ILabelLayout owner, boolean internal)
LabelCandidate
described by location, size, model parameter and internal flag.pos
- the location of the upper left corner of the candidatesize
- the size of the candidateparam
- the parameters of the label model associated with this candidateowner
- the label associated with the candidateinternal
- true
if the candidate is allowed to overlap with its owner, false
otherwisepublic YRectangle getBoundingBox()
The bounding box describes the smallest paraxial box that contains the candidate.
getBoundingBox
in interface IPlaneObject
public YOrientedRectangle getBox()
If the label is rotated, this box will be oriented accordingly.
public double getCustomProfit()
The profit describes the priority of this candidate with respect to other candidates. Labeling algorithms will use the profit to decide which candidate to choose.
The value is restricted to the interval [0,1]
, where 1
specifies the highest possible profit.
IllegalArgumentException
- if the specified value lies outside of [0,1]
optimization strategy
.setCustomProfit(double)
public double getEdgeOverlapPenalty()
The penalty should be a factor between 0
and 1
, where 0
means that an overlap is considered
unimportant and 1
means that an overlap is considered severe.
IllegalArgumentException
- if the specified penalty is outside [0,1]
setEdgeOverlapPenalty(double)
public double getHeight()
The bounding box is the smallest paraxial box that contains the candidate.
getSize()
,
getBoundingBox()
public YPoint getLocation()
The bounds are the smallest paraxial box that contains the candidate.
getBoundingBox()
public Object getModelParameter()
public double getNodeOverlapPenalty()
The penalty should be a factor between 0
and 1
, where 0
means that an overlap is considered
unimportant and 1
means that an overlap is considered severe.
IllegalArgumentException
- if the specified penalty is outside [0,1]
setNodeOverlapPenalty(double)
public double getOverlapPenalty()
getEdgeOverlapPenalty()
,
getNodeOverlapPenalty()
public ILabelLayout getOwner()
ILabelLayout
for which this candidate was created.public YDimension getSize()
The bounds are the smallest paraxial box that contains the candidate.
getBoundingBox()
public double getWidth()
The bounds are the smallest paraxial box that contains the candidate.
getSize()
,
getBoundingBox()
public double getX()
The bounds are the smallest paraxial box that contains the candidate.
getLocation()
,
getBoundingBox()
public double getY()
The bounds are the smallest paraxial box that contains the candidate.
getLocation()
,
getBoundingBox()
public boolean isInternal()
Internal labels reside inside the boundaries of a node.
true
if the candidate represents an internal label, false
otherwisepublic boolean isPropagated()
If this candidate is propagated, its model parameter and box were transferred to the label
.
true
if this candidate was chosen, false
otherwisepropagate()
public void propagate()
When this candidate is chosen to provide the placement of the label, this method transfers the model parameter and the
candidate box to the ILabelLayout
.
getOwner()
,
getModelParameter()
,
getBox()
public void setCustomProfit(double value)
The profit describes the priority of this candidate with respect to other candidates. Labeling algorithms will use the profit to decide which candidate to choose.
The value is restricted to the interval [0,1]
, where 1
specifies the highest possible profit.
IllegalArgumentException
- if the specified value lies outside of [0,1]
optimization strategy
.value
- the custom profit for this candidategetCustomProfit()
public void setEdgeOverlapPenalty(double value)
The penalty should be a factor between 0
and 1
, where 0
means that an overlap is considered
unimportant and 1
means that an overlap is considered severe.
IllegalArgumentException
- if the specified penalty is outside [0,1]
value
- the penalty for overlaps with edgesgetEdgeOverlapPenalty()
public void setNodeOverlapPenalty(double value)
The penalty should be a factor between 0
and 1
, where 0
means that an overlap is considered
unimportant and 1
means that an overlap is considered severe.
IllegalArgumentException
- if the specified penalty is outside [0,1]
value
- the penalty for overlaps with nodesgetNodeOverlapPenalty()
public String toString()
String
representation of this LabelCandidate
.
The String
contains the owning label and the coordinates of the candidate's bounds.
toString
in class Object
getOwner()
,
getLocation()