gpt4 book ai didi

java - 在 Jfree 图表中增加图例的大小

转载 作者:行者123 更新时间:2023-11-30 11:12:55 28 4
gpt4 key购买 nike

如何增加显示颜色的图例键的大小。字体大小由 chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));

调整

但我找不到如何管理颜色键大小的方法。我的代码是

plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0,0.0));
plot.setToolTipGenerator(new StandardPieToolTipGenerator(
StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
plot.setDirection(Rotation.CLOCKWISE);


List keys = dataset.getKeys();
int i=0;
for (Iterator it = keys.iterator(); it.hasNext();) {
Comparable key = (Comparable) it.next();
plot.setSectionPaint(key,requiredcol[i]);
//plot.setExplodePercent(key, 0.04);
i++;
}
// create a Ring Chart...
JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
chart.setPadding(new RectangleInsets(0,0,0,0));
chart.setBackgroundPaint(java.awt.Color.white);


if(showLegend){
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setPosition(RectangleEdge.RIGHT);
chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));
}
//chart.removeLegend();
// save it to an image
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final File file1 = new File(chartDirectory + File.separator + chartFileName.toString().trim());
ChartUtilities.saveChartAsPNG(file1, chart, width, height, info);
currentImageMap = ImageMapUtilities.getImageMap(chartFileName.toString(),info);
}

plot.setSectionOutlineStroke(new BasicStroke(3)); 我的键大小也有少量反射(reflect)。请帮忙!

  [1]: http://i.stack.imgur.com/bDh4Z.png

最佳答案

感谢找到答案herehere对于类似的问题,我能够在我的项目中实现它。

这是我的 Scala 代码:

plot.getRenderer().asInstanceOf[StackedBarRenderer].setBaseLegendShape(new Rectangle(30,30))

在 Java 中,这转化为:

((AbstractRenderer) plot.getRenderer()).setBaseLegendShape(new Rectangle(30,30));

结果如我所料:颜色键的形状和大小相应改变。

关于java - 在 Jfree 图表中增加图例的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26658459/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com