Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

java - Is it possible to use Jzy3D in a Netbeans 7.0 application?

Alright, so we're trying to incorporate a 3D scatterplot into our project in Netbeans 7.0, and one of the libraries we chose to test was Jzy3D. It looks likes it would do everything we needed it to, but unfortunately, it's not doing anything.

I have JOGL installed properly, and have tested it and found it to be working. Then I have included the same dependencies as in the demo. I have also tried directly including the .jars. And yes, gluegen-rt.jar is in the library folder.

EDIT: To get JOGL working, we had to heavily modify build settings. Honestly, my boss did most of it, so I'm not entirely sure how to replicate it yet. Now, I'm trying to put a chart in a JFrame, and the FrameSwing extension from the Jzy3D library is giving the following error:

Exception in thread "main" java.lang.ClassCastException: org.jzy3d.plot3d.rendering.canvas.CanvasAWT cannot be cast to javax.swing.JComponent
    at org.jzy3d.bridge.swing.FrameSwing.(FrameSwing.java:36)
    at scratchwork.My3DChart.main(My3DChart.java:40)

I'll keep working at it, but if someone knows what's wrong, it would be nice to know.

Update: It appears that CanvasAWT is extended from Canvas which is extended from Component, not JComponent. This seems to be the problem, and I've submitted it to the Jzy3D authors.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Maybe you forgot to create the chart using the "swing" option in the constructor as stated here. It creates the chart with a CanvasSwing which is a JComponent as expected in a Swing app.

Building a Swing chart creates a JOGL lightweight component that can be mixed with other JComponents appearing on top (the default AWT chart is heavyweight and remains on top of any other UI component).

Jzy3d has already been working with success both in Swing and other Windowing toolkits, so it should work for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...