|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.plotter.label.LabelPositioningAlgorithm
public class LabelPositioningAlgorithm
LabelPositioningAlgorithm uses simulated annealing to position labels near their markers in a way that minimizes overlap of labels.
The basic algorithm is taken from [1]. [1] references [2] and [3], which would probably be a better sources for the limited version of [1] that we implement here, but I was unable to find copies of them on the internet.
The algorithm is:
The initial value of T is such that P = 2/3 when dE = 1. In other words, T = 1 - ln(1/3). This seems very small, but it seems to work.
[1] |
Shawn Edmondson, Jon Christensen, Joe Marks, and Stuart M. Shieber.
A general cartographic labeling algorithm. Cartographica,
33(4):13-23, Winter 1997. http://www.eecs.harvard.edu/~shieber/Biblio/Papers/gen-label.pdf |
---|---|
[2] | Jon Christensen, Joe Marks, Stuart M. Shieber. 1993. Algorithms for cartographic label placement. In Gary G. Kelly, editor, Proceedings of the American Congress on Surveying and Mapping '93, Vol. 1 pages 75-89, New Orleans, Louisiana, February. |
[3] | Jon Christensen, Joe Marks, Stuart M. Shieber. 1995. An empirical study of algorithms for point-feature label placement. ACM Transactions on Graphics, 14(3):203-232, July. |
Field Summary | |
---|---|
private List<Label> |
labels
List of labels to position. |
private int |
N
Number of labels in labels . |
Constructor Summary | |
---|---|
LabelPositioningAlgorithm(List<Label> labels)
Constructs a new LabelPositioningAlgorithm for the given list of labels. |
Method Summary | |
---|---|
void |
computePositions()
Computes the optimal positioning for the given labels. |
private double |
evaluatePositioning()
Computes E for a given labelling. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final List<Label> labels
private final int N
labels
.
Constructor Detail |
---|
public LabelPositioningAlgorithm(List<Label> labels)
labels
- Labels
to position. May be empty, must not
be null.Method Detail |
---|
public void computePositions()
This method is safe to call even when the list of labels is empty.
private double evaluatePositioning()
Future improvement: Modify this to take into account markers and
lines so that we can avoid drawing labels on top of them. The rest
of the algorithm can probably stay the same, although paper [1]
referenced above
should be read
more closely, since it deals exactly with this type of algorithm.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |