我有一组由 Java 生成的步行图。整个图表的标签在Calibri 8中是一致的。除非该值为 0.00,这在 Arial 8 中很突出。
我追踪到这个类:
import java.text.MessageFormat;
public class ItemLabelGen extends StandardCategoryItemLabelGenerator {
public String GenLable(CategoryDataset ds, int row, int column) {
Number num = ds.getValue(row, column);
return MessageFormat.format("{0,number,#0.00}",num);
}
}
所以我的问题是,我如何在这里控制字体大小或字体本身? 0.00 非常突出,让我们的人们感到疯狂。
如果我无法在 MessageFormat 中控制它,有什么办法可以强制它使用特定字体,因为我有该值?
蒂亚,
最佳答案
告诉图表的 CategoryPlot
使用的 BarRenderer
使用所需的字体
。
CategoryPlot plot = (CategoryPlot) chart.getPlot();
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setBaseItemLabelFont(new Font("Calibri", Font.PLAIN, 8));
关于java - MessageFormat.format - 字体大小是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37557421/