0

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.

liuzp
  • 1
  • 1

1 Answers1

0

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.

Martin Pernollet
  • 2,285
  • 1
  • 28
  • 39
  • Sorry for the really long time to respond, the past few wees have been hell on earth to me and just now I got the time to check your answer, which lead me to fix the .pom file error that I was having, but unfortunately the Quality.Advanced error remains intact, even if I change the entire code, not changing a semi-colon, by the one provided by you. – liuzp Mar 13 '22 at 19:31
  • You have to replace Quality.Advanced field by Quality.Advanced() method call. See this line https://github.com/jzy3d/jzy3d-api/blob/master/jzy3d-tutorials/src/main/java/org/jzy3d/demos/surface/SurfaceDemoAWT.java#L54 – Martin Pernollet Mar 14 '22 at 08:35
  • so... The thing is that I've copied your example on Git Hub, _ipsis litteris_ and it still gives me the `Builder cannot be resolved The field Quality.Advanced is not visible` error, this time in the line 35 in the comment `// Define a function to plot`, can you still help me? – liuzp Apr 13 '22 at 18:13
  • As there is no reference to Quality.Advanced as a field in the demo, but only to Quality.Advanced() as a method, I presume something got wrong in your project dependencies. I suggest you restart a new project based on the example I provided. – Martin Pernollet Apr 27 '22 at 11:45