public class IlvAnnealingPointLabelDescriptor extends IlvAnnealingLabelDescriptor implements IlvPersistentObject
IlvAnnealingPointLabelDescriptor
can be used to
specify that the label should be placed close to specific point (the
point labeling problem). A typical application is to place
labels of cities on a map. These labels should be close to the related
cities, but they should not overlap each other and should not overlap
any city.
Sample drawings produced by the Annealing Label Layout algorithm with point label descriptors:
Modifier and Type | Field and Description |
---|---|
static int |
ELLIPTIC
Option for the shape of the path.
|
static int |
RECTANGULAR
Option for the shape of the path.
|
actDistFromPath, actPathLocation, IGNORED, LABEL, maxDistFromPath, maxPathLocation, OBSTACLE
Constructor and Description |
---|
IlvAnnealingPointLabelDescriptor()
Creates a new empty instance of a point label descriptor.
|
IlvAnnealingPointLabelDescriptor(IlvAnnealingPointLabelDescriptor d)
Creates a copy of a label descriptor.
|
IlvAnnealingPointLabelDescriptor(IlvInputStream stream)
Creates a new
IlvAnnealingPointLabelDescriptor from an
IlvInputStream . |
IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
IlvPoint referencePoint,
double minDist,
double maxDist,
int preferredDirection)
Creates a new instance of a point label descriptor.
|
IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
IlvPoint referencePoint,
int shape,
double halfWidth,
double halfHeight,
double maxDistFromPath,
double preferredDistFromPath,
int preferredDirection)
Creates a new instance of a point label descriptor.
|
IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
int shape,
int preferredDirection)
Creates a new instance of a point label descriptor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
considerObstacle(Object obstacle)
Returns
true if the overlap between the label and the
input obstacle should be considered during the quality calculation of
the Simulated Annealing label layout algorithm. |
IlvAnnealingLabelDescriptor |
copy()
Returns a copy of this label descriptor.
|
double |
getHalfHeight()
Returns the half height of the path around the reference point.
|
double |
getHalfWidth()
Returns the half width of the path around the reference point.
|
double |
getMaxDistFromPath()
Returns the maximum distance from the location on the path.
|
int |
getPreferredDirection()
Returns the preferred direction where the label is placed relative to
the reference point or related obstacle.
|
double |
getPreferredDistFromPath()
Returns the preferred distance from the location on the path.
|
double |
getPreferredPathLocation()
Returns the preferred location on the path.
|
IlvPoint |
getReferencePoint()
Returns a copy of the reference point of the label.
|
Object |
getRelatedObstacle()
Returns the obstacle that is related to the label.
|
int |
getShape()
Returns the shape of the allowed area around the reference point or
related obstacle.
|
void |
initialize(IlvLabelingModel labelingModel)
Initializes the label descriptor before layout.
|
void |
setHalfHeight(double hheight)
Sets the half height of the path around the reference point.
|
void |
setHalfWidth(double halfWidth)
Sets the half width of the path around the reference point.
|
void |
setMaxDistFromPath(double distance)
Sets the maximum distance from the location on the path.
|
void |
setPosition(double pathLocation,
double distFromPath)
Sets the label conceptually to the specified position.
|
void |
setPreferredDirection(int direction)
Sets the preferred direction where the label is placed relative to the
reference point or related obstacle.
|
void |
setPreferredDistFromPath(double distance)
Sets the preferred distance from the location on the path.
|
void |
setReferencePoint(IlvPoint point)
Sets the reference point of the label.
|
void |
setRelatedObstacle(Object obstacle)
Sets the obstacle that is related to the label.
|
void |
setShape(int shape)
Sets the shape of the allowed area around the reference point or
related obstacle.
|
void |
setTowardsPreferredPosition(double pathLocation,
double distFromPath,
int i,
int maxI)
Sets the label to a position that is closer to the preferred position
than the input position given by
pathLocation and
distFromPath . |
void |
write(IlvOutputStream stream)
Writes the label descriptor to the output stream.
|
getActDistFromPath, getActPathLocation, getLabel, getMaxPathLocation, getMinDist, getRotation, getTreatAs, isAutoCorrect, isFixed, setActDistFromPath, setActPathLocation, setAutoCorrect, setFixed, setMaxPathLocation, setTreatAs, updatePosition
public static final int ELLIPTIC
public static final int RECTANGULAR
public IlvAnnealingPointLabelDescriptor()
setRelatedObstacle(Object)
,
setReferencePoint(IlvPoint)
,
setHalfWidth(double)
,
setHalfHeight(double)
,
setMaxDistFromPath(double)
,
setPreferredDistFromPath(double)
,
setPreferredDirection(int)
,
setShape(int)
,
IlvAnnealingLabelLayout.setLabelDescriptor(Object, IlvAnnealingLabelDescriptor)
public IlvAnnealingPointLabelDescriptor(Object label, Object relatedObstacle, int shape, int preferredDirection)
The label can be placed in an area around the obstacle. The size of the area is determined by the size of the related obstacle. The options for the shape of the area are:
IlvAnnealingPointLabelDescriptor.ELLIPTIC
- The
area has an elliptic shape. This should be used if the the related
obstacle is a circle or an ellipse.
IlvAnnealingPointLabelDescriptor.RECTANGULAR
- The
area has a rectangular shape. This should be used if the related
obstacle is a rectangle.
label
- The label.relatedObstacle
- The obstacle that is related to the label.shape
- The shape of the allowed area around the related obstacle.preferredDirection
- The direction from the reference point where
the label should preferably be placed.IlvAnnealingLabelLayout.setLabelDescriptor(Object, IlvAnnealingLabelDescriptor)
public IlvAnnealingPointLabelDescriptor(Object label, Object relatedObstacle, IlvPoint referencePoint, double minDist, double maxDist, int preferredDirection)
The label can be placed in a circular area such that the label is
between minDist
and maxDist
away from the
reference point. The distance of the label is measured from the
reference point to the closest corner of the label. The layout
algorithm strictly observes this range. It does not place the label
closer than minDist
or farther then maxDist
from the reference point.
Furthermore, the layout takes as hint the direction where the label should be preferably placed relative to the reference point. Valid options for the preferred direction are:
label
- The label.relatedObstacle
- The obstacle that is related to the label, e.g.
when labeling cities of a geographic map, the related obstacle
should be the object that representing the city that has this
label. The algorithm does not count overlaps between the label and
its related obstacle. If the layout algorithm should count all
overlaps to all labels, the related obstacle should be
null
.referencePoint
- The reference point the label should be close to.minDist
- The minimum distance from the label to the reference
point.maxDist
- The maximum distance from the label to the reference
point.preferredDirection
- The direction from the reference point where
the label should preferably be placed.IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor)
public IlvAnnealingPointLabelDescriptor(Object label, Object relatedObstacle, IlvPoint referencePoint, int shape, double halfWidth, double halfHeight, double maxDistFromPath, double preferredDistFromPath, int preferredDirection)
The label can be placed in an area that can be described by a path and and additional offset from the path. The options for the shape of the path are:
IlvAnnealingPointLabelDescriptor.ELLIPTIC
- The
path resembles an elliptic shape.IlvAnnealingPointLabelDescriptor.RECTANGULAR
- The
path is a rectangular shape.halfWidth
and halfHeight
specify the
dimensions of the path. For instance, if the path should be a circle,
specify the radius of the circle as halfWidth
and
halfHeight
. The label is placed no farther than
maxDistFromPath
away from the path.
Furthermore, the layout takes as hint the distance and direction where the label should be preferably placed relative to the reference point. Valid options for the preferred direction are:
label
- The label.relatedObstacle
- The obstacle that is related to the label, e.g.
when labeling cities of a geographic map, the related obstacle
should be the object that representing the city that has this
label. The algorithm does not count overlaps between the label and
its related obstacle. If the layout algorithm should count all
overlaps to all labels, the related obstacle should be
null
.referencePoint
- The reference point the label should be close to.
If the reference point is null
, the center of the
related obstacle is taken as reference point.shape
- The shape of the allowed area around the reference point.halfWidth
- The half width of the path around the reference point.halfHeight
- The half height of the path around the reference
point.maxDistFromPath
- The maximum distance the label is allowed to be
placed away from the path (towards the outside).preferredDistFromPath
- The preferred distance the label is placed
away from the path (towards the outside).preferredDirection
- The direction from the reference point where
the label should preferably be placed.IlvAnnealingLabelLayout.setLabelDescriptor(Object, IlvAnnealingLabelDescriptor)
public IlvAnnealingPointLabelDescriptor(IlvAnnealingPointLabelDescriptor d)
d
- The original label descriptor.public IlvAnnealingPointLabelDescriptor(IlvInputStream stream) throws IOException, IlvReadFileException
IlvAnnealingPointLabelDescriptor
from an
IlvInputStream
.stream
- The input stream from which the descriptor must be read.IlvReadFileException
- if an error occurs while reading.IOException
public IlvAnnealingLabelDescriptor copy()
copy
in class IlvAnnealingLabelDescriptor
public void initialize(IlvLabelingModel labelingModel)
initialize
in class IlvAnnealingLabelDescriptor
labelingModel
- The labeling model attached to the layout
algorithm.public void setPosition(double pathLocation, double distFromPath)
For experts: This method does not really move the label in the
labeling model, but updates internal data structures that allow to
test easily what would happen if the label would be at the input
position. The real move of the label via IlvLabelingModel.moveLabel(Object, double, double, boolean)
is
delayed until the end of all tests.
setPosition
in class IlvAnnealingLabelDescriptor
pathLocation
- The location on the path.distFromPath
- The distance from the location on the path.IlvAnnealingLabelDescriptor.updatePosition(double, double)
public void setTowardsPreferredPosition(double pathLocation, double distFromPath, int i, int maxI)
pathLocation
and
distFromPath
.
You should not call this directly. The layout algorithm calls this method iteratively to test various positions that are closer to the preferred position.
setTowardsPreferredPosition
in class IlvAnnealingLabelDescriptor
pathLocation
- The current location on the path.distFromPath
- The current distance from the location on the pathi
- The number of the iteration step, from 0 to maxI -
1
.maxI
- The maximum number of iteration steps.setPosition(double, double)
,
getPreferredPathLocation()
,
getPreferredDistFromPath()
public double getPreferredPathLocation()
getPreferredPathLocation
in class IlvAnnealingLabelDescriptor
public boolean considerObstacle(Object obstacle)
true
if the overlap between the label and the
input obstacle should be considered during the quality calculation of
the Simulated Annealing label layout algorithm. In fact, it returns
false
if the input obstacle is the related obstacle.considerObstacle
in class IlvAnnealingLabelDescriptor
obstacle
- The obstacle to test.true
if there is a penalty if the label overlaps
the obstacle, and false
, if there is no penalty.public void setRelatedObstacle(Object obstacle)
obstacle
- The obstacle to set.getRelatedObstacle()
,
setReferencePoint(IlvPoint)
public final Object getRelatedObstacle()
null
if only an array of reference points was specified.getRelatedObstacle
in class IlvAnnealingLabelDescriptor
setRelatedObstacle(Object)
public void setReferencePoint(IlvPoint point)
null
, the position of the related
obstacle defines where the label must be placed.
Note that a copy of the input point is stored. The original input point can be reused afterwards.
point
- The label reference point.getReferencePoint()
,
setRelatedObstacle(Object)
public final IlvPoint getReferencePoint()
null
if no reference point was specified.setReferencePoint(IlvPoint)
public void setShape(int shape)
shape
- The shape of the area.getShape()
public final int getShape()
setShape(int)
public void setHalfWidth(double halfWidth)
null
.halfWidth
- The half width of the path around the reference point.getHalfWidth()
public final double getHalfWidth()
setHalfWidth(double)
public void setHalfHeight(double hheight)
null
.hheight
- The half height of the path around the reference point.getHalfHeight()
public final double getHalfHeight()
setHalfHeight(double)
public void setPreferredDistFromPath(double distance)
distance
- The preferred distance from the location on the path.getPreferredDistFromPath()
,
setMaxDistFromPath(double)
public final double getPreferredDistFromPath()
getPreferredDistFromPath
in class IlvAnnealingLabelDescriptor
setPreferredDistFromPath(double)
public void setMaxDistFromPath(double distance)
setMaxDistFromPath
in class IlvAnnealingLabelDescriptor
distance
- The maximum distance from the location on the path.getMaxDistFromPath()
public final double getMaxDistFromPath()
getMaxDistFromPath
in class IlvAnnealingLabelDescriptor
setMaxDistFromPath(double)
public void setPreferredDirection(int direction)
IlvDirection.Left
IlvDirection.Right
IlvDirection.Top
IlvDirection.Bottom
(the default value)direction
- The preferred direction to set.getPreferredDirection()
public final int getPreferredDirection()
setPreferredDirection(int)
public void write(IlvOutputStream stream) throws IOException
IlvGraphic
.write
in interface IlvPersistentObject
stream
- The output stream.IOException
- standard IO error.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.