PlotterPalette
by Matt Morse, NeXT Technical publications

Overview

PlotterPalette is a project that creates a dynamically loadable paletteÐPlotterPalette.paletteÐ for Interface Builder.  (See the Interface Builder release notes for 2.0 for a discussion of loadable palettes.)  When you load this palette into Interface Builder, a new display appears in the Palettes window.  This display contains a single object, a PlotView.

The PlotView class defines an object that draws x and y axes and can plot points.  Points can be input in either of two ways.  The user can click the mouse button while the cursor is over the PlotView, thus creating a point.  Or, when the PlotView receives a plot: message, it asks its delegate for a stream of data from which it can parse coordinates for the points.   

For a program that uses a PlotView, see the Plotter project.  The Plotter project also has a more complete readme file which discusses the PlotView class in more detail.  The discussion that follows will assume you're familiar with the material in the readme file for the Plotter project. 

Program Organization

The palette nib file
PlotterPalette.nib is the nib file that contains the PlotView object for the loadable palette.  If you open this nib file you'll see a panel containing a CustomView that's been assigned the PlotView class.  By opening the Classes window, you can verify that PlotView is defined as a subclass of View.  Using the Class inspector, examine PlotView's outlets and action methods.  (Comments within PlotView.m describe each of these methods.)

The inspector nib file
PlotViewInspector.nib contains the objects that make up the inspector for the PlotView class.  The inspector lets the user set the radius used for the points in the graph.  This interface is owned by an object of the PlotViewInspector class.  (To verify this, inspect the attributes of the File's Owner object in the File window.)   Check the connections of the File's Owner.  Notice that its theSlider and theTextField outlets are connected to the appropriate objects, and that its window outlet is connected to the panel that contains these objects.  Finally, inspect the panel that contains the interface for the PlotView inspector and notice that the Deferred option is not checked.  Inspector panels won't work it they're deferred.

Major Classes in the Application
The two custom classes in Plotter are:
 
 PlotView	A subclass of View that knows how to draw axes (see drawingFuncs.psw for the drawing code), how to respond to mouse-down and mouse-dragged events within its bounds, and how to register and draw points.  It communicates with a delegate object to get a stream of data to use for the points it will plot.  PlotView uses a Storage object to hold the point structures it parses from the stream.
 		
		This class is designed to be reusable.  By providing it with an appropriate delegate and connecting Plot and Clear buttons to it, it can be used in another application.
		
		PlotView knows how to archive and unarchive itself (the write: and read: methods) so that it can be stored in a nib file.  When it's sent an inspectorName: message, it returns "PlotViewInspector".  This is how Interface Builder knows to load the code for the PlotViewInspector class when the user tries to inspect a PlotView.
 
 PlotViewInspector
 		A PlotViewInspector, as the name suggests, is an object that's designed to inspect PlotViews.  When created, a PlotViewInspector loads its interface from a Mach object file section named "PlotViewInspector.nib".  This interface is displayed in Interface Builder's Inspector window.  Using the slider provided by this interface,  the user can set the radius of the points used in the PlotView.  When the user clicks OK, the object that's being inspected receives a setRadius: message.   		

Other Files

In addition to the files discussed above, the Plotter project includes these files:

drawingFuncs.psw	Wraps for PostScript procedures that draw PlotView's axes and points.

cross.tiff		A TIFF image that's used as the cursor when the user presses the mouse button within the PlotView.

Plotter_main.m,	Created by Interface Builder.
IB.proj,
Makefile,
Plotter.paletteheader, 

Not valid  for 1.0
Valid  for 2.0