Listing 1

class TdkCanvas {

	//...
	public void plotLine(TeLine2D& line) = 0;
	//...

}

class TdkJNICanvas : public TdkCanvas
{

public:

	// constructor expects the bridged TdkSwingCanvas instance
        TdkJNICanvas(JNIEnv *env, jobject *jThis);

	//...
	public void plotLine(TeLine2D& line);
	//...

private:

        JavaVM *jvm_;         //Stores the Java virtual machine
        jobject objCanvas_; 	//Stores the Java«s TdkSwingCanvas instance

}

void TdkJNICanvas::plotLine(jobject& line)
{
        //Gets the current environment
        JNIEnv *env = getCurrentJAVAEnv(jvm_);
        jclass clsCanvas = env->GetObjectClass(objCanvas_);

        //Get the plotLine method ID
        jmethodID metCanvas = getMethodID(env, clsCanvas,
		"plotLine", "(Ltdk/core/geometry/TeLine2D;)V");
        //Runs the method
        env->CallVoidMethod(objCanvas_, metCanvas, line);
}

//-------------

package tdk.graphics;

interface TdkCanvas {

	void plotLine(TeLine2D line);
}

public class TdkSwingCanvas implements TdkCanvas {


	//...
	private Graphics currGraphics_;
	//...

	public void plotLine(TeLine2D line) {

		//...

		// all geoms are Graphics2D Shape compositions
		currGraphics_.draw(line.getShape());

		//...