DIRECTORY Histograms, IO, Real, RealFns, Rope; HistogramsPrivate: CEDAR DEFINITIONS IMPORTS Real, RealFns = {OPEN Histograms; DataRef: TYPE = REF Data; Data: TYPE = RECORD [counts: SEQUENCE length:NAT OF Count]; Count: TYPE = CARDINAL; IntPair: TYPE ~ RECORD [i, j: INTEGER]; Histogram: TYPE = REF HistogramRep; HistogramRep: TYPE = MONITORED RECORD [ dimensionality: [1 .. 2], BinNamer: BinNameProc, data: DataRef, nI, nJ: INT ฌ 0, iFactor, iOffset, jFactor, jOffset: REAL, x0, y0, xChg, yChg: REAL, log: BoolPair, maxCount: Count ฌ 0, maxValid: BOOL ฌ TRUE, noters: NoterList ฌ NIL, clientData: REF ANY ]; NoterList: TYPE ~ LIST OF Noter; CreateData: TYPE ~ REF CreateDataPrivate; CreateDataPrivate: TYPE ~ RECORD [variant: SELECT kind: * FROM oneD => [factor: REAL ฌ 1.0, offset: REAL ฌ 0.0, log: BOOL ฌ FALSE], twoD => [iFactor, jFactor: REAL ฌ 1.0, iOffset, jOffset: REAL ฌ 0.0, log: BoolPair ฌ ALL[FALSE]], ENDCASE]; ShowData: TYPE ~ REF ShowDataPrivate; ShowDataPrivate: TYPE ~ RECORD [ format: ROPE ฌ NIL, width: NAT ฌ 0, base: REAL ฌ 0.0 ]; ReadSpecs: PROC [from: IO.STREAM] RETURNS [create: CreateData ฌ NIL, show: ShowData ฌ NIL]; InvertI: PROC [h: Histogram, x: REAL] RETURNS [INTEGER] ~ INLINE {RETURN [Real.Round[((IF h.log[X] THEN RealFns.Ln[x] ELSE x)-h.iOffset)/h.iFactor]]}; InvertJR: PROC [h: Histogram, y: REAL, log: BOOL ฌ FALSE] RETURNS [REAL] ~ INLINE {RETURN [((IF h.log[Y]=log THEN y ELSE IF log THEN RealFns.Exp[y] ELSE RealFns.Ln[y])-h.jOffset)/h.jFactor]}; Invert2: PROC [h: Histogram, x, y: REAL] RETURNS [IntPair] ~ INLINE {RETURN [[ i: Real.Round[((IF h.log[X] THEN RealFns.Ln[x] ELSE x)-h.iOffset)/h.iFactor], j: Real.Round[((IF h.log[Y] THEN RealFns.Ln[y] ELSE y)-h.jOffset)/h.jFactor] ]]}; ExvertI: PROC [h: Histogram, i: REAL, log: BOOL ฌ FALSE] RETURNS [x: REAL] ~ INLINE { x ฌ i*h.iFactor + h.iOffset; IF h.log[X]=log THEN NULL ELSE IF log THEN x ฌ RealFns.Ln[x] ELSE x ฌ RealFns.Exp[x]}; ExvertJ: PROC [h: Histogram, j: REAL, log: BOOL ฌ FALSE] RETURNS [y: REAL] ~ INLINE { y ฌ j*h.jFactor + h.jOffset; IF h.log[Y]=log THEN NULL ELSE IF log THEN y ฌ RealFns.Ln[y] ELSE y ฌ RealFns.Exp[y]}; MaybeEx: PROC [x: REAL, log: BOOL] RETURNS [REAL] ~ INLINE { IF log THEN RETURN RealFns.Exp[x] ELSE RETURN [x]}; Ensure1: PROC [old: DataRef, n: INT] RETURNS [new: DataRef]; Noter: TYPE ~ RECORD [ Note: PROC [REF ANY, Histogram, ChangeNote], data: REF ANY ฌ NIL]; ChangeKind: TYPE ~ {add, set}; ChangeNote: TYPE ~ RECORD [ range: Range2, change: SELECT kind: ChangeKind FROM add => [dn: INTEGER], set => [n: CARDINAL], ENDCASE]; AddNoter: PROC [Histogram, Noter]; RemNoter: PROC [Histogram, Noter]; }. า HistogramsPrivate.mesa Copyright ำ 1992 by Xerox Corporation. All rights reserved. Last tweaked by Mike Spreitzer on June 28, 1988 3:33:27 pm PDT The Note proc is called under the Histogram's monitor. สู•NewlineDelimiter –(cedarcode) style™code™Kšœ ฯeœ1™—K˜Kšฯk œ žœ˜.K˜šฯnœžœž ˜$Kšžœ˜Kšœžœ ˜—K˜Kšœ žœžœ˜Kš œžœžœ žœžœžœ˜;K˜Kšœžœžœ˜Kšœ žœžœžœ˜'K˜Kšœ žœžœ˜#šœžœž œžœ˜'K˜KšŸœ˜Kšœ˜Kšœžœ˜Kšœ$žœ˜)Kšœžœ˜K˜K˜Kšœ žœžœ˜Kšœžœ˜Kšœ žœž˜K˜—K˜Kšœ žœžœžœ˜ K˜Kšœ žœžœ˜)šœžœžœ žœ ž˜>Kš œžœžœ žœžœ˜DKš œžœžœžœžœ˜aKšžœ˜ —K˜Kšœ žœžœ˜%šœžœžœ˜ Kšœžœžœ˜Kšœžœ˜Kšœžœ˜K˜—K˜KšŸ œžœžœžœžœžœžœ˜[K˜š Ÿœžœžœžœžœ˜7Kš œžœžœžœ žœžœ˜^—K˜šŸœžœžœžœžœžœžœ˜HKšœžœžœžœžœžœžœžœžœ'˜v—K˜šŸœžœžœžœ ˜:šœžœžœ˜Kšœžœ žœžœ˜MKšœžœ žœžœ˜LK˜——K˜šŸœžœžœžœžœžœžœ˜Jšœžœ˜ K˜Kšžœžœžœžœžœžœžœ˜V——K˜šŸœžœžœžœžœžœžœ˜Jšœžœ˜ K˜Kšžœžœžœžœžœžœžœ˜V——K˜šŸœžœžœžœžœžœžœ˜