我正在使用 jfreechart 绘制表盘图表,并且我想减小字体大小。
我该怎么做?
最佳答案
我使用 jfreechart 为显示器生成表盘图像,上面有三种不同的字体。
- 标题字体。
- 表盘刻度字体。
- 表盘底部的“图例”字体,称为 DialTextAnnotation。
不确定您要寻找哪一个,所以我将概述每一个。 只需查看生成此代码的代码(在 groovy 中),以下是每个代码的过程:
标题
使用主类JFreeChart
的方法setTitle(java.awt.Font font)
方法。
可以在构造函数中调整字体大小。
// Set the title font to bold SansSerif size 12.
JFreeChart chart = new JFreeChart(myplot);
chart.setTitle(
new org.jfree.chart.title.TextTitle("The title",
new java.awt.Font("SansSerif", java.awt.Font.BOLD, 12)
);
);
注释
// Set the annotation font to bold Dialog size 8
DialTextAnnotation annotation = new DialTextAnnotation("My Annotation Text");
annotation.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 8));
// Add to the plot
myplot.addLayer(annotation);
拨号刻度
// Create the dial scale
StandardDialScale scale = new StandardDialScale(.......
// Set the dial font to plain dialog size 14
scale.setTickLabelFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14));
关于java - 如何减小表盘中的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/427603/