Chapter 2.
Setting Up the Development Environment


OVERVIEW

 

Perspective for Java can be used with one of the following development platforms:

 

A Java 1.1 compliant browser (Internet Explorer 4.0 or Netscape 4.0)

 

A Java 1.1 compliant Development Environment (JDE) such as Symantec Visual Café 4.0.

REQUIRED FILES

 

The files that you will need to use Perspective will be different depending on your development environment: a Java Development Environment (JDE) or a Java 1.1 compliant browser.

Files Required for a JDE

 

If you are using a Java Development Environment to develop Perspective JavaCharts, you need this:

 

A Perspective for Java .JAR file (Complete Library with Editor, Heavyweight Bean, or Lightweight Bean. See Chapter 1 for details)

 

The Perspective for Java .JAR file is the Perspective class library that must be included in the component library in a Java Development Environment such as Symantec VisualCafe. The .JAR file includes the applets, the class files, and the JavaBean information for Perspective.class. The .JAR file is available via the 3D web page at http://www.threedgraphics.com.

Files Required for a Browser

 

If you are using a Browser to develop Perspective JavaCharts, you need these files:

 

A Perspective for Java .JAR file (Complete Library with Editor, Heavyweight Bean, or Lightweight Bean. See Chapter 1 for details)

 

PFJ_GIFS.ZIP

 

PFJ_TILE.ZIP

 

Sample Code (optional)

FILE LOCATIONS

 

The required file locations will be different depending on your development environment: a Java Development Environment (JDE) or a Java 1.1 compliant browser.

Using a JDE

 

The Perspective for Java .JAR file must be installed as a component in the JDE's component library. Use the documentation provided with your JDE to add this file to the component library.

Using a Browser

 

To create a full system on a local machine, install the files as follows:

 

1.

Create a directory on your hard disk.

 

2.

Copy the Perspective for Java .JAR file into the directory.

 

3.

Unzip the PFJ_GIFS.ZIP files into the same directory. The extracted files must reside in the same directory as the .JAR file.

 

4.

Create a "tiles" subdirectory. Unzip the PFJ_TILE.ZIP file into the "tiles" subdirectory.

 

5.

Unzip the sample code .ZIP files into the same directory. The extracted HTML and .java files must reside in the same directory as the .JAR file.

DEVELOPMENT REQUIREMENTS

 

Perspective for Java is a Java 1.1 library and requires a browser with full 1.1 compatibility (i.e., at least 4.0 versions of either of the two major browsers or a development environment that is fully compatible with Java 1.1).

Java Bean

 

Perspective for Java requires a Java development environment with full Java 1.1 compatibility:

 

Symantec Visual Café

 

Borland JBuilder

 

Sybase PowerJ

 

IBM Visual Age

 

Or any other Bean-aware Java Development Environment

HTML

 

Perspective for Java requires a browser with full Java 1.1 compatibility:

 

Netscape Communicator 4.03 with the JDK 1.1 Patch

 

Internet Explorer 4.0

USING PERSPECTIVE IN A SERVLET

 

Perspective charts can be also be used in a servlet-based application. The following locations provide basic information about Java servlet development:

 

http://java.sun.com/products/servlet/ ; Javasoft servlet product page.

 

http://java.sun.com/products/servlet/technical.html; Javasoft technical resources page on servlets.

 

The technical resources page includes a number of useful articles and tutorials for developing and using servlets.

 

The Three |D| Graphics web page contains a number of well-documented example Java programs that illustrate how to use Perspective in a servlet-based application.

 

If you want to display a Perspective chart as a .gif image in an .html page, see the GifServlet.Java example program.

 

If you want to display a Perspective chart as a .gif image in an .html page that is continuously updated (i.e., a "server push"), see the PushServlet.Java example program. This servlet should be used in conjunction with the .html page in the Server Push Example (ServerPush.html).

 

When a "server push" is used, the chart image will change and display updated data without the browser doing anything and without the user selecting the "Reload" button. Note that both of these servlets are basically the same. The first example only saves the image once. In the "server push" example, the .html file continuously forwards the browser back to the servlet.

 

For more information, see the servlet documentation at Javasoft.

 

If you want to update a Perspective chart based on parameters passed to the servlet, remember that parameters are passed to a servlet in the URL. For example:

 

http://my.domain.com/servlets/
MyChartServlet?user=Bob&data=payroll&chartType=15

 

In this example, three parameters are passed to the servlet called MyChartServlet:

 

user = Bob
data = payroll
chartType = 15

 

Depending on the parameters, you can display a different chart, using the sample servlets provided above. Any parameters could be passed -- it just depends on how you want to develop your web application.

 

The value of each parameter can be obtained in your servlet's code using the following method:

 

ServletRequest.getParameter(String paramName)

 

For more information, see the servlet documentation at Javasoft.

 

If you want to allow the user to download a Perspective chart as a .gif image, the simplest solution is to display the chart in an .html page, and let the user download it using the functionality provided by the Web browser.

 

If this is not acceptable, you can directly download the chart image from a servlet (e.g., the user will see a "Save As..." dialog from the browser). To do this, write the .gif image to the OutputStream provided by the ServletResponse object. See the example DownloadGifServlet.java that implements this solution.

 

When you are ready to use the servlet on your Web site, you will need to check your Web Server's documentation. Different Web Servers have different mechanisms for deploying a servlet. In very general terms:

 

1)

You will need to place your servlet's .class file in a directory where it is accessible to your Web Server.

 

2)

You will need to change a configuration file of some kind, so the server can access the servlet. Some Web Servers may provide a graphical UI for this purpose.