1
  final PiePlot plot = (PiePlot) chart.getPlot();
  for (int i = 0; i < 2; i++) {
    plot.setSectionPaint(i, color[i]);
    plot.setSectionPaint(plot.getSectionKey(i), color[i]);
  }

円グラフのセクションに他の色を設定しようとしています。

setSectionPaint(int, Color)メソッドは非推奨です

setSectionPaint(Comparable, Color)plot.getSectionKey(int index )メソッド:保護されているため、Comparableオブジェクトを取得できません。

エラー/警告メッセージなしでセクションの色を変更できるようにするための解決策はありますか?または、比較可能なオブジェクトを取得する方法は?

4

1 に答える 1

1

Comparable keyの目的の実装を呼び出すには、データセットから正しいものを提供する必要がありますsetSectionPaint()。たとえば、の場合org.jfree.chart.demo.PieChartDemo1、次のようにセクションOneをに設定しColor.blackます。

plot.setSectionPaint("One", Color.black);
于 2012-10-15T16:34:46.107 に答える