TAPropertiesImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Beach, February 9, 1985 9:36:46 pm PST
last edited by Stone, November 19, 1982 5:09 pm
DIRECTORY
IO,
NodeProps USING [PutProp, GetSpecs, GetProp],
Rope,
TAProperties,
TextNode USING [Ref];
TAPropertiesImpl:
CEDAR PROGRAM
IMPORTS IO, NodeProps, Rope
EXPORTS TAProperties = {
OPEN TAProperties;
ROPE: TYPE = Rope.ROPE;
artworkAtom: ATOM = $ArtworkClass;
artworkFileNameAtom: ATOM = $ArtworkFileName;
artworkPathAtom: ATOM = $ArtworkPath;
artworkImageAtom: ATOM = $ArtworkImage;
boundingBoxAtom: ATOM = $BoundingBox;
originAtom: ATOM = $Origin;
trueRope: ROPE = "TRUE";
artworkNode: ROPE = "ArtworkNode";
artworkFileName: ROPE = "ArtworkFileName";
artworkImage: ROPE = "ArtworkImage";
AnArtworkNode:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [
BOOLEAN] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, artworkAtom])#
NIL
THEN
IF Rope.Equal[artworkNode, NodeProps.GetSpecs[artworkAtom, propValue]]
THEN
RETURN[TRUE];
RETURN[FALSE];
};
SetArtworkProp:
PUBLIC
PROCEDURE [node: TextNode.Ref] = {
NodeProps.PutProp[node, artworkAtom, artworkNode]};
AnArtworkFileName:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [
BOOLEAN] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, artworkAtom])#
NIL
THEN
IF Rope.Equal[artworkFileName, NodeProps.GetSpecs[artworkAtom, propValue]]
THEN
RETURN[TRUE];
RETURN[FALSE];
};
SetArtworkFileNameProp:
PUBLIC
PROCEDURE [node: TextNode.Ref] = {
NodeProps.PutProp[node, artworkAtom, artworkFileName]};
AnArtworkImage:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [
BOOLEAN] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, artworkAtom])#
NIL
THEN
IF Rope.Equal[artworkImage, NodeProps.GetSpecs[artworkAtom, propValue]]
THEN
RETURN[TRUE];
RETURN[FALSE];
};
SetArtworkImageProp:
PUBLIC
PROCEDURE [node: TextNode.Ref] = {
NodeProps.PutProp[node, artworkAtom, artworkImage]};
AnArtworkPath:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [
BOOLEAN] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, artworkPathAtom])#
NIL
THEN
IF Rope.Equal[trueRope, NodeProps.GetSpecs[artworkPathAtom, propValue]]
THEN
RETURN[TRUE];
RETURN[FALSE];
};
SetArtworkPathProp:
PUBLIC
PROCEDURE [node: TextNode.Ref] = {
NodeProps.PutProp[node, artworkPathAtom, trueRope]};
GetBoundingBox:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [x,y:
REAL ← 0] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, boundingBoxAtom])#
NIL
THEN {
s: IO.STREAM ← IO.RIS[ NodeProps.GetSpecs[boundingBoxAtom, propValue]];
x ← s.GetReal[];
y ← s.GetReal[]};
RETURN[x,y]};
SetBoundingBoxProp:
PUBLIC
PROCEDURE [node: TextNode.Ref, x,y:
REAL] = {
NodeProps.PutProp[node, boundingBoxAtom, IO.PutFR["%g %g", IO.real[x], IO.real[y]]]};
GetOrigin:
PUBLIC
PROCEDURE [node: TextNode.Ref]
RETURNS [x,y:
REAL ← 0] = {
propValue: REF;
IF node#
NIL
THEN
IF (propValue ← NodeProps.GetProp[node, originAtom])#
NIL
THEN {
s: IO.STREAM ← IO.RIS[ NodeProps.GetSpecs[originAtom, propValue]];
x ← s.GetReal[];
y ← s.GetReal[]};
RETURN[x,y]};
SetOriginProp:
PUBLIC
PROCEDURE [node: TextNode.Ref, x,y:
REAL] = {
NodeProps.PutProp[node, originAtom, IO.PutFR["%g %g", IO.real[x], IO.real[y]]]};
}.