简体   繁体   中英

How to use Jzy3d java 3d chart library?

Can someone please give me some extra basic example of how jzy3d should be used?
(The source site's examples don't seam to work for me)

I tried the following code:

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;

public class Test {

    public static void main(String[] args) {

        JFrame frame = new JFrame();
        Chart chart = getChart();

        frame.add((javax.swing.JComponent) chart.getCanvas());

        frame.setSize(800, 800);
        frame.setLocationRelativeTo(null);
        frame.setTitle("test");
        frame.setVisible(true);
    }

    public static Chart getChart() {
        // Define a function to plot
        Mapper mapper = new Mapper() {
            public double f(double x, double y) {
                return 10 * Math.sin(x / 10) * Math.cos(y / 20) * x;
            }
        };

        // Define range and precision for the function to plot
        Range range = new Range(-150, 150);
        int steps = 50;

        // Create the object to represent the function over the given range.
        org.jzy3d.plot3d.primitives.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.setWireframeDisplayed(true);
        surface.setWireframeColor(Color.BLACK);
        //surface.setFace(new ColorbarFace(surface));
        surface.setFaceDisplayed(true);
        //surface.setFace2dDisplayed(true); // opens a colorbar on the right part of the display

        // Create a chart
        Chart chart = new Chart();
        chart.getScene().getGraph().add(surface);
        return chart;
    }
}

But when I try to run it, I get that exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path

Can anyone help?

You should add jogl.jar to classpath and jogl.dll to PATH.
For more info look here and here .

You can read jogl Installation Instructions here .

You should run your program or demo where the JOGL native libraries stand, ie ./bin/{platform}. If you are working with Eclipse, right click on the project, choose Propeties, Java Build Path then the Libraries tab. Under the item "jogl.jar - ..." select "Native library location: (None)" and click the Edit button. Press the Workspace... button and select the ./bin/{platform} folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM