|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor
ilog.views.graphlayout.labellayout.annealing.IlvAnnealingPointLabelDescriptor
public class IlvAnnealingPointLabelDescriptor
The class 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:
| Field Summary | |
|---|---|
static int |
ELLIPTIC
Option for the shape of the path. |
static int |
RECTANGULAR
Option for the shape of the path. |
| Fields inherited from class ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor |
|---|
actDistFromPath, actPathLocation, IGNORED, LABEL, maxDistFromPath, maxPathLocation, OBSTACLE |
| Constructor Summary | |
|---|---|
IlvAnnealingPointLabelDescriptor()
Creates a new empty instance of a point label descriptor. |
|
IlvAnnealingPointLabelDescriptor(IlvInputStream stream)
Creates a new IlvAnnealingPointLabelDescriptor from
an IlvInputStream. |
|
IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
IlvPoint referencePoint,
float minDist,
float maxDist,
int preferredDirection)
Creates a new instance of a point label descriptor. |
|
IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
IlvPoint referencePoint,
int shape,
float halfWidth,
float halfHeight,
float maxDistFromPath,
float 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. |
|
| Method Summary | |
|---|---|
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. |
IlvRect |
getBoundingBox()
|
float |
getHalfHeight()
Returns the half height of the path around the reference point. |
float |
getHalfWidth()
Returns the half width of the path around the reference point. |
float |
getMaxDistFromPath()
Returns the maximal distance from the location on the path. |
Object |
getObject()
|
int |
getPreferredDirection()
Returns the preferred direction where the label is placed relative to the reference point or related obstacle. |
float |
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 |
setBoundingBox(IlvRect bbox)
|
void |
setHalfHeight(float halfHeight)
Sets the half height of the path around the reference point. |
void |
setHalfWidth(float halfWidth)
Sets the half width of the path around the reference point. |
void |
setMaxDistFromPath(float distance)
Sets the maximal distance from the location on the path. |
void |
setPosition(double pathLocation,
float 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(float 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,
float 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. |
| Methods inherited from class ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor |
|---|
getLabel, getMinDist, getRotation, getTreatAs, setTreatAs, updatePosition |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ELLIPTIC
public static final int RECTANGULAR
| Constructor Detail |
|---|
public IlvAnnealingPointLabelDescriptor()
setRelatedObstacle(java.lang.Object),
setReferencePoint(ilog.views.IlvPoint),
setHalfWidth(float),
setHalfHeight(float),
setMaxDistFromPath(float),
setPreferredDistFromPath(float),
setPreferredDirection(int),
setShape(int),
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.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.
IlvDirection.Left
IlvDirection.Right
IlvDirection.Top
IlvDirection.Bottom
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(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor)
public IlvAnnealingPointLabelDescriptor(Object label,
Object relatedObstacle,
IlvPoint referencePoint,
float minDist,
float 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:
IlvDirection.Left
IlvDirection.Right
IlvDirection.Top
IlvDirection.Bottom
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 minimal distance from the label to the reference point.maxDist - The maximal 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,
float halfWidth,
float halfHeight,
float maxDistFromPath,
float 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:
IlvDirection.Left
IlvDirection.Right
IlvDirection.Top
IlvDirection.Bottom
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 maximal 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(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor)
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| Method Detail |
|---|
public void initialize(IlvLabelingModel labelingModel)
initialize in class IlvAnnealingLabelDescriptorlabelingModel - The labeling model attached to the layout algorithm.
public void setPosition(double pathLocation,
float 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(java.lang.Object, float, float, boolean) is delayed until the end
of all tests.
setPosition in class IlvAnnealingLabelDescriptorpathLocation - The location on the path.distFromPath - The distance from the location on the path.IlvAnnealingLabelDescriptor.updatePosition(float, float)
public void setTowardsPreferredPosition(double pathLocation,
float 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 IlvAnnealingLabelDescriptorpathLocation - 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 maximal number of iteration steps.setPosition(double, float),
getPreferredPathLocation(),
getPreferredDistFromPath()public double getPreferredPathLocation()
getPreferredPathLocation in class IlvAnnealingLabelDescriptorpublic 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 IlvAnnealingLabelDescriptorobstacle - 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)
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
obstacle - The obstacle to set.getRelatedObstacle(),
setReferencePoint(ilog.views.IlvPoint)public final Object getRelatedObstacle()
null if only an array of reference points was
specified.
getRelatedObstacle in class IlvAnnealingLabelDescriptorsetRelatedObstacle(java.lang.Object)public void setReferencePoint(IlvPoint point)
null, the position of
the related obstacle defines the where the label must be placed.
Note that a copy of the input point is stored. The original input point
can be reused afterwards.
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
point - The label reference point.getReferencePoint(),
setRelatedObstacle(java.lang.Object)public final IlvPoint getReferencePoint()
null if no reference point was specified.
setReferencePoint(ilog.views.IlvPoint)public void setShape(int shape)
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
shape - The shape of the area.getShape()public final int getShape()
setShape(int)public void setHalfWidth(float halfWidth)
null.
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
halfWidth - The half width of the path around the reference point.getHalfWidth()public final float getHalfWidth()
setHalfWidth(float)public void setHalfHeight(float halfHeight)
null.
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
halfHeight - The half height of the path around the reference point.getHalfHeight()public final float getHalfHeight()
setHalfHeight(float)public void setPreferredDistFromPath(float distance)
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
distance - The preferred distance from the location on the path.getPreferredDistFromPath(),
setMaxDistFromPath(float)public final float getPreferredDistFromPath()
getPreferredDistFromPath in class IlvAnnealingLabelDescriptorsetPreferredDistFromPath(float)public void setMaxDistFromPath(float distance)
If you use this method to change a descriptor that is currently installed
for a label, you should reinstall it by calling
IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
distance - The maximal distance from the location on the path.getMaxDistFromPath()public final float getMaxDistFromPath()
setMaxDistFromPath(float)public void setPreferredDirection(int direction)
IlvDirection.Left IlvDirection.Right IlvDirection.Top IlvDirection.Bottom IlvAnnealingLabelLayout.setLabelDescriptor(java.lang.Object, ilog.views.graphlayout.labellayout.annealing.IlvAnnealingLabelDescriptor) again
to make the change active.
direction - The preferred direction to set.getPreferredDirection()public final int getPreferredDirection()
setPreferredDirection(int)
public void write(IlvOutputStream stream)
throws IOException
IlvGraphic.
write in interface IlvPersistentObjectstream - The output stream.
IOException - standard IO error.public final void setBoundingBox(IlvRect bbox)
public final IlvRect getBoundingBox()
public final Object getObject()
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||