BuildGraph Language
The language interpreted by the BuildGraph class is (hopefully!) simple
and straight forward. It is made up of about 20 reserved words, some words
having multiple meanings depending on context. The best way to understand
how to construct a graph definition file is to look at
examples.
Context is changed using a keyword and a { } pair. In C this would be considerd the
scope. Only a subset of keywords can change the context. These keywords
usually define an object that must be constructed from a set of definitions
examples of such objects are fonts, axis, datasets, titles, labels etc.
The BuildGraph language is not complete. Some plot
features available in the class definitions are not available in the plot
language.
The Interpreter
The language interpreter only recognises predefines keywords, numbers
(scientific notation is recognised), the context (scope) defining
braces { }, and strings delimetered by ".
Everything following the # characeter is interpreted as a comment. All
blank lines are ignored.
Anything else will be reported as an error.
Context keywords
To change context a keyword is followed (and encloses context commands) by
a pair of braces. An example of a new context is the font context.
font {
style bold
name "Helvetica"
size 25
}
The font command above might itself be enclosed in the title context or
label context.
- GRAPH2D
- This is currently one of three main contexts (like the main
procedure in C). This defines the type of graph to build. A
non-interactive plot using the Graph2D class.
- G2DINT
- The second type of plot to build. An interactive plot using the
G2Dint class.
- CONTOUR
- The third type of plot to build. An interactive contour plot using the
Contour class.
- AXIS
- Define an axis using keywords such as LABEL, AXIS, BOTTOM, TOP, LEFT,
RIGHT, COLOR and ATTACH.
- DATA
- Define a data set, using keywords such as, URL, MARKER, COLOR.
- CDATA
- Define the data grid for a contour plot.
- MARKER
- In the context of a dataset this keyword will define
the STYLE, COLOR and SIZE of the marker to use for the data set.
In the context of GRAPH2D or G2DINT it should only contain
the URL of the marker file.
- TITLE
- In the context of GRAPH2D, G2DINT or CONTOUR define the title of the plot. In
the context of AXIS define the axis title. TITLE uses the keywords NAME, FONT
and COLOR. A title example
title {
name "This could be a plot title or an axis title"
color 0 255 255
font {
style plain
name "TimesRoman"
size 15
}
}
- LABEL
- Only to be used in the Axis context, define the axis labels, using
the keywords FONT and COLOR
- FONT
- Define a font using the keywords SIZE, STYLE and NAME.
- GRID
- Define the grid to be displayed, using the keywords ON, OFF, and
COLOR.
- ZERO
- Define the zero line to be displayed, using the keywords ON, OFF, and
COLOR.
Keywords
- FUNCTION string
- The function string to be parsed to the DATA ParseFunction class
- Context
- DATA - The function that will be used to construct the data.
- CDATA - The function that will be used to construct the data.
XRANGE number number number
The number of points and the range of points to be used with the
declared function to construct the data set.
xrange 100 -1.0 1.0.
number of points is 100, the range of the data is [-1.0,1.0]
Context
DATA - The range of the data to be plotted.
CDATA - The x range of the data to be contoured.
YRANGE number number number
The number of points and the range of points to be used with the
declared function to construct the data set.
yrange 100 -1.0 1.0.
number of points is 100, the range of the data is [-1.0,1.0]
Context
CDATA - The y range of the data to be contoured.
SQUARE
The aspect ratio of the graph will be 1.
Context
GRAPH
G2DINT
CONTOUR
NUMBER integer
Number of contour levels to be plotted
Context
CONTOUR
LOG
Contour levels will use a log scale.
Context
CONTOUR
LLEVELS integer
The stride for the contour levels that have labels. If set to zero
no labels will be displayed.
Context
CONTOUR
URL string
Should be followed by a string which is the url of the file to be
loaded.
- Context
- MARKER - the url of the marker file to load
- DATA - the url of the data file to load.
SIZE integer
Should be followed by an integer.
- Context
- MARKER - the size of the marker to draw.
- FONT - the size of the font.
COLOR integer integer integer
Should be followed by 3 integers in the range 0 to 255. The values
of red, green and blue.
- Context
- FONT - Color of the text
- DATA - Color of the plotted data
- CDATA - Color of the contours
BACKGROUND integer integer integer
Should be followed by 3 integers in the range 0 to 255. The values
of red, green and blue.
- Context
- GRAPH - the background color of the applet
- G2DINT - the background color of the applet
- CONTOUR - the background color of the applet
- DATA - the background color of the data window
- CDATA - the background color of the data window
NAME string
Should be followed by a string.
- Context
- FONT - the logical name of the font
- DATA - the logical name of the dataset. This is the name used in the
ATTACH command to attach datasets to axis.
- TITLE - the string to display in the title of the axis or the plot.
STYLE integer or keyword
Should be followed by an integer or keyword.
- Context
- MARKER - the integer following the STYLE keyword is the marker
to use while drawing the dataset.
- FONT - should be followed by one of the following keywords PLAIN, BOLD
or ITALICS. In the FONT context STYLE can be repeated and
as in the Font class the styles become aditive. An example of a bold-italic
font is
font {
name "TimeRoman"
size 20
style bold
style italic
}
BOTTOM integer or alone
Either an axis orientation command or the width of a boundary
of the plot.
- Context
- AXIS - The orientation of the plot
- GRAPH2D - followed by an integer the width of the bottom boundary of
the plot
TOP integer or alone
Either an axis orientation command or the width of a boundary
of the plot.
- Context
- AXIS - The orientation of the plot
- GRAPH2D - followed by an integer the width of the top boundary of
the plot
LEFT integer or alone
Either an axis orientation command or the width of a boundary
of the plot.
- Context
- AXIS - The orientation of the plot
- GRAPH2D - followed by an integer the width of the left boundary of
the plot
RIGHT integer or alone
Either an axis orientation command or the width of a boundary
of the plot.
- Context
- AXIS - The orientation of the plot
- GRAPH2D - followed by an integer the width of the right boundary of
the plot
ON
- Context
- DATA - draw straight line segments between data points.
- GRID - draw the grid
- ZERO - draw the zero line
OFF
- Context
- DATA - don't draw straight line segments between data points.
- GRID - don't draw the grid
- ZERO - don't draw the zero line
ATTACH string
Attach a named dataset to an axis.
- Context
- AXIS - attach the named data set (defined in the DATA context using
the NAME keyword) to the current axis.
PLAIN
Only to be used as a STYLE value in the FONT context.
BOLD
Only to be used as a STYLE value in the FONT context.
ITALIC
Only to be used as a STYLE value in the FONT context.