Chapter 6: Creating a Fax Application


The javax.comm package includes the CommPortIdentifier class to control access to the various communication ports on a computer and the CommPort and ParallelPort classes to retrieve and set the properties of the ports on a computer that communicate with the modem and fax machine.

This chapter explains how to develop a Fax application that uses the Java Communication Application Programming Interface and the CommPort, ParallelPort, and CommPortIdentifier classes.

Architecture of the Fax Application

The Fax application allows an end user to specify a fax number, select a file, and send the content of the file as a fax to the specified number. The application sends the fax by converting a text file to an image. This process is called encoding the fax.

The Fax application uses the following files:

  • PortFax.java: Creates the user interface of the Fax application.

  • ConvertIntoHTML.java: Converts the text that is currently open in the edit pane of the Fax application to an image of an HTML page.

  • ConvertIntoTextImage.java: Converts the text that is currently open in the edit pane of the Fax application to a text image.

  • FaxPropertyPage.java: Sets the properties of the COM port that sends the fax.

  • FaxStatusListener.java: Defines various static variables, such as ST_OPEN_PORT, ST_INIT_MODEM, and ST_SEND_PAGE, which indicate the status of the Fax application.

  • SendingFax.java: Sends the fax to the destination.

  • PreparedFaxDoc.java: Defines an interface to create the fax document. The ConvertIntoHTML.java and ConvertIntoTextImage.java files implement this interface.

  • ModemCapabilities.java: Sets the encoding and decoding capabilities of a modem.

  • ImageToFaxEncoder.java: Encodes the image that is sent using the Fax application.

  • LCFrame.java: Converts the encoded fax image to frames. The modem sends the frames to the receiver.

Figure 6-1 shows the architecture of the Fax application:

click to expand: this figure shows the sequence in which all the files in the fax application are used.
Figure 6-1: Architecture of the Fax Application

The PortFax.java file calls the ConvertIntoTextImage.java and ConvertIntoHTML.java files to convert the fax document to an image. The PortFax.java file invokes the FaxPropertyPage.java file to set the properties of the port to which the modem is connected. The FaxStatusListener.java file helps the PortFax.java file determine the status of the Fax application.

The end user sends a fax using the SendingFax.java file, which invokes the ImageToFaxEncoder.java file to encode the fax document. The LCFrame.java file helps the SendingFax.java file convert the encoded fax document into frames. The SendingFax.java file invokes the ModemCapabilities.java file to retrieve and set the encoding and decoding capabilities of a modem that helps the modem detect incoming frames to send a fax.

The PortFax.java file passes the frames to the modem, which in turn passes the frames to the fax number of the destination.




Developing Applications Using JCA
Developing Applications Using JCA
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 43

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net