NodeStyleImpl.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Written by Bill Paxton, January 1981
Bill Paxton, December 1, 1982 7:38 am
Maxwell, January 6, 1983 8:46 am
Russ Atkinson, March 7, 1985 3:34:46 am PST
Plass, March 14, 1985 5:00:54 pm PST
Rick Beach, March 21, 1985 2:32:26 pm PST
Doug Wyatt, September 25, 1986 12:29:42 pm PDT
Implements JaM commands for style rules and commands to load styles.
DIRECTORY
NodeStyle USING [DataEntry, DataList, overflow, RealCode, RealParam, Style, TabStop, LeaderTabStop, RuleTabStop, RulesTabStop, TabRealParam],
Real USING [Round];
NodeStyleImpl: CEDAR MONITOR
IMPORTS Real
EXPORTS NodeStyle
~ BEGIN OPEN NodeStyle;
Real Parameters
lastIntAsReal: REAL ← LAST[INT];
firstIntAsReal:
REAL ←
FIRST[
INT];
IntegerValue:
PUBLIC
PROC [value:
REAL ← 0.0]
RETURNS [
INT] ~ {
RETURN [
SELECT value
FROM
> lastIntAsReal => LAST[INT],
< firstIntAsReal => FIRST[INT],
ENDCASE => Real.Round[value]];
};
realArray:
REF
ARRAY RealCode
OF
REAL ~
NEW[
ARRAY RealCode
OF
REAL ←
ALL[0.0]];
array of real-valued distances
nextFreeRealCode: RealCode ← 1;
next free entry in realArray
reserve entry 0 for 0.0
overflowCount: INT ← 0;
EnterReal:
ENTRY
PROC [value:
REAL ← 0.0]
RETURNS [code: RealCode] ~ {
ENABLE UNWIND => NULL;
FOR code ← RealCode.
FIRST, code+1
UNTIL code=nextFreeRealCode
DO
IF realArray[code]=value THEN RETURN; -- value already in realArray
ENDLOOP;
IF code=overflow THEN overflowCount ← overflowCount+1 -- realArray is full
ELSE { realArray[code] ← value; nextFreeRealCode ← code+1 }; -- enter in realArray
};
SetReal:
PUBLIC
PROC [s: Style, param: RealParam, value:
REAL ← 0.0] ~ {
code: RealCode ~ EnterReal[value];
IF code=overflow THEN s.dataList ← NEW[DataEntry ← [s.dataList, real[param, value]]];
s.real[param] ← code;
};
GetReal:
PUBLIC
PROC [s: Style, param: RealParam]
RETURNS [value:
REAL ← 0.0] ~ {
code: RealCode ~ s.real[param];
IF code#overflow THEN RETURN[realArray[code]]
ELSE {
FOR entry:
REF DataEntry ← s.dataList, entry.next
UNTIL entry=
NIL
DO
WITH entry
SELECT
FROM
e: REF DataEntry.real => IF e.param=param THEN RETURN[e.value];
ENDCASE;
ENDLOOP;
ERROR; -- failed to find it on the data list --
};
};
Tabs
GetTabLoc:
PUBLIC
PROC [stop: TabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.loc) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,loc]];
};
GetTabLeaderSpacing:
PUBLIC
PROC [stop: LeaderTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.spacing) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,spacing]];
};
GetTabRuleWeight:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.weight) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,weight]];
};
GetTabRuleVShift:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.vshift) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,vshift]];
};
GetTabRealCode:
PUBLIC
PROC [s: Style, stop: TabStop, which: TabRealParam,
value:
REAL ← 0.0]
RETURNS [code: RealCode] ~ {
code ← EnterReal[value];
IF code=overflow THEN s.dataList ← NEW[DataEntry ← [s.dataList, tab[stop, which, value]]];
};
GetRulesTabCount:
PUBLIC
PROC [stop: RulesTabStop]
RETURNS [count:
INT] ~ {
RETURN [stop.rules.length];
};
GetRulesTabInfo:
PUBLIC
PROC [stop: RulesTabStop, num:
INT]
RETURNS [weight, vshift:
REAL] ~ {
For num in [0..RulesTabCount), returns the weight and vshift values for that rule.
weight ← stop.rules.array[num].weight;
vshift ← stop.rules.array[num].vshift;
};
GetTabOverflow:
PROC [s: Style, stop: TabStop, which: TabRealParam]
RETURNS [value:
REAL ← 0.0] ~ {
FOR x: DataList ← s.dataList, x.next
UNTIL x=
NIL
DO
WITH x
SELECT
FROM
xx: REF DataEntry.tab => IF xx.tabStop=stop AND xx.which=which THEN RETURN [xx.value];
ENDCASE;
ENDLOOP;
ERROR -- failed to find it on the data list --
};
Dimensions
pointsPerPica: PUBLIC REAL ← 12.0;
pointsPerInch: PUBLIC REAL ← 1.0/0.0138370; -- 72.27
pointsPerCentimeter: PUBLIC REAL ← pointsPerInch/2.540;
pointsPerMillimeter: PUBLIC REAL ← pointsPerCentimeter/10;
pointsPerDidot: PUBLIC REAL ← pointsPerCentimeter/26.60;
pointsPerFil: PUBLIC REAL ← 10000.0;
pointsPerFill: PUBLIC REAL ← pointsPerFil*pointsPerFil;
pointsPerFilll: PUBLIC REAL ← pointsPerFill*pointsPerFil;
END.