Download as pdf or txt
Download as pdf or txt
You are on page 1of 86

Format Specification

TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 1 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Format Specification
TGML 1.0
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 2 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Abstract
This specification defines the features and syntax for TAC Graphics Markup
Language (TGML), which is a XML-based language for describing TAC dynamic
vector graphics.

Status of this document


This is the first official version of the TGML 1.0 Format Specification.

The versions A1-A7 have been used during the development of the TGML
Graphics and this version (B1) has been reviewed as version A7 by the TGML
Development Team. The detailed history of the A1-A7 versions has been removed
in this version and replaced with a brief description (see Appendix D).
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 3 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Table of content
1 Overview ............................................................................................................... 5
1.1 TGML version ................................................................................................ 5
1.2 Namespaces .................................................................................................... 5
1.3 Properties and attributes ................................................................................. 6
1.3.1 Default values.......................................................................................... 6
1.3.2 Attribute inheritance................................................................................ 6
1.3.3 Custom attributes..................................................................................... 6
1.4 Error notifications........................................................................................... 7
1.5 Implicit syntax................................................................................................ 7
2 Coordinate system ................................................................................................. 8
2.1 Coordinates..................................................................................................... 8
2.2 Initial scale ..................................................................................................... 8
3 Rendering model ................................................................................................... 9
4 TGML types and enumerations ........................................................................... 10
4.1 Arrays ........................................................................................................... 12
5 Common attributes .............................................................................................. 13
6 Document structure ............................................................................................. 14
7 Document type element and Metadata ................................................................ 15
7.1 Document type element: <TGML> .............................................................. 15
7.2 Metadata: <Metadata>.................................................................................. 16
8 Grouping elements .............................................................................................. 17
8.1 Grouping: <Group>...................................................................................... 17
8.2 Components: <Component>......................................................................... 18
9 Basic shapes ........................................................................................................ 21
9.1 Shape attributes ............................................................................................ 21
9.2 Line: <Line>................................................................................................. 23
9.3 Polyline: <Polyline>..................................................................................... 25
9.4 Polygon: <Polygon>..................................................................................... 26
9.5 Rectangle: <Rectangle> ............................................................................... 27
9.6 Ellipse: <Ellipse> ......................................................................................... 29
10 Segment shapes ................................................................................................. 31
10.1 Elliptical arc: <Arc>................................................................................... 31
10.2 Elliptical pie: <Pie>.................................................................................... 32
10.3 Elliptical chord: <Chord>........................................................................... 33
11 Curves and paths ............................................................................................... 34
11.1 Cubic Bezier curve: <Curve>..................................................................... 34
11.2 Path element: <Path>.................................................................................. 35
12 Raster images .................................................................................................... 36
12.1 Image element: <Image>............................................................................ 36
13 Text.................................................................................................................... 37
13.1 Text line: <Text>........................................................................................ 39
13.2 Text flow: <TextBox>................................................................................ 39
14 Linking .............................................................................................................. 40
14.1 Link element: <Link>................................................................................. 40
15 Transformations................................................................................................. 41
15.1 Rotation: <Rotate> ..................................................................................... 42
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 4 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15.2 Skewing: <SkewX> and <SkewY>............................................................ 44


15.3 Scaling: <Scale>......................................................................................... 46
15.4 Translations: <Translate>........................................................................... 47
16 Animations ........................................................................................................ 48
16.1 Animation: <Animate>............................................................................... 48
16.2 Sequences: <Sequence> ............................................................................. 51
17 Dynamics........................................................................................................... 52
17.1 Signal binding: <Bind> .............................................................................. 54
17.2 Value conversion: <ConvertValue> ........................................................... 55
17.3 Text value conversion: <ConvertText>...................................................... 58
17.4 Value range conversion: <ConvertRange> ................................................ 59
17.5 Custom conversion: <ConvertCustom> ..................................................... 61
18 Scripting ............................................................................................................ 62
18.1 Script element: <Script>............................................................................. 62
18.2 Target area element: <TargetArea>............................................................ 65
19 Gradients ........................................................................................................... 67
19.1 Linear gradient: <LinearGradient>............................................................. 67
19.2 Radial gradient: <RadialGradient>............................................................. 69
19.3 Gradient stop: <GradientStop> .................................................................. 71
20 Attribute exposure ............................................................................................. 73
20.1 The Expose element: <Expose> ................................................................. 73
Appendix A: TGML code snippets ........................................................................ 74
Appendix B: Components ...................................................................................... 75
Appendix C: TGML scripting ................................................................................ 76
Global variables.................................................................................................. 76
About data types................................................................................................. 76
Common event methods ..................................................................................... 77
Mouse event methods ......................................................................................... 78
SignalChange event methods ............................................................................. 79
TGML DOM methods........................................................................................ 79
Standard DOM methods (commonly used) ........................................................ 80
TGML JavaScript functions ............................................................................... 82
JavaScript 1.5 ..................................................................................................... 85
Appendix D: Document history.............................................................................. 86
Version A1-A7 ................................................................................................... 86
Version B1.......................................................................................................... 86
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 5 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

1 Overview
TAC Graphics Markup Language (TGML) is a declarative XML based language
for dynamic 2D graphics.

TGML is inspired by the XML based Scalable Vector Graphics (SVG) which is an
open standard for 2D graphics.

TGML specifies a hierarchy of runtime objects with a set of properties and logic.
Each markup element (XML element) represents a TGML object which can be
edited, or configured, in the Graphics Editor. However, not all of the objects are
graphical (visible). Several objects are used to add a specific behavior to a
graphical object, such as enabling dynamic update of attributes, transformations
and gradients.

The TGML object model is based on the W3C Document Object Model (DOM).
The TGML graphics elements are accessible for applications through the exposed
TGML DOM interfaces.

1.1 TGML version


The TGML version is specified in a XML processing instruction:

<?xml version="1.0"?>
<?TGML Version="1.0"?>

<TGML Width="800" Height="6000" Stretch="Uniform"


Background="#FFFFFF">
...
</TGML>

1.2 Namespaces
The TGML graphics elements specified in this specification belong to the default
XML namespace, TGML.

TGML allows inclusion of elements from foreign namespaces anywhere with the
TGML content. In general, the TGML loader will include the unknown (foreign)
elements in the DOM, but will otherwise ignore the unknown elements.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 6 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

1.3 Properties and attributes


In the underlying class library, public data members are exposed as properties.
Each TGML element attribute has a corresponding property in the TGML class that
implements the TGML element.

1.3.1 Default values


Most of the object properties have a default value. Element attributes that are
omitted in the TGML document are considered to be undefined. An undefined
attribute will result in assigning a default value to the corresponding property,
unless the value is inherited from a parent element, see 1.3.2 Attribute inheritance.

1.3.2 Attribute inheritance


TGML supports attribute inheritance similar to the SVG and XAML attribute
inheritance.

The attribute inheritance means that a child element inherits (gets) the attribute
value from an ancestor element if the attribute value is undefined (omitted) and if
the attribute has been specified for an ancestor (any of the parents).

In the example below, Line will inherit the Stroke value from the Group.
StrokeWidth is not defined either, but since it is not specified at the parent level,
StrokeWidth will be assigned the default StrokeWidth value.

<Group Stroke="#FF0000">
<Line X1="10.00" Y1="10.00" X2="100.00" Y2="100.00"/>
</Group>

1.3.3 Custom attributes


The implementation of attribute inheritance also enables the user to specify custom
attributes, since an element will accept attributes that are actually unknown for the
element. For example, in the attribute inheritance example above, Stroke was
specified, and accepted at the group level, despite the Group does not have a Stroke
attribute.

Custom attributes can for example be used to create "local" variables. The custom
attribute can be bound to a signal, or animated, as any other attribute of an element
and it can be accessed from scripts in the graphics.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 7 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

1.4 Error notifications


TGML does not specify any error or warning notifications. However, the TGML
implementation (e.g. Graphics Services) and the viewer and editor applications
should notify the user about any error conditions.

1.5 Implicit syntax


TGML uses an implicit syntax. The object model implementation is not exposed in
the serialized TGML.

The following example defines a group containing a line. The TGML code does
not reveal how the containment is implemented in Group. The Group
implementation includes for example a child list that is the actual container, but
such information is not serialized.

<Group>
<Line X1="50.00" Y1="100.00" X2="150.00" Y2="200.00
Fill="#FF0000" Stroke="#000000"/>
</Group>

Undefined (non-specified) attributes values are not serialized, to avoid breaking the
attribute inheritance.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 8 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

2 Coordinate system
The origin of the TGML default coordinate system is in the upper-left corner.
Values of x increase as you move right, and values of y increase as you move
down.

Container elements such as TGML and Component establish new coordinate


systems. Group is also a container element, but does not establish a new coordinate
system.

TGML +
0,0

Component +
0,0

2.1 Coordinates
The unit of measurement for coordinates is the device independent pixel, which is
1/96 of an inch (96dpi). The data type for coordinates and lengths (e.g. Width and
Height) is Double.

2.2 Initial scale


A TGML viewer uses the Width, Height and Stretch attributes of the outermost
TGML element to determine the initial scale. Stretch specifies if the document shall
be scaled to fit within the drawing area (preserving the aspect ratio or not) or if the
original size shall be preserved (scale 1:1).
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 9 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

3 Rendering model
The following description is a summary of the TGML rendering model, which is
very similar to the SVG rendering model.

Elements in a TGML document have an implicit drawing order, with the first
elements in the TGML document getting "painted" first. Subsequent elements are
painted on top of previously painted elements.

Grouping elements have the effect of producing a temporary separate canvas onto
which child elements are painted. Upon the completion of the group, any filter
effects specified for the group are applied to create a modified temporary canvas.
The modified temporary canvas is composited into the background, taking into
account any group-level settings, such as opacity, on the group.

Individual graphics elements are rendered as if each graphics element represented


its own group (applicable when for example opacity is defined for the element).

”Grouping elements have the


effect of producing a
temporary separate canvas
onto which child elements are
painted.”

”Upon the completion of the


group, any filter effects
specified for the group are
applied to create a modified
temporary canvas.”

”The modified temporary


canvas is composited into the
background, taking into The whole picture
account any group-level
settings, such as opacity, on
the group.”
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 10 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

4 TGML types and enumerations

Type / Enumeration Description


Animation An enumeration that controls an animation:

"Start"
"Stop"
Bool A boolean value:

"True"
"False"
Brush Describes how an area (Fill) or a stroke (Stroke) is
painted. Accepted values (WP1):

"None"
"‹Color›"

‹Color›: see Color below.


CalcMode Specifies how values shall be interpolated when
animated:

"Discrete"
"Linear"

Remark: "Linear" is only applicable when animating


attributes of the types Double, Color, Point and array of
Point.
Color A RGB or an ARGB color.

RGB is described as the hexadecimal representation of


the red, green and the blue components (in that order).

ARGB is described as the hexadecimal representation of


the alpha (00-FF, where 00 is fully transparent), red,
green and the blue components (in that order).

Example, opaque red:


Fill="#FF0000"

Example, 50% transparent red:


Fill="#7FFF0000"
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 11 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Double Double-precision floating-point numbers. For example,


heights and widths are Double.

Example:
"50.25"
FontStyle Describes the style of the font:

"Normal"
"Italic"
FontWeight Describes the weight of the font:

"Normal"
"Bold"
Format This enumeration describes the formatting of the
subscribed data.

"None": No formatting. The data type of the received


data matches the data type of the server variable
(integer, float, boolean, string etc).
"Presentation": Formatted as text. The server is
expected to deliver the text representation of the value,
if any (e.g. On/Off instead of 0/1).
HorizontalAlign Describes the horizontal alignment of a text string.

"Center"
"Left"
"Right"
Point Represents a XY coordinate.

Syntax:
"‹Double› , ‹Double›"

Example:
"25.00 , 50.00"
Repeat Describes the way the animation will be repeated:

"‹Iterations›"
"Forever"

‹Iterations› specifies the number of times the animation


will be repeated.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 12 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

SpreadMethod Specifies how the gradient should be drawn outside of


the specified gradient vector or space:

"Pad": The color values at the ends of the gradient


vector are used to fill the remaining space.
"Reflect": The gradient is repeated in the reverse
direction until the space is filled.
"Repeat": The gradient is repeated in the original
direction until the space is filled.
Stretch An enumeration that specifies how the content shall be
stretched.

"None": Preserve the original size.


"Uniform": Resize the content, preserving the native
aspect ratio.
"Fill": The content is resized but aspect ratio is not
preserved.
String A string value, i.e. plain text. Reserved XML characters
(& < >) are escaped using the standard XML escaping.
TextDecoration Describes decorations that are added to texts.

"None"
"Underline"
"Strikethrough"
Visibility An enumeration that specifies the visibility of an
element:

"Visible"
"Hidden"

4.1 Arrays
Some attributes accepts arrays of values, such as arrays of Double and Point.
Arrays are written as a sequence of values, delimited by space.

Examples
StrokeDashArray="5.0 3.0 2.0 3.0"
Points="50.0,150.0 100.0,50.0 150.0,150.0"
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 13 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

5 Common attributes
The following attributes are applicable to all TGML elements.

Attribute Type Description


ID String The identity of the element. Reserved for scripts and
other entities that need to use unique element identifiers
to access specific elements.

Inheritable: No
Animatable: No
Name String The name of the element. The primary use is to identify
exposed elements such as Bind.

Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 14 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

6 Document structure
The following example describes a static TGML document with a group containing
a line, a polyline and a polygon:

<TGML Width="400" Height="250" Stretch="Uniform"


Background="#FFFFFF">
<Metadata Name="Title" Value="TGML example"/>
<Group>
<Line X1="75.0" Y1="50.0" X2="325.0" Y2="75.0"
Stroke="#FF0000" StrokeWidth="2.0"/>
<Polyline Points="50.0,100.0 150.0,75.0 175.0,125.0
150.0,200.0 75.0,125.0" Stroke="#0000FF"/>
<Polygon Points="200.0,125.0 350.0,100.0 325.0,150.0
350.0,200.0 250.0,175.0" Stroke="#00FF00" Fill="#FFFF00" />
</Group>
</TGML>

A TGML Graphics document always consists of at least one element, the root
("outermost") TGML element. This TGML element is the ancestor of all other
elements in the document.

A Metadata element carries information about its parent element. In the example
above, the metadata information applies to the outermost TGML element, which
means that this is the metadata information for the TGML Graphics document.

A TGML element and grouping elements, such as Group, can contain any number
of graphics elements, including other grouping elements.

Elements that describe shapes and other graphical (visible) objects can also have
children, but these children are not visible objects, but elements that add a specific
behavior, such as gradients, animations and dynamic bindings.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 15 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

7 Document type element and Metadata

7.1 Document type element: <TGML>


The root (outermost) element of a TGML document is TGML. This element
specifies that the document type is TGML.

Attributes
Attribute Type Description
Background Brush The background color of the document canvas (the
viewing area).

Default: "#FFFFFF"
Inheritable: No
Animatable: Yes
Height Double The height of the document. See Remarks.

Default: "600"
Inheritable: No
Animatable: No
Stretch Stretch Specifies how the document shall be stretched initially
within a viewer. See Remarks.

Default: "None"
Inheritable: No
Animatable: No
Width Double The width of the document. See Remarks.

Default: "800"
Inheritable: No
Animatable: No

Remarks
The viewer uses the width, height and stretch information to determine how the
document initially shall be stretched (transformed).

The viewer shall be able to display a document that misses information about the
width and height. Viewing such a document means that no stretching is applied and
any scroll bars are disabled.

Stretch="None": Preserve the original size. This usually means that scroll bars are
enabled so the user can scroll to the right and the bottom of the document.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 16 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Stretch="Uniform": Resize the content, preserving the native aspect ratio. Scroll
bars are initially disabled.

Stretch="Fill": The content is resized but aspect ratio is not preserved. Scroll bars
are initially disabled.

7.2 Metadata: <Metadata>


The Metadata element carries textual information about its parent element. It is up
to the TGML applications to create and interpret the metadata.

Applying metadata to the outermost TGML element is the same as applying the
information to the TGML document.

Attributes
Attribute Type Description
Name String A name that identifies the information.

Inheritable: No
Animatable: No
Value String The information.

Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 17 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

8 Grouping elements

8.1 Grouping: <Group>


The Group element is a container element, used for grouping elements together so
they can, for example, be moved, copied and resized as if they were a single
element.

Attributes
Attribute Type Description
Opacity Double A value between 0.0 (transparent) and 1.0 (opaque).

Default: "1.0"
Inheritable: No
Animatable: Yes
Visibility Visibility Specifies if the element shall be visible or not.

Default: "Visible"
Inheritable: No
Animatable: Yes

Example
<TGML>
<Group Opacity="0.5">
<Line X1="50.0" Y1="50.0" X2="150.0" Y2="150.0" />
<Line X1="50.0" Y1="100.0" X2="150.0" Y2="200.0" />
</Group>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 18 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

8.2 Components: <Component>


The Component element is a container element (similar to Group) which defines a
reusable group of elements.

Top and Left of Component specifies the position of the component in the parent
coordinate system. Component itself establishes a new coordinate system for the
contained elements, which means that the upper left corner of Component is the
origin (0,0) for the contained elements

Width and Height specifies the "viewport" (size on screen) of the component.
ContentWidth and ContentHeight specify the "viewbox", which is the boundary of
the contained elements. If the viewport is different from the viewbox, a scale
transformation is applied by the TGML implementation (similar to Stretch="Fill",
see 7.1 Document type element). In other words, resizing a Component has the
effect of scaling the content of the Component.

The Clip attribute specifies if the renderer shall clip elements that exceed (are
drawn outside) the specified viewbox or not.

When a Component includes Bind or Link elements, the Name of Component will
prefix the exposed bind names ("MyComponent.MyBind").

For more information about Components, see Appendix B: Components.

Attributes
Attribute Type Description
Clip Bool Specifies if the content shall be clipped or not.

Default: "True"
Inheritable: No
Animatable: No
ContentHeight Double Specifies the viewbox height (height of the content).

Inheritable: No
Animatable: No
ContentWidth Double Specifies the viewbox width (width of the content).

Inheritable: No
Animatable: No
Height Double The viewport height of the component (height on
screen).

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 19 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Left Double The x-coordinate of the component's upper left


corner.

Default: "0"
Inheritable: No
Animatable: Yes
Opacity Double A value between 0.0 (transparent) and 1.0 (opaque).

Default: "1.0"
Inheritable: No
Animatable: Yes
Top Double The y-coordinate of the component's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Visibility Visibility Specifies if the element shall be visible or not.

Default: "Visible"
Inheritable: No
Animatable: Yes
Width Double The viewport width of the component (width on
screen).

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 20 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example
<TGML>
<Rectangle Left="0.0" Top="55" Width="30" Height="30"
Fill="#FF0000" Stroke="#FF0000" />
<Polyline Points="30.0,65.0 60.0,5.0 90.0,35.0"
Stroke="#FF0000" StrokeWidth="2.0"/>

<Component Left="150.0" Top="20.0" Width="50.0" Height="50.0"


ContentWidth="91" ContentHeight="86">
<Rectangle Left="0.0" Top="55" Width="30" Height="30"
Fill="#FF0000" Stroke="#FF0000" />
<Polyline Points="30.0,65.0 60.0,5.0 90.0,35.0"
Stroke="#FF0000" StrokeWidth="2.0"/>
</Component>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 21 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9 Basic shapes

9.1 Shape attributes


The following table describes the common attributes of the basic shapes.

Attributes
Attribute Type Description
Fill Brush Specifies how the shape's interior is painted.

Default: "None"
Inheritable: Yes
Animatable: Yes
Opacity Double A value between 0.0 (transparent) and 1.0
(opaque).

Default: "1.0"
Inheritable: No
Animatable: Yes
Stroke Brush Describes how the line is painted.

Default: "#000000"
Inheritable: Yes
Animatable: Yes
StrokeDashArray Array of The pattern of dashes and gaps used to outline
Double shapes:

"‹dash›[ ‹gap› ‹dash› ‹gap› ...]"

If the array only specifies the first dash, the line is


patterned as if a gap with the same length as dash
was specified.

An array with only one dash set to "0" will result


in a line without any pattern.

Default: "0"
Inheritable: Yes
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 22 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

StrokeWidth Double The width of the line's outline.

Default: "1"
Inheritable: Yes
Animatable: Yes
Visibility Visibility Specifies if the element shall be visible or not.

Default: "Visible"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 23 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9.2 Line: <Line>


The Line element describes a straight line between two points.

Attributes
Attribute Type Description
Opacity Double See 9.1 Shape attributes.
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.
X1 Double The x-coordinate of the line's start point.

Default: "0"
Inheritable: No
Animatable: Yes
X2 Double The x-coordinate of the line's end point.

Default: "0"
Inheritable: No
Animatable: Yes
Y1 Double The y-coordinate of the line's start point.

Default: "0"
Inheritable: No
Animatable: Yes
Y2 Double The y-coordinate of the line's end point.

Default: "0"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 24 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

<TGML>
<Line X2="100.0" Y2="50.0"/>

<Line X1="50.0" Y1="50.0" X2="150.0" Y2="100.0" Stroke="#0000FF"


StrokeWidth="2" StrokeDashArray="5.0 3.0 2.0 3.0"/>

<Line X1="25.0" Y1="65.0" X2="150.0" Y2="125.0" Stroke="#FF0000"


StrokeWidth="2" StrokeDashArray="5.0"/>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 25 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9.3 Polyline: <Polyline>


The Polyline element describes a series of connected straight lines.

Attributes
Attribute Type Description
Fill Brush See 9.1 Shape attributes.
Opacity Double See 9.1 Shape attributes.
Points Array of The vertex points of the polyline:
Point
"‹x1›,‹y1› ‹x2›,‹y2› ..."

Inheritable: No
Animatable: No
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.

Example
<TGML>
<Polyline Points="50.0,150.0 100.0,50.0 150.0,150.0"
Stroke="#0000FF"/>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 26 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9.4 Polygon: <Polygon>


The Polygon element describes a polygon, which is a connected series of lines that
forms a closed shape. The end point does not have to be specified. The polygon is
closed "automatically".

Attributes
Attribute Type Description
Fill Brush See 9.1 Shape attributes.
Opacity Double See 9.1 Shape attributes.
Points Array of The vertex points of the polygon:
Point
"‹x1›,‹y1› ‹x2›,‹y2› ..."

Inheritable: No
Animatable: No
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.

Example
<TGML>
<Polygon Points="50.0,150.0 100.0,50.0 150.0,150.0"
Stroke="#0000FF" Fill="#FFFF00"/>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 27 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9.5 Rectangle: <Rectangle>


Rectangle defines a rectangle. Rounded rectangles can be achieved by setting
values for the attributes RadiusX and RadiusY.

Attributes
Attribute Type Description
Fill Brush See 9.1 Shape attributes.
Height Double The height of the rectangle.

Inheritable: No
Animatable: Yes
Left Double The x-coordinate of the rectangle's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Opacity Double See 9.1 Shape attributes.
RadiusX Double For rounded rectangles. The x-axis radius of the
ellipse used to round off the corners of the
rectangle.

Default: "0"
Inheritable: No
Animatable: Yes
RadiusY Double For rounded rectangles. The y-axis radius of the
ellipse used to round off the corners of the
rectangle.

Default: "0"
Inheritable: No
Animatable: Yes
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 28 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Top Double The y-coordinate of the rectangle's upper left


corner.

Default: "0"
Inheritable: No
Animatable: Yes
Visibility Visibility See 9.1 Shape attributes.
Width Double The width of the rectangle.

Inheritable: No
Animatable: Yes

Example
<TGML>

<Rectangle Left="10" Top="10" Width="100" Height="50"


Fill="#FFFF00" Stroke="#000000"/>

<Rectangle Left="120" Top="10" Width="100" Height="50"


Fill="#FFFF00" Stroke="#000000" RadiusX="10" RadiusY="10"/>

</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 29 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

9.6 Ellipse: <Ellipse>


Ellipse defines an ellipse.

Attributes
Attribute Type Description
Fill Brush See 9.1 Shape attributes.
Height Double The height of the ellipse.

Inheritable: No
Animatable: Yes
Left Double The x-coordinate of the ellipse's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Opacity Double See 9.1 Shape attributes.
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Top Double The y-coordinate of the ellipse's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Visibility Visibility See 9.1 Shape attributes.
Width Double The width of the ellipse.

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 30 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

<TGML>

<Ellipse Left="10" Top="10" Width="100" Height="50"


Fill="#FFFF00" Stroke="#000000"/>

<Ellipse Left="120" Top="10" Width="50" Height="50"


Fill="#FFFF00" Stroke="#000000"/>

</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 31 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

10 Segment shapes

10.1 Elliptical arc: <Arc>


Arc defines an elliptical arc. The elliptical arc is part of an ellipse:

RadiusY

RadiusX
Center

StartAngle

SweepAngle

Attributes
Attribute Type Description
Center Point The center point of the ellipse.

Default: "0.0 , 0.0"


Inheritable: No
Animatable: Yes
Fill Brush See 9.1 Shape attributes.
Opacity Double See 9.1 Shape attributes.
RadiusX Double The horizontal radius of the ellipse.

Inheritable: No
Animatable: Yes
RadiusY Double The vertical radius of the ellipse.

Inheritable: No
Animatable: Yes
StartAngle Double Specifies the angle between the x-axis and the
starting point of the arc.

Default: "0.0"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 32 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

SweepAngle Double Specifies the angle between the starting and


ending points of the arc.

Default: "0.0"
Inheritable: No
Animatable: Yes
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.

10.2 Elliptical pie: <Pie>


Pie defines an elliptical pie slice. Pie is similar to Arc:

RadiusY

RadiusX
Center

StartAngle

SweepAngle

Attributes
See 10 Elliptical arc.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 33 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

10.3 Elliptical chord: <Chord>


Chord defines an elliptical chord. Chord is similar to Pie and Arc:

RadiusY

RadiusX
Center

StartAngle

SweepAngle

Attributes
See 10 Elliptical arc.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 34 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

11 Curves and paths

11.1 Cubic Bezier curve: <Curve>


Curve defines a cubic Bezier curve. The cubic Bezier curve has a start point, an
end point and two control points. The control points act as magnets, pulling the
curve in certain directions to influence the way the Bezier curve bends.

Curve supports "polybezier", which is a consecutive set of Bezier points. The end
point of the preceding Bezier becomes the start point of the following Bezier.

Points="11.0,71.0 16.7,43.7 39.0,6.4 70.0,14.0 101.3,25.2 89.5,66.9 143.0,72.0"

The start point The control points The control points


of the first and the end point of and the end point of
Bezier. the first Bezier. the second Bezier.

Attributes
Attribute Type Description
Closed Bool Describes if the curve is closed or not (If Points
data ends with "z" or not).

Default: "False"
Inheritable: No
Animatable: No
Fill Brush See 9.1 Shape attributes.
Opacity Double See 9.1 Shape attributes.
Points Array of The points (start point, control points and end
Point point) of the Bezier. Polybezier is supported.

Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 35 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Stroke Brush See 9.1 Shape attributes.


StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.

11.2 Path element: <Path>


Path represents the outline of a shape.

The path is described by the attribute PathData, which can contain moveto, line,
curve (both cubic and quadratic Beziers), arc and closepath instructions.

The Path element is an implementation of the SVG path data specification. For
more information of the path data syntax, see the "Scalable Vector Graphics (SVG)
1.1 Specification".

Attributes
Attribute Type Description
Fill Brush See 9.1 Shape attributes.
Opacity Double See 9.1 Shape attributes.
PathData String SVG path data.

Inheritable: No
Animatable: No
Stroke Brush See 9.1 Shape attributes.
StrokeDashArray Array of See 9.1 Shape attributes.
Double
StrokeWidth Double See 9.1 Shape attributes.
Visibility Visibility See 9.1 Shape attributes.

Remarks
Some of the path commands may be converted, or replaced, when importing SVG
paths. For example, h, H (horizontal lineto) and v, V (vertical lineto) may be
replaced with l and L (lineto).
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 36 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

12 Raster images

12.1 Image element: <Image>


Image represents a raster image. Image supports JPEG and PNG images.

The image data is stored as a Base64 encoded string in the CDATA section of the
Image element.

<Image Left="100" Top="100" Width="100" Height="100" ...>


<![CDATA[iVBORw0KGgoAAAANSUh...SUVORK5CYII=]]>
</Image>

The image data is accessible through the Content attribute.

Attributes
Attribute Type Description
Content String The image data.

Inheritable: No
Animatable: Yes
Height Double The height of the image.

Inheritable: No
Animatable: Yes
Left Double The x-coordinate of the image's upper left corner.

Default: "0"
Inheritable: No
Animatable: Yes
Opacity Double See 9.1 Shape attributes.
Top Double The y-coordinate of the image's upper left corner.

Default: "0"
Inheritable: No
Animatable: Yes
Visibility Visibility See 9.1 Shape attributes.
Width Double The width of the image.

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 37 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

13 Text
TGML supports two types of text elements: Text and TextBox. Text causes a single
line of text to be rendered, whereas TextBox wraps the text within the specified
box.

The character data (the text) is stored within the Text element (as XML Element
Content):

<Text ....>An example</Text>

The character data is accessible through the attribute Content which means that it is
possible to create dynamic texts by animating, or binding, the Content attribute.

Common text attributes


Attribute Type Description
Content String The character data.

Inheritable: No
Animatable: Yes
FontFamily String The name of the font (or font family).

Inheritable: Yes
Animatable: Yes
FontSize Double The size of the font, in device independent
pixels (see 2.1 Coordinates).

Inheritable: Yes
Animatable: Yes
FontStyle FontStyle The style of the font (i.e. Normal or Italic).

Default: "Normal"
Inheritable: Yes
Animatable: Yes
FontWeight FontWeight The weight of the font (i.e. Normal or Bold).

Default: "Normal"
Inheritable: Yes
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 38 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

HorizontalAlign HorizontalAlign Describes the horizontal alignment of a text


string:

Text: relative to the x-coordinate Left.


TextBox: relative the specified box.

Default: "Left"
Inheritable: Yes
Animatable: Yes
Left Double The x-coordinate of the text area's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Opacity Double A value between 0.0 (transparent) and 1.0
(opaque).

Default: "1.0"
Inheritable: No
Animatable: Yes
Stroke Brush Specifies how the text is painted.

Default: "#000000"
Inheritable: Yes
Animatable: Yes
TextDecoration TextDecoration Specifies decorations that are added to the
text.

Default: "None"
Inheritable: Yes
Animatable: Yes
Top Double The y-coordinate of the text area's upper left
corner.

Default: "0"
Inheritable: No
Animatable: Yes
Visibility Visibility Specifies if the text shall be visible or not.

Default: "Visible"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 39 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

13.1 Text line: <Text>


Text defines a graphics element consisting of text. Each Text element causes a
single string of text to be rendered. The Text element performs no automatic line
breaking or word wrapping.

Attributes
See Common text attributes above.

13.2 Text flow: <TextBox>


Text defines a graphics element consisting of text. TextBox wraps the text within
the specified box.

Attributes
Attribute Type Description
Height Double The height of the text area.

Inheritable: No
Animatable: Yes
Width Double The width of the text area.

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 40 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

14 Linking

14.1 Link element: <Link>


Link represents a hyperlink to another "presentation" stored in the database, or file
system, of the connected server. Examples of presentation objects are TGML
Graphics files, trend log views and on-line plots.

Link indicates that the immediate parent shape or container element shall be a
"hyperlink object" which the user can click on to navigate to another presentation.

A Link is bound to a presentation object in the server with the same technique as
used for Dynamics. The Name attribute of the Link element is exposed as a
connection point to which the presentation object is connected in the bind tool. See
17 Dynamics for more information about bindings.

Link makes the parent element an "interactive" element, and a TGML viewer is
supposed to open the linked presentation object when the user clicks on the
element.

Example
The following example shows how to make a text a link object:

<TGML>
<Text...>
Open Overview
<Link Name="Overview"/>
</Text>
</TGML>

Remarks
Only painted regions are "clickable". Clicking on an "hollow" shape (Fill="None")
will have no effect.

TAC Vista Workstation graphics has support for attached, or linked, Notes files. A
Link element that belongs to (is a child of) the TGML element shall be handled by
the TGML Viewer as a "Notes attachment" if the bound object is of the type Notes.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 41 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15 Transformations
The transformation elements control the size, position, rotation and skew of
graphic objects. The transformation establishes a transformed coordinate system
for the immediate parent element.

Transformations are applied in the same order as they are specified in the TGML
file.

Transformations can be nested to any level. The effect of nested transformations is


to post-multiply (i.e. concatenate) the subsequent transformation matrices onto
previously defined transformations.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 42 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15.1 Rotation: <Rotate>


Rotate rotates the coordinate system for the immediate parent element about a
specified point.

Attributes
Attribute Type Description
Angle Double The angle of the rotation, measured in degrees.

A positive value implies clockwise rotation. A negative


value implies counter-clockwise rotation.

Default: "0.0"
Inheritable: No
Animatable: Yes
Center Point Describes the position of the center point ("X,Y") of the
rotation.

"0.0 , 0.0" represents the upper-left corner of the element


and "1.0 , 1.0" represents the lower-right corner, see
Remarks.

Default: "0.5 , 0.5"


Inheritable: No
Animatable: Yes

Remarks
The picture below illustrates different Center values:

0.0 , 0.0 1.0 , 0.0

-0.5 , 0.5 0.5 , 0.5 1.5 , 0.5

0.0 , 1.0 1.0 , 1.0

Center point coordinates:


XCOORDINATE = LeftELEMENT + XCENTER * WidthELEMENT
YCOORDINATE = TopELEMENT + YCENTER * HeightELEMENT
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 43 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example
<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000" Fill="None"/>

<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"


Stroke="#0000FF" Fill="#FFFF00" Opacity="0.75">
<Rotate Angle="20" Center="0.5,0.5"/>
</Polygon>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 44 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15.2 Skewing: <SkewX> and <SkewY>


SkewX and SkewY skews (stretches) the coordinate system for the immediate parent
element about a specified point.

SkewX specifies a skew transformation along the x-axis. The skew angle is
measured in degrees from the y-axis.

SkewY specifies a skew transformation along the y-axis. The skew angle is
measured in degrees from the x-axis.

SkewX SkewY
Y Angle

X
Angle

Transformation along Transformation along


the x-axis the y-axis

Attributes
Attribute Type Description
Angle Double The skew angle, measured in degrees.

A positive value implies counterclockwise skew. A


negative value implies clockwise skew.

Default: "0.0"
Inheritable: No
Animatable: Yes
Center Point Describes the position of the center point of the skew.

See 15.1 Rotation: <Rotate> for more information about


Center.

Default: "0.5 , 0.5"


Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 45 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000" Fill="None"/>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#0000FF" Fill="#FFFF00" Opacity="0.75">
<Skew Angle="45" Center="0.5,0.5"/>
</Polygon>

<Polygon Points="250.0,50.0 350.0,50.0 350.0,150.0 250.0,150.0"


Stroke="#000000" Fill="None"/>
<Polygon Points="250.0,50.0 350.0,50.0 350.0,150.0 250.0,150.0"
Stroke="#0000FF" Fill="#FF0000" Opacity="0.75">
<Skew Angle="45" Center="0.5,0.5"/>
</Polygon>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 46 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15.3 Scaling: <Scale>


Scale scales the coordinate system for the immediate parent element.

Attributes
Attribute Type Description
Center Point Describes the position of the center point (origin) of the
scale.

See 15.1 Rotation: <Rotate> for more information about


Center.

Default: "0.5 , 0.5"


Inheritable: No
Animatable: Yes
ScaleX Double The horizontal scale factor.

Default: "0.0"
Inheritable: No
Animatable: Yes
ScaleY Double The vertical scale factor.

Default: "0.0"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 47 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

15.4 Translations: <Translate>


Translate translates (moves) the coordinate system for the immediate parent
element.

Attributes
Attribute Type Description
X Double Specifies the x-direction.

Default: "0.0"
Inheritable: No
Animatable: Yes
Y Double Specifies the y-direction.

Default: "0.0"
Inheritable: No
Animatable: Yes

Example
<TGML>
<Rectangle Left="0" Top="0" Width="50" Height="50"
Fill="#FF0000"/>

<Rectangle Left="0" Top="0" Width="50" Height="50"


Fill="#FF0000">
<Translate X="100" Y="100"/>
</Rectangle>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 48 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

16 Animations
An animation is a time-based modification of an element attribute. The animation
defines a mapping of time to values for the target attribute.

The TGML implementation (Graphics Services) only runs animations in Dynamic


mode. The value of an attribute that has been animated (changed) in Dynamic
mode is not preserved in the TGML file. The animated value is only valid while
running in Dynamic mode.

16.1 Animation: <Animate>


Animate animates a specified attribute of the immediate parent element.

Attributes
Attribute Type Description
Animation Animation Starts and stops the animation in Dynamic
mode.

Default: "Start"
Inheritable: No
Animatable: Yes
Attribute String The animated attribute of the parent
element.

Inheritable: No
Animatable: No
AutoReverse Bool Indicates whether the timeline plays in
reverse after it completes a forward
iteration.

Default: "False"
Inheritable: No
Animatable: Yes
CalcMode CalcMode Specifies how values shall be interpolated.
See Remarks.

Default: "Discrete"
Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 49 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Duration Double Specifies the "simple duration" of the


animation in seconds.

Inheritable: Yes
Animatable: Yes
Freeze Bool Specifies if the animated attribute value
shall be kept or not when the animation
ends (end of "active duration" or stopped
by setting Animation to Stop).

Default: "False"
Inheritable: No
Animatable: Yes
From String (untyped) The starting value of an animation. The
type is determined by the referenced
Attribute.

Inheritable: Yes
Animatable: Yes
Repeat Repeat Describes the way the animation will be
repeated.

Default: "Forever"
Inheritable: No
Animatable: Yes
To String (untyped) The ending value of the animation. The
type is determined by the referenced
Attribute.

Inheritable: Yes
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 50 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Remarks

The picture below illustrates different CalcMode values:

CalcMode=Discrete CalcMode=Linear

Value Value

To=10 • To=10

From=0 • Time From=0 • Time

0 1 2 0 1 2

Duration=2 Duration=2

Example
The following example shows a blink animation.

<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000" Fill="#FF0000">
<Animate Attribute="Visibility" From="Visible" To="Hidden"
Duration="1.0" AutoReverse="True" />
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 51 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

16.2 Sequences: <Sequence>


Sequence plays a sequence of graphical elements (shapes, text, images etc) as a
"movie". The Interval attribute controls the "frame rate". Interval specifies for how
long time, in seconds, each graphical element shall be visible. The sequence can be
started and stopped by setting the attribute Animation to "Start" and "Stop".

Sequence belongs to the immediate parent container element and controls the
visibility of the container's graphical elements.

Attribute Type Description


Animation Animation Starts and stops the animation in Dynamic
mode.

Default: "Start"
Inheritable: No
Animatable: Yes
Interval Double Specifies for how long time each of the
container's shapes shall be visible.

Inheritable: Yes
Animatable: Yes

Example
The following example plays a sequence of three rectangles. The "frame rate"
(Interval) is set to one second. The Visibility attributes of the second and third
rectangle are set to "Hidden" to hide them in Edit mode.

<Tgml>
<Group>
<Sequence Interval="1"/>
<Rectangle Top="50.0" Left="50.0" Width="100" Height="100"
Fill="#00FF00" Stroke="#000000" Visibility="Visible"/>
<Rectangle Top="50.0" Left="50.0" Width="100" Height="100"
Fill="#FFFF00" Stroke="#000000" Visibility="Hidden"/>
<Rectangle Top="50.0" Left="50.0" Width="100" Height="100"
Fill="#FF0000" Stroke="#000000" Visibility="Hidden"/>
</Group>
</Tgml>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 52 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17 Dynamics
A dynamic graphic object is an object (TGML element) whose properties (TGML
attributes) are bound to, and controlled by, server variables (signals).

The TGML implementation (Graphics Services) only runs the dynamics engine in
Dynamic mode, i.e. bound properties are not dynamically updated in Static (edit)
mode.

Server variables are connected to element attributes via Bind elements with
associated rule elements. A Bind element belongs to the immediate parent element
and specifies which attribute of the parent element that will be dynamically
updated (similar to animations). The rule elements belong to the immediate parent
Bind element and they specify how a signal value will be converted to a TGML
attribute value.

The rules are evaluated in sequence, in the same order as they are specified. A rule
is executed (and the specified attribute is set) only if the specified conditions are
fulfilled. If no matching rules are found, the bound attribute is left unaffected.

TGML support different types of rule elements (ConvertValue, ConvertRange,


ConvertText etc). Different types of rules can be combined in the same Bind
element.

The Name attribute of the Bind element identifies the binding and is exposed to
bind tools as a binding point to which the server variable is connected.

Dynamic object Binding Server

Rectangle

Binding point
Temperature

Server
Bind Attribute="Fill" Name="Temperature"
variable
(signal)
T1
Attribute value = Red

ConvertValue SignalEqualTo="0" AttributeValue="#FF0000"


ConvertValue SignalEqualTo="1" AttributeValue="#00FF00"

Signal value = 0
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 53 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Bindings can be thought of as a "connection table" between the exposed Bind


elements and the server variables. The implementation of the bindings, or
"connection table", may differ between TAC servers (for example TACOS and
Xenta 511). However, regardless of implementation, the TGML implementation
(Graphics Services) will only have knowledge about the Name of the Bind
elements.

Subscriptions are set up using the names of the Bind elements. When the value of a
bound signal is updated, it will be experienced as if the binding point was updated
(the signal identity is "hidden" behind the binding point). It is up to the server, or
the communication proxy depending on the binding implementation, to resolve the
name.

A TGML document may contain multiple Bind elements with the same Name.
However, the TGML implementation will only expose the Name once to the bind
tool (unique binding point). This makes it possible to have multiple presentations
of a signal, using a single binding point.

Dynamic rotation
Bind Name="Fan"

Binding point: Server variable:


Fan F1

On Dynamic text
Bind Name="Fan"

Dynamic color
Bind Name="Fan"
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 54 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17.1 Signal binding: <Bind>


Bind enables a dynamic (server/device controlled) update of an attribute of the
immediate parent element. The Name of the Bind element is exposed to bind tools
as a binding point (Name is a common attribute, see 5Common attributes).

Bind makes the parent element an "interactive" element. The TGML viewer is
supposed to respond (e.g. show a "change value" dialog) when the user clicks on
the element.

Attributes
Attribute Type Description
Attribute String The bound attribute of the parent element.

Inheritable: No
Animatable: No
Format Format Specifies the formatting of the subscribed data. See
Remarks.

Default: "None"
Inheritable: No
Animatable: No

Remarks
Format is an instruction to the server how the subscribed value shall be formatted.

"None" means "deliver the data as is". The data type is preserved (integer, float,
boolean, string etc). You typically use conversion elements to convert the server
variable value to a TGML element attribute value.

"Presentation" is an instruction to the server: Deliver the text representation of the


variable value, if any (e.g. On/Off instead of 0/1). "Presentation" is typically used
when the data shall be presented by a Text element without any value conversions.

Example
The following example shows how you can create a dynamic text without any
conversion elements using the presentation format:

<TGML>
<Text ...>
<Bind Name="Status" Attribute="TextContent"
Format="Presentation" />
This string is displayed as default.
</Text>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 55 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17.2 Value conversion: <ConvertValue>


ConvertValue specifies how a server variable (signal) value shall be converted to a
TGML element attribute value. A ConvertValue element belongs to the immediate
parent Bind element.

A ConvertValue rule is only executed when each of the specified conditions are
fulfilled. The following example means: "Set the attribute to #00FF00 (green)
when the signal value is more than 18 and less than or equal to 22".

<Bind Name="Temperature" Attribute="Fill">


<ConvertValue AttributeValue="#00FF00"
SignalMoreThan="18.0" SignalLessOrEqualTo="22.0"/>
</Bind>

The following example shows a rule that never can be fulfilled (and thus never
executed) since the signal value never can be both equal to 0 and more than 10:

<ConvertValue Name="Bad Rule"


AttributeValue="#FF0000" SignalEqualTo="0"
SignalMoreThan="10"/>

Attributes
Attribute Type Description
AttributeValue String The attribute value that is to be set (resulting
(untyped) value). The type is determined by the bound
Attribute (referenced by the Bind element).

Inheritable: No
Animatable: No
SignalEqualTo String Corresponds to "=".
(untyped)
Inheritable: No
Animatable: No
SignalMoreThan String Corresponds to ">".
(untyped)
Inheritable: No
Animatable: No
SignalMoreOrEqualTo String Corresponds to ">=".
(untyped)
Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 56 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

SignalLessThan String Corresponds to "<".


(untyped)
Inheritable: No
Animatable: No
SignalLessOrEqualTo String Corresponds to "<=".
(untyped)
Inheritable: No
Animatable: No

Examples
<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000" Fill="#000000">
<Bind Name="State" Attribute="Fill">
<ConvertValue AttributeValue="#00FF00" SignalEqualTo="1"/>
<ConvertValue AttributeValue="#FF0000" SignalEqualTo="0"/>
</Bind>
</Polygon>
</TGML>

Sinal value: 1 Sinal value: 0


Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 57 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000" Fill="#000000">
<Bind Name="Temperature" Attribute="Fill">
< ConvertValue AttributeValue="#0000FF"
SignalLessThan="18.0"/>
< ConvertValue AttributeValue="#00FF00"
SignalMoreOrEqualTo="18.0" SignalLessOrEqualTo="22.0"/>
< ConvertValue AttributeValue="#FF0000"
SignalMoreThan="22.0"/>
</Bind>
</Polygon>
</TGML>

Sinal value: Sinal value: Sinal value:


Less than 18.0 Between 18.0 and 22.0 More than 22.0
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 58 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17.3 Text value conversion: <ConvertText>


ConvertText specifies how a server variable (signal) value shall be converted to a
TGML element attribute value. ConvertText assumes that the signal value is a text.

A ConvertText element belongs to the immediate parent Bind element. A


ConvertText rule is executed when the signal value matches the specified text
(SignalEqualTo).

Attributes
Attribute Type Description
AttributeValue String The attribute value that is to be set (resulting
(untyped) value). The type is determined by the bound
Attribute (referenced by the Bind element).

Inheritable: No
Animatable: No
SignalEqualTo String Corresponds to "=".

Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 59 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17.4 Value range conversion:


<ConvertRange>
ConvertRange specifies how a server variable (signal) value shall be converted to a
TGML element attribute value using min and max values. A ConvertRange
element belongs to the immediate parent Bind element.

A ConvertRange rule is executed when the signal value is within the specified
range. The Example below shows how the attribute value is calculated.

Attributes
Attribute Type Description
AttributeMaxValue String The upper bound of the attribute value. The
(untyped) referenced attribute (referenced by the Bind
element) will be set to this value when the
signal value is more than or equal to
SignalMaxValue.

Inheritable: No
Animatable: No
AttributeMinValue String The lower bound of the attribute value. The
(untyped) referenced attribute (referenced by the Bind
element) will be set to this value when the
signal value is less than or equal to
SignalMinValue.

Inheritable: No
Animatable: No
SignalMaxValue String The upper bound of the signal value.
(untyped)
Inheritable: No
Animatable: No
SignalMinValue String The lower bound of the signal value.
(untyped)
Inheritable: No
Animatable: No
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 60 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example
<TGML>
<Polygon Points="150.0,50.0 160.0,150.0 140.0,150.0"
. Fill="#FF0000" Stroke="#000000" StrokeWidth="1.0">
<Rotate Angle="0.0" Center="0.5,1.1">
<Bind Name="Flow" Attribute="Angle">
<ConvertRange
AttributeMinValue="-90.0" SignalMinValue="0.0"
AttributeMaxValue="90.0" SignalMaxValue="60.0" />
</Bind>
</Rotate>
</Polygon>
</TGML>

Signal value: 30.0


Attribute value: 0.0

Signal value: 0.0 Signal value: 60.0


Attribute value: -90.0 Attribute value: 90.0
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 61 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

17.5 Custom conversion: <ConvertCustom>


ConvertCustom defines a custom conversion of a signal value.

ConvertCustom contains a Script element with a JavaScript function named


convert:

function convert(value)
{
// TODO: add conversion code here

return value;
}

The function takes one parameter which is the signal value and it is supposed to
return a converted value.

The user can insert any valid JavaScript code in the function body to accomplish a
value conversion. By default the function just returns the signal value as is.

Example
<TGML>

<Rectangle Left="10" Top="10" Width="100" Height="50"


Fill="#FFFF00" Stroke="#000000">
<Bind Name="Temp" Attribute="Fill">
<ConvertCustom>
<Script> <![CDATA[
function convert(value)
{
if(value >= 18 && value <= 22)
value = "#00FF00"
else
value = "#FF0000"

return value;
}
]]></Script>
</ConvertCustom>
</Bind>
</Rectangle>

</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 62 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

18 Scripting
TGML supports the script language JavaScript 1.5, which you can use to access the
elements and their attributes in View mode. The script engine is not running in Edit
mode.

The DOM (the elements and their attributes) is accessed using DOM methods such
as getCurrentTarget, getAttribute and setAttribute.

Apart from accessing the DOM, it is also possible to interact with the TGML
Viewer (and thus the underlying system) using TAC specific JavaScript functions
such as setValue and execute.

The execution of the scripts is event driven. Event attributes are used to specify the
event and a function name. The function will be executed in View mode when the
specified event is raised.

See Appendix C: TGML scripting for more information about DOM methods, event
object methods and JavaScript functions.

18.1 Script element: <Script>


Script defines a script block that belongs to the immediate parent element.
Specifying an event attribute on the Script element makes the parent element the
target for the specified event. For example, if OnMouseClick and the function name
"click" are specified, the click function will be executed when the user clicks on the
parent element (assuming that the element is a visible graphical element).

If the parent element of Script is a container element, such as Component, the


mouse event will be sent when any of the contained graphical elements are hit. The
hit element is the target, while the parent element, which handles the event, is the
current target.

The functions are always defined with an in parameter. The parameter is a


reference to the event object which can be used to get event specific information
and to access the DOM, starting with getTarget or getCurrentTarget.

Each Script element (script block) creates a JavaScript context. Function calls
between script blocks (contexts) are not supported, i.e. no support for global script
functions.

The script functions are stored in the CDATA section of the Script element. The
CDATA section is accessible through the Content attribute.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 63 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Element attributes
Attribute Type Description
Content String The script.

Inheritable: No
Animatable: No

Events and event attributes


Event attribute Event type Target Description
OnDocumentLoad DocumentLoadEvent Any The TGML document has been loaded (opened).
element
Cancelable: No
OnMouseClick MouseClickEvent Painted A mouse button is clicked over an element.
element
Cancelable: Yes
OnMouseDown MouseDownEvent Painted A mouse button is pressed over an element.
element
Cancelable: Yes
OnMouseUp MouseUpEvent Painted A mouse button is released over an element.
element
Cancelable: Yes
OnMouseOver MouseOverEvent Painted The cursor is moved onto an element.
element
Cancelable: Yes
OnMouseMove MouseMoveEvent Painted The cursor is moved while it is over an element.
element
Cancelable: Yes
OnMouseOut MouseOutEvent Painted The cursor is moved away from an element.
element
Cancelable: Yes
OnSignalChange SignalChangeEvent Bind The value of the bound signal has been changed.
element
The referenced attribute in the Bind element is
updated before the event is sent.

Cancelable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 64 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

<Tgml>
<Rectangle Name="MyRect" Left="50" Top="50" Width="100"
Height="100" Fill="#FFFFFF" Stroke="#000000" >

<Script OnMouseClick="click"><![CDATA[
function click(evt)
{
element = evt.getTarget();
name = element.getAttribute("Name");

mouseX = evt.getClientX();
mouseY = evt.getClientY();

message = "You hit " + name + " at " +


mouseX + "," + mouseY;

alert(message);
}
]]></Script>

</Rectangle>
</Tgml>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 65 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

18.2 Target area element: <TargetArea>


TargetArea represents a "clickable" area in the graphics. TargetArea is not painted
(always invisible).

You do not have to use TargetArea to be able to handle mouse events. All of the
graphical (painted) elements can be targets of mouse events. Use TargetArea when
you need an invisible but clickable area.

Attributes
Attribute Type Description
Height Double The height of the area.

Inheritable: No
Animatable: Yes
Left Double The x-coordinate of the area's upper left corner.

Default: "0"
Inheritable: No
Animatable: Yes
Top Double The y-coordinate of the area's upper left corner.

Default: "0"
Inheritable: No
Animatable: Yes
Width Double The width of the area.

Inheritable: No
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 66 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

In the following example the TargetArea is used to create a "mouse sensitive" area
that covers the whole Component.

Without the TargetArea, the MouseOver and MouseOut events will be sent every
time the cursor passes the contained elements since the Script is defined at the
Component level in this example. The TargetArea has the effect of "hiding" the
contained shapes and you will only get one MouseOver and one MouseOut when
the cursor passes the Component.

<Tgml>
<Component Left="50.0" Top="50.0" Width="102" Height="102"
ContentHeight="102" ContentWidth="102"
>
<Script OnMouseOut="out" OnMouseOver="over" ><![CDATA[
function over(evt)
{
// Show blue edge
component = evt.getCurrentTarget();
rectangle = component.getChildByName("Hovering");
rectangle.setAttribute("Visibility", "Visible");
}

function out(evt)
{
// Hide blue edge
component = evt.getCurrentTarget();
rectangle = component.getChildByName("Hovering");
rectangle.setAttribute("Visibility", "Hidden");
}
]]></Script>

<Shapes .../>

<Rectangle Name="Hovering" Visibility="Hidden"


Left="1.0" Top="1.0" Width="100" Height="100"
Fill="None" Stroke="#0000FF" />

<TargetArea Left="0.0" Top="0.0" Width="102" Height="102"/>


</Component>
</Tgml>

The following TGML fragment is an example of an invisible "link area" which can
be placed above other shapes:

<TargetArea Left="50.0" Top="50.0" Width="100.0" Height="100.0">


<Link Name="AnotherGraphics" />
</TargetArea>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 67 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

19 Gradients
Gradients consist of continuously smooth color transitions along a vector from one
color to another. TGML provides for two types of gradients, linear gradients and
radial gradients.

19.1 Linear gradient: <LinearGradient>


The LinearGradient creates a linear gradient brush for the stroke or fill area of the
immediate parent.

LinearGradient works in conjunction with gradient stops (see 19.3 Gradient stop),
which describe the location and color of transition points in gradients.

Attributes
Attribute Type Description
Attribute String The brush attribute of the parent ("Fill" or
"Stroke").

Inheritable: No
Animatable: No
EndPoint Point The ending coordinates of the linear gradient,
see Remarks

Default: "1.0 , 0.0"


Inheritable: Yes
Animatable: Yes
SpreadMethod SpreadMethod Specifies how the gradient should be drawn
outside of the specified gradient vector or
space, see Remarks.

Default: "Pad"
Inheritable: Yes
Animatable: Yes
StartPoint Point The starting coordinates of the linear gradient,
see Remarks.

Default: "0.0 , 0.0"


Inheritable: Yes
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 68 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Remarks
StartPoint and EndPoint specifies the starting and ending coordinates of the linear
gradient. "0.0 , 0.0" represents the upper-left corner of the element and "1.0 , 1.0"
represents the lower-right corner. In the following picture, the StartPoint and
EndPoint are set to "0.0,0.0" and "1.0,1.0", respectively.

The following pictures illustrate different values of SpreadMethod.

Example
See 19.3 Gradient stop.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 69 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

19.2 Radial gradient: <RadialGradient>


RadialGradient defines a radial gradient brush for the stroke or fill area of the
immediate parent.

RadialGradient works in conjunction with gradient stops (see 19.3 Gradient stop),
which describe the location and color of transition points in gradients.

Attributes
Attribute Type Description
Attribute String The brush attribute of the parent ("Fill" or
"Stroke").

Inheritable: No
Animatable: No
Center Point The center of the circle of the radial gradient,
see Remarks.

Default:"0.5 , 0.5"
Inheritable: Yes
Animatable: Yes
Focus Point The location of the focal point that defines the
beginning of the gradient, see Remarks.

Default:"0.5 , 0.5"
Inheritable: Yes
Animatable: Yes
RadiusX Double The horizontal radius of the circle of the radial
gradient, see Remarks.

Default:"0.5"
Inheritable: Yes
Animatable: Yes
RadiusY Double The vertical radius of the circle of a radial
gradient, see Remarks.

Default:"0.5"
Inheritable: Yes
Animatable: Yes
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 70 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

SpreadMethod SpreadMethod Specifies how the gradient should be drawn


outside of the specified gradient vector or
space, see Remarks.

Default: "Pad"
Inheritable: Yes
Animatable: Yes

Remarks
The RadialGradient is similar in programming model to the LinearGradient.
However RadialGradient does not have start and end points, but a circle, along
with a focal point, to define the gradient behavior. The focal point defines the
beginning of the gradient, and the circle defines the end point of the gradient.

Note that RadialGradient only supports the spread method Pad in TGML version
1.0.

Focus (0.3)

Center (0.5 , 0.5)

RadiusX (0.5)

RadiusY (0.5)

Example
See 19.3 Gradient stop.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 71 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

19.3 Gradient stop: <GradientStop>


The GradientStop describes the location and color of a transition point in a
gradient. GradientStop belongs to its immediate parent gradient element.

Attributes
Attribute Type Description
Color Color The color of the gradient stop.

Inheritable: Yes
Animatable: Yes
Offset Double The location of the gradient stop within the gradient.

Inheritable: Yes
Animatable: Yes

Remarks
The following picture illustrates the relations between the StartPoint/EndPoint of
the LinearGradient and the Color/Offset of the GradientStop elements.

StartPoint of EndPoint of
LinearGradient LinearGradient

GradientStop, GradientStop,
Color=#FFFFFF, Color=#0000FF,
Offset=0.0 Offset=1.0

GradientStop, GradientStop,
Color=#FFFFFF, Color=#0000FF,
Offset=0.25 Offset=0.75
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 72 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Examples
<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000">
<LinearGradient Attribute="Fill">
<GradientStop Color="#FFFFFF" Offset="0.0"/>
<GradientStop Color="#0000FF" Offset="1.0"/>
</LinearGradient>
</Polygon>
</TGML>

<TGML>
<Polygon Points="50.0,50.0 150.0,50.0 150.0,150.0 50.0,150.0"
Stroke="#000000">
<RadialGradient Attribute="Fill" Center="0.5,0.5"
Focus="0.35,0.35" RadiusX="0.5" RadiusY="0.5" >
<GradientStop Color="#FFFFFF" Offset="0.0"/>
<GradientStop Color="#0000FF" Offset="1.0"/>
</RadialGradient>
</Polygon>
</TGML>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 73 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

20 Attribute exposure
In TGML, it is possible to indicate that an attribute shall be exposed by the TGML
editor in such a way that it is easy to find and set the attribute value.

The primary purpose is to be able to create a "Component interface" to the user. A


Component can be rather complex. The component developer can choose to expose
some of the attributes of the Component (or the contained elements) to, for
example, make it easy to change the appearance of the Component.

An Expose element is used to expose an attribute. The Name of the Expose element
is presented to the user instead of the original attribute name.

The attribute exposure is only handled by the TGML editor. TGML viewers shall
ignore the exposure.

20.1 The Expose element: <Expose>


Expose indicates that an attribute of the immediate parent element shall be exposed
by the TGML editor, using the Name of the Expose element instead of the original
attribute name.

Attributes
Attribute Type Description
ExposedAttribute String The exposed attribute of the parent element.

Inheritable: No
Animatable: No

Example
<Component...>
<Rectangle...>
<Expose ExposedAttribute=“Fill” Name=“Background”/>
</Rectangle>
<Ellipse...>
<Bind ...>
<ConvertRange...>
<Expose ExposedAttribute=“SignalMinValue” Name=“Min”/>
<Expose ExposedAttribute=“SignalMaxValue” Name=“Max”/>
</ConvertRange>
</Bind>
</Ellipse>
</Component>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 74 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Appendix A: TGML code snippets


A snippet is a stored piece of TGML code. It can be used for reusing constructs
such as preconfigured animations and gradients.

A snippet file contains only one TGML snippet. The root (outermost) element
includes at least two Metadata elements describing the snippet: one for Name and
one for Description. It is recommended that the file name matches the "Name"
metadata.

<Metadata Name="Name" Value="Blink"/>


<Metadata Name="Description" Value="Blink twice per second"/>

The following example shows an "animation snippet" that could be inserted as a


child to any graphical (renderable) TGML element.

<Animate Attribute="Visibility" Duration="1.0"


From="Visible" To="Hidden">
<Metadata Name="Name" Value="Blink"/>
<Metadata Name="Description" Value="Blink twice per second"/>
</Animate>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 75 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Appendix B: Components
Component library
Components are stored the same way as TGML code snippets. Component is the
root element and the associated Metadata elements describe the component.

The ComponentContent element


The document type ComponentContent is the root of the document when the
content of a component is edited in the TGML graphics editor. ComponentContent
is replaced with Component when the component is stored in the library.

The attributes of ComponentContent:


Height
Opacity
Visibility
Width

Width and Height is replaced with (copied to) ContentWidth and ContentHeight of
the Component element when the component is stored.

Initial viewport
The Width and Height of the stored Component is the initial viewport (the initial
size of the component) when it is pasted into a TGML document.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 76 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Appendix C: TGML scripting

Global variables
Variables declared outside the Java script functions are global within the script
block. The global variables exist while the TGML document is displayed
(executed) in Dynamic mode.

The global variables can only be accessed by the functions that are defined in the
same script block.

About data types


Java script variables are untyped. If you, for example, use global variables or
custom attributes to store numeric values: Convert the variables to a Number.

<Tgml>
<Rectangle Step="1" Fill="#FFFFFF" Height="50.0" Left="50.0"
Stroke="#000000" Top="50.0" Width="50.0">

<Bind Name="Value"/>

<Script OnMouseClick="click" OnSignalChange="signal"><![CDATA[

value = NaN; // Global variable, initialized with Not a Number.

function signal(evt)
{
value = new Number(evt.getValue());
// Note: getValue may return a string.
}

function click(evt)
{
// If value is a numeric value (not a NaN).
if(!isNaN(value))
{
target = evt.getTarget();

// Convert the custom attribute Step to a Number


// (stored as string)
increase = new Number(target.getAttribute("Step"));

// Increase the value


newValue = value + increase;

// Get the name of the binding


bind = target.getChildByName("Value");
fullName = bind.getFullBindName();

// Set the new value


setValue(fullName, newValue);
}
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 77 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

else
{
alert("Not a numeric value.")
}

// Do not display any "change value" dialogs when clicking.


evt.preventDefault();
}

]]></Script>
</Rectangle>
</Tgml>

Common event methods


Method Description
getCurrentTarget() Returns the element which the Script belongs to (i.e. the
EventTarget whose EventListeners are currently being
processed.)
getTarget() Returns the element to which the event was originally
dispatched (for example, the element you clicked on).
preventDefault() If the event is cancelable, preventDefault cancels the default
action normally taken by the implementation (e.g. the viewer,
see Remarks below).
stopPropagation() Prevents further propagation of an event.

Remarks
When an element contains Bind or Link, the viewer are supposed to respond (e.g.
show a "change value" dialog or open the linked presentation object) when the user
clicks on the element. This is the "default action" for the viewer which is cancelled
by the preventDefault function.

preventDefault in an OnMouseClick function cancels the change value dialog


(when the element contains a Bind) or the link function (when the element contains
a Link).

preventDefault in an OnSignalChange function cancels the error indication (the red


cross).

Example
<Tgml>
<Component Left="99.5" Top="99.5" Width="101.0" Height="101.0"
ContentHeight="101.0" ContentWidth="101.0">

<Script OnMouseDown="down"><![CDATA[
function down(evt)
{
// The Rectangle will be the target since the Component
// has no painted (clickable) surface.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 78 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

rectangle = evt.getTarget();

// The Component is the current target because it is


// the immediate parent of the Script (i.e. the executed
// event listener).
component = evt.getCurrentTarget();
}
]]></Script>

<Rectangle Left="0.5" Top="0.5" Width="100.0" Height="100.0"


Fill="#FFFFFF" Stroke="#000000"/>

</Component>
</Tgml>

Mouse event methods


Method Description
getButton() Returns an integer describing which button was
pressed or released. Applicable for
MouseDownEvent and MouseUpEvent.

0 = Left button.
1 = Middle button.
2 = Right button.
getClientX() Returns the X coordinate of the cursor, relative the
origin of the target coordinate system.

The coordinate is calculated using the


transformations of the target element.
getClientY() Returns the Y coordinate of the cursor, relative the
origin of the target coordinate system.

The coordinate is calculated using the


transformations of the target element.
getCurrentTargetX() Returns the X coordinate of the cursor, relative the
origin of the current target coordinate system.

The coordinate is calculated using the


transformations of the current target element.
getCurrentTargetY() Returns the Y coordinate of the cursor, relative the
origin of the current target coordinate system.

The coordinate is calculated using the


transformations of the current target element.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 79 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

getCurrentTargetParentX() Returns the X coordinate of the cursor, relative the


origin of the current target's parent coordinate
system.

The coordinate is calculated using the


transformations of the current target's parent.
getCurrentTargetParentY() Returns the Y coordinate of the cursor, relative the
origin of the current target's parent coordinate
system.

The coordinate is calculated using the


transformations of the current target's parent.
getScreenX() Returns the X coordinate of the cursor, relative to the
origin of the document coordinate system.
getScreenY() Returns the Y coordinate of the cursor, relative to the
origin of the document coordinate system.

SignalChange event methods


Method Description
getStatus() Returns the status of the signal:

0: Error (Bad quality).


1: Stored value (Uncertain quality).
2: Real value (Good quality).
3: Forced value (Good quality).
getPresentationValue() Returns the value of the bound signal as a "presentation
value", see 17.1 Signal binding: <Bind>
getValue() Returns the value of the bound signal.

TGML DOM methods


Object Method Description
Any getChildByName("‹name›") Returns the child element that has the
element Name attribute with the given value. If
no such element exists, this returns
null. If more than one element has a
Name attribute with that value, what is
returned is undefined.
Bind or getFullBindName() Returns the exposed name of the Bind
Link or Link element, including names of
parent components.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 80 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Example

<Tgml>
<Component Name="MyComponent" Left="99.5" Top="99.5"
Width="101.0" Height="101.0" ContentHeight="101.0"
ContentWidth="101.0">

<Script OnMouseClick="click"><![CDATA[
function click(evt)
{
component = evt.getCurrentTarget();
bind = component.getChildByName("Value");
fullName = bind.getFullBindName(); // "MyCmponent.Value"
....
}
]]></Script>

<Rectangle Left="0.5" Top="0.5" Width="100.0"


Height="100.0" Fill="#FFFFFF" Stroke="#000000">
<Bind Name="Value" Attribute="Fill" />
</Rectangle>

</Component>
</Tgml>

Standard DOM methods (commonly used)


See W3C Document Object Model (DOM) Level 3 Core Specification for more
information.

Object Method Description


Any getAttribute("‹attribute›") Returns the value of ‹attribute›.
element
Any getChildNodes() Returns a NodeList that contains all
element children of this node.
Any getOwnerDocument() Returns the document.
element
Any getParentNode() Returns the parent element.
element
Any getTagName() Returns the element tag name, e.g.
element Rectangle or Bind.
Any setAttribute("‹attribute›", Sets the value of ‹attribute› to
element "‹value›") ‹value›. If the element does not have
the attribute, it is created (as a TGML
custom attribute).
Document getDocumentElement() Returns the TGML (root) element.
Document getElementById("‹Id›") Returns the child element that has
the Id attribute with the given value.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 81 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Document getElementsByTagName Returns a NodeList of all the


("‹tagName›") elements in document order with a
given tag name.
NodeList getLength() Returns the number of elements in
the NodeList.
NodeList item("‹index›") Returns the element at ‹index› in the
NodeList.

Example
<Tgml>
<Rectangle Left="50" Top="50" Width="100" Height="100"
Fill="#C0C0C0" Stroke="#000000" >
<Script OnMouseOver="over" OnMouseOut="out"><![CDATA[
function over(evt)
{
// Change fill color while hovering.

rectangle = evt.getTarget();

// Get the original fill color and store


// it as a custom attribute of the rectangle.
color = rectangle.getAttribute("Fill");
rectangle. setAttribute("originalColor", color);

// Change color to blue


rectangle.setAttribute("Fill", "#0000FF");
}

function out(evt)
{
// Restore the fill color

rectangle = evt.getTarget();
color = rectangle.getAttribute("originalColor");
rectangle.setAttribute("Fill", color);
}
]]></Script>

</Rectangle>
</Tgml>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 82 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

TGML JavaScript functions


Method Description
alert("‹message›") Displays a message box.
confirm("‹message›") Displays a confirm box with "Yes" and "No"
buttons.

Returns true if the user clicks "Yes" or false if the


user clicks "No".

execute("‹command›") Requests an execute operation to be performed by


execute("‹command›", the TGML viewer (start a Windows program).
"‹options›")
command is the name of the program (full path)
and options is the command line options.

Returns true if succeeded or false if failed.

Note: The implementation of this function is


system dependent. May not be implemented in
some systems.
invoke("‹bindingName›", Requests an operation to be performed on a bound
"‹operation›") object by the TGML viewer. The bindingName is
the full name (as it is exposed to the binding tools)
of a Bind or Link element.

Returns true if succeeded or false if failed.

Note: The implementation of this function is


system dependent. May not be implemented in
some systems.
openFile("‹path›", Request the TGML viewer to open a file. The
"‹operation›") operation is typical Windows object verbs.

Returns true if succeeded or false if failed.

Note: The implementation of this function is


system dependent. May not be implemented in
some systems.
prompt("‹message›", Prompts the user to enter a value.
"‹defaultValue›")
Returns the entered value or null if cancelled.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 83 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

setValue("‹bindingName›", Sets the value of a bound signal object. The


"‹value›") bindingName is the full name (as it is exposed to
the binding tools) of a Bind element.

Returns true if succeeded or false if failed.

Note: The implementation of this function is


system dependent. May not be implemented in
some systems.

Examples
<Tgml>
<Component Name="Switch" Left="50" Top="50" Width="102"
Height="102" ContentHeight="102" ContentWidth="102">

<Rectangle Left="1" Top="1" Width="100.0" Height="100.0"


Fill="#C0C0C0" Stroke="#000000">

<Script OnMouseClick="click"
OnSignalChange="signal"><![CDATA[

currentValue = NaN;

function click(evt)
{
rect = evt.getTarget();

oldVal = new Number(currentValue);


// Note: currentValue is set in function signal.

if(!isNaN(oldVal)) // Skip if no value has arrived.


{
// Toggle
newVal = (oldVal==0) ? 1 : 0;

// Get the Bind element (named Value).


bind = rect.getChildByName("Value");

// Get the full binding name.


fullName = bind.getFullBindName();

toggle = confirm("Toggle \"" + fullName + "\" from "


+ oldVal + " to " + newVal + "\n\nAre you sure?");

if(toggle == true)
setValue(fullName, newVal);
}

// The rect contains a Bind element. Cancel the


// default viewer action (do not display the
// default "edit value" dialog).
evt.preventDefault();
}
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 84 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

function signal(evt)
{
currentValue = evt.getValue();
}

]]></Script>

<Bind Attribute="Fill" Name="Value">


<ConvertValue AttributeValue="#FF0000" SignalEqualTo="0"/>
<ConvertValue AttributeValue="#00FF00" SignalEqualTo="1"/>
</Bind>

</Rectangle>
</Component>
</Tgml>

The example below assumes that the Link named "Report" is bound to a TACOS
report object. The function invoke will result in a "print report" operation in Vista
Workstation.

<Tgml>
<Text Left="100" Top="100">
Print TACOS report

<Script OnMouseClick="click"><![CDATA[
function click(evt)
{
rect = evt.getTarget();
link = rect.getChildByName("Report");
fullName = link.getFullBindName();

// Print the linked report


invoke(fullName, "PrintReport");

// The text contains a Link. Cancel the default


// Link operation.
evt.preventDefault();
}
]]></Script>

<Link Name="Report"/>

</Text>
</Tgml>
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 85 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

JavaScript 1.5
For more information about JavaScript 1.5, see ECMAScript Language
Specification, Rev 3.
Format Specification
TGML 1.0
Company Date Version Page
TAC AB 2006-10-12 B1 86 (86)
Author Document ID
Lars-Eric Assarsson TGML_Format_Specification

Appendix D: Document history

Version A1-A7
The A1-A7 versions were used by the TGML development team during the
development of the TGML Graphics. The full history of the revisions is
documented in the TGML Format Specification, version A7.

Version B1
This is the first official version of the TGML 1.0 Format Specification. This
version has been reviewed as version A7. The content in this version is the same as
in version A7.

You might also like