0

我需要使用 Jfreechart 制作 3d 圆柱条形图,如链接图片所示:http ://www.jzy3d.org/gallery/web/demo-histogram.png 。我在两行代码上有问题:chart.getAxeLayout().setMainColor(Color.WHITE);chart.getView().setBackgroundColor(Color.BLACK);,都在 main 方法中。有谁知道这里有什么问题?

提前致谢

import java.awt.Color;

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.ChartLauncher;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.primitives.MultiColorScatter;

public class chart 
{
    int size = 100000;
    float x;
    float y;
    float z;
    public void crtaj()
    {
        Coord3d[] points = new Coord3d[size];

        // Create scatter points
        for(int i=0; i<size; i++){
            x = (float)Math.random() - 0.5f;
            y = (float)Math.random() - 0.5f;
            z = (float)Math.random() - 0.5f;
            points[i] = new Coord3d(x, y, z);
        }       

        // Create a drawable scatter with a colormap
        MultiColorScatter scatter = new MultiColorScatter( points, new ColorMapper( new ColorMapRainbow(), -0.5f, 0.5f ) );

        // Create a chart and add scatter
        Chart chart = new Chart();
        chart.getAxeLayout();//.setMainColor(Color.WHITE);
        chart.getView();//.setBackgroundColor(Color.BLACK);
        chart.getScene().add(scatter);
        ChartLauncher.openChart(chart);
    }

    public static void main(String[] args)
    {
        /*chart proba = new chart();
        proba.crtaj();*/

        int size = 100000;
        float x;
        float y;
        float z;
        Coord3d[] points = new Coord3d[size];

        // Create scatter points
        for(int i=0; i<size; i++){
            x = (float)Math.random() - 0.5f;
            y = (float)Math.random() - 0.5f;
            z = (float)Math.random() - 0.5f;
            points[i] = new Coord3d(x, y, z);
        }       

        // Create a drawable scatter with a colormap
        MultiColorScatter scatter = new MultiColorScatter( points, new ColorMapper( new ColorMapRainbow(), -0.5f, 0.5f ) );

        Chart chart = new Chart();
        chart.getAxeLayout().setMainColor(Color.WHITE);
        chart.getView().setBackgroundColor(Color.BLACK);
        chart.getScene().add(scatter);
        ChartLauncher.openChart(chart);
    }
}
4

1 回答 1

0

在您的代码中,您已导入java.awt.Color. 您需要导入org.jzy3d.colors.Color而不是java.awt.Color. 删除java.awt.Color导入并添加导入语句,如下所示:

import org.jzy3d.colors.Color;

它会起作用的。

于 2013-07-31T15:33:34.293 回答