
As you can see, when the range axis is spanning over a large area, and the ticklabels are too close together, they start overlapping. I would like to implement some kind of logic to detect if they are overlapping, and if so, just show a preferred one (or as many as will fit). I am a bit unsure of how to accomplish this, however.
The logic would be something like this:
- Prioritize each label after importance
- Get hold of the Java2d coordinates of each tick label (x,y,width,height)
- If the area of a label is overlapping with another, just show the most important one
But which methods are available to do this? From the API docs I bought I found this method
public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge);
But what is this area and edge I need to supply the function with? And how would I get a hold of the width and height if a ticklabel? And is this the right way to go about it, or is there a better way that will lead to success?
I posted the question on the JFree forums (as trashgod found) and got a few nice hints there. The final code I posted there that solved my problem was as follows: