The Java implementation is very similar: Each type of callback is implemented by a specific class. To create a new callback, the user must extend this class and overwrite the default invoke method of the class. Then the callback is registered by the addCallback method and the invoke method is called by Open Inventor. The user's data defined in C++ as the first argument of functionCB should be defined as a member of your own extended class.

The following example from the Print.java program shows how to set a callback on a keyboard event.

The ProcessKeyEventsextends the SoEventCallbackCB to add its own invoke method. A specific constructor is defined to save the user's data:

Pointers, values

All objects are handled through references. No pointers or values, but only references.

Operator redefinition

Several C++ classes redefine standard operators. This is not possible in Java. Alternate methods are provided to allow this kind of operation. For example, the SbVec3f operator = method is replaced by SbVec3f.setValue().

Methods with parameters given as references on basic types

When a C++ method takes a reference on a basic type as an argument, the Java prototype differs from the C++. This difference does not exist for Inventor types (So or Sb). The Java binding uses a reference on a basic type array to get the new value.
An example of this difference is shown with the Render Area getAntialiasing method.
In C++:

void getAntialiasing(SbBool &smoothing, int &numPasses) const

In Java:

public void getAntialiasing(boolean [] smoothing, int [] numPasses)

To call this method with Java, the user must define an array of 1 element for each parameter:

FEI Visualization Sciences Group is the leading provider of advanced 3D visualization and analysis software tools for developers, engineers and scientists in natural resources, medical and life sciences, and engineering.