Skip to content Skip to navigation

OpenStax_CNX

You are here: Home » Content » Java3000: The Guzdial-Ericson Multimedia Class Library

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Java3000: The Guzdial-Ericson Multimedia Class Library

Module by: R.G. (Dick) Baldwin. E-mail the author

Summary: Learn how to use the Guzdial-Ericson Multimedia Class Library

Preface

In the weeks and months to come, I will publish several modules that use a multimedia class library developed and made available by Mark Guzdial and Barbara Ericson of the Georgia Institute of Technology. The purpose of this module is to provide the information that you will need to obtain and use a copy of that library.

Images and listings

Images

Listings

Preview

Among other things, the Guzdial-Ericson multimedia class library makes it practical to write object-oriented programs for the manipulation of images in an interesting and educational way. For example, the image in Image 1 was produced by manipulating and merging the images shown in Image 2 and Image 3 .

1
Image 1: Result of merging two images.
This image shows the result of merging an image of a penguin  with an image of a rabbot. The picture morphs from the penguin image on the left to the rabbit image on the right.

One of the input images is shown in Image 2 .

2
Image 2: Input image #1.
This is the rabbit image that was merged with  the penguin image to produce the resulting image shown in Image 1.

The other input image is shown in Image 3 .

3
Image 3: Input image #2.
This is the penguin image that was merged with  the rabbit image to produce the resulting image shown in Image 1.

Discussion

The Guzdial-Ericson library was originally published by Guzdial and Ericson in conjunction with their book Introduction to Computing and Programming with Java: A Multimedia Approach . While the book isn't free, the library is freely available and is published under a Creative Commons Attribution 3.0 United States License .

As of July, 2012, the latest version of the library can be downloaded in a zip file named bookClasses-3-9-10-with-doc.zip at http://home.cc.gatech.edu/TeaParty/47. Additional information is available at http://coweb.cc.gatech.edu/mediaComp-plan/101 .

Download the library

In order to work with the programs in the modules that use the library, you will need to download a copy of the latest version of the library from the site listed above. To guard against the possibility of that link becoming broken at some point in the future, I am depositing a backup copy of the zip file containing the library on the cnx.org site and you can download it here .

Prepare the library for use

Once you have downloaded the zip file, you will need to extract the folder named bookClasses from the zip file and store it somewhere on your computer's disk.

Library documentation

When you examine the contents of the bookClasses folder, you will see that in addition to source code and compiled class files for the library, the folder also contains javadoc documentation for the library in a folder named doc and some other material as well. Go to the doc folder and open the file named index.html in your browser to view the documentation.

Put the library on the classpath

You will need to put the path to the bookClasses folder on your classpath in order to incorporate classes from the library into your programs.

4
Image 4: Putting the library on the classpath.
del *.class
javac -cp .;M:\bookClasses *.java
java -cp .;M:\bookClasses Prob01

For example, Image 4 shows three commands that you can execute at a Windows command prompt to

  • delete the class files from the current folder,
  • compile the source-code files in the current folder, and
  • execute the compiled version of a program named Prob01 in the current folder

(The commands shown in Image 4 assume that the bookClasses folder is in the root directory on the M-drive. The bookClasses folder will likely be in a different location on your computer. They also assume that you are compiling and running a program having its main method in a class named Prob01 in a file named Prob01.java .)

Be sure to include the period and the semicolon shown before the M in Image 4 . This tells the Java compiler and the Java Virtual Machine to search first in the current folder before searching elsewhere on the disk for the required files.

You can also put the three commands in a batch file and run the batch file to avoid having to type the three commands each time you need to compile and run the program. In that case, you should add a pause command following the other three commands.

If you are using an IDE such as DrJava, JCreator, or JGrasp, see the instructions for the IDE to learn how to set the classpath in the IDE.

Two versions of Hello World

It is often useful to have the code for a simple program to test your system. This section presents two versions of the classical Hello World program. The first version is a simple text version that doesn't use Ericson's library. This version can be used to confirm that the Java Development Kit (JDK) is properly installed on your computer.

The second version is a graphic version that does require Ericson's library. This version can be used to confirm proper installation and use of the library.

A text version of Hello World

The simple program shown in Listing 1 causes the words Text Hello World to be displayed on the standard output device when the program is compiled and executed.

5
Listing 1: A text version of Hello World.

class TextHelloWorld{
  public static void main(String[] args){
    System.out.println("Text Hello World");
  }//end main
}//end class

As mentioned above, this program does not require the use of Ericson's library. It can be compiled and executed using a batch file containing the commands shown in Image 5 . You should make certain that you can compile and execute this program before progressing to the graphic version.

6
Image 5: Batch file for text version of Hello World.

echo off
del *.class
javac TextHelloWorld.java
java TextHelloWorld
pause

A graphic version of Hello World

Listing 2 contains the code for a graphic version of Hello World.

7
Listing 2: A graphic version of Hello World.

import java.awt.Color;

class GraphicHelloWorld{
  public static void main(String[] args){
    Picture pix = new Picture(200,100);
    pix.setAllPixelsToAColor(Color.RED);
    pix.addMessage("Graphic Hello World",15,50);
    pix.show();
  }// end main
}//end class

The program shown in Listing 2 causes the image shown in Image 6 to be displayed when the program is compiled and executed.

8
Image 6: Hello World in graphics.
A graphic image with the text Hello World

As mentioned above, this program does require the use of Ericson's library. It can be compiled and executed using a batch file containing the commands shown in Image 7 . You should make certain that you can compile and execute this program before progressing to more complex programs involving Ericson's library.

9
Image 7: Batch file for graphic version of Hello World. .

echo off

del *.class
javac -cp .;M:\bookClasses GraphicHelloWorld.java
java -cp .;M:\bookClasses GraphicHelloWorld
pause

(Once again, the commands shown in Image 7 assume that the bookClasses folder is in the root directory on the M-drive. The bookClasses folder will likely be in a different location on your computer.)

Miscellaneous

This section contains a variety of miscellaneous information.

Note:

Housekeeping material
  • Module name: Java OOP: The Guzdial-Ericson Multimedia Class Library
  • File: Java3000.htm
  • Published: 07/27/12
  • Revised: 01/01/13

Note:

Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have misappropriated copies of my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I receive no compensation for those sales and don't know who does receive compensation. If you purchase such a book, please be aware that it is a bootleg copy of a module that is freely available on cnx.org.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks