Histograph.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) May 22, 1986 7:17:53 pm PDT
DIRECTORY
ImagerFont USING [Font],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
Histograph: CEDAR DEFINITIONS = BEGIN
Font: TYPE = ImagerFont.Font;
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
General operations
NewHistograph: PROC [
dataWidth: NAT ← 480, -- # of samples buffered for display
dataHeight: NAT ← 100, -- # of vertical units for samples
maxSample: INT ← 100, -- sample corresponding to the height
averageFactor: REAL ← 0.9, -- used to compute declining average
vertiLog: NAT ← 0, -- log base to use on Y-axis (0, 1 => linear)
title: ROPENIL, -- graph title
subTitle: ROPENIL, -- graph sub-title
firstSampleX: NAT ← 64, -- x position of first sample
numberW: INTEGER ← 32, -- # of units for displaying numbers
name: ROPENIL, -- name to use if top-level viewer
parent: Viewer ← NIL, -- parent viewer
wx: INTEGER ← 0, -- x position in parent
wy: INTEGER ← 0, -- y position in parent
historical: BOOLTRUE, -- => strip chart style, else random access
border: BOOLFALSE, -- => give returned viewer a border
childXbound: BOOLFALSE, -- => make right bound match parent
tickX: NAT ← 60, -- # of units to use between horizontal ticks
tickY: NAT ← 25, -- # of units to use between vertical ticks
numberFont: Font ← NIL, -- font for numbers (default: Helvetica8)
smallFont: Font ← NIL, -- font for subTitle (default: Helvetica8)
largeFont: Font ← NIL] -- font for title (default: Helvetica10)
RETURNS [Viewer];
... creates a new Histograph class of viewer.
FetchSample: PROC [viewer: Viewer, index: NAT] RETURNS [REAL];
Fetches the sample at the given index. Returns 0.0 if the sample was never written. Useful if using this viewer class as a histogram instead of as a strip chart.
Reset: PROC [viewer: Viewer, paint: BOOLTRUE];
Clears all of the data samples. If paint, also forks a paint update.
Historical operations (requires viewer created with historical: TRUE)
AddSample: PROC [viewer: Viewer, sample: REAL, paint: BOOLTRUE];
Adds a data sample to the histograph. Requires that the viewer was created with historical = TRUE, otherwise Error[$notHistorical] is raised. If paint, also forks a paint update.
Random access operations (requires viewer created with historical: FALSE)
StoreSample: PROC [viewer: Viewer, index: NAT, sample: REAL, paint: BOOLTRUE];
Stores the sample to the given index. Returns 0.0 if the sample was never written. Requires that the viewer was created with historical = FALSE, otherwise Error[$historical] is raised. If paint, also forks a paint update.
ModifySample: PROC [viewer: Viewer, index: NAT, sample: REAL, paint: BOOLTRUE];
Adds the sample to the sample at the given index. Requires that the viewer was created with historical = FALSE, otherwise Error[$historical] is raised. If paint, also forks a paint update.
Exceptions
Error: ERROR [code: ATOM, message: ROPE];
The error raised when certain preconditions are not met. Some codes are:
$historical: historical = FALSE was required
$notHistorical: historical = TRUE was required
$notHistograph: viewer data not from this implementation
$invalidIndex: index > dataWidth
END.