如何减少拨号图表中的字体大小

use*_*094 2 java jfreechart

我正在使用jfreechart绘制拨号图表,我想减小字体大小.

我怎样才能做到这一点?

Nic*_*las 6

我使用jfreechart为显示器生成一个拨号图像,上面有三种不同的字体.

替代文字

  1. 标题字体.
  2. 表盘刻有字体.
  3. 表盘底部的"图例"字体,称为DialTextAnnotation.

不知道你正在寻找哪一个,所以我将概述每一个.只看我生成这个的代码(它是在groovy中)这里的每个程序:

标题

使用main类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)
   );
);
Run Code Online (Sandbox Code Playgroud)

注解

// 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);
Run Code Online (Sandbox Code Playgroud)

拨号刻度

// 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));
Run Code Online (Sandbox Code Playgroud)