1 java rotation jfreechart marker
我想旋转 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));
Run Code Online (Sandbox Code Playgroud)
它不允许我上传图片,链接如下: http: //i54.tinypic.com/5z40fs.png
我想要垂直的“标签”,以获得更好的外观。
谢谢
我发现向垂直标记添加文本注释以更好地控制其标签更容易。这是一个例子:
// 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);
Run Code Online (Sandbox Code Playgroud)
这种旋转使标签出现在从下到上阅读的垂直标记线的左侧。我使用变量“labelOffset”和“labelHeight”来确定标签相对于垂直线的确切位置,但这些也可以静态设置。
| 归档时间: |
|
| 查看次数: |
3885 次 |
| 最近记录: |