It's not very difficult to do this - DateAxis has to be changed a little bit:
1. I need two new variables
Code: Select all
private double winkel; //The angle I need
private boolean mywinkel = false; //Do I need the angle?
2. Then I need getter/setter:
Code: Select all
public double getWinkel() {
return winkel;
}
public void setWinkel(double winkel) {
this.mywinkel = true;
this.winkel = Math.toRadians(winkel);
}
public boolean isMywinkel() {
return mywinkel;
}
3. And then I change the refreshTicksHorizontal-Method at the if-Statements:
Code: Select all
if (isVerticalTickLabels()) {
anchor = TextAnchor.CENTER_RIGHT;
rotationAnchor = TextAnchor.CENTER_RIGHT;
if (edge == RectangleEdge.TOP) {
angle = Math.PI / 2.0;
} else {
angle = -Math.PI / 2.0;
}
}
if (isMywinkel()) {
System.out.println("meiwinkl");
anchor = TextAnchor.CENTER_RIGHT;
rotationAnchor = TextAnchor.CENTER_RIGHT;
if (edge == RectangleEdge.TOP) {
angle = getWinkel();
} else {
angle = -getWinkel();
}
}
else {
if (edge == RectangleEdge.TOP) {
anchor = TextAnchor.BOTTOM_CENTER;
rotationAnchor = TextAnchor.BOTTOM_CENTER;
} else {
anchor = TextAnchor.TOP_CENTER;
rotationAnchor = TextAnchor.TOP_CENTER;
}
}
4. And the refreshTicksVertical-Method also at the Statements:
Code: Select all
if (isVerticalTickLabels()) {
anchor = TextAnchor.BOTTOM_CENTER;
rotationAnchor = TextAnchor.BOTTOM_CENTER;
if (edge == RectangleEdge.LEFT) {
angle = -Math.PI / 2.0;
} else {
angle = Math.PI / 2.0;
}
}
if (isMywinkel()) {
System.out.println("meiwinkl");
anchor = TextAnchor.BOTTOM_CENTER;
rotationAnchor = TextAnchor.BOTTOM_CENTER;
if (edge == RectangleEdge.LEFT) {
angle = -this.winkel;
} else {
angle = this.winkel;
}
}
else {
if (edge == RectangleEdge.LEFT) {
anchor = TextAnchor.CENTER_RIGHT;
rotationAnchor = TextAnchor.CENTER_RIGHT;
} else {
anchor = TextAnchor.CENTER_LEFT;
rotationAnchor = TextAnchor.CENTER_LEFT;
}
}
5. And in my program it looks like this:
Code: Select all
((DateAxis) plot.getDomainAxis()).setVerticalTickLabels(true);
((DateAxis) plot.getDomainAxis()).setWinkel(47.9);
chart.getLegend().setPosition(RectangleEdge.RIGHT);