A Java API for 3d and 2d charts
Jzy3d is a framework for easily drawing 3d and 2d charts in Java, using either fast native GPU rendering or CPU based rendering to enhance portability across combination of OS/JVM/GPU.
The framework targets simplicity and portability across Java windowing toolkits (AWT, SWT, NEWT, Swing, JavaFX, Offscreen rendering), running either on MacOS, Windows and Linux. Jzy3d is available for other languages or platforms such as Scala, Groovy, Matlab, C#, and even Python.
The API can be used freely in commercial applications. You can explore the tutorials. an then purchase the extended developper guide to support the development effort.
Refer to the tutorial README file to get help on creating your first chart project with the help of example code.
As this library focuses on portability of the charts, the org.jzy3d.demos.surface
package in jzy3d-tutorials demonstrates the same chart running on AWT, SWT, Swing using native OpenGL powered by JOGL and jGL CPU rendering.
public class SurfaceDemoAWT extends AWTAbstractAnalysis {
public static void main(String[] args) throws Exception {
SurfaceDemoAWT d = new SurfaceDemoAWT();
AnalysisLauncher.open(d);
}
@Override
public void init() {
// Define a function to plot
Mapper mapper = new Mapper() {
@Override
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 = new SurfaceBuilder().orthonormal(new OrthonormalGrid(range, steps), mapper);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface, new Color(1, 1, 1, .5f)));
surface.setFaceDisplayed(true);
surface.setWireframeDisplayed(true);
surface.setWireframeColor(Color.BLACK);
// Create a chart
GLCapabilities c = new GLCapabilities(GLProfile.get(GLProfile.GL2));
IPainterFactory p = new AWTPainterFactory(c);
IChartFactory f = new AWTChartFactory(p);
chart = f.newChart(Quality.Advanced);
chart.getScene().getGraph().add(surface);
}
}
Multiple chart types
Flexible layout
Algorithms
Interactions
High and low level OpenGL programming
Cross platforms and compatible
Extensions
Jzy3d depends on the following libraries that are available on Jzy3d Maven repository (See tutorials for recommended Maven setup)
The tutorial provides the code samples you need to add the library to a Maven project.
If you did not built the framework yourself and depend on Jzy3D Maven Repository, then you may wish to see sources and javadoc in your IDE. Simply call :
mvn dependency:resolve -Dclassifier=javadoc
mvn dependency:resolve -Dclassifier=sources
This will run all test named **/Test*.java
or **/*Test.java
.
mvn clean install
Integration tests compare charts to baseline images pixel wise. They are important in te toolbelt but have the drawback of being less portable accross computers
jzy3d-tests-java9
since at lest Java 9 JREs are required to detect HiDPI for EmulGL charts.This will run all test named **/ITTest*.java
and unit tests.
mvn clean install -Pintegration-tests
This will skip all tests (unit and integration)
mvn clean install -DskipTests
Some test require a manual verification.
mvn clean source:jar javadoc:jar deploy
Comment module jzy3d-tutorial manually
mvn compile javadoc:javadoc javadoc:aggregate
Follow these steps to import in IntelliJ
Import Maven project
or Import Maven project from SCM
Version 2.0 is a major refactor to allow using multiple OpenGL implementations, which opened the door to EmulGL. To ease porting your 1.* charts, we add the following cheatsheet.
Class name in 1.* | Class name in 2.0 |
---|---|
Quality.Advanced, Intermediate | Quality.Advanced(), Intermediate() |
AbstractDrawable | Drawable |
AbstractWireframeable | Wireframeable |
AxeBox | AxisBox |
DrawableTexture | NativeDrawableImage & EmulGLDrawableImage |
IChartComponentFactory | IChartFactory |
AWTChartComponentFactory | AWTChartFactory |
NewtChartComponentFactory | NewtChartFactory |
JavaFXChartComponentFactory | JavaFXChartFactory |
SwingChartComponentFactory | SwingChartFactory |
SWTChartComponentFactory | SWTChartFactory |
FallbackChartFactory | |
ColorbarViewportLayout | ViewAndColorbarsLayout |
ViewMouseController | NewtViewCameraController |
Halign | Horizontal |
Valign | Vertical |
Surface | SurfaceBuilder |
SurfaceBuilder is not static anymore to be overridable.
IPainter
IPainterFactory
EmulGLPainterFactory
IAnimator
IImageWrapper
and SymbolHandler