public static void applyChartTheme(JFreeChart chart) {
final StandardChartTheme chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme
.createJFreeTheme();
// The default font used by JFreeChart unable to render Chinese
// properly.
// We need to provide font which is able to support Chinese rendering.
if (Locale.getDefault().getLanguage().equals(Locale.SIMPLIFIED_CHINESE.getLanguage())) {
final Font oldExtraLargeFont = chartTheme.getExtraLargeFont();
final Font oldLargeFont = chartTheme.getLargeFont();
final Font oldRegularFont = chartTheme.getRegularFont();
final Font oldSmallFont = chartTheme.getSmallFont();
final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(),
oldExtraLargeFont.getSize());
final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(),
oldLargeFont.getSize());
final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(),
oldRegularFont.getSize());
final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(),
oldSmallFont.getSize());
chartTheme.setExtraLargeFont(extraLargeFont);
chartTheme.setLargeFont(largeFont);
chartTheme.setRegularFont(regularFont);
chartTheme.setSmallFont(smallFont);
}
chartTheme.apply(chart);
}
[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7845854/viewspace-1044599/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7845854/viewspace-1044599/