jzy3d builder cannot be resolved error on eclipse

212 views Asked by At

So, I've recently downloaded (via Maven) jzy3d library so that I can translate and improve an existing program of mine from JS to Java, and to get a handle on the new library I was trying some examples available on the library site but, as the title shows I keep getting the "Builder cannot be resolved" error. I've tried to add the org.jzy3d.plot3d.builder.Builder import but also without success, as it returns a non used import alert.

This is my code:

package randomProjects;

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.ChartLauncher;
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.Mapper;
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
import org.jzy3d.plot3d.primitives.Shape;
import org.jzy3d.plot3d.rendering.canvas.Quality;

public class SurfPlotTest_JZY3D {

    public static void main(String[] args){
        
        // 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 a surface drawing that function;
        Shape surface = 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(false);
        surface.setWireframeColor(Color.BLACK);

        // Create a chart and add the surface
        Chart chart = new Chart(Quality.Advanced);
        chart.getScene().getGraph().add(surface);
        ChartLauncher.openChart(chart);
        
    }
    
}

And this is the error message:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Builder cannot be resolved
    The field Quality.Advanced is not visible

    at randomProjects.SurfPlotTest_JZY3D.main(SurfPlotTest_JZY3D.java:30)

I also find important to mention that there is another error in the program at line #37, that I've tried fixing exchanging Quality.Advanced by Quality.Advanced(), but again, without any success what so ever.

A bit of an update in the hope of an answer

If I use the manually imported project files, also available in the library site, I don't get the builder error, but instead when compiling it returns the following error.

The project: org.jzy3d-0.9 which is referenced by the classpath, does not exist.

And this is the example code present in the project

package org.jzy3d.demos.surface;

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.keyboard.camera.CameraKeyController;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.demos.AbstractDemo;
import org.jzy3d.demos.DemoLauncher;
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.canvas.Quality;

public class ColorWaveDemo extends AbstractDemo {
    public static void main(String[] args) throws Exception {
        DemoLauncher.openDemo(new ColorWaveDemo());
    }

    public ColorWaveDemo() {
    }

    @Override
    public void init() {
        // Define a function to plot
        Mapper mapper = new Mapper() {
            public double f(double x, double y) {
                return x * Math.sin(x * y);
            }
        };

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

        // Create the object to represent the function over the given range.
        final Shape surface = 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(false);

        // Create a chart
        chart = new Chart(Quality.Advanced, getCanvasType());
        chart.getScene().getGraph().add(surface);
        chart.addController(new CameraKeyController());
    }
}

Consider me a complete noob in importing libraries via Maven or otherwise, I'm doing all this to get a handle and learn how to, so I would appreciate a detailed answer. If needed I can also include my .pom file.

1

There are 1 answers

4
Martin Pernollet On

The tutorial page from the website is quite outdated. You may find easier to use the tutorials that are embedded in the library, e.g. this surface example.

The readme of this module should help as well.