Program: Penman Plotter

This program in Example 11-10 is an outgrowth of the Plotter class from Section 8.12. It connects to a Penman plotter. These serial-port plotters were made in the United Kingdom in the 1980s, so it is unlikely that you will meet one. However, there are several companies that still make pen plotters. See Figure 11-4 for a photograph of the plotter in action.

Penman plotter in action

Figure 11-4.  Penman plotter in action

Example 11-10.

import*; import javax.comm.*; import java.util.*; /** * A Plotter subclass for drawing on a Penman plotter. * These were made in the UK and sold into North American markets. * It is a little "turtle" style robot plotter that communicates * over a serial port. For this, we use the "Java Communications" API. * Java Communications is a "standard extension" and must be downloaded * and installed separately from the JDK before you can even compile this * program. * */ public class Penman extends Plotter { private final String OK_PROMPT = "\r\n!"; private final int MAX_REPLY_BYTES = 50; // paranoid upper bound private byte b, reply[] = new byte[22]; private SerialPort tty; private DataInputStream is; private DataOutputStream os; /** Construct a Penman plotter object */ public Penman( ) throws NoSuchPortException,PortInUseException, IOException,UnsupportedCommOperationException { super( ); init_comm("COM2"); // setup serial commx init_plotter( ...

Get Java Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.