【发布时间】:2014-04-08 18:47:04
【问题描述】:
我正在尝试以这种方式设置图表 x 轴的字体:
CategoryPlot plotCat = (CategoryPlot) chart.getPlot();
CategoryAxis xAxis = plotCat.getDomainAxis();
Font font = new Font("SanSerif", Font.STRIKETHRU, 3);
//or Font font = new Font(Font.FontFamily.HELVETICA, 3, Font.BOLD);
xAxis.setTickLabelFont(font);
//or xAxis.setLabelFont(font);
这是我一直在阅读的解决方案,但它对我不起作用。我不断收到消息:The method setTickLabelFont(Font) in the type Axis is not applicable for the arguments (Font) 和 The method setLabelFont(Font) in the type Axis is not applicable for the arguments (Font)。
是什么原因导致我无法对这些标签应用不同的字体?
这可能是因为我正在导入com.itextpdf.text.Font 而不是java.awt.Font,但是com.itextpdf.text.Font 是设置PDF 中其他元素的字体所必需的。如果这确实是问题的原因,我该如何解决这些差异?
【问题讨论】:
标签: java fonts import itext jfreechart