15.4.6 Object Groups

A number of Octave high level plot functions return groups of other
graphics objects or they return graphics objects that have their
properties linked in such a way that changes to one of the properties
results in changes in the others. A graphic object that groups other
objects is an hggroup

Function File: hggroup()

Function File: hggroup(hax)

Function File: hggroup(…, property, value, …)

Function File: h =hggroup(…)

Create handle graphics group object with axes parent hax.

If no parent is specified, the group is created in the current axes.

Multiple property/value pairs may be specified for the hggroup, but they
must appear in pairs.

The optional return value h is a graphics handle to the created
hggroup object.

Programming Note: An hggroup is a way to group base graphics objects such
as line objects or patch objects into a single unit which can react
appropriately. For example, the individual lines of a contour plot are
collected into a single hggroup so that they can be made visible/invisible
with a single command, set (hg_handle, "visible", "off").

which groups the two plots into a single object and controls their
visibility directly. The default properties of an hggroup are
the same as the set of common properties for the other graphics
objects. Additional properties can be added with the addproperty
function.

Built-in Function: addproperty(name, h, type)

Built-in Function: addproperty(name, h, type, arg, …)

Create a new property named name in graphics object h.

type determines the type of the property to create. args
usually contains the default value of the property, but additional
arguments might be given, depending on the type of the property.

The supported property types are:

string

A string property. arg contains the default string value.

any

An un-typed property. This kind of property can hold any octave
value. args contains the default value.

radio

A string property with a limited set of accepted values. The first
argument must be a string with all accepted values separated by
a vertical bar (’|’). The default value can be marked by enclosing
it with a ’{’ ’}’ pair. The default value may also be given as
an optional second string argument.

boolean

A boolean property. This property type is equivalent to a radio
property with "on|off" as accepted values. arg contains
the default property value.

double

A scalar double property. arg contains the default value.

handle

A handle property. This kind of property holds the handle of a
graphics object. arg contains the default handle value.
When no default value is given, the property is initialized to
the empty matrix.

data

A data (matrix) property. arg contains the default data
value. When no default value is given, the data is initialized to
the empty matrix.

color

A color property. arg contains the default color value.
When no default color is given, the property is set to black.
An optional second string argument may be given to specify an
additional set of accepted string values (like a radio property).

type may also be the concatenation of a core object type and
a valid property name for that object type. The property created
then has the same characteristics as the referenced property (type,
possible values, hidden state…). This allows one to clone an
existing property into the graphics object h.

Once a property in added to an hggroup, it is not linked to any
other property of either the children of the group, or any other
graphics object. Add so to control the way in which this newly added
property is used, the addlistener function is used to define a
callback function that is executed when the property is altered.

Built-in Function: addlistener(h, prop, fcn)

Register fcn as listener for the property prop of the graphics
object h.

Property listeners are executed (in order of registration) when the property
is set. The new value is already available when the listeners are executed.

prop must be a string naming a valid property in h.

fcn can be a function handle, a string or a cell array whose first
element is a function handle. If fcn is a function handle, the
corresponding function should accept at least 2 arguments, that will be
set to the object handle and the empty matrix respectively. If fcn
is a string, it must be any valid octave expression. If fcn is a cell
array, the first element must be a function handle with the same signature
as described above. The next elements of the cell array are passed
as additional arguments to the function.

Link graphic object properties, such that a change in one is propagated to
the others.

The input h is a vector of graphic handles to link.

prop may be a string when linking a single property, or a cell array
of strings for multiple properties. During the linking process all
properties in prop will initially be set to the values that exist on
the first object in the list h.

The function returns hlink which is a special object describing the
link. As long as the reference hlink exists the link between graphic
objects will be active. This means that hlink must be preserved in
a workspace variable, a global variable, or otherwise stored using a
function such as setappdata, guidata. To unlink properties,
execute clear hlink.

These capabilities are used in a number of basic graphics objects.
The hggroup objects created by the functions of Octave contain
one or more graphics object and are used to:

group together multiple graphics objects,

create linked properties between different graphics objects, and

to hide the nominal user data, from the actual data of the objects.

For example the stem function creates a stem series where each
hggroup of the stem series contains two line objects representing
the body and head of the stem. The ydata property of the
hggroup of the stem series represents the head of the stem,
whereas the body of the stem is between the baseline and this value. For
example

shows the difference between the xdata of the hggroup
of a stem series object and the underlying line.

The basic properties of such group objects is that they consist of one
or more linked hggroup, and that changes in certain properties of
these groups are propagated to other members of the group. Whereas,
certain properties of the members of the group only apply to the current
member.

In addition the members of the group can also be linked to other
graphics objects through callback functions. For example the baseline of
the bar or stem functions is a line object, whose length
and position are automatically adjusted, based on changes to the
corresponding hggroup elements.