0

所以,我最近(通过 Maven)下载了 jzy3d 库,这样我就可以将我现有的程序从 JS 转换和改进为 Java,并掌握新库的处理,我正在尝试库网站上提供的一些示例,但是,如标题所示,我不断收到“无法解析生成器”错误。我尝试添加org.jzy3d.plot3d.builder.Builder导入但也没有成功,因为它返回未使用的导入警报。

这是我的代码:

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);
        
    }
    
}

这是错误消息:

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)

我还发现在第 37 行的程序中还有另一个错误很重要,我尝试通过Quality.Advanced()修复交换Quality.Advanced,但同样没有任何成功。

稍微更新一下,希望有答案

如果我使用手动导入的项目文件(也可在库站点中找到),我不会收到生成器错误,而是在编译时返回以下错误。

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

这是项目中的示例代码

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());
    }
}

在通过 Maven 或其他方式导入库时,请考虑我是一个完全的菜鸟,我正在做这一切以掌握并学习如何操作,所以我将不胜感激。如果需要,我还可以包含我的 .pom 文件。

4

1 回答 1

0

网站上的教程页面已经过时了。您可能会发现更容易使用库中嵌入的教程,例如这个表面示例

模块的自述文件也应该有所帮助。

于 2022-02-14T16:41:55.750 回答