Notice: This material is excerpted from Special Edition Using Java, ISBN: 0-7897-0604-0. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.
by Mark Wutka
Even though you have now learned how to use Java, you may still be wondering what to do with it. This chapter will introduce you to some companies that are doing Java development in the real-world, show you some of the ways they are using Java, and give you some idea of how to take advantage of Java's unique features.
In this chapter you will see:
The University of Michigan Weather Underground has been providing weather information to Internet users since 1991. Back then, the only way this data was available was through the text-based telnet interface. In 1993, the Weather Underground decided it was time to go graphical, so they hired Alan Steremberg. Alan created "Blue Skies," a graphical front end to the weather system that ran on the Macintosh computer. Unfortunately, this left other users such as PC and UNIX workstation users out in the cold. Now, thanks to the wonders of Java, Alan, along with Christopher Schwerzler, has made graphical weather data available to a much wider audience.
This new Java version of "Blue Skies" can display textual weather information on top of a graphical map. As the mouse passes over a city on the map, the status bar at the top is updated with that city's current conditions. Users can get the National Weather Service forecast for a city just by clicking on that city. "Blue Skies" also allows users to zoom in on a particular area. The following figure shows a sample weather map from the "Blue Skies" applet:
Fig. 31.1 The "Blue Skies" applet displays a map of precipitation.
You can find "Blue Skies" on the World Wide Web at the address:
This is just one of the many ways that Java can be used to access data that was once only available in text form.
Creative Media Cauldron is an up and coming Web development shop located in New York City's "Silicon Alley." The company develops cutting-edge Internet content and tools that are both high-impact and cost-effective. They blend a rare mixture of artistic design sense and technology expertise.
Creative Media Cauldron has made great use of Java's Object-Oriented features by creating a framework of reusable objects. They sell a number of useful components that they call "Plug-In Playlets." These playlets are applets that you can use to add neat features to your Web pages. Among the playlets currently available are: Streaming Animation, Temporal ImageMap, HotButton Panel, and Invisible Download.
The Streaming Animation playlet is used for displaying simple animation sequences while larger sequences are still downloading. This allows your page to be "active" faster, while still allowing you to display complex animation sequences. For instance, you might display a simple 2-frame animation that the user can interact with while you are downloading a much-nicer 20-frame animation.
The Temporal ImageMap playlet is a neat variation on the old clickable image that you find on many Web pages. Rather than provide one image with different sections you can click on, the Temporal ImageMap shows you different images at different times, allowing you to click on any one you like. This allows you to create a large number of clickable images, yet display them in an area the size of a single image. The following two figures show snapshots of the Temporal ImageMap at two separate times. Notice that the icons on the left and right have changed.
Fig. 31.2 Each icon in a Temporal ImageMap leads to a different Web page
Fig. 31.3 Temporal ImageMaps conserve space by cycling images through the same area.
The HotButton Panel playlet creates a button that is "alive." When you pass the mouse over the button, it changes. For instance, you could create a button that displayed an image, but when the mouse passed over it, you could also display a text description of the button. This is similar to the concept of the "Hot Zone" in windows, where you see the name of a button if you leave the mouse pointer on the button for a few seconds. The following two figures show a hot button before the mouse passes over it, and while the mouse is sitting on top of the button. Notice the text that appears while mouse is on top of the button.
Fig. 31.4 The HotButton looks just like a normal image.
Fig. 31.5 The HotButton changes its appearance when the mouse passes over it.
The Invisible Download playlet allows you to download images and other items and have them cached for later use. For instance, you might have a main Web page with a link to an image page containing 20 different images. You can use the Invisible Download playlet from the main page to start downloading the images for the image page ahead of time. That way, when a user clicked on the link for the image page, some or all of the images would already be loaded.
Since Creative Media Cauldron has developed these playlets on top of a core set of objects, much of the code for these playlets is shared. One of the advantages of having large amount of shared code is that once the code for one playlet is downloaded, the other playlets using that same code will not have to wait for it to be downloaded. From a development standpoint, Creative Media Cauldron can develop new playlets very quickly because they have built a framework that handles many common tasks for them.
Creative Media Cauldron is very excited about the opportunities presented by Java. According to Andruid Kerne of Creative Media Cauldron, "Java inside of Netscape is the most powerful cross-platform development environment ever created. We are excited to create truly interactive distributed environments across the Internet."
Creative Media Cauldron can be found on the World Wide Web at the address:
MagnaStar Inc. was the first company to be formed for the express purpose of doing 100% Java coding. They provide consulting, training and lecturing in Java, in addition to programming. MagnaStar's primary focus is in doing custom work for clients, although when the programmers are not working on a client project, they are honing their Java skills and pushing Java to its limits. Many of their research products end up in class libraries that are used for client applications, while others will be marketed on their own sometime in the future. MagnaStar's location on the World Wide Web is:
One of the difficulties faced by many companies in migrating to the Internet is that much of a company's data is still on older "legacy" systems that aren't very Internet friendly. Many companies are using the Common Gateway Interface (CGI) to access their legacy data, but many more are finding that CGI just isn't interactive enough to suit their needs. MagnaStar uses Java to create network front-ends for their clients' legacy systems. Java's graphical user interface and networking capabilities make it an ideal tool for accessing legacy data. Using Java, a salesperson out on the road can access the company's ordering system over the Internet through a Java applet.
Java promises to provide greater flexibility in common applications and reduce the size of these applications. One of the reasons that packages such as word processors are so large these days is because of the number of features they provide. The problem here is that everyone uses a different set of features, and only in very rare circumstances does one person use every single feature provided. A word processor written in Java could allow you to add a thesaurus only when you needed it. Someone who never used a thesaurus would never have the thesaurus code in their application. Java supports the concept of "dynamic loading" of classes-it can add new classes "on-the-fly." For example, you could suddenly decide that you need a thesaurus and Java could download the thesaurus from the Internet while you were still running your word processor. MagnaStar's "Universal Applications" program, still under development, is aimed towards achieving this kind of dynamic application.
Java provides a number of features that can help make a Web page more effective. One of the most useful features is the ability to jump to other URLs. Rather than using the old static text link, or even an image map, you can create unique, lively ways of displaying links to other Web pages.
MagnaStar has written several applets that help enhance Web pages. The UltraNav navigation tool helps users navigate through a hierarchy of information that same way that a file manager navigates through files and directories. For instance, you might want to organize your information into categories such as "Business", "Education", and "Games." You might want to further break "Business" down into "Sales" and "Finance." If you were doing this with static Web pages, you would have a link to the Business page, which would then have links to the Sales and Finance pages. UltraNav lets you create a shortcut. Rather than having to pull up three different pages to get to Sales, UltraNav shows you the choices and lets you navigate down to Sales from within UltraNav, then when you select Sales, you jump directly to the Sales page. In other words, UltraNav uses Java to help you create Web shortcuts, saving users time, and also presenting a sort of "overhead view" of the page hierarchy. Figure 31.6 shows UltraNav in action:
UltraNav is available over the World Wide Web for demonstration:
MagnaStar's Carousel provides yet another way to create interesting links. It presents a number of images in the form of a 3D kiosk. You can use the mouse to spin the carousel around to see the different images, then when you see one you are interested in, you can click on the image and visit the page it refers to. The following figure shows Carousel in action:
Fig. 31.6 MagnaStar's Carousel presents a rotating kiosk of images.
You can try out Carousel on the World Wide Web:
MagnaStar also creates games in Java to help make a page more interesting. Someone surfing the Web might stop at a page for 10 seconds, but if there's a game on the page, they might stay a little longer. That is significant if you are trying to put advertising on your pages.
Java isn't just for sprucing up your Web pages. It is a powerful language, well-suited for application development. In fact, MagnaStar is so confident in Java's suitability for development that they develop 100% of their code in Java. Some of the advantages that Java provides over some of the more traditional languages like C++ are:
MagnaStar has created a database system called "Products Unlimited" that allows users to browse through a large catalog of company products and locate products quickly. According to Joe Weber of MagnaStar, "The unique user interface makes it trivial for Web viewers to find the products they are looking for, and because the entire system is coded in Java, without any modifications, users of Products Unlimited can present their information on the World Wide Web for every platform, all with the same friendly interface."
Pioneer Technologies Inc. (PTI), has already seen some success creating Web pages, now it is looking to branch into online client-server computing using Java. PTI hopes to offer a variety of online services, available through a server on the Internet.
Pioneer Technologies' architecture consists of a single server program, which can dynamically load any number of service objects, and a client applet, that can dynamically load objects to provide custom graphical interfaces for various services.
Fig. 31.7 The PTI Architecture Features a Server with Multiple Services and a Client with multiple user interfaces.
Java's ability to load classes dynamically is a key to PTI's online technology. PTI uses a single server program-no matter what services are running, it always uses the same code for the server. The server program can be configured to provide a certain set of services, and can also add services on the fly.
On the client side, the story is very similar. PTI uses a single client applet to communicate with the server program. Whenever a user requests a service, the client checks to see if it already has the user interface class for that service loaded. If not, it downloads the user interface class from the server and proceeds on.
Another key to PTI's architecture is the concept of interfaces. In order to support multiple services, Pioneer Technologies has designed a common interface between server and service. The server may query the service for information such as its version and the version of the client software required to use it. The server also uses the interface to pass client messages on to the service. Because each service supports the same interface, the server program never needs to be changed in order to support new services.
Interfaces are just as important on the client side in PTI's architecture. The user interface classes all provide the same interface for the client applet. The client applet can query a user interface class for its version, and also pass on messages from the server. For instance, suppose the server provides a banking service where you can check your account balance. When a user requests the banking service, the client applet asks the server what version of the banking service user interface is required. It then sees if it has the banking service user interface loaded already, and if so, what version it is. If the versions do not match, it automatically loads the newer version. This allows services to be upgraded on the server on-the-fly.
In designing the client applet, Pioneer Technologies took advantage of the AWT's Panel class. The client applet divides its interface into two portions-the server interface and the service interface. The server interface allows clients to log onto the server, see what services are available, and select a service. The service interface contains the user interface to a particular service. For instance, a user running the server interface would see something like:
Fig. 31.8 The PTI client applet allows users to choose among a variety of services.
Once a service like the funds transfer service is selected, the client applet would look like:
Fig. 31.9 Each service in the PTI client has its own panel, and is presented on a card layout.
Each service user interface is a separate instance of a Panel class. The client applet simply displays the user interface Panel for a service when the user selects that service. By using the CardLayout layout manager, the Client applet is able to switch between server interface and service interface at any time.
Pioneer Technologies hopes to be able to provide their own online services, as well as license this technology to other companies. They are located on the World Wide Web at http://www.pioneertech.com/pti.
For technical support for our books and software contact support@mcp.com
Copyright ©1996, Que Corporation