1

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?

Martin Pernollet
  • 2,285
  • 1
  • 28
  • 39
Jsncrdnl
  • 3,005
  • 5
  • 28
  • 43

2 Answers2

0

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.

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • I follow the first tip of this link : (http://code.google.com/p/jzy3d/wiki/FAQ). But now I get another error :: Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\UserName\workspace\Test\bin2\win32\jogl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform – Jsncrdnl Nov 08 '11 at 11:10
  • Read this post: http://stackoverflow.com/questions/5328951/jogl-32-vs-64-bit-libraries-error – Alex K Nov 08 '11 at 11:14
  • And this articles: https://sites.google.com/site/justinscsstuff/jogl-tutorial-1 & http://jogamp.org/jogl/doc/HowToBuild.html – Alex K Nov 08 '11 at 11:16
  • The links helped me found a 64bit version to use in my project. And I can now go farther. Now the problem is relative to the integration in my interface. Indeed, I followed that instructions :: (http://code.google.com/p/jzy3d/wiki/EmbeddingChartInAnExistingApplication). With Swing :: """Exception in thread "main" java.lang.ClassCastException: org.jzy3d.plot3d.rendering.canvas.CanvasAWT cannot be cast to javax.swing.JComponent"""". With AWT :: "Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: com.sun.opengl.impl.JAWTFactory.JAWT_GetAWT0(Ljava/nio/ByteBuffer;)Z" – Jsncrdnl Nov 08 '11 at 11:48
  • Read this post: http://stackoverflow.com/questions/6494668/is-it-possible-to-use-jzy3d-in-a-netbeans-7-0-application/6538335 – Alex K Nov 08 '11 at 12:09
  • I actually did read that part of the site and have called """new Chart("swing")""" but I still get this error – Jsncrdnl Nov 08 '11 at 12:21
0

You should run your program or demo where the JOGL native libraries stand, i.e. ./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.

Martin Pernollet
  • 2,285
  • 1
  • 28
  • 39
  • I follow the first tip of this link but now I get another error :: Exception in thread "main" java.lang.UnsatisfiedLinkError: """C:\Users\UserName\workspace\Test\bin2\win32\jogl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform """ – Jsncrdnl Nov 08 '11 at 11:11
  • You might not be using the appropriate binaries. Try to load the AMD binaries. – Martin Pernollet Nov 15 '11 at 14:59
  • Because you're trying to run the 32 bit demo on a 64 bit JVM. The `paltform` @Martin was referring to should be `amd64` or `win64` or whatever path contains the jogl.dll for 64 bits. Or, you can use a 32 bit JVM to run it (to be selected in "Running configuration"). – Matthieu Jun 08 '13 at 08:41