I attempted to do a hello world application on jzy3d plotting library. I took the example from the website and when I run it I got the following error:
Exception in thread "main" java.lang.RuntimeException: No implemented
exception
Can anyone tell me what this means?
Here is the code for your reference:
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.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 HelloWorld {
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);
}
}
Error:
Exception in thread "main" java.lang.RuntimeException: No implemented
exception at
org.jzy3d.chart.factories.ChartComponentFactory.newFrame(ChartComponentFactory.java:148)
at org.jzy3d.chart.ChartLauncher.frame(ChartLauncher.java:82) at
org.jzy3d.chart.ChartLauncher.openChart(ChartLauncher.java:39) at
org.jzy3d.chart.ChartLauncher.openChart(ChartLauncher.java:33) at
org.jzy3d.chart.ChartLauncher.openChart(ChartLauncher.java:17) at
helloworld.HelloWorld.main(HelloWorld.java:77)
maybe this is a bug of the library itself, I had the same issue using jzy3d 0.9.1. Waiting for a new release, I solved the problem switching to the previous version jzy3d 0.9 that you can download from http://jzy3d.org/download-0.9.php . That worked for me, I hope it will work for you as well.
Best Regards
Related
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.
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.
To get the below code to run, I need to either:
comment out MapUtils.createDefaultEventDispatcher(this, map);
or
change map type to UnfoldingMap[] map;
it seems to me that the tutorial is wrong in this regard. the error I see in eclipse is:
The method createDefaultEventDispatcher(PApplet, UnfoldingMap[]) in the type MapUtils is not applicable for the arguments (SampleMapApp, UnfoldingMap)
Can anyone suggest to me how I can fix this?
import processing.core.PApplet;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.providers.AbstractMapProvider;
import de.fhpotsdam.unfolding.providers.Google;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.utils.MapUtils;
public class SampleMapApp extends PApplet {
UnfoldingMap map;
public void setup() {
AbstractMapProvider provider = new Google.GoogleTerrainProvider();
size(800, 600, P2D);
map = new UnfoldingMap(this, 50, 50, 500, 350, provider);
// Show map around the location in the given zoom level.
map.zoomAndPanTo(14, new Location(53.385f, -6.161f));
// Add mouse and keyboard interactions
MapUtils.createDefaultEventDispatcher(this, map);
}
public void draw() {
map.draw();
}
}
OK, turns out that downloading the latest and greatest processing has fixed the issue. I'd love to know why the code 'mostly' works though if it was a library issue all along. thanks tnagel for getting me to check the processing version.
I am trying to get a Box2D PointLight to render on the screen, but upon rendering, it throws an exception. I have revised the API and the Box2D User Manual, as well as watched videos on the topic, but have yet to find a solution to my problem. Here is my code and the error.
package com.mygdx.test;
import box2dLight.PointLight;
import box2dLight.RayHandler;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.World;
public class Test extends ApplicationAdapter {
/** the camera **/
OrthographicCamera camera;
RayHandler rayHandler;
World world;
#Override
public void create() {
camera = new OrthographicCamera(48, 32);
camera.update();
world = new World(new Vector2(0, -10), true);
rayHandler = new RayHandler(world);
new PointLight(rayHandler, 32);
}
#Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
world.step(Gdx.graphics.getDeltaTime(), 8, 3);
rayHandler.setCombinedMatrix(camera.combined);
rayHandler.updateAndRender();
}
And the error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: com.badlogic.gdx.graphics.glutils.FrameBuffer.getColorBufferTexture()Lcom/badlogic/gdx/graphics/Texture;
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
Caused by: java.lang.NoSuchMethodError: com.badlogic.gdx.graphics.glutils.FrameBuffer.getColorBufferTexture()Lcom/badlogic/gdx/graphics/Texture;
at box2dLight.LightMap.gaussianBlur(LightMap.java:76)
at box2dLight.LightMap.render(LightMap.java:37)
at box2dLight.RayHandler.render(RayHandler.java:328)
at box2dLight.RayHandler.updateAndRender(RayHandler.java:262)
at com.mygdx.test.Test.render(Test.java:33)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:215)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
I had the same issue with a newly generated libgdx project, however updating the box2dlights version from 1.3 to 1.4 solved this error for me.
Have you tried using this method?
new PointLight(rayHandler, RAYS_NUM, new Color(1,1,1,1), lightDistance, x, y);
I have also noticed, you should do
world.step();
at the end of the render() method. Probably wont fix the problem, but i just noticed
I am just learning how to use Java JNA, and I am trying to call a simple function from the Microsoft Kinect SDK. (NuiGetSensorCount) which just returns the number of connected kinects.
Here is my attempt:
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
public class Driver {
public interface KinectLibrary extends Library {
KinectLibrary INSTANCE = (KinectLibrary)Native.loadLibrary(("Microsoft.Kinect"),KinectLibrary.class);
//_Check_return_ HRESULT NUIAPI NuiGetSensorCount( _In_ int * pCount );
NativeLong NuiGetSensorCount(Pointer pCount);
}
public static void main(String[] args) {
Pointer devCount = new Pointer(0);
KinectLibrary.INSTANCE.NuiGetSensorCount(devCount);
System.out.println("Devices:"+devCount.getInt(0));
}
}
But I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'NuiGetSensorCount': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Library$Handler.invoke(Library.java:199)
at $Proxy0.NuiGetSensorCount(Unknown Source)
at Driver.main(Driver.java:30)
Can anybody provide help of how to change my code so it finds the correct native function? And also provide some information/reference so that I could try to debug this myself (some way to see what function Java JNA is looking for, and compare it to what the .dll contains)
I figured out my problem. First, I used a program called dependency walker http://dependencywalker.com/ to view all the symbols in the DLL and I determined that the DLL I was using (Microsoft.Kinect.dll) did not actually contain the function I was trying to call. I found out that Kinect10.dll was the one I needed. After changing that, I had to make a small change to my pointer and it works perfectly!
Here is the fixed code.
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
public class Driver{
public interface KinectLibrary extends StdCallLibrary {
KinectLibrary INSTANCE = (KinectLibrary)Native.loadLibrary(("Kinect10"),KinectLibrary.class);
//_Check_return_ HRESULT NUIAPI NuiGetSensorCount( _In_ int * pCount );
NativeLong NuiGetSensorCount(IntByReference pCount);
}
public static void main(String[] args) {
IntByReference a = new IntByReference();
KinectLibrary.INSTANCE.NuiGetSensorCount(a);
System.out.println("Devices:"+a.getValue());
}
}
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, 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.