JOGL图表编译错误

时间:2011-07-30 10:07:26

标签: java opengl charts jogl jzy3d

我正在尝试使用Jzy3D库并在openGl下绘制一些图表。 但是当我尝试编译代码时,我获得了以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GLCanvas
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.jzy3d.chart.Chart.initializeCanvas(Chart.java:65)
    at org.jzy3d.chart.Chart.<init>(Chart.java:56)
    at org.jzy3d.chart.Chart.<init>(Chart.java:39)
    at mychart.MyChart.<init>(MyChart.java:44)
    at mychart.MyChart.main(MyChart.java:58)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLCanvas
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 17 more

我还添加了我编写的代码,以防出现问题:

package mychart;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;

import org.jzy3d.chart.Chart;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Builder;
import org.jzy3d.plot3d.builder.Mapper;
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
import org.jzy3d.plot3d.primitives.Shape;
import org.jzy3d.plot3d.rendering.legends.colorbars.ColorbarLegend;

public class MyChart {

    protected Chart chart;

    public MyChart(){

        Mapper mapper = new Mapper(){

            @Override
            public double f(double x, double y) {
                // TODO Auto-generated method stub
                return 20*x*(1-Math.sin(y));
            }
        };

        Range range = new Range(-100, 100);
        int steps = 30;

        final Shape surface = (Shape) Builder.buildOrthonormal
                (new OrthonormalGrid(range, steps, range, steps), mapper);
        surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), 
                surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
        surface.setFaceDisplayed(true);
        surface.setWireframeDisplayed(true);
        surface.setWireframeColor(Color.BLACK);

        chart = new Chart();
        chart.getScene().getGraph().add(surface);

        ColorbarLegend cl = new ColorbarLegend(surface, chart.getView().getAxe().getLayout());
        cl.setMinimumSize(new Dimension(100, 300));

        surface.setLegend(cl);  
    }

    public Chart getChart(){
        return chart;
    }

    public static void main(String[] args){
        MyChart myChart = new MyChart();

        Frame frame = new Frame();
        frame.setSize(1000, 600);
        frame.add((Component)myChart.getChart().getCanvas());
        frame.setVisible(true);
    }
}

我正在使用Eclipse Indigo IDE,Jogl 2.0库(当我将它们导入Eclipse时填充了Native Library Path),Jzy3D 0.8.4版本。我在Windows 7 Ultimate下工作。

1 个答案:

答案 0 :(得分:0)

Jzy3D可能需要JOGL 1.x