1. Products
  2.   3D
  3.   Java
  4.   Jzy3d

Jzy3d

 
 

Open Source Java Library for Working with 3D Charts

Java Library that has provided functionality for drawing 3D Charts and scientific data. It supports various chart types like surface, bar and scatter charts as well as other chart families.

Jzy3d is an open source Java plotting library that gives software developers the capability to create their own apps that can draw charts and 3d scientific data with just a couple of lines of Java code. The library supports several important features related to surfaces, scatter plots, bar charts, and a lot of other 3d primitives. You can easily customize the axis and chart layout with just a couple of Java commands.

The API is very stable and can be easily integrated into any commercial or personal project. It has included support for several important charts types such as surface charts, bar charts, scatter charts, 2D & 3D graphs charts, rich chart options, and primitive types like spheres, triangles, polygons, and so on.

The library has provided a very flexible layout that has included easy-to-ease chart layout settings such as color bars, contour functions, tooltips, lights, color mappers support for coloring objects, background images, 2D post renderers, and much more. You can also easily integrate the chart into your AWT, Swing, and SWT applications. Several advanced features like 2d envelopes, Dual depth peeling, 3d line strip interpolation to smooth paths, Mouse interaction with objects, Thread Controllers, animation, and much more.

Previous Next

Getting Started with Jzy3d

The easiest way to install Jzy3d is by using GitHub.Please use the following command for a smooth installation. 

Install Jzy3d via GitHub

git clone --depth=1 https://github.com/jzy3d/jzy3d-api.git 

Draw Surface Chart via Java

The open source Jzy3d library gives software developers the capability to draw surface charts using Java commands. First of all, you need to define the range for the function to plot the chart. After that, you can create the object to represent the function over the given range. Now you can easily draw charts. You draw a simple surface, big surface, Delaunay tesselation, no wireframe surface, and more.

How to Draw a Surface Chart using Java API ?

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.factories.AWTChartComponentFactory;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Mapper;
import org.jzy3d.plot3d.builder.SurfaceBuilder;
import org.jzy3d.plot3d.primitives.Shape;

public class SurfaceChartExample {

    public static void main(String[] args) {
        // Define the function to be plotted
        Mapper mapper = new Mapper() {
            @Override
            public double f(double x, double y) {
                return Math.sin(x) * Math.cos(y);
            }
        };

        // Define the range of the plot
        Range range = new Range(-Math.PI, Math.PI);

        // Build the surface
        SurfaceBuilder surfaceBuilder = new SurfaceBuilder();
        Shape surface = surfaceBuilder.buildOrthonormal(new OrthonormalGrid(range, 50, range, 50), mapper);

        // Set surface color
        surface.setColor(Color.GREEN);

        // Create a chart
        Chart chart = AWTChartComponentFactory.chart();

        // Add the surface to the chart
        chart.getScene().getGraph().add(surface);

        // Show the chart
        chart.open("Surface Chart Example");
    }
}
 

Create 3D Polar Charts

The Jzy3d library gives software programmers the power to create 3D Polar Charts with ease inside their apps. You can need to set the values for the chart as a dedicated polar dataset allows you to easily make operations on the coordinates. You can define the chart title, the dataset for the chart, chart legend, tooltips, and URLs.

How to Create 3D Polar Charts using Java Library?

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.factories.AWTChartComponentFactory;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Mapper;
import org.jzy3d.plot3d.builder.SurfaceBuilder;
import org.jzy3d.plot3d.primitives.Shape;

public class SurfaceChartExample {

    public static void main(String[] args) {
        // Define the function to be plotted
        Mapper mapper = new Mapper() {
            @Override
            public double f(double x, double y) {
                return Math.sin(x) * Math.cos(y);
            }
        };

        // Define the range of the plot
        Range range = new Range(-Math.PI, Math.PI);

        // Build the surface
        SurfaceBuilder surfaceBuilder = new SurfaceBuilder();
        Shape surface = surfaceBuilder.buildOrthonormal(new OrthonormalGrid(range, 50, range, 50), mapper);

        // Set surface color
        surface.setColor(Color.GREEN);

        // Create a chart
        Chart chart = AWTChartComponentFactory.chart();

        // Add the surface to the chart
        chart.getScene().getGraph().add(surface);

        // Show the chart
        chart.open("Surface Chart Example");
    }
}
 

Build and Manage 3D Charts via Java

The open source Jzy3d library gives software developers the capability to build and manage 3D charts inside their application using Java commands. The Jzy3d Logarithm Toolbox can be very helpful in drawing 3d charts with log scales very easily. You can also easily edit your charts with ease. It provides dedicated axis, views, ordering strategies, and colormaps suitable for clean logarithmic charts with ease.

Edit Surface Mesh via Java

The Jzy3d library gives software developers the capability to edit their surface meshes via Java code. It has provided SDK that has provided interactive surface editor which enables users to model a surface by grabbing its mesh points with the mouse or trackpad. The surface is presented in an excel-like table that is synchronized with drawing.

How to Edit Surface Mesh inside Java Apps ?


import javax.swing.*;

public class Jzy3dSurfaceMeshExample {

    public static void main(String[] args) {
        // Define the surface function
        Mapper mapper = new Mapper() {
            @Override
            public double f(double x, double y) {
                return Math.sin(x) * Math.cos(y);
            }
        };

        // Define the range for x and y
        Range range = new Range(-Math.PI, Math.PI);

        // Create a surface mesh
        Surface surface = new Surface(mapper, range, 50, Color.RED);

        // Create a chart
        Chart chart = new Chart(Quality.Advanced);

        // Add the surface to the chart
        chart.getScene().getGraph().add(surface);

        // Create a frame for the chart
        JFrame frame = new JFrame("Jzy3d Surface Mesh Example");
        frame.setSize(800, 600);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Add the chart to the frame
        frame.getContentPane().add(chart.getCanvas());

        // Make the frame visible
        frame.setVisible(true);

        // Edit the surface function after a delay
        SwingUtilities.invokeLater(() -> {
            // Modify the surface function
            Mapper newMapper = new Mapper() {
                @Override
                public double f(double x, double y) {
                    return Math.sin(x) * Math.sin(y); // Modified function
                }
            };

            // Update the surface with the new function
            surface.setMapper(newMapper);
            chart.render();
        });
    }
}
 
 English