Table Of Contents

Graph IDEProgramming ► Single Coordinate Graph

The following is a complete script for programming a Single Coordinate Graph. It places a Function onto the graph and then autoscales the graph.

/* Declarations */

@@class() SingleCoordinateGraph:Object

@@method(public, class) (id)stored;
@@method(public, class) (id)alloc;
@@method(public, class) (id)append;
@@method(public, instance) (id)init;
@@method(public, instance) (void)autoscale;
@@method(public, instance) (void)focus;
@@method(public, instance) (void)unfocus;
@@method(public, instance) (void)release;

@@end

double cos(double a);

@@class() Function:Object

@@method(public, class) (id)alloc;
@@method(public, class) (id)stored;
@@method(public, class) (id)append;
@@method(public, instance) (id)init;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id aGraphic, aGraph;
int ii;
unsigned animationCount;

aGraph = [SingleCoordinateGraph append];

[aGraph moveCenterToXValue:400.0 yValue:400.0];
[aGraph sizeToCenteredWidth:300.0 height:300.0];

[aGraph focus];

{
id myFunction;
int ii;
double xValue, yValue;
unsigned animationCount;
double red;

myFunction = [Function append];

animationCount = [myFunction animationCount];

/*
Empty the data and then append new data.
*/

[myFunction emptyData];

for(ii = 0; ii < 500; ii++)
{
xValue = 0.01 * ii + animationCount * 0.5;
yValue = cos(xValue);
[myFunction appendXValue:xValue yValue:yValue];
}

[myFunction finalize];

}

[aGraph unfocus];

[aGraph autoscale];

[aGraph finalize];

}

The general API is define in the section Graphic. The following is API description specific to the Single Coordinate Graph graphic.

@@method(public, instance) (void)autoscale;
  Call like this:

[aGraph autoscale];

Autoscales the receiver.

@@method(public, instance) (void)focus;
  Call like this:

[aGraph focus];

Sets the focused layer to the receiver's foreground data layer. After this call any graphics that are inserted or appended are done so to the graph's foreground data layer.

@@method(public, instance) (void)unfocus;
  Call like this:

[aGraph unfocus];

Sets the focused layer to the layer that the receiver is in. After this call any graphics that are inserted or appended are done so to the same layer as the graph.

@@method(public, instance) (void)updateMainTitleToUFT8String:(const char *)aUTF8String;
  Call like this:

[aGraph updateMainTitleToUFT8String:"My Title"];

Sets the main title of the graph.

@@method(public, instance) (void)updateXTitleToUFT8String:(const char *)aUTF8String;
  Call like this:

[aGraph updateXTitleToUFT8String:"My X Title"];

Sets the x-axis title of the graph.

@@method(public, instance) (void)updateYTitleToUFT8String:(const char *)aUTF8String;
  Call like this:

[aGraph updateYTitleToUFT8String:"My Y Title"];

Sets the y-axis title of the graph.




© Copyright 1993-2022 by VVimaging, Inc. (VVI); All Rights Reserved. Please email support@vvi.com with any comments you have concerning this documentation. See Legal for trademark and legal information.