我想旋转 IntervalMarker 的标签:
IntervalMarker im = new IntervalMarker(...);
im.setLabel("LABEL");
// im.setLabelOffsetType(LengthAdjustmentType.EXPAND);
// im.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
// im.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
im.setLabelAnchor(RectangleAnchor.TOP_LEFT);
im.setLabelTextAnchor(TextAnchor.TOP_LEFT);
im.setPaint(new Color(208, 194, 214));
它不允许我上传图片,这是链接: http://i54.tinypic.com/5z40fs.png
为了更好看,我希望“LABEL”垂直。
谢谢
最佳答案
我发现将文本注释添加到垂直标记以更好地控制其标签更容易。这是一个例子:
// vertical line marker and label
Marker updateMarker = new ValueMarker(dayOf, Color.black, dashedStroke, null, null, 1.0f);
XYTextAnnotation updateLabel = new XYTextAnnotation("Update", dayOf - labelOffset, labelHeight);
updateLabel.setFont(new Font("Sans Serif", Font.BOLD, 10));
updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
updateLabel.setRotationAngle(-3.14 / 2);
updateLabel.setPaint(Color.black);
plot.addDomainMarker(updateMarker, Layer.BACKGROUND);
plot.addAnnotation(updateLabel);
这种旋转使标 checkout 现在从下到上阅读的垂直标记线的左侧。我使用变量“labelOffset”和“labelHeight”来确定标签相对于垂直线的确切位置,但这些也可以静态设置。
关于java - IntervalMarker 的 JFreeChart 垂直标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7037996/