The HOOPS/Java integration consists of a connection between HOOPS/3dGS and the Java/SWT 'Canvas' GUI object. This document describes how to use the HOOPS/Java integration to build a Java/SWT application that incorporates the HOOPS/3DF components. Some familiarity with Java/SWT, HOOPS/3DGS and HOOPS/MVO is assumed.
Developers should start by compiling and running the basic java_simple_swt application as the starting point for their application. This is an example for Java developers wishing to incorporate the HOOPS/3DF components into either existing or new Java applications. This integration uses the Java/SWT libraries. The readable source code is located in your <hoops>/demo/java/java_simple_swt directory.
The HOOPS/Java integration is supported under the J2SE Development Kit 6.0 (JDK 6.0), on the Windows 32-bit and 64-bit platforms with Visual Studio 2010(VC10). It is also supported on Linux platforms.
The following steps are required to compile and run a HOOPS/Java based application:
The above files should all be located in your <hoops>/bin/nt_i386_vc< MS Visual Studio Version > directory.
This section discusses the relationship between Java and HOOPS/3DF components. Building an application with both these toolkits minimally involves using the following objects from each component.
A Java/SWT application would typically have a master document object.
Your application should have at least one HoopsSwtCanvas; typically, you would create a custom canvas derived from HoopsSwtCanvas. The readable source for the HoopsSwtCanvas class can be found the <hoops>/Dev_Tools/hoops_java/source directory. This canvas interacts with the master document object.
HBaseModel, HBaseView and an Operator class derived from HBaseOperator. Applications that want to implement selection of geometry will also need a HSelectionSet object. These objects are all connected by private data members which store pointers to other objects in the following manner:
Programming with an object oriented GUI framework like Java/SWT involves creating a set of objects and defining the ways in which they are connected, the manner in which they send and receive messages, and then launching the framework's event loop. Building an application using Java/SWT and HOOPS/3DF specifically requires creation and initialization of:
A Java/SWT application typically creates a master application object which implements the function main(). The java_simple_swt application provides an example which creates a custom class called SWTApplicaton and calls its CreateNewDocument method:
The sample SWTApplicaton implementation includes a method called CreateNewDocument which will create a our document object called SWTDocument:
The GUI aspect of the HOOPS/Java integration simply consists of a customized Java/SWT canvas called SimpleHJCanvas as diagramed up above. As many HoopsSwtCanvas objects can be created as needed to implement the GUI's design. The application should create a custom HoopsSwtCanvas class, as shown in java_simple_swt:
Your custom canvas will most likely be created and attached in your custom document. In this case, the SWTDocument class extends the Thread class. When start is called from SWTApplicaton::CreateNewDocument, the Java Virtual Manual calls run. This is where the SimpleHJCanvas is created, included as part of the shell and set to visible.
One global pointer to a HOOPS/MVO HDB object should be declared and initialized in the application's main class. The java_simple_swt app does this in the SWTApplicaton constructor:
For each SimpleHJCanvas object there is one HBaseModel. In the java_simple_swt app, HoopsSwtCanvas, which is the parent class of SimpleHJCanvas, creates one in its constructor. SWTDocument uses its instance of SimpleHJCanvas to access the model for loading files:
Multiple HBaseView objects can be created, with one object created for each SimpleHJCanvas as define in its parent HoopsSWTCanvas's constructor. In the java_simple_swt example, the SWTDocument accesses the view via its instance of SimpleHJCanvas to perform such operations as writing out to a file.
A default operator should be created during view initialization as it is done HoopsSwtCanvas::CreateView. In the The java_simple_swt app, SWTDocument sets the current operator by using its instance of HSimpleHJCanvas: